Skip to content

Commit b9b14a4

Browse files
committed
sync/git(fix[update_repo]) Disambiguate rev-list for local refs matching paths
why: When a git repo has a local branch whose name matches a directory (e.g. branch "notes" + directory "notes/"), git rev-list fails with "fatal: ambiguous argument". The error was caught but not recorded in SyncResult, so vcspull reported the sync as successful despite the visible fatal error. what: - Check show_ref output for refs/heads/<tag> before calling rev-list - Use fully-qualified refs/heads/ path when available, avoiding the ambiguity entirely (no fatal error emitted, no retry needed) - Fall back to bare tag name when no refs/heads/ match exists (e.g. tags, SHAs, or refs not yet fetched)
1 parent 24453fe commit b9b14a4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/libvcs/sync/git.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,20 @@ def update_repo(
467467

468468
# This will fail if the tag does not exist (it probably has not
469469
# been fetched yet).
470+
#
471+
# When the ref is local, use the fully-qualified refs/heads/ path
472+
# if available to avoid ambiguity with paths (e.g. a branch named
473+
# "notes" when a directory "notes/" also exists).
474+
if is_remote_ref:
475+
rev_list_commit = git_remote_name + "/" + git_tag
476+
elif f"refs/heads/{git_tag}" in show_ref_output:
477+
rev_list_commit = f"refs/heads/{git_tag}"
478+
else:
479+
rev_list_commit = git_tag
470480
try:
471481
error_code = 0
472482
tag_sha = self.cmd.rev_list(
473-
commit=git_remote_name + "/" + git_tag if is_remote_ref else git_tag,
483+
commit=rev_list_commit,
474484
max_count=1,
475485
)
476486

0 commit comments

Comments
 (0)