mirror of
https://github.com/git/git
synced 2024-08-24 02:11:08 +00:00
![Phillip Wood](/assets/img/avatar_default.png)
While a rebase is stopped for the user to edit a commit message it can be convenient for them to also edit the todo list. The scripted version of rebase supported this but the C version does not. We already check to see if the todo list has been updated by an exec command so extend this to rewords and squashes. It only costs a single stat call to do this so it should not affect the speed of the rebase (especially as it has just stopped for the user to edit a message) Note that for squashes the editor may be opened on a different pick to the squash itself as we edit the message at the end of a chain fixups and squashes. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
56 lines
1.5 KiB
Bash
Executable file
56 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='rebase should reread the todo file if an exec modifies it'
|
|
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/lib-rebase.sh
|
|
|
|
test_expect_success 'setup' '
|
|
test_commit first file &&
|
|
test_commit second file &&
|
|
test_commit third file
|
|
'
|
|
|
|
test_expect_success 'rebase exec modifies rebase-todo' '
|
|
todo=.git/rebase-merge/git-rebase-todo &&
|
|
git rebase HEAD -x "echo exec touch F >>$todo" &&
|
|
test -e F
|
|
'
|
|
|
|
test_expect_success SHA1 'loose object cache vs re-reading todo list' '
|
|
GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo &&
|
|
export GIT_REBASE_TODO &&
|
|
write_script append-todo.sh <<-\EOS &&
|
|
# For values 5 and 6, this yields SHA-1s with the same first two digits
|
|
echo "pick $(git rev-parse --short \
|
|
$(printf "%s\\n" \
|
|
"tree $EMPTY_TREE" \
|
|
"author A U Thor <author@example.org> $1 +0000" \
|
|
"committer A U Thor <author@example.org> $1 +0000" \
|
|
"" \
|
|
"$1" |
|
|
git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO
|
|
|
|
shift
|
|
test -z "$*" ||
|
|
echo "exec $0 $*" >>$GIT_REBASE_TODO
|
|
EOS
|
|
|
|
git rebase HEAD -x "./append-todo.sh 5 6"
|
|
'
|
|
|
|
test_expect_success 'todo is re-read after reword and squash' '
|
|
write_script reword-editor.sh <<-\EOS &&
|
|
GIT_SEQUENCE_EDITOR="echo \"exec echo $(cat file) >>actual\" >>" \
|
|
git rebase --edit-todo
|
|
EOS
|
|
|
|
test_write_lines first third >expected &&
|
|
set_fake_editor &&
|
|
GIT_SEQUENCE_EDITOR="$EDITOR" FAKE_LINES="reword 1 squash 2 fixup 3" \
|
|
GIT_EDITOR=./reword-editor.sh git rebase -i --root third &&
|
|
test_cmp expected actual
|
|
'
|
|
|
|
test_done
|