From 21fce7f2a1bf5b00d21785ee88bcc2a79072c6bf Mon Sep 17 00:00:00 2001 From: AlanZhang2002 Date: Tue, 29 Apr 2025 10:29:16 -0700 Subject: [PATCH 1/2] added separator after ref to remove git reset --soft ambiguity --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index ae0a5bb..95dbec7 100644 --- a/main.go +++ b/main.go @@ -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 } From 7d9699e5fc4edc37734493e82e4064bd4ae5013a Mon Sep 17 00:00:00 2001 From: AlanZhang2002 Date: Thu, 1 May 2025 11:23:47 -0700 Subject: [PATCH 2/2] added test for same SHA and filename --- test_e2e.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test_e2e.sh b/test_e2e.sh index 142d7c1..855e87c 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -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 ##############################################