12
12
13
13
. git-sh-setup
14
14
15
- dotest=" $GIT_DIR /rebase-merge"
16
-
17
15
# The file containing rebase commands, comments, and empty lines.
18
16
# This file is created by "git rebase -i" then edited by the user. As
19
17
# the lines are processed, they are removed from the front of this
20
18
# file and written to the tail of $done.
21
- todo=" $dotest " /git-rebase-todo
19
+ todo=" $state_dir " /git-rebase-todo
22
20
23
21
# The rebase command lines that have already been processed. A line
24
22
# is moved here when it is first handled, before any associated user
25
23
# actions.
26
- done=" $dotest " /done
24
+ done=" $state_dir " /done
27
25
28
26
# The commit message that is planned to be used for any changes that
29
27
# need to be committed following a user interaction.
30
- msg=" $dotest " /message
28
+ msg=" $state_dir " /message
31
29
32
30
# The file into which is accumulated the suggested commit message for
33
31
# squash/fixup commands. When the first of a series of squash/fixups
@@ -42,44 +40,44 @@ msg="$dotest"/message
42
40
# written to the file so far (including the initial "pick" commit).
43
41
# Each time that a commit message is processed, this line is read and
44
42
# updated. It is deleted just before the combined commit is made.
45
- squash_msg=" $dotest " /message-squash
43
+ squash_msg=" $state_dir " /message-squash
46
44
47
45
# If the current series of squash/fixups has not yet included a squash
48
46
# command, then this file exists and holds the commit message of the
49
47
# original "pick" commit. (If the series ends without a "squash"
50
48
# command, then this can be used as the commit message of the combined
51
49
# commit without opening the editor.)
52
- fixup_msg=" $dotest " /message-fixup
50
+ fixup_msg=" $state_dir " /message-fixup
53
51
54
52
# $rewritten is the name of a directory containing files for each
55
53
# commit that is reachable by at least one merge base of $head and
56
54
# $upstream. They are not necessarily rewritten, but their children
57
55
# might be. This ensures that commits on merged, but otherwise
58
56
# unrelated side branches are left alone. (Think "X" in the man page's
59
57
# example.)
60
- rewritten=" $dotest " /rewritten
58
+ rewritten=" $state_dir " /rewritten
61
59
62
- dropped=" $dotest " /dropped
60
+ dropped=" $state_dir " /dropped
63
61
64
62
# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
65
63
# GIT_AUTHOR_DATE that will be used for the commit that is currently
66
64
# being rebased.
67
- author_script=" $dotest " /author-script
65
+ author_script=" $state_dir " /author-script
68
66
69
67
# When an "edit" rebase command is being processed, the SHA1 of the
70
68
# commit to be edited is recorded in this file. When "git rebase
71
69
# --continue" is executed, if there are any staged changes then they
72
70
# will be amended to the HEAD commit, but only provided the HEAD
73
71
# commit is still the commit to be edited. When any other rebase
74
72
# command is processed, this file is deleted.
75
- amend=" $dotest " /amend
73
+ amend=" $state_dir " /amend
76
74
77
75
# For the post-rewrite hook, we make a list of rewritten commits and
78
76
# their new sha1s. The rewritten-pending list keeps the sha1s of
79
77
# commits that have been processed, but not committed yet,
80
78
# e.g. because they are waiting for a 'squash' command.
81
- rewritten_list=" $dotest " /rewritten-list
82
- rewritten_pending=" $dotest " /rewritten-pending
79
+ rewritten_list=" $state_dir " /rewritten-list
80
+ rewritten_pending=" $state_dir " /rewritten-pending
83
81
84
82
GIT_CHERRY_PICK_HELP=" $resolvemsg "
85
83
export GIT_CHERRY_PICK_HELP
@@ -145,22 +143,22 @@ make_patch () {
145
143
* )
146
144
echo " Root commit"
147
145
;;
148
- esac > " $dotest " /patch
146
+ esac > " $state_dir " /patch
149
147
test -f " $msg " ||
150
148
commit_message " $1 " > " $msg "
151
149
test -f " $author_script " ||
152
150
get_author_ident_from_commit " $1 " > " $author_script "
153
151
}
154
152
155
153
die_with_patch () {
156
- echo " $1 " > " $dotest " /stopped-sha
154
+ echo " $1 " > " $state_dir " /stopped-sha
157
155
make_patch " $1 "
158
156
git rerere
159
157
die " $2 "
160
158
}
161
159
162
160
die_abort () {
163
- rm -rf " $dotest "
161
+ rm -rf " $state_dir "
164
162
die " $1 "
165
163
}
166
164
@@ -205,20 +203,20 @@ pick_one_preserving_merges () {
205
203
esac
206
204
sha1=$( git rev-parse $sha1 )
207
205
208
- if test -f " $dotest " /current-commit
206
+ if test -f " $state_dir " /current-commit
209
207
then
210
208
if test " $fast_forward " = t
211
209
then
212
210
while read current_commit
213
211
do
214
212
git rev-parse HEAD > " $rewritten " /$current_commit
215
- done < " $dotest " /current-commit
216
- rm " $dotest " /current-commit ||
213
+ done < " $state_dir " /current-commit
214
+ rm " $state_dir " /current-commit ||
217
215
die " Cannot write current commit's replacement sha1"
218
216
fi
219
217
fi
220
218
221
- echo $sha1 >> " $dotest " /current-commit
219
+ echo $sha1 >> " $state_dir " /current-commit
222
220
223
221
# rewrite parents; if none were rewritten, we can fast-forward.
224
222
new_parents=
@@ -425,7 +423,7 @@ do_next () {
425
423
mark_action_done
426
424
pick_one $sha1 ||
427
425
die_with_patch $sha1 " Could not apply $sha1 ... $rest "
428
- echo " $sha1 " > " $dotest " /stopped-sha
426
+ echo " $sha1 " > " $state_dir " /stopped-sha
429
427
make_patch $sha1
430
428
git rev-parse --verify HEAD > " $amend "
431
429
warn " Stopped at $sha1 ... $rest "
@@ -490,7 +488,7 @@ do_next () {
490
488
printf ' Executing: %s\n' " $rest "
491
489
# "exec" command doesn't take a sha1 in the todo-list.
492
490
# => can't just use $sha1 here.
493
- git rev-parse --verify HEAD > " $dotest " /stopped-sha
491
+ git rev-parse --verify HEAD > " $state_dir " /stopped-sha
494
492
${SHELL:-@ SHELL_PATH@ } -c " $rest " # Actual execution
495
493
status=$?
496
494
if test " $status " -ne 0
@@ -525,19 +523,19 @@ do_next () {
525
523
test -s " $todo " && return
526
524
527
525
comment_for_reflog finish &&
528
- headname =$( cat " $dotest " /head-name) &&
529
- oldhead =$( cat " $dotest " /head) &&
530
- shortonto=$( git rev-parse --short $( cat " $dotest " /onto) ) &&
526
+ head_name =$( cat " $state_dir " /head-name) &&
527
+ orig_head =$( cat " $state_dir " /head) &&
528
+ shortonto=$( git rev-parse --short $( cat " $state_dir " /onto) ) &&
531
529
newhead=$( git rev-parse HEAD) &&
532
- case $headname in
530
+ case $head_name in
533
531
refs/* )
534
- message=" $GIT_REFLOG_ACTION : $headname onto $shortonto " &&
535
- git update-ref -m " $message " $headname $newhead $oldhead &&
536
- git symbolic-ref HEAD $headname
532
+ message=" $GIT_REFLOG_ACTION : $head_name onto $shortonto " &&
533
+ git update-ref -m " $message " $head_name $newhead $orig_head &&
534
+ git symbolic-ref HEAD $head_name
537
535
;;
538
536
esac && {
539
- test ! -f " $dotest " /verbose ||
540
- git diff-tree --stat $( cat " $dotest " /head) ..HEAD
537
+ test ! -f " $state_dir " /verbose ||
538
+ git diff-tree --stat $( cat " $state_dir " /head) ..HEAD
541
539
} &&
542
540
{
543
541
test -s " $rewritten_list " &&
@@ -549,9 +547,9 @@ do_next () {
549
547
" $GIT_DIR " /hooks/post-rewrite rebase < " $rewritten_list "
550
548
true # we don't care if this hook failed
551
549
fi &&
552
- rm -rf " $dotest " &&
550
+ rm -rf " $state_dir " &&
553
551
git gc --auto &&
554
- warn " Successfully rebased and updated $headname ."
552
+ warn " Successfully rebased and updated $head_name ."
555
553
556
554
exit
557
555
}
@@ -602,9 +600,9 @@ skip_unnecessary_picks () {
602
600
603
601
get_saved_options () {
604
602
test -d " $rewritten " && preserve_merges=t
605
- test -f " $dotest " /strategy && strategy=" $( cat " $dotest " /strategy) "
606
- test -f " $dotest " /verbose && verbose=t
607
- test -f " $dotest " /rebase-root && rebase_root=t
603
+ test -f " $state_dir " /strategy && strategy=" $( cat " $state_dir " /strategy) "
604
+ test -f " $state_dir " /verbose && verbose=t
605
+ test -f " $state_dir " /rebase-root && rebase_root=t
608
606
}
609
607
610
608
# Rearrange the todo list that has both "pick sha1 msg" and
@@ -704,7 +702,7 @@ first and then run 'git rebase --continue' again."
704
702
}
705
703
fi
706
704
707
- record_in_rewritten " $( cat " $dotest " /stopped-sha) "
705
+ record_in_rewritten " $( cat " $state_dir " /stopped-sha) "
708
706
709
707
require_clean_work_tree " rebase"
710
708
do_rest
@@ -715,15 +713,15 @@ abort)
715
713
716
714
git rerere clear
717
715
718
- headname =$( cat " $dotest " /head-name)
719
- head =$( cat " $dotest " /head)
720
- case $headname in
716
+ head_name =$( cat " $state_dir " /head-name)
717
+ orig_head =$( cat " $state_dir " /head)
718
+ case $head_name in
721
719
refs/* )
722
- git symbolic-ref HEAD $headname
720
+ git symbolic-ref HEAD $head_name
723
721
;;
724
722
esac &&
725
- output git reset --hard $head &&
726
- rm -rf " $dotest "
723
+ output git reset --hard $orig_head &&
724
+ rm -rf " $state_dir "
727
725
exit
728
726
;;
729
727
skip)
@@ -747,28 +745,28 @@ then
747
745
die " Could not checkout $switch_to "
748
746
fi
749
747
750
- head =$( git rev-parse --verify HEAD) || die " No HEAD?"
751
- mkdir " $dotest " || die " Could not create temporary $dotest "
748
+ orig_head =$( git rev-parse --verify HEAD) || die " No HEAD?"
749
+ mkdir " $state_dir " || die " Could not create temporary $state_dir "
752
750
753
- : > " $dotest " /interactive || die " Could not mark as interactive"
754
- echo " $head_name " > " $dotest " /head-name
751
+ : > " $state_dir " /interactive || die " Could not mark as interactive"
752
+ echo " $head_name " > " $state_dir " /head-name
755
753
756
- echo $head > " $dotest " /head
754
+ echo $orig_head > " $state_dir " /head
757
755
case " $rebase_root " in
758
756
' ' )
759
- rm -f " $dotest " /rebase-root ;;
757
+ rm -f " $state_dir " /rebase-root ;;
760
758
* )
761
- : > " $dotest " /rebase-root ;;
759
+ : > " $state_dir " /rebase-root ;;
762
760
esac
763
- echo $onto > " $dotest " /onto
764
- test -z " $strategy " || echo " $strategy " > " $dotest " /strategy
765
- test t = " $verbose " && : > " $dotest " /verbose
761
+ echo $onto > " $state_dir " /onto
762
+ test -z " $strategy " || echo " $strategy " > " $state_dir " /strategy
763
+ test t = " $verbose " && : > " $state_dir " /verbose
766
764
if test t = " $preserve_merges "
767
765
then
768
766
if test -z " $rebase_root "
769
767
then
770
768
mkdir " $rewritten " &&
771
- for c in $( git merge-base --all $head $upstream )
769
+ for c in $( git merge-base --all $orig_head $upstream )
772
770
do
773
771
echo $onto > " $rewritten " /$c ||
774
772
die " Could not init rewritten commits"
@@ -782,21 +780,21 @@ then
782
780
# parents to rewrite and skipping dropped commits would
783
781
# prematurely end our probe
784
782
merges_option=
785
- first_after_upstream=" $( git rev-list --reverse --first-parent $upstream ..$head | head -n 1) "
783
+ first_after_upstream=" $( git rev-list --reverse --first-parent $upstream ..$orig_head | head -n 1) "
786
784
else
787
785
merges_option=" --no-merges --cherry-pick"
788
786
fi
789
787
790
- shorthead=$( git rev-parse --short $head )
788
+ shorthead=$( git rev-parse --short $orig_head )
791
789
shortonto=$( git rev-parse --short $onto )
792
790
if test -z " $rebase_root "
793
791
# this is now equivalent to ! -z "$upstream"
794
792
then
795
793
shortupstream=$( git rev-parse --short $upstream )
796
- revisions=$upstream ...$head
794
+ revisions=$upstream ...$orig_head
797
795
shortrevisions=$shortupstream ..$shorthead
798
796
else
799
- revisions=$onto ...$head
797
+ revisions=$onto ...$orig_head
800
798
shortrevisions=$shorthead
801
799
fi
802
800
git rev-list $merges_option --pretty=oneline --abbrev-commit \
@@ -837,13 +835,13 @@ then
837
835
mkdir " $dropped "
838
836
# Save all non-cherry-picked changes
839
837
git rev-list $revisions --left-right --cherry-pick | \
840
- sed -n " s/^>//p" > " $dotest " /not-cherry-picks
838
+ sed -n " s/^>//p" > " $state_dir " /not-cherry-picks
841
839
# Now all commits and note which ones are missing in
842
840
# not-cherry-picks and hence being dropped
843
841
git rev-list $revisions |
844
842
while read rev
845
843
do
846
- if test -f " $rewritten " /$rev -a " $( sane_grep " $rev " " $dotest " /not-cherry-picks) " = " "
844
+ if test -f " $rewritten " /$rev -a " $( sane_grep " $rev " " $state_dir " /not-cherry-picks) " = " "
847
845
then
848
846
# Use -f2 because if rev-list is telling us this commit is
849
847
# not worthwhile, we don't want to track its multiple heads,
@@ -889,5 +887,5 @@ has_action "$todo" ||
889
887
test -d " $rewritten " || test -n " $force_rebase " || skip_unnecessary_picks
890
888
891
889
output git checkout $onto || die_abort " could not detach HEAD"
892
- git update-ref ORIG_HEAD $head
890
+ git update-ref ORIG_HEAD $orig_head
893
891
do_rest
0 commit comments