path: root/t/
diff options
authorAntti Keränen <>2020-08-13 17:42:57 (GMT)
committerJunio C Hamano <>2020-08-13 18:32:34 (GMT)
commit5da69c0dacb65cf80fc80b53e652fefad7469bf1 (patch)
tree0b3a795ee3fbdeed68967fc8995c5f786619d60a /t/
parent47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc (diff)
rebase -i: fix possibly wrong onto hash in todo
'todo_list_write_to_file' may overwrite the static buffer, originating from 'find_unique_abbrev', that was used to store the short commit hash 'c' for "# Rebase a..b onto c" message in the todo editor. This is because the buffer that is returned from 'find_unique_abbrev' is valid until 4 more calls to `find_unique_abbrev` are made. As 'todo_list_write_to_file' calls 'find_unique_abbrev' for each rebased commit, the hash for 'c' is overwritten if there are 4 or more commits in the rebase. This behavior has been broken since its introduction. Fix by storing the short onto commit hash in a different buffer that remains valid, before calling 'todo_list_write_to_file'. Found-by: Jussi Keränen <> Signed-off-by: Antti Keränen <> Acked-by: Alban Gruin <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 6 insertions, 0 deletions
diff --git a/t/ b/t/
index 4a7d21f..1b4fa08 100755
--- a/t/
+++ b/t/
@@ -1760,6 +1760,12 @@ test_expect_success 'correct error message for commit --amend after empty pick'
test_i18ngrep "middle of a rebase -- cannot amend." err
+test_expect_success 'todo has correct onto hash' '
+ GIT_SEQUENCE_EDITOR=cat git rebase -i no-conflict-branch~4 no-conflict-branch >actual &&
+ onto=$(git rev-parse --short HEAD~4) &&
+ test_i18ngrep "^# Rebase ..* onto $onto" actual
# This must be the last test in this file
test_expect_success '$EDITOR and friends are unchanged' '