Skip to content

Commit 2c9f83b

Browse files
authored
Merge pull request #946 from AlanZhang2002/ambiguous-git-reset
added separator after ref to remove git reset --soft ambiguity
2 parents 913a6be + 7d9699e commit 2c9f83b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ func (git *repoSync) SyncRepo(ctx context.Context, refreshCreds func(context.Con
17801780
// Reset the repo (note: not the worktree - that happens later) to the new
17811781
// ref. This makes subsequent fetches much less expensive. It uses --soft
17821782
// so no files are checked out.
1783-
if _, _, err := git.Run(ctx, git.root, "reset", "--soft", remoteHash); err != nil {
1783+
if _, _, err := git.Run(ctx, git.root, "reset", "--soft", remoteHash, "--"); err != nil {
17841784
return false, "", err
17851785
}
17861786

test_e2e.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,40 @@ function e2e::sync_crash_no_worktree_cleanup_retry() {
14911491
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]}"
14921492
}
14931493

1494+
##############################################
1495+
# Test syncing if a file named for the SHA exists
1496+
##############################################
1497+
function e2e::sync_sha_shafile_exists() {
1498+
echo "${FUNCNAME[0]} 1" > "$REPO/file"
1499+
git -C "$REPO" commit -qam "${FUNCNAME[0]} 1"
1500+
SHA1=$(git -C "$REPO" rev-list -n1 HEAD)
1501+
echo "${FUNCNAME[0]} 2" > "$REPO/file"
1502+
git -C "$REPO" commit -qam "${FUNCNAME[0]} 2"
1503+
SHA2=$(git -C "$REPO" rev-list -n1 HEAD)
1504+
1505+
GIT_SYNC \
1506+
--one-time \
1507+
--repo="file://$REPO" \
1508+
--ref="$SHA1" \
1509+
--root="$ROOT" \
1510+
--link="link"
1511+
assert_link_exists "$ROOT/link"
1512+
assert_file_exists "$ROOT/link/file"
1513+
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]} 1"
1514+
1515+
touch "$ROOT/$SHA2"
1516+
1517+
GIT_SYNC \
1518+
--one-time \
1519+
--repo="file://$REPO" \
1520+
--ref="$SHA2" \
1521+
--root="$ROOT" \
1522+
--link="link"
1523+
assert_link_exists "$ROOT/link"
1524+
assert_file_exists "$ROOT/link/file"
1525+
assert_file_eq "$ROOT/link/file" "${FUNCNAME[0]} 2"
1526+
}
1527+
14941528
##############################################
14951529
# Test changing repos with storage intact
14961530
##############################################

0 commit comments

Comments
 (0)