Skip to content

Fix shallow clone for tag/branch#68

Merged
EstAK merged 1 commit intomainfrom
shallowbranch
Mar 10, 2026
Merged

Fix shallow clone for tag/branch#68
EstAK merged 1 commit intomainfrom
shallowbranch

Conversation

@apaolillo
Copy link
Owner

Shallow clones (--depth 1) only fetch HEAD of the default branch, so a subsequent git checkout <tag> fails with "pathspec did not match".

Use git clone --depth 1 --branch <ref> instead, which fetches the target ref directly in a single step; no separate checkout is needed.

Also refactor project_git_clone to build each git command (clone, checkout, submodules) independently, then dispatch once on single_run_command. This removes the nested shallow x single_run branching and gracefully handles an empty commit (clone HEAD only).

Shallow clones (`--depth 1`) only fetch HEAD of the default branch, so
a subsequent `git checkout <tag>` fails with "pathspec did not match".

Use `git clone --depth 1 --branch <ref>` instead, which fetches the
target ref directly in a single step; no separate checkout is needed.

Also refactor project_git_clone to build each git command (clone,
checkout, submodules) independently, then dispatch once on
single_run_command. This removes the nested shallow x single_run
branching and gracefully handles an empty commit (clone HEAD only).

Signed-off-by: Antonio Paolillo <apaolill@gmail.com>
@apaolillo apaolillo requested a review from EstAK March 10, 2026 12:46
@apaolillo apaolillo self-assigned this Mar 10, 2026
@EstAK EstAK merged commit be193df into main Mar 10, 2026
5 checks passed
@EstAK EstAK deleted the shallowbranch branch March 10, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants