@matheusbsbs / matheus-bagliano / commits / 6bb4e485cf
Fork 0

rebase: align variable names

git-rebase--interactive.sh will soon be sourced from git-rebase.sh. Align the names of variables used in these scripts to prepare for that. Some names in git-rebase--interactive.sh, such as "author_script" and "amend", are currently used in their upper case form to refer to a file and in their lower case form to refer to something else. In these cases, change the name of the existing lower case variable and downcase the name of the variable that refers to the file. Currently, git-rebase.sh uses mostly lower case variable names, while git-rebase--interactive.sh uses mostly upper case variable names. For consistency, downcase all variables, not just the ones that will be shared between the two script files. Helped-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin von Zweigbergk committed Feb 6, 2011 at 13:43 UTC 6bb4e485cff86d87b5265f26d6138357444e5eb9
2 files changed +256 -256
git-rebase--interactive.sh
+240 -240
@@ -36,22 +36,22 @@ autosquash move commits that begin with squash!/fixup! under -i
36 . git-sh-setup
37 require_work_tree
38
39 -DOTEST="$GIT_DIR/rebase-merge"
39 +dotest="$GIT_DIR/rebase-merge"
40
41 # The file containing rebase commands, comments, and empty lines.
42 # This file is created by "git rebase -i" then edited by the user. As
43 # the lines are processed, they are removed from the front of this
44 -# file and written to the tail of $DONE.
45 -TODO="$DOTEST"/git-rebase-todo
44 +# file and written to the tail of $done.
45 +todo="$dotest"/git-rebase-todo
46
47 # The rebase command lines that have already been processed. A line
48 # is moved here when it is first handled, before any associated user
49 # actions.
50 -DONE="$DOTEST"/done
50 +done="$dotest"/done
51
52 # The commit message that is planned to be used for any changes that
53 # need to be committed following a user interaction.
54 -MSG="$DOTEST"/message
54 +msg="$dotest"/message
55
56 # The file into which is accumulated the suggested commit message for
57 # squash/fixup commands. When the first of a series of squash/fixups
@@ -61,34 +61,34 @@ MSG="$DOTEST"/message
61 # is appended to the file as it is processed.
62 #
63 # The first line of the file is of the form
64 -# # This is a combination of $COUNT commits.
65 -# where $COUNT is the number of commits whose messages have been
64 +# # This is a combination of $count commits.
65 +# where $count is the number of commits whose messages have been
66 # written to the file so far (including the initial "pick" commit).
67 # Each time that a commit message is processed, this line is read and
68 # updated. It is deleted just before the combined commit is made.
69 -SQUASH_MSG="$DOTEST"/message-squash
69 +squash_msg="$dotest"/message-squash
70
71 # If the current series of squash/fixups has not yet included a squash
72 # command, then this file exists and holds the commit message of the
73 # original "pick" commit. (If the series ends without a "squash"
74 # command, then this can be used as the commit message of the combined
75 # commit without opening the editor.)
76 -FIXUP_MSG="$DOTEST"/message-fixup
76 +fixup_msg="$dotest"/message-fixup
77
78 -# $REWRITTEN is the name of a directory containing files for each
79 -# commit that is reachable by at least one merge base of $HEAD and
80 -# $UPSTREAM. They are not necessarily rewritten, but their children
78 +# $rewritten is the name of a directory containing files for each
79 +# commit that is reachable by at least one merge base of $head and
80 +# $upstream. They are not necessarily rewritten, but their children
81 # might be. This ensures that commits on merged, but otherwise
82 # unrelated side branches are left alone. (Think "X" in the man page's
83 # example.)
84 -REWRITTEN="$DOTEST"/rewritten
84 +rewritten="$dotest"/rewritten
85
86 -DROPPED="$DOTEST"/dropped
86 +dropped="$dotest"/dropped
87
88 # A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
89 # GIT_AUTHOR_DATE that will be used for the commit that is currently
90 # being rebased.
91 -AUTHOR_SCRIPT="$DOTEST"/author-script
91 +author_script="$dotest"/author-script
92
93 # When an "edit" rebase command is being processed, the SHA1 of the
94 # commit to be edited is recorded in this file. When "git rebase
@@ -96,24 +96,24 @@ AUTHOR_SCRIPT="$DOTEST"/author-script
96 # will be amended to the HEAD commit, but only provided the HEAD
97 # commit is still the commit to be edited. When any other rebase
98 # command is processed, this file is deleted.
99 -AMEND="$DOTEST"/amend
99 +amend="$dotest"/amend
100
101 # For the post-rewrite hook, we make a list of rewritten commits and
102 # their new sha1s. The rewritten-pending list keeps the sha1s of
103 # commits that have been processed, but not committed yet,
104 # e.g. because they are waiting for a 'squash' command.
105 -REWRITTEN_LIST="$DOTEST"/rewritten-list
106 -REWRITTEN_PENDING="$DOTEST"/rewritten-pending
107 -
108 -PRESERVE_MERGES=
109 -STRATEGY=
110 -ONTO=
111 -VERBOSE=
112 -OK_TO_SKIP_PRE_REBASE=
113 -REBASE_ROOT=
114 -AUTOSQUASH=
115 -test "$(git config --bool rebase.autosquash)" = "true" && AUTOSQUASH=t
116 -NEVER_FF=
105 +rewritten_list="$dotest"/rewritten-list
106 +rewritten_pending="$dotest"/rewritten-pending
107 +
108 +preserve_merges=
109 +strategy=
110 +onto=
111 +verbose=
112 +ok_to_skip_pre_rebase=
113 +rebase_root=
114 +autosquash=
115 +test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
116 +force_rebase=
117
118 GIT_CHERRY_PICK_HELP="\
119 hint: after resolving the conflicts, mark the corrected paths
@@ -125,7 +125,7 @@ warn () {
125 }
126
127 output () {
128 - case "$VERBOSE" in
128 + case "$verbose" in
129 '')
130 output=$("$@" 2>&1 )
131 status=$?
@@ -144,7 +144,7 @@ commit_message () {
144 }
145
146 run_pre_rebase_hook () {
147 - if test -z "$OK_TO_SKIP_PRE_REBASE" &&
147 + if test -z "$ok_to_skip_pre_rebase" &&
148 test -x "$GIT_DIR/hooks/pre-rebase"
149 then
150 "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
@@ -155,10 +155,10 @@ run_pre_rebase_hook () {
155 }
156
157
158 -ORIG_REFLOG_ACTION="$GIT_REFLOG_ACTION"
158 +orig_reflog_action="$GIT_REFLOG_ACTION"
159
160 comment_for_reflog () {
161 - case "$ORIG_REFLOG_ACTION" in
161 + case "$orig_reflog_action" in
162 ''|rebase*)
163 GIT_REFLOG_ACTION="rebase -i ($1)"
164 export GIT_REFLOG_ACTION
@@ -168,16 +168,16 @@ comment_for_reflog () {
168
169 last_count=
170 mark_action_done () {
171 - sed -e 1q < "$TODO" >> "$DONE"
172 - sed -e 1d < "$TODO" >> "$TODO".new
173 - mv -f "$TODO".new "$TODO"
174 - count=$(sane_grep -c '^[^#]' < "$DONE")
175 - total=$(($count+$(sane_grep -c '^[^#]' < "$TODO")))
176 - if test "$last_count" != "$count"
171 + sed -e 1q < "$todo" >> "$done"
172 + sed -e 1d < "$todo" >> "$todo".new
173 + mv -f "$todo".new "$todo"
174 + new_count=$(sane_grep -c '^[^#]' < "$done")
175 + total=$(($new_count+$(sane_grep -c '^[^#]' < "$todo")))
176 + if test "$last_count" != "$new_count"
177 then
178 - last_count=$count
179 - printf "Rebasing (%d/%d)\r" $count $total
180 - test -z "$VERBOSE" || echo
178 + last_count=$new_count
179 + printf "Rebasing (%d/%d)\r" $new_count $total
180 + test -z "$verbose" || echo
181 fi
182 }
183
@@ -193,22 +193,22 @@ make_patch () {
193 *)
194 echo "Root commit"
195 ;;
196 - esac > "$DOTEST"/patch
197 - test -f "$MSG" ||
198 - commit_message "$1" > "$MSG"
199 - test -f "$AUTHOR_SCRIPT" ||
200 - get_author_ident_from_commit "$1" > "$AUTHOR_SCRIPT"
196 + esac > "$dotest"/patch
197 + test -f "$msg" ||
198 + commit_message "$1" > "$msg"
199 + test -f "$author_script" ||
200 + get_author_ident_from_commit "$1" > "$author_script"
201 }
202
203 die_with_patch () {
204 - echo "$1" > "$DOTEST"/stopped-sha
204 + echo "$1" > "$dotest"/stopped-sha
205 make_patch "$1"
206 git rerere
207 die "$2"
208 }
209
210 die_abort () {
211 - rm -rf "$DOTEST"
211 + rm -rf "$dotest"
212 die "$1"
213 }
214
@@ -228,11 +228,11 @@ do_with_author () {
228 pick_one () {
229 ff=--ff
230 case "$1" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac
231 - case "$NEVER_FF" in '') ;; ?*) ff= ;; esac
231 + case "$force_rebase" in '') ;; ?*) ff= ;; esac
232 output git rev-parse --verify $sha1 || die "Invalid commit name: $sha1"
233 - test -d "$REWRITTEN" &&
233 + test -d "$rewritten" &&
234 pick_one_preserving_merges "$@" && return
235 - if test -n "$REBASE_ROOT"
235 + if test -n "$rebase_root"
236 then
237 output git cherry-pick "$@"
238 return
@@ -253,20 +253,20 @@ pick_one_preserving_merges () {
253 esac
254 sha1=$(git rev-parse $sha1)
255
256 - if test -f "$DOTEST"/current-commit
256 + if test -f "$dotest"/current-commit
257 then
258 if test "$fast_forward" = t
259 then
260 while read current_commit
261 do
262 - git rev-parse HEAD > "$REWRITTEN"/$current_commit
263 - done <"$DOTEST"/current-commit
264 - rm "$DOTEST"/current-commit ||
262 + git rev-parse HEAD > "$rewritten"/$current_commit
263 + done <"$dotest"/current-commit
264 + rm "$dotest"/current-commit ||
265 die "Cannot write current commit's replacement sha1"
266 fi
267 fi
268
269 - echo $sha1 >> "$DOTEST"/current-commit
269 + echo $sha1 >> "$dotest"/current-commit
270
271 # rewrite parents; if none were rewritten, we can fast-forward.
272 new_parents=
@@ -280,9 +280,9 @@ pick_one_preserving_merges () {
280 p=$(expr "$pend" : ' \([^ ]*\)')
281 pend="${pend# $p}"
282
283 - if test -f "$REWRITTEN"/$p
283 + if test -f "$rewritten"/$p
284 then
285 - new_p=$(cat "$REWRITTEN"/$p)
285 + new_p=$(cat "$rewritten"/$p)
286
287 # If the todo reordered commits, and our parent is marked for
288 # rewriting, but hasn't been gotten to yet, assume the user meant to
@@ -301,10 +301,10 @@ pick_one_preserving_merges () {
301 ;;
302 esac
303 else
304 - if test -f "$DROPPED"/$p
304 + if test -f "$dropped"/$p
305 then
306 fast_forward=f
307 - replacement="$(cat "$DROPPED"/$p)"
307 + replacement="$(cat "$dropped"/$p)"
308 test -z "$replacement" && replacement=root
309 pend=" $replacement$pend"
310 else
@@ -333,18 +333,18 @@ pick_one_preserving_merges () {
333 test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
334
335 # redo merge
336 - author_script=$(get_author_ident_from_commit $sha1)
337 - eval "$author_script"
338 - msg="$(commit_message $sha1)"
336 + author_script_content=$(get_author_ident_from_commit $sha1)
337 + eval "$author_script_content"
338 + msg_content="$(commit_message $sha1)"
339 # No point in merging the first parent, that's HEAD
340 new_parents=${new_parents# $first_parent}
341 if ! do_with_author output \
342 - git merge $STRATEGY -m "$msg" $new_parents
342 + git merge $strategy -m "$msg_content" $new_parents
343 then
344 - printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
344 + printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
345 die_with_patch $sha1 "Error redoing merge $sha1"
346 fi
347 - echo "$sha1 $(git rev-parse HEAD^0)" >> "$REWRITTEN_LIST"
347 + echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
348 ;;
349 *)
350 output git cherry-pick "$@" ||
@@ -365,46 +365,46 @@ nth_string () {
365 }
366
367 update_squash_messages () {
368 - if test -f "$SQUASH_MSG"; then
369 - mv "$SQUASH_MSG" "$SQUASH_MSG".bak || exit
370 - COUNT=$(($(sed -n \
368 + if test -f "$squash_msg"; then
369 + mv "$squash_msg" "$squash_msg".bak || exit
370 + count=$(($(sed -n \
371 -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
372 - -e "q" < "$SQUASH_MSG".bak)+1))
372 + -e "q" < "$squash_msg".bak)+1))
373 {
374 - echo "# This is a combination of $COUNT commits."
374 + echo "# This is a combination of $count commits."
375 sed -e 1d -e '2,/^./{
376 /^$/d
377 - }' <"$SQUASH_MSG".bak
378 - } >"$SQUASH_MSG"
377 + }' <"$squash_msg".bak
378 + } >"$squash_msg"
379 else
380 - commit_message HEAD > "$FIXUP_MSG" || die "Cannot write $FIXUP_MSG"
381 - COUNT=2
380 + commit_message HEAD > "$fixup_msg" || die "Cannot write $fixup_msg"
381 + count=2
382 {
383 echo "# This is a combination of 2 commits."
384 echo "# The first commit's message is:"
385 echo
386 - cat "$FIXUP_MSG"
387 - } >"$SQUASH_MSG"
386 + cat "$fixup_msg"
387 + } >"$squash_msg"
388 fi
389 case $1 in
390 squash)
391 - rm -f "$FIXUP_MSG"
391 + rm -f "$fixup_msg"
392 echo
393 - echo "# This is the $(nth_string $COUNT) commit message:"
393 + echo "# This is the $(nth_string $count) commit message:"
394 echo
395 commit_message $2
396 ;;
397 fixup)
398 echo
399 - echo "# The $(nth_string $COUNT) commit message will be skipped:"
399 + echo "# The $(nth_string $count) commit message will be skipped:"
400 echo
401 commit_message $2 | sed -e 's/^/# /'
402 ;;
403 - esac >>"$SQUASH_MSG"
403 + esac >>"$squash_msg"
404 }
405
406 peek_next_command () {
407 - sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$TODO"
407 + sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$todo"
408 }
409
410 # A squash/fixup has failed. Prepare the long version of the squash
@@ -414,24 +414,24 @@ peek_next_command () {
414 # messages, effectively causing the combined commit to be used as the
415 # new basis for any further squash/fixups. Args: sha1 rest
416 die_failed_squash() {
417 - mv "$SQUASH_MSG" "$MSG" || exit
418 - rm -f "$FIXUP_MSG"
419 - cp "$MSG" "$GIT_DIR"/MERGE_MSG || exit
417 + mv "$squash_msg" "$msg" || exit
418 + rm -f "$fixup_msg"
419 + cp "$msg" "$GIT_DIR"/MERGE_MSG || exit
420 warn
421 warn "Could not apply $1... $2"
422 die_with_patch $1 ""
423 }
424
425 flush_rewritten_pending() {
426 - test -s "$REWRITTEN_PENDING" || return
426 + test -s "$rewritten_pending" || return
427 newsha1="$(git rev-parse HEAD^0)"
428 - sed "s/$/ $newsha1/" < "$REWRITTEN_PENDING" >> "$REWRITTEN_LIST"
429 - rm -f "$REWRITTEN_PENDING"
428 + sed "s/$/ $newsha1/" < "$rewritten_pending" >> "$rewritten_list"
429 + rm -f "$rewritten_pending"
430 }
431
432 record_in_rewritten() {
433 oldsha1="$(git rev-parse $1)"
434 - echo "$oldsha1" >> "$REWRITTEN_PENDING"
434 + echo "$oldsha1" >> "$rewritten_pending"
435
436 case "$(peek_next_command)" in
437 squash|s|fixup|f)
@@ -443,8 +443,8 @@ record_in_rewritten() {
443 }
444
445 do_next () {
446 - rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" || exit
447 - read -r command sha1 rest < "$TODO"
446 + rm -f "$msg" "$author_script" "$amend" || exit
447 + read -r command sha1 rest < "$todo"
448 case "$command" in
449 '#'*|''|noop)
450 mark_action_done
@@ -472,9 +472,9 @@ do_next () {
472 mark_action_done
473 pick_one $sha1 ||
474 die_with_patch $sha1 "Could not apply $sha1... $rest"
475 - echo "$sha1" > "$DOTEST"/stopped-sha
475 + echo "$sha1" > "$dotest"/stopped-sha
476 make_patch $sha1
477 - git rev-parse --verify HEAD > "$AMEND"
477 + git rev-parse --verify HEAD > "$amend"
478 warn "Stopped at $sha1... $rest"
479 warn "You can amend the commit now, with"
480 warn
@@ -497,47 +497,47 @@ do_next () {
497 esac
498 comment_for_reflog $squash_style
499
500 - test -f "$DONE" && has_action "$DONE" ||
500 + test -f "$done" && has_action "$done" ||
501 die "Cannot '$squash_style' without a previous commit"
502
503 mark_action_done
504 update_squash_messages $squash_style $sha1
505 - author_script=$(get_author_ident_from_commit HEAD)
506 - echo "$author_script" > "$AUTHOR_SCRIPT"
507 - eval "$author_script"
505 + author_script_content=$(get_author_ident_from_commit HEAD)
506 + echo "$author_script_content" > "$author_script"
507 + eval "$author_script_content"
508 output git reset --soft HEAD^
509 pick_one -n $sha1 || die_failed_squash $sha1 "$rest"
510 case "$(peek_next_command)" in
511 squash|s|fixup|f)
512 # This is an intermediate commit; its message will only be
513 # used in case of trouble. So use the long version:
514 - do_with_author output git commit --no-verify -F "$SQUASH_MSG" ||
514 + do_with_author output git commit --no-verify -F "$squash_msg" ||
515 die_failed_squash $sha1 "$rest"
516 ;;
517 *)
518 # This is the final command of this squash/fixup group
519 - if test -f "$FIXUP_MSG"
519 + if test -f "$fixup_msg"
520 then
521 - do_with_author git commit --no-verify -F "$FIXUP_MSG" ||
521 + do_with_author git commit --no-verify -F "$fixup_msg" ||
522 die_failed_squash $sha1 "$rest"
523 else
524 - cp "$SQUASH_MSG" "$GIT_DIR"/SQUASH_MSG || exit
524 + cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG || exit
525 rm -f "$GIT_DIR"/MERGE_MSG
526 do_with_author git commit --no-verify -e ||
527 die_failed_squash $sha1 "$rest"
528 fi
529 - rm -f "$SQUASH_MSG" "$FIXUP_MSG"
529 + rm -f "$squash_msg" "$fixup_msg"
530 ;;
531 esac
532 record_in_rewritten $sha1
533 ;;
534 x|"exec")
535 - read -r command rest < "$TODO"
535 + read -r command rest < "$todo"
536 mark_action_done
537 printf 'Executing: %s\n' "$rest"
538 # "exec" command doesn't take a sha1 in the todo-list.
539 # => can't just use $sha1 here.
540 - git rev-parse --verify HEAD > "$DOTEST"/stopped-sha
540 + git rev-parse --verify HEAD > "$dotest"/stopped-sha
541 ${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
542 status=$?
543 if test "$status" -ne 0
@@ -563,42 +563,42 @@ do_next () {
563 warn "Unknown command: $command $sha1 $rest"
564 if git rev-parse --verify -q "$sha1" >/dev/null
565 then
566 - die_with_patch $sha1 "Please fix this in the file $TODO."
566 + die_with_patch $sha1 "Please fix this in the file $todo."
567 else
568 - die "Please fix this in the file $TODO."
568 + die "Please fix this in the file $todo."
569 fi
570 ;;
571 esac
572 - test -s "$TODO" && return
572 + test -s "$todo" && return
573
574 comment_for_reflog finish &&
575 - HEADNAME=$(cat "$DOTEST"/head-name) &&
576 - OLDHEAD=$(cat "$DOTEST"/head) &&
577 - SHORTONTO=$(git rev-parse --short $(cat "$DOTEST"/onto)) &&
578 - NEWHEAD=$(git rev-parse HEAD) &&
579 - case $HEADNAME in
575 + headname=$(cat "$dotest"/head-name) &&
576 + oldhead=$(cat "$dotest"/head) &&
577 + shortonto=$(git rev-parse --short $(cat "$dotest"/onto)) &&
578 + newhead=$(git rev-parse HEAD) &&
579 + case $headname in
580 refs/*)
581 - message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO" &&
582 - git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
583 - git symbolic-ref HEAD $HEADNAME
581 + message="$GIT_REFLOG_ACTION: $headname onto $shortonto" &&
582 + git update-ref -m "$message" $headname $newhead $oldhead &&
583 + git symbolic-ref HEAD $headname
584 ;;
585 esac && {
586 - test ! -f "$DOTEST"/verbose ||
587 - git diff-tree --stat $(cat "$DOTEST"/head)..HEAD
586 + test ! -f "$dotest"/verbose ||
587 + git diff-tree --stat $(cat "$dotest"/head)..HEAD
588 } &&
589 {
590 - test -s "$REWRITTEN_LIST" &&
591 - git notes copy --for-rewrite=rebase < "$REWRITTEN_LIST" ||
590 + test -s "$rewritten_list" &&
591 + git notes copy --for-rewrite=rebase < "$rewritten_list" ||
592 true # we don't care if this copying failed
593 } &&
594 if test -x "$GIT_DIR"/hooks/post-rewrite &&
595 - test -s "$REWRITTEN_LIST"; then
596 - "$GIT_DIR"/hooks/post-rewrite rebase < "$REWRITTEN_LIST"
595 + test -s "$rewritten_list"; then
596 + "$GIT_DIR"/hooks/post-rewrite rebase < "$rewritten_list"
597 true # we don't care if this hook failed
598 fi &&
599 - rm -rf "$DOTEST" &&
599 + rm -rf "$dotest" &&
600 git gc --auto &&
601 - warn "Successfully rebased and updated $HEADNAME."
601 + warn "Successfully rebased and updated $headname."
602
603 exit
604 }
@@ -618,11 +618,11 @@ skip_unnecessary_picks () {
618 # fd=3 means we skip the command
619 case "$fd,$command" in
620 3,pick|3,p)
621 - # pick a commit whose parent is current $ONTO -> skip
621 + # pick a commit whose parent is current $onto -> skip
622 sha1=${rest%% *}
623 case "$(git rev-parse --verify --quiet "$sha1"^)" in
624 - "$ONTO"*)
625 - ONTO=$sha1
624 + "$onto"*)
625 + onto=$sha1
626 ;;
627 *)
628 fd=1
@@ -637,11 +637,11 @@ skip_unnecessary_picks () {
637 ;;
638 esac
639 printf '%s\n' "$command${rest:+ }$rest" >&$fd
640 - done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
641 - mv -f "$TODO".new "$TODO" &&
640 + done <"$todo" >"$todo.new" 3>>"$done" &&
641 + mv -f "$todo".new "$todo" &&
642 case "$(peek_next_command)" in
643 squash|s|fixup|f)
644 - record_in_rewritten "$ONTO"
644 + record_in_rewritten "$onto"
645 ;;
646 esac ||
647 die "Could not skip unnecessary pick commands"
@@ -650,17 +650,17 @@ skip_unnecessary_picks () {
650 # check if no other options are set
651 is_standalone () {
652 test $# -eq 2 -a "$2" = '--' &&
653 - test -z "$ONTO" &&
654 - test -z "$PRESERVE_MERGES" &&
655 - test -z "$STRATEGY" &&
656 - test -z "$VERBOSE"
653 + test -z "$onto" &&
654 + test -z "$preserve_merges" &&
655 + test -z "$strategy" &&
656 + test -z "$verbose"
657 }
658
659 get_saved_options () {
660 - test -d "$REWRITTEN" && PRESERVE_MERGES=t
661 - test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
662 - test -f "$DOTEST"/verbose && VERBOSE=t
663 - test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
660 + test -d "$rewritten" && preserve_merges=t
661 + test -f "$dotest"/strategy && strategy="$(cat "$dotest"/strategy)"
662 + test -f "$dotest"/verbose && verbose=t
663 + test -f "$dotest"/rebase-root && rebase_root=t
664 }
665
666 # Rearrange the todo list that has both "pick sha1 msg" and
@@ -699,7 +699,7 @@ rearrange_squash () {
699 esac
700 printf '%s\n' "$pick $sha1 $message"
701 used="$used$sha1 "
702 - while read -r squash action msg
702 + while read -r squash action msg_content
703 do
704 case " $used" in
705 *" $squash "*) continue ;;
@@ -709,13 +709,13 @@ rearrange_squash () {
709 +*)
710 action="${action#+}"
711 # full sha1 prefix test
712 - case "$msg" in "$sha1"*) emit=1;; esac ;;
712 + case "$msg_content" in "$sha1"*) emit=1;; esac ;;
713 *)
714 # message prefix test
715 - case "$message" in "$msg"*) emit=1;; esac ;;
715 + case "$message" in "$msg_content"*) emit=1;; esac ;;
716 esac
717 if test $emit = 1; then
718 - printf '%s\n' "$action $squash $action! $msg"
718 + printf '%s\n' "$action $squash $action! $msg_content"
719 used="$used$squash "
720 fi
721 done <"$1.sq"
@@ -747,17 +747,17 @@ while test $# != 0
747 do
748 case "$1" in
749 --no-verify)
750 - OK_TO_SKIP_PRE_REBASE=yes
750 + ok_to_skip_pre_rebase=yes
751 ;;
752 --verify)
753 - OK_TO_SKIP_PRE_REBASE=
753 + ok_to_skip_pre_rebase=
754 ;;
755 --continue)
756 is_standalone "$@" || usage
757 get_saved_options
758 comment_for_reflog continue
759
760 - test -d "$DOTEST" || die "No interactive rebase running"
760 + test -d "$dotest" || die "No interactive rebase running"
761
762 # Sanity check
763 git rev-parse --verify HEAD >/dev/null ||
@@ -771,26 +771,26 @@ do
771 then
772 : Nothing to commit -- skip this
773 else
774 - . "$AUTHOR_SCRIPT" ||
774 + . "$author_script" ||
775 die "Cannot find the author identity"
776 - amend=
777 - if test -f "$AMEND"
776 + current_head=
777 + if test -f "$amend"
778 then
779 - amend=$(git rev-parse --verify HEAD)
780 - test "$amend" = $(cat "$AMEND") ||
779 + current_head=$(git rev-parse --verify HEAD)
780 + test "$current_head" = $(cat "$amend") ||
781 die "\
782 You have uncommitted changes in your working tree. Please, commit them
783 first and then run 'git rebase --continue' again."
784 git reset --soft HEAD^ ||
785 die "Cannot rewind the HEAD"
786 fi
787 - do_with_author git commit --no-verify -F "$MSG" -e || {
788 - test -n "$amend" && git reset --soft $amend
787 + do_with_author git commit --no-verify -F "$msg" -e || {
788 + test -n "$current_head" && git reset --soft $current_head
789 die "Could not commit staged changes."
790 }
791 fi
792
793 - record_in_rewritten "$(cat "$DOTEST"/stopped-sha)"
793 + record_in_rewritten "$(cat "$dotest"/stopped-sha)"
794
795 require_clean_work_tree "rebase"
796 do_rest
@@ -801,17 +801,17 @@ first and then run 'git rebase --continue' again."
801 comment_for_reflog abort
802
803 git rerere clear
804 - test -d "$DOTEST" || die "No interactive rebase running"
804 + test -d "$dotest" || die "No interactive rebase running"
805
806 - HEADNAME=$(cat "$DOTEST"/head-name)
807 - HEAD=$(cat "$DOTEST"/head)
808 - case $HEADNAME in
806 + headname=$(cat "$dotest"/head-name)
807 + head=$(cat "$dotest"/head)
808 + case $headname in
809 refs/*)
810 - git symbolic-ref HEAD $HEADNAME
810 + git symbolic-ref HEAD $headname
811 ;;
812 esac &&
813 - output git reset --hard $HEAD &&
814 - rm -rf "$DOTEST"
813 + output git reset --hard $head &&
814 + rm -rf "$dotest"
815 exit
816 ;;
817 --skip)
@@ -820,18 +820,18 @@ first and then run 'git rebase --continue' again."
820 comment_for_reflog skip
821
822 git rerere clear
823 - test -d "$DOTEST" || die "No interactive rebase running"
823 + test -d "$dotest" || die "No interactive rebase running"
824
825 output git reset --hard && do_rest
826 ;;
827 -s)
828 case "$#,$1" in
829 *,*=*)
830 - STRATEGY="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
830 + strategy="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
831 1,*)
832 usage ;;
833 *)
834 - STRATEGY="-s $2"
834 + strategy="-s $2"
835 shift ;;
836 esac
837 ;;
@@ -839,29 +839,29 @@ first and then run 'git rebase --continue' again."
839 # we use merge anyway
840 ;;
841 -v)
842 - VERBOSE=t
842 + verbose=t
843 ;;
844 -p)
845 - PRESERVE_MERGES=t
845 + preserve_merges=t
846 ;;
847 -i)
848 # yeah, we know
849 ;;
850 --no-ff)
851 - NEVER_FF=t
851 + force_rebase=t
852 ;;
853 --root)
854 - REBASE_ROOT=t
854 + rebase_root=t
855 ;;
856 --autosquash)
857 - AUTOSQUASH=t
857 + autosquash=t
858 ;;
859 --no-autosquash)
860 - AUTOSQUASH=
860 + autosquash=
861 ;;
862 --onto)
863 shift
864 - ONTO=$(parse_onto "$1") ||
864 + onto=$(parse_onto "$1") ||
865 die "Does not point to a valid commit: $1"
866 ;;
867 --)
@@ -872,27 +872,27 @@ first and then run 'git rebase --continue' again."
872 shift
873 done
874
875 -test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
876 -test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
877 -test -d "$DOTEST" &&
875 +test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
876 +test ! -z "$rebase_root" -a $# -le 1 || usage
877 +test -d "$dotest" &&
878 die "Interactive rebase already started"
879
880 git var GIT_COMMITTER_IDENT >/dev/null ||
881 die "You need to set your committer info first"
882
883 -if test -z "$REBASE_ROOT"
883 +if test -z "$rebase_root"
884 then
885 - UPSTREAM_ARG="$1"
886 - UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
887 - test -z "$ONTO" && ONTO=$UPSTREAM
885 + upstream_arg="$1"
886 + upstream=$(git rev-parse --verify "$1") || die "Invalid base"
887 + test -z "$onto" && onto=$upstream
888 shift
889 else
890 - UPSTREAM=
891 - UPSTREAM_ARG=--root
892 - test -z "$ONTO" &&
893 - die "You must specify --onto when using --root"
890 + upstream=
891 + upstream_arg=--root
892 + test -z "$onto" &&
893 + die "You must specify --onto when using --root"
894 fi
895 -run_pre_rebase_hook "$UPSTREAM_ARG" "$@"
895 +run_pre_rebase_hook "$upstream_arg" "$@"
896
897 comment_for_reflog start
898
@@ -904,76 +904,76 @@ then
904 die "Could not checkout $1"
905 fi
906
907 -HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
908 -mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
907 +head=$(git rev-parse --verify HEAD) || die "No HEAD?"
908 +mkdir "$dotest" || die "Could not create temporary $dotest"
909
910 -: > "$DOTEST"/interactive || die "Could not mark as interactive"
911 -git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
912 - echo "detached HEAD" > "$DOTEST"/head-name
910 +: > "$dotest"/interactive || die "Could not mark as interactive"
911 +git symbolic-ref HEAD > "$dotest"/head-name 2> /dev/null ||
912 + echo "detached HEAD" > "$dotest"/head-name
913
914 -echo $HEAD > "$DOTEST"/head
915 -case "$REBASE_ROOT" in
914 +echo $head > "$dotest"/head
915 +case "$rebase_root" in
916 '')
917 - rm -f "$DOTEST"/rebase-root ;;
917 + rm -f "$dotest"/rebase-root ;;
918 *)
919 - : >"$DOTEST"/rebase-root ;;
919 + : >"$dotest"/rebase-root ;;
920 esac
921 -echo $ONTO > "$DOTEST"/onto
922 -test -z "$STRATEGY" || echo "$STRATEGY" > "$DOTEST"/strategy
923 -test t = "$VERBOSE" && : > "$DOTEST"/verbose
924 -if test t = "$PRESERVE_MERGES"
921 +echo $onto > "$dotest"/onto
922 +test -z "$strategy" || echo "$strategy" > "$dotest"/strategy
923 +test t = "$verbose" && : > "$dotest"/verbose
924 +if test t = "$preserve_merges"
925 then
926 - if test -z "$REBASE_ROOT"
926 + if test -z "$rebase_root"
927 then
928 - mkdir "$REWRITTEN" &&
929 - for c in $(git merge-base --all $HEAD $UPSTREAM)
928 + mkdir "$rewritten" &&
929 + for c in $(git merge-base --all $head $upstream)
930 do
931 - echo $ONTO > "$REWRITTEN"/$c ||
931 + echo $onto > "$rewritten"/$c ||
932 die "Could not init rewritten commits"
933 done
934 else
935 - mkdir "$REWRITTEN" &&
936 - echo $ONTO > "$REWRITTEN"/root ||
935 + mkdir "$rewritten" &&
936 + echo $onto > "$rewritten"/root ||
937 die "Could not init rewritten commits"
938 fi
939 # No cherry-pick because our first pass is to determine
940 # parents to rewrite and skipping dropped commits would
941 # prematurely end our probe
942 - MERGES_OPTION=
943 - first_after_upstream="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
942 + merges_option=
943 + first_after_upstream="$(git rev-list --reverse --first-parent $upstream..$head | head -n 1)"
944 else
945 - MERGES_OPTION="--no-merges --cherry-pick"
945 + merges_option="--no-merges --cherry-pick"
946 fi
947
948 -SHORTHEAD=$(git rev-parse --short $HEAD)
949 -SHORTONTO=$(git rev-parse --short $ONTO)
950 -if test -z "$REBASE_ROOT"
951 - # this is now equivalent to ! -z "$UPSTREAM"
948 +shorthead=$(git rev-parse --short $head)
949 +shortonto=$(git rev-parse --short $onto)
950 +if test -z "$rebase_root"
951 + # this is now equivalent to ! -z "$upstream"
952 then
953 - SHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)
954 - REVISIONS=$UPSTREAM...$HEAD
955 - SHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD
953 + shortupstream=$(git rev-parse --short $upstream)
954 + revisions=$upstream...$head
955 + shortrevisions=$shortupstream..$shorthead
956 else
957 - REVISIONS=$ONTO...$HEAD
958 - SHORTREVISIONS=$SHORTHEAD
957 + revisions=$onto...$head
958 + shortrevisions=$shorthead
959 fi
960 -git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \
960 +git rev-list $merges_option --pretty=oneline --abbrev-commit \
961 --abbrev=7 --reverse --left-right --topo-order \
962 - $REVISIONS | \
962 + $revisions | \
963 sed -n "s/^>//p" |
964 while read -r shortsha1 rest
965 do
966 - if test t != "$PRESERVE_MERGES"
966 + if test t != "$preserve_merges"
967 then
968 - printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
968 + printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
969 else
970 sha1=$(git rev-parse $shortsha1)
971 - if test -z "$REBASE_ROOT"
971 + if test -z "$rebase_root"
972 then
973 preserve=t
974 for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)
975 do
976 - if test -f "$REWRITTEN"/$p -a \( $p != $ONTO -o $sha1 = $first_after_upstream \)
976 + if test -f "$rewritten"/$p -a \( $p != $onto -o $sha1 = $first_after_upstream \)
977 then
978 preserve=f
979 fi
@@ -983,43 +983,43 @@ do
983 fi
984 if test f = "$preserve"
985 then
986 - touch "$REWRITTEN"/$sha1
987 - printf '%s\n' "pick $shortsha1 $rest" >> "$TODO"
986 + touch "$rewritten"/$sha1
987 + printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
988 fi
989 fi
990 done
991
992 # Watch for commits that been dropped by --cherry-pick
993 -if test t = "$PRESERVE_MERGES"
993 +if test t = "$preserve_merges"
994 then
995 - mkdir "$DROPPED"
995 + mkdir "$dropped"
996 # Save all non-cherry-picked changes
997 - git rev-list $REVISIONS --left-right --cherry-pick | \
998 - sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
997 + git rev-list $revisions --left-right --cherry-pick | \
998 + sed -n "s/^>//p" > "$dotest"/not-cherry-picks
999 # Now all commits and note which ones are missing in
1000 # not-cherry-picks and hence being dropped
1001 - git rev-list $REVISIONS |
1001 + git rev-list $revisions |
1002 while read rev
1003 do
1004 - if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
1004 + if test -f "$rewritten"/$rev -a "$(sane_grep "$rev" "$dotest"/not-cherry-picks)" = ""
1005 then
1006 # Use -f2 because if rev-list is telling us this commit is
1007 # not worthwhile, we don't want to track its multiple heads,
1008 # just the history of its first-parent for others that will
1009 # be rebasing on top of it
1010 - git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$DROPPED"/$rev
1010 + git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$dropped"/$rev
1011 short=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)
1012 - sane_grep -v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
1013 - rm "$REWRITTEN"/$rev
1012 + sane_grep -v "^[a-z][a-z]* $short" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
1013 + rm "$rewritten"/$rev
1014 fi
1015 done
1016 fi
1017
1018 -test -s "$TODO" || echo noop >> "$TODO"
1019 -test -n "$AUTOSQUASH" && rearrange_squash "$TODO"
1020 -cat >> "$TODO" << EOF
1018 +test -s "$todo" || echo noop >> "$todo"
1019 +test -n "$autosquash" && rearrange_squash "$todo"
1020 +cat >> "$todo" << EOF
1021
1022 -# Rebase $SHORTREVISIONS onto $SHORTONTO
1022 +# Rebase $shortrevisions onto $shortonto
1023 #
1024 # Commands:
1025 # p, pick = use commit
@@ -1034,18 +1034,18 @@ cat >> "$TODO" << EOF
1034 #
1035 EOF
1036
1037 -has_action "$TODO" ||
1037 +has_action "$todo" ||
1038 die_abort "Nothing to do"
1039
1040 -cp "$TODO" "$TODO".backup
1041 -git_editor "$TODO" ||
1040 +cp "$todo" "$todo".backup
1041 +git_editor "$todo" ||
1042 die_abort "Could not execute editor"
1043
1044 -has_action "$TODO" ||
1044 +has_action "$todo" ||
1045 die_abort "Nothing to do"
1046
1047 -test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
1047 +test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
1048
1049 -output git checkout $ONTO || die_abort "could not detach HEAD"
1050 -git update-ref ORIG_HEAD $HEAD
1049 +output git checkout $onto || die_abort "could not detach HEAD"
1050 +git update-ref ORIG_HEAD $head
1051 do_rest
git-rebase.sh
+16 -16
@@ -36,13 +36,13 @@ cd_to_toplevel
36
37 LF='
38 '
39 -OK_TO_SKIP_PRE_REBASE=
40 -RESOLVEMSG="
39 +ok_to_skip_pre_rebase=
40 +resolvemsg="
41 When you have resolved this problem run \"git rebase --continue\".
42 If you would prefer to skip this patch, instead run \"git rebase --skip\".
43 To restore the original branch and stop rebasing run \"git rebase --abort\".
44 "
45 -unset newbase
45 +unset onto
46 strategy=recursive
47 strategy_opts=
48 do_merge=
@@ -86,7 +86,7 @@ continue_merge () {
86 then
87 echo "You still have unmerged paths in your index"
88 echo "did you forget to use git add?"
89 - die "$RESOLVEMSG"
89 + die "$resolvemsg"
90 fi
91
92 cmt=`cat "$merge_dir/current"`
@@ -96,7 +96,7 @@ continue_merge () {
96 then
97 echo "Commit failed, please do not call \"git commit\""
98 echo "directly, but instead do one of the following: "
99 - die "$RESOLVEMSG"
99 + die "$resolvemsg"
100 fi
101 if test -z "$GIT_QUIET"
102 then
@@ -139,11 +139,11 @@ call_merge () {
139 ;;
140 1)
141 git rerere $allow_rerere_autoupdate
142 - die "$RESOLVEMSG"
142 + die "$resolvemsg"
143 ;;
144 2)
145 echo "Strategy: $rv $strategy failed, try another" 1>&2
146 - die "$RESOLVEMSG"
146 + die "$resolvemsg"
147 ;;
148 *)
149 die "Unknown exit code ($rv) from command:" \
@@ -199,7 +199,7 @@ is_interactive () {
199 }
200
201 run_pre_rebase_hook () {
202 - if test -z "$OK_TO_SKIP_PRE_REBASE" &&
202 + if test -z "$ok_to_skip_pre_rebase" &&
203 test -x "$GIT_DIR/hooks/pre-rebase"
204 then
205 "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
@@ -234,10 +234,10 @@ while test $# != 0
234 do
235 case "$1" in
236 --no-verify)
237 - OK_TO_SKIP_PRE_REBASE=yes
237 + ok_to_skip_pre_rebase=yes
238 ;;
239 --verify)
240 - OK_TO_SKIP_PRE_REBASE=
240 + ok_to_skip_pre_rebase=
241 ;;
242 --continue|--skip|--abort)
243 test $total_argc -eq 1 || usage
@@ -245,7 +245,7 @@ do
245 ;;
246 --onto)
247 test 2 -le "$#" || usage
248 - newbase="$2"
248 + onto="$2"
249 shift
250 ;;
251 -M|-m|--m|--me|--mer|--merg|--merge)
@@ -359,7 +359,7 @@ continue)
359 finish_rb_merge
360 exit
361 fi
362 - git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
362 + git am --resolved --3way --resolvemsg="$resolvemsg" &&
363 move_to_original_branch
364 exit
365 ;;
@@ -378,7 +378,7 @@ skip)
378 finish_rb_merge
379 exit
380 fi
381 - git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
381 + git am -3 --skip --resolvemsg="$resolvemsg" &&
382 move_to_original_branch
383 exit
384 ;;
@@ -425,7 +425,7 @@ then
425 unset root_flag
426 upstream_arg="$upstream_name"
427 else
428 - test -z "$newbase" && die "--root must be used with --onto"
428 + test -z "$onto" && die "--root must be used with --onto"
429 unset upstream_name
430 unset upstream
431 root_flag="--root"
@@ -433,7 +433,7 @@ else
433 fi
434
435 # Make sure the branch to rebase onto is valid.
436 -onto_name=${newbase-"$upstream_name"}
436 +onto_name=${onto-"$upstream_name"}
437 case "$onto_name" in
438 *...*)
439 if left=${onto_name%...*} right=${onto_name#*...} &&
@@ -554,7 +554,7 @@ then
554 git format-patch -k --stdout --full-index --ignore-if-in-upstream \
555 --src-prefix=a/ --dst-prefix=b/ \
556 --no-renames $root_flag "$revisions" |
557 - git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
557 + git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
558 move_to_original_branch
559 ret=$?
560 test 0 != $ret -a -d "$apply_dir" &&