rebase -i: fix possibly wrong onto hash in todo
authorAntti Keränen <redacted>
Thu, 13 Aug 2020 17:42:57 +0000 (20:42 +0300)
committerJunio C Hamano <redacted>
Thu, 13 Aug 2020 18:32:34 +0000 (11:32 -0700)
commit5da69c0dacb65cf80fc80b53e652fefad7469bf1
tree0b3a795ee3fbdeed68967fc8995c5f786619d60a
parent47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc
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 <redacted>
Signed-off-by: Antti Keränen <redacted>
Acked-by: Alban Gruin <redacted>
Signed-off-by: Junio C Hamano <redacted>
sequencer.c
t/t3404-rebase-interactive.sh
git clone https://git.99rst.org/PROJECT