Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2020-11-04 18:29:37 +0300
committerJunio C Hamano <gitster@pobox.com>2020-11-05 01:10:41 +0300
commite100bea48102dca7e21359993085e89c7f154f9d (patch)
treea21bd9a41d2c961a46298747a3bdb20a850e2888 /t/t3404-rebase-interactive.sh
parentb927c80531cca9b9107754186532e8cb00884008 (diff)
rebase -i: stop overwriting ORIG_HEAD buffer
After rebasing, ORIG_HEAD is supposed to point to the old HEAD of the rebased branch. The code used find_unique_abbrev() to obtain the object name of the old HEAD and wrote to both .git/rebase-merge/orig-head (used by `rebase --abort` to go back to the previous state) and to ORIG_HEAD. The buffer find_unique_abbrev() gives back is volatile, unfortunately, and was overwritten after the former file is written but before ORIG_FILE is written, leaving an incorrect object name in it. Avoid relying on the volatile buffer of find_unique_abbrev(), and instead supply our own buffer to keep the object name. I think that all of the users of head_hash should actually be using opts->orig_head instead as passing a string rather than a struct object_id around is a hang over from the scripted implementation. This patch just fixes the immediate bug and adds a regression test based on Caspar's reproduction example[1]. The users will be converted to use struct object_id and head_hash removed in the next few commits. [1] https://lore.kernel.org/git/CAFzd1+7PDg2PZgKw7U0kdepdYuoML9wSN4kofmB_-8NHrbbrHg@mail.gmail.com Reported-by: Caspar Duregger <herr.kaste@gmail.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3404-rebase-interactive.sh')
-rwxr-xr-xt/t3404-rebase-interactive.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 07a1617351..1e56696e4f 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -1797,6 +1797,17 @@ test_expect_success 'todo has correct onto hash' '
test_i18ngrep "^# Rebase ..* onto $onto" actual
'
+test_expect_success 'ORIG_HEAD is updated correctly' '
+ test_when_finished "git checkout master && git branch -D test-orig-head" &&
+ git checkout -b test-orig-head A &&
+ git commit --allow-empty -m A1 &&
+ git commit --allow-empty -m A2 &&
+ git commit --allow-empty -m A3 &&
+ git commit --allow-empty -m A4 &&
+ git rebase master &&
+ test_cmp_rev ORIG_HEAD test-orig-head@{1}
+'
+
# This must be the last test in this file
test_expect_success '$EDITOR and friends are unchanged' '
test_editor_unchanged