mirror of
https://github.com/git/git
synced 2024-10-03 23:29:36 +00:00
Merge branch 'js/rebase-autosquash-double-fixup-fix'
"rebase -i" segfaulted when rearranging a sequence that has a fix-up that applies another fix-up (which may or may not be a fix-up of yet another step). * js/rebase-autosquash-double-fixup-fix: rebase --autosquash: fix a potential segfault
This commit is contained in:
commit
a2a0942a16
|
@ -5385,10 +5385,13 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
|
||||||
todo_list->items[i].command =
|
todo_list->items[i].command =
|
||||||
starts_with(subject, "fixup!") ?
|
starts_with(subject, "fixup!") ?
|
||||||
TODO_FIXUP : TODO_SQUASH;
|
TODO_FIXUP : TODO_SQUASH;
|
||||||
if (next[i2] < 0)
|
if (tail[i2] < 0) {
|
||||||
|
next[i] = next[i2];
|
||||||
next[i2] = i;
|
next[i2] = i;
|
||||||
else
|
} else {
|
||||||
|
next[i] = next[tail[i2]];
|
||||||
next[tail[i2]] = i;
|
next[tail[i2]] = i;
|
||||||
|
}
|
||||||
tail[i2] = i;
|
tail[i2] = i;
|
||||||
} else if (!hashmap_get_from_hash(&subject2item,
|
} else if (!hashmap_get_from_hash(&subject2item,
|
||||||
strhash(subject), subject)) {
|
strhash(subject), subject)) {
|
||||||
|
|
|
@ -424,4 +424,20 @@ test_expect_success 'abort last squash' '
|
||||||
! grep first actual
|
! grep first actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'fixup a fixup' '
|
||||||
|
echo 0to-fixup >file0 &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m "to-fixup" file0 &&
|
||||||
|
test_tick &&
|
||||||
|
git commit --squash HEAD -m X --allow-empty &&
|
||||||
|
test_tick &&
|
||||||
|
git commit --squash HEAD^ -m Y --allow-empty &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m "squash! $(git rev-parse HEAD^)" -m Z --allow-empty &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -m "squash! $(git rev-parse HEAD^^)" -m W --allow-empty &&
|
||||||
|
git rebase -ki --autosquash HEAD~5 &&
|
||||||
|
test XZWY = $(git show | tr -cd W-Z)
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue