rebase -i: Introduce a constant AMEND
Add a constant AMEND holding the filename of the $DOTEST/amend file, and document how this temporary file is used. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Jan 14, 2010 at 06:54 UTC
a4049ae7ac97cb8887e9cd499c4dd0fed0eb968d
1 file changed
+12
-4
git-rebase--interactive.sh
+12
-4
@@ -80,6 +80,14 @@ DROPPED="$DOTEST"/dropped
80
# being rebased.
81
AUTHOR_SCRIPT="$DOTEST"/author-script
82
83
+# When an "edit" rebase command is being processed, the SHA1 of the
84
+# commit to be edited is recorded in this file. When "git rebase
85
+# --continue" is executed, if there are any staged changes then they
86
+# will be amended to the HEAD commit, but only provided the HEAD
87
+# commit is still the commit to be edited. When any other rebase
88
+# command is processed, this file is deleted.
89
+AMEND="$DOTEST"/amend
90
+
91
PRESERVE_MERGES=
92
STRATEGY=
93
ONTO=
@@ -381,7 +389,7 @@ peek_next_command () {
389
}
390
391
do_next () {
384
- rm -f "$MSG" "$AUTHOR_SCRIPT" "$DOTEST"/amend || exit
392
+ rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" || exit
393
read command sha1 rest < "$TODO"
394
case "$command" in
395
'#'*|''|noop)
@@ -409,7 +417,7 @@ do_next () {
417
pick_one $sha1 ||
418
die_with_patch $sha1 "Could not apply $sha1... $rest"
419
make_patch $sha1
412
- git rev-parse --verify HEAD > "$DOTEST"/amend
420
+ git rev-parse --verify HEAD > "$AMEND"
421
warn "Stopped at $sha1... $rest"
422
warn "You can amend the commit now, with"
423
warn
@@ -587,10 +595,10 @@ do
595
. "$AUTHOR_SCRIPT" ||
596
die "Cannot find the author identity"
597
amend=
590
- if test -f "$DOTEST"/amend
598
+ if test -f "$AMEND"
599
then
600
amend=$(git rev-parse --verify HEAD)
593
- test "$amend" = $(cat "$DOTEST"/amend) ||
601
+ test "$amend" = $(cat "$AMEND") ||
602
die "\
603
You have uncommitted changes in your working tree. Please, commit them
604
first and then run 'git rebase --continue' again."