summaryrefslogtreecommitdiff
path: root/git-rebase.sh
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2009-06-16 22:33:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-06-18 18:54:48 (GMT)
commit0e987a12fc1d481d81ad9c56f4714efb08667213 (patch)
tree3558298ec717c32ddac1204e6c9f751ab0da4d38 /git-rebase.sh
parent2e6a30ef8fbaedc5f2ee199d36f7256bb0cfdf1e (diff)
downloadgit-0e987a12fc1d481d81ad9c56f4714efb08667213.zip
git-0e987a12fc1d481d81ad9c56f4714efb08667213.tar.gz
git-0e987a12fc1d481d81ad9c56f4714efb08667213.tar.bz2
am, rebase: teach quiet option
git-am and git-rebase are talkative scripts. Teach them to be quiet when told, allowing them to speak only when they fail or experience errors. The quiet option is maintained when git-am or git-rebase fails to apply a patch. This means subsequent --resolved, --continue, --skip, --abort invocations will be quiet if the original invocation was quiet. Drop a handful of >&2 redirection; the rest of the program sends all the info messages to stdout, not to stderr. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-rebase.sh')
-rwxr-xr-xgit-rebase.sh48
1 files changed, 38 insertions, 10 deletions
diff --git a/git-rebase.sh b/git-rebase.sh
index b83fd3f..84b5173 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Junio C Hamano.
#
-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
same name. When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -72,11 +72,20 @@ continue_merge () {
echo "directly, but instead do one of the following: "
die "$RESOLVEMSG"
fi
- printf "Committed: %0${prec}d " $msgnum
+ if test -z "$GIT_QUIET"
+ then
+ printf "Committed: %0${prec}d " $msgnum
+ fi
else
- printf "Already applied: %0${prec}d " $msgnum
+ if test -z "$GIT_QUIET"
+ then
+ printf "Already applied: %0${prec}d " $msgnum
+ fi
+ fi
+ if test -z "$GIT_QUIET"
+ then
+ git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
fi
- git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
prev_head=`git rev-parse HEAD^0`
# save the resulting commit so we can read-tree on it later
@@ -97,6 +106,10 @@ call_merge () {
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
export GITHEAD_$cmt GITHEAD_$hd
+ if test -n "$GIT_QUIET"
+ then
+ export GIT_MERGE_VERBOSITY=1
+ fi
git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
rv=$?
case "$rv" in
@@ -138,7 +151,7 @@ move_to_original_branch () {
finish_rb_merge () {
move_to_original_branch
rm -r "$dotest"
- echo "All done."
+ say All done.
}
is_interactive () {
@@ -209,6 +222,7 @@ do
end=$(cat "$dotest/end")
msgnum=$(cat "$dotest/msgnum")
onto=$(cat "$dotest/onto")
+ GIT_QUIET=$(cat "$dotest/quiet")
continue_merge
while test "$msgnum" -le "$end"
do
@@ -221,6 +235,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
+ GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
@@ -238,6 +253,7 @@ do
msgnum=$(cat "$dotest/msgnum")
msgnum=$(($msgnum + 1))
onto=$(cat "$dotest/onto")
+ GIT_QUIET=$(cat "$dotest/quiet")
while test "$msgnum" -le "$end"
do
call_merge "$msgnum"
@@ -249,6 +265,7 @@ do
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
+ GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
@@ -260,9 +277,11 @@ do
git rerere clear
if test -d "$dotest"
then
+ GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch
else
dotest="$GIT_DIR"/rebase-apply
+ GIT_QUIET=$(cat "$dotest/quiet")
move_to_original_branch
fi
git reset --hard $(cat "$dotest/orig-head")
@@ -300,6 +319,13 @@ do
-v|--verbose)
verbose=t
diffstat=t
+ GIT_QUIET=
+ ;;
+ -q|--quiet)
+ GIT_QUIET=t
+ git_am_opt="$git_am_opt -q"
+ verbose=
+ diffstat=
;;
--whitespace=*)
git_am_opt="$git_am_opt $1"
@@ -445,15 +471,15 @@ then
then
# Lazily switch to the target branch if needed...
test -z "$switch_to" || git checkout "$switch_to"
- echo >&2 "Current branch $branch_name is up to date."
+ say "Current branch $branch_name is up to date."
exit 0
else
- echo "Current branch $branch_name is up to date, rebase forced."
+ say "Current branch $branch_name is up to date, rebase forced."
fi
fi
# Detach HEAD and reset the tree
-echo "First, rewinding head to replay your work on top of it..."
+say "First, rewinding head to replay your work on top of it..."
git checkout -q "$onto^0" || die "could not detach HEAD"
git update-ref ORIG_HEAD $branch
@@ -471,7 +497,7 @@ fi
# we just fast forwarded.
if test "$mb" = "$branch"
then
- echo >&2 "Fast-forwarded $branch_name to $onto_name."
+ say "Fast-forwarded $branch_name to $onto_name."
move_to_original_branch
exit 0
fi
@@ -493,7 +519,8 @@ then
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
echo $onto > "$GIT_DIR"/rebase-apply/onto &&
- echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head
+ echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head &&
+ echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet
exit $ret
fi
@@ -507,6 +534,7 @@ prev_head=$orig_head
echo "$prev_head" > "$dotest/prev_head"
echo "$orig_head" > "$dotest/orig-head"
echo "$head_name" > "$dotest/head-name"
+echo "$GIT_QUIET" > "$dotest/quiet"
msgnum=0
for cmt in `git rev-list --reverse --no-merges "$revisions"`