summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDerrick Stolee <derrickstolee@github.com>2022-07-19 18:33:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-07-19 19:49:04 (GMT)
commit89fc0b53fdb4ea2f9581ea728577f4d2a4947672 (patch)
treeb6d8559ef8a9ee3803e2a64af1ad2c412e90a551 /t
parent900b50c242dfa6b47033cbb495d2fd9d06752ff1 (diff)
downloadgit-89fc0b53fdb4ea2f9581ea728577f4d2a4947672.zip
git-89fc0b53fdb4ea2f9581ea728577f4d2a4947672.tar.gz
git-89fc0b53fdb4ea2f9581ea728577f4d2a4947672.tar.bz2
rebase: update refs from 'update-ref' commands
The previous change introduced the 'git rebase --update-refs' option which added 'update-ref <ref>' commands to the todo list of an interactive rebase. Teach Git to record the HEAD position when reaching these 'update-ref' commands. The ref/before/after triple is stored in the $GIT_DIR/rebase-merge/update-refs file. A previous change parsed this file to avoid having other processes updating the refs in that file while the rebase is in progress. Not only do we update the file when the sequencer reaches these 'update-ref' commands, we then update the refs themselves at the end of the rebase sequence. If the rebase is aborted before this final step, then the refs are not updated. The 'before' value is used to ensure that we do not accidentally obliterate a ref that was updated concurrently (say, by an older version of Git or a third-party tool). Now that the 'git rebase --update-refs' command is implemented to write to the update-refs file, we can remove the fake construction of the update-refs file from a test in t2407-worktree-heads.sh. Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t2407-worktree-heads.sh21
-rwxr-xr-xt/t3404-rebase-interactive.sh17
2 files changed, 23 insertions, 15 deletions
diff --git a/t/t2407-worktree-heads.sh b/t/t2407-worktree-heads.sh
index 8a03f14..50815ac 100755
--- a/t/t2407-worktree-heads.sh
+++ b/t/t2407-worktree-heads.sh
@@ -81,25 +81,16 @@ test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase (mer
grep "cannot force update the branch '\''wt-2'\'' checked out at.*wt-2" err
'
-test_expect_success 'refuse to overwrite: worktree in rebase with --update-refs' '
- test_when_finished rm -rf .git/worktrees/wt-3/rebase-merge &&
-
- mkdir -p .git/worktrees/wt-3/rebase-merge &&
- touch .git/worktrees/wt-3/rebase-merge/interactive &&
+test_expect_success !SANITIZE_LEAK 'refuse to overwrite: worktree in rebase with --update-refs' '
+ test_when_finished git -C wt-3 rebase --abort &&
- cat >.git/worktrees/wt-3/rebase-merge/update-refs <<-EOF &&
- refs/heads/fake-3
- $(git rev-parse HEAD~1)
- $(git rev-parse HEAD)
- refs/heads/fake-4
- $(git rev-parse HEAD)
- $(git rev-parse HEAD)
- EOF
+ git branch -f can-be-updated wt-3 &&
+ test_must_fail git -C wt-3 rebase --update-refs conflict-3 &&
for i in 3 4
do
- test_must_fail git branch -f fake-$i HEAD 2>err &&
- grep "cannot force update the branch '\''fake-$i'\'' checked out at.*wt-3" err ||
+ test_must_fail git branch -f can-be-updated HEAD 2>err &&
+ grep "cannot force update the branch '\''can-be-updated'\'' checked out at.*wt-3" err ||
return 1
done
'
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 75c0b90..2fffcf5 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1817,6 +1817,23 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
)
'
+test_expect_success '--update-refs updates refs correctly' '
+ git checkout -B update-refs no-conflict-branch &&
+ git branch -f base HEAD~4 &&
+ git branch -f first HEAD~3 &&
+ git branch -f second HEAD~3 &&
+ git branch -f third HEAD~1 &&
+ test_commit extra2 fileX &&
+ git commit --amend --fixup=L &&
+
+ git rebase -i --autosquash --update-refs primary &&
+
+ test_cmp_rev HEAD~3 refs/heads/first &&
+ test_cmp_rev HEAD~3 refs/heads/second &&
+ test_cmp_rev HEAD~1 refs/heads/third &&
+ test_cmp_rev HEAD refs/heads/no-conflict-branch
+'
+
# This must be the last test in this file
test_expect_success '$EDITOR and friends are unchanged' '
test_editor_unchanged