33# Copyright (c) 2005 Junio C Hamano.
44#
55
6- USAGE=' [--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
6+ USAGE=' [--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q] '
77LONG_USAGE=' git-rebase replaces <branch> with a new branch of the
88same name. When the --onto option is provided the new branch starts
99out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -72,11 +72,20 @@ continue_merge () {
7272 echo " directly, but instead do one of the following: "
7373 die " $RESOLVEMSG "
7474 fi
75- printf " Committed: %0${prec} d " $msgnum
75+ if test -z " $GIT_QUIET "
76+ then
77+ printf " Committed: %0${prec} d " $msgnum
78+ fi
7679 else
77- printf " Already applied: %0${prec} d " $msgnum
80+ if test -z " $GIT_QUIET "
81+ then
82+ printf " Already applied: %0${prec} d " $msgnum
83+ fi
84+ fi
85+ if test -z " $GIT_QUIET "
86+ then
87+ git rev-list --pretty=oneline -1 " $cmt " | sed -e ' s/^[^ ]* //'
7888 fi
79- git rev-list --pretty=oneline -1 " $cmt " | sed -e ' s/^[^ ]* //'
8089
8190 prev_head=` git rev-parse HEAD^0`
8291 # save the resulting commit so we can read-tree on it later
@@ -97,6 +106,10 @@ call_merge () {
97106 eval GITHEAD_$cmt =' "${cmt_name##refs/heads/}~$(($end - $msgnum))"'
98107 eval GITHEAD_$hd =' $(cat "$dotest/onto_name")'
99108 export GITHEAD_$cmt GITHEAD_$hd
109+ if test -n " $GIT_QUIET "
110+ then
111+ export GIT_MERGE_VERBOSITY=1
112+ fi
100113 git-merge-$strategy " $cmt ^" -- " $hd " " $cmt "
101114 rv=$?
102115 case " $rv " in
@@ -138,7 +151,7 @@ move_to_original_branch () {
138151finish_rb_merge () {
139152 move_to_original_branch
140153 rm -r " $dotest "
141- echo " All done."
154+ say All done.
142155}
143156
144157is_interactive () {
207220 end=$( cat " $dotest /end" )
208221 msgnum=$( cat " $dotest /msgnum" )
209222 onto=$( cat " $dotest /onto" )
223+ GIT_QUIET=$( cat " $dotest /quiet" )
210224 continue_merge
211225 while test " $msgnum " -le " $end "
212226 do
219233 head_name=$( cat " $GIT_DIR " /rebase-apply/head-name) &&
220234 onto=$( cat " $GIT_DIR " /rebase-apply/onto) &&
221235 orig_head=$( cat " $GIT_DIR " /rebase-apply/orig-head) &&
236+ GIT_QUIET=$( cat " $GIT_DIR " /rebase-apply/quiet)
222237 git am --resolved --3way --resolvemsg=" $RESOLVEMSG " &&
223238 move_to_original_branch
224239 exit
236251 msgnum=$( cat " $dotest /msgnum" )
237252 msgnum=$(( $msgnum + 1 ))
238253 onto=$( cat " $dotest /onto" )
254+ GIT_QUIET=$( cat " $dotest /quiet" )
239255 while test " $msgnum " -le " $end "
240256 do
241257 call_merge " $msgnum "
247263 head_name=$( cat " $GIT_DIR " /rebase-apply/head-name) &&
248264 onto=$( cat " $GIT_DIR " /rebase-apply/onto) &&
249265 orig_head=$( cat " $GIT_DIR " /rebase-apply/orig-head) &&
266+ GIT_QUIET=$( cat " $GIT_DIR " /rebase-apply/quiet)
250267 git am -3 --skip --resolvemsg=" $RESOLVEMSG " &&
251268 move_to_original_branch
252269 exit
258275 git rerere clear
259276 if test -d " $dotest "
260277 then
278+ GIT_QUIET=$( cat " $dotest /quiet" )
261279 move_to_original_branch
262280 else
263281 dotest=" $GIT_DIR " /rebase-apply
282+ GIT_QUIET=$( cat " $dotest /quiet" )
264283 move_to_original_branch
265284 fi
266285 git reset --hard $( cat " $dotest /orig-head" )
298317 -v|--verbose)
299318 verbose=t
300319 diffstat=t
320+ GIT_QUIET=
321+ ;;
322+ -q|--quiet)
323+ GIT_QUIET=t
324+ git_am_opt=" $git_am_opt -q"
325+ verbose=
326+ diffstat=
301327 ;;
302328 --whitespace=* )
303329 git_am_opt=" $git_am_opt $1 "
@@ -442,15 +468,15 @@ then
442468 then
443469 # Lazily switch to the target branch if needed...
444470 test -z " $switch_to " || git checkout " $switch_to "
445- echo >&2 " Current branch $branch_name is up to date."
471+ say " Current branch $branch_name is up to date."
446472 exit 0
447473 else
448- echo " Current branch $branch_name is up to date, rebase forced."
474+ say " Current branch $branch_name is up to date, rebase forced."
449475 fi
450476fi
451477
452478# Detach HEAD and reset the tree
453- echo " First, rewinding head to replay your work on top of it..."
479+ say " First, rewinding head to replay your work on top of it..."
454480git checkout -q " $onto ^0" || die " could not detach HEAD"
455481git update-ref ORIG_HEAD $branch
456482
468494# we just fast forwarded.
469495if test " $mb " = " $branch "
470496then
471- echo >&2 " Fast-forwarded $branch_name to $onto_name ."
497+ say " Fast-forwarded $branch_name to $onto_name ."
472498 move_to_original_branch
473499 exit 0
474500fi
490516 test 0 ! = $ret -a -d " $GIT_DIR " /rebase-apply &&
491517 echo $head_name > " $GIT_DIR " /rebase-apply/head-name &&
492518 echo $onto > " $GIT_DIR " /rebase-apply/onto &&
493- echo $orig_head > " $GIT_DIR " /rebase-apply/orig-head
519+ echo $orig_head > " $GIT_DIR " /rebase-apply/orig-head &&
520+ echo " $GIT_QUIET " > " $GIT_DIR " /rebase-apply/quiet
494521 exit $ret
495522fi
496523
@@ -504,6 +531,7 @@ prev_head=$orig_head
504531echo " $prev_head " > " $dotest /prev_head"
505532echo " $orig_head " > " $dotest /orig-head"
506533echo " $head_name " > " $dotest /head-name"
534+ echo " $GIT_QUIET " > " $dotest /quiet"
507535
508536msgnum=0
509537for cmt in ` git rev-list --reverse --no-merges " $revisions " `
0 commit comments