Merge branch 'sb/quiet-porcelains'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Jul 2009 02:40:50 +0000 (19:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Jul 2009 02:40:50 +0000 (19:40 -0700)
* sb/quiet-porcelains:
stash: teach quiet option
am, rebase: teach quiet option
submodule, repack: migrate to git-sh-setup's say()
git-sh-setup: introduce say() for quiet options
am: suppress apply errors when using 3-way
t4150: test applying with a newline in subject

1  2 
git-rebase.sh
git-submodule.sh
diff --combined git-rebase.sh
index 334629fc97c0d06e9c9cfda058bdd999810f9d55,84b5173f936f89ef7750cc9d5b9f6b041c8aef1f..18bc6946cfa592c11cf7499b1c1ff9a6cb378b26
@@@ -3,7 -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 +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 +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 +151,7 @@@ move_to_original_branch () 
  finish_rb_merge () {
        move_to_original_branch
        rm -r "$dotest"
-       echo "All done."
+       say All done.
  }
  
  is_interactive () {
@@@ -168,8 -181,10 +181,8 @@@ run_pre_rebase_hook () 
        if test -z "$OK_TO_SKIP_PRE_REBASE" &&
           test -x "$GIT_DIR/hooks/pre-rebase"
        then
 -              "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
 -                      echo >&2 "The pre-rebase hook refused to rebase."
 -                      exit 1
 -              }
 +              "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
 +              die "The pre-rebase hook refused to rebase."
        fi
  }
  
@@@ -207,6 -222,7 +220,7 @@@ d
                        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
                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
                        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"
                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
                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")
        -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"
@@@ -357,7 -385,8 +383,7 @@@ f
  
  # The tree must be really really clean.
  if ! git update-index --ignore-submodules --refresh; then
 -      echo >&2 "cannot rebase: you have unstaged changes"
 -      exit 1
 +      die "cannot rebase: you have unstaged changes"
  fi
  diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
  case "$diff" in
@@@ -442,15 -471,15 +468,15 @@@ the
        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
  
@@@ -468,7 -497,7 +494,7 @@@ f
  # 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
@@@ -490,7 -519,8 +516,8 @@@ the
        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
  
@@@ -504,6 -534,7 +531,7 @@@ prev_head=$orig_hea
  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"`
diff --combined git-submodule.sh
index f4f35626713bd8ec238262731b0fd2ab59d6f07f,58d2fd2ccb65925e81b1aab3c8e624359b286a14..ebed711da41a7ac3c4caa7ae9b7f73e0c75f4fe7
@@@ -5,7 -5,7 +5,7 @@@
  # Copyright (c) 2007 Lars Hjemli
  
  USAGE="[--quiet] [--cached] \
 -[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch]|summary [-n|--summary-limit <n>] [<commit>]] \
 +[add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit <n>] [<commit>]] \
  [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]"
  OPTIONS_SPEC=
  . git-sh-setup
@@@ -14,23 -14,11 +14,11 @@@ require_work_tre
  
  command=
  branch=
- quiet=
  reference=
  cached=
  nofetch=
  update=
  
- #
- # print stuff on stdout unless -q was specified
- #
- say()
- {
-       if test -z "$quiet"
-       then
-               echo "$@"
-       fi
- }
  # Resolve relative url by appending to parent's url
  resolve_relative_url ()
  {
@@@ -137,7 -125,7 +125,7 @@@ cmd_add(
                        shift
                        ;;
                -q|--quiet)
-                       quiet=1
+                       GIT_QUIET=1
                        ;;
                --reference)
                        case "$2" in '') usage ;; esac
@@@ -273,7 -261,7 +261,7 @@@ cmd_init(
        do
                case "$1" in
                -q|--quiet)
-                       quiet=1
+                       GIT_QUIET=1
                        ;;
                --)
                        shift
@@@ -333,7 -321,7 +321,7 @@@ cmd_update(
                case "$1" in
                -q|--quiet)
                        shift
-                       quiet=1
+                       GIT_QUIET=1
                        ;;
                -i|--init)
                        init=1
                        reference="$1"
                        shift
                        ;;
 +              -m|--merge)
 +                      shift
 +                      update="merge"
 +                      ;;
                --)
                        shift
                        break
                                action="rebase"
                                msg="rebased onto"
                                ;;
 +                      merge)
 +                              command="git merge"
 +                              action="merge"
 +                              msg="merged in"
 +                              ;;
                        *)
                                command="git checkout $force -q"
                                action="checkout"
@@@ -659,7 -638,7 +647,7 @@@ cmd_status(
        do
                case "$1" in
                -q|--quiet)
-                       quiet=1
+                       GIT_QUIET=1
                        ;;
                --cached)
                        cached=1
@@@ -713,7 -692,7 +701,7 @@@ cmd_sync(
        do
                case "$1" in
                -q|--quiet)
-                       quiet=1
+                       GIT_QUIET=1
                        shift
                        ;;
                --)
@@@ -768,7 -747,7 +756,7 @@@ d
                command=$1
                ;;
        -q|--quiet)
-               quiet=1
+               GIT_QUIET=1
                ;;
        -b|--branch)
                case "$2" in