Skip to content

added separator after ref to remove git reset --soft ambiguity #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,7 @@ func (git *repoSync) SyncRepo(ctx context.Context, refreshCreds func(context.Con
// Reset the repo (note: not the worktree - that happens later) to the new
// ref. This makes subsequent fetches much less expensive. It uses --soft
// so no files are checked out.
if _, _, err := git.Run(ctx, git.root, "reset", "--soft", remoteHash); err != nil {
if _, _, err := git.Run(ctx, git.root, "reset", "--soft", remoteHash, "--"); err != nil {
return false, "", err
}

Expand Down
34 changes: 34 additions & 0 deletions test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,40 @@ function e2e::sync_crash_no_worktree_cleanup_retry() {
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]}"
}

##############################################
# Test syncing if a file named for the SHA exists
##############################################
function e2e::sync_sha_shafile_exists() {
echo "${FUNCNAME[0]} 1" > "$REPO/file"
git -C "$REPO" commit -qam "${FUNCNAME[0]} 1"
SHA1=$(git -C "$REPO" rev-list -n1 HEAD)
echo "${FUNCNAME[0]} 2" > "$REPO/file"
git -C "$REPO" commit -qam "${FUNCNAME[0]} 2"
SHA2=$(git -C "$REPO" rev-list -n1 HEAD)

GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--ref="$SHA1" \
--root="$ROOT" \
--link="link"
assert_link_exists "$ROOT/link"
assert_file_exists "$ROOT/link/file"
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]} 1"

touch "$ROOT/$SHA2"

GIT_SYNC \
--one-time \
--repo="file://$REPO" \
--ref="$SHA2" \
--root="$ROOT" \
--link="link"
assert_link_exists "$ROOT/link"
assert_file_exists "$ROOT/link/file"
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]} 2"
}

##############################################
# Test changing repos with storage intact
##############################################
Expand Down