Merge branch 'mz/maint-rebase-stat-config'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2010 05:49:50 +0000 (21:49 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Dec 2010 05:49:50 +0000 (21:49 -0800)
* mz/maint-rebase-stat-config:
rebase: only show stat if configured to true

1  2 
git-rebase.sh
diff --combined git-rebase.sh
index 0e9d52a5007ed12a23d52a157a7118a50b7693f8,6ab95a33e9818ba53ef0d37a0808969410c23cda..9a6d7a4730a3ca81a4060f73b2be516fe235bb43
@@@ -3,7 -3,7 +3,7 @@@
  # Copyright (c) 2005 Junio C Hamano.
  #
  
 -USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
 +USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--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>
@@@ -44,12 -44,12 +44,13 @@@ To restore the original branch and sto
  "
  unset newbase
  strategy=recursive
 +strategy_opts=
  do_merge=
  dotest="$GIT_DIR"/rebase-merge
  prec=4
  verbose=
- diffstat=$(git config --bool rebase.stat)
+ diffstat=
+ test "$(git config --bool rebase.stat)" = true && diffstat=t
  git_am_opt=
  rebase_root=
  force_rebase=
@@@ -80,7 -80,6 +81,7 @@@ continue_merge () 
                then
                        printf "Committed: %0${prec}d " $msgnum
                fi
 +              echo "$cmt $(git rev-parse HEAD^0)" >> "$dotest/rewritten"
        else
                if test -z "$GIT_QUIET"
                then
@@@ -111,9 -110,9 +112,9 @@@ call_merge () 
        export GITHEAD_$cmt GITHEAD_$hd
        if test -n "$GIT_QUIET"
        then
 -              export GIT_MERGE_VERBOSITY=1
 +              GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
        fi
 -      git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
 +      eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
        rv=$?
        case "$rv" in
        0)
@@@ -153,11 -152,6 +154,11 @@@ move_to_original_branch () 
  
  finish_rb_merge () {
        move_to_original_branch
 +      git notes copy --for-rewrite=rebase < "$dotest"/rewritten
 +      if test -x "$GIT_DIR"/hooks/post-rewrite &&
 +              test -s "$dotest"/rewritten; then
 +              "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten
 +      fi
        rm -r "$dotest"
        say All done.
  }
@@@ -199,6 -193,14 +200,6 @@@ test -f "$GIT_DIR"/rebase-apply/applyin
  
  is_interactive "$@" && exec git-rebase--interactive "$@"
  
 -if test $# -eq 0
 -then
 -      test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
 -      test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
 -              die 'A rebase is in progress, try --continue, --skip or --abort.'
 -      die "No arguments given and $GIT_DIR/rebase-apply already exists."
 -fi
 -
  while test $# != 0
  do
        case "$1" in
                test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
                        die "No rebase in progress?"
  
 +              git update-index --ignore-submodules --refresh &&
                git diff-files --quiet --ignore-submodules || {
                        echo "You must edit all merge conflicts and then"
                        echo "mark them as resolved using git add"
        -M|-m|--m|--me|--mer|--merg|--merge)
                do_merge=t
                ;;
 +      -X*|--strategy-option*)
 +              case "$#,$1" in
 +              1,-X|1,--strategy-option)
 +                      usage ;;
 +              *,-X|*,--strategy-option)
 +                      newopt="$2"
 +                      shift ;;
 +              *,--strategy-option=*)
 +                      newopt="$(expr " $1" : ' --strategy-option=\(.*\)')" ;;
 +              *,-X*)
 +                      newopt="$(expr " $1" : ' -X\(.*\)')" ;;
 +              1,*)
 +                      usage ;;
 +              esac
 +              strategy_opts="$strategy_opts $(git rev-parse --sq-quote "--$newopt")"
 +              do_merge=t
 +              ;;
        -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
                --strateg=*|--strategy=*|\
        -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
        --root)
                rebase_root=t
                ;;
 -      -f|--f|--fo|--for|--forc|force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase)
 +      -f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)
                force_rebase=t
                ;;
        --rerere-autoupdate|--no-rerere-autoupdate)
  done
  test $# -gt 2 && usage
  
 +if test $# -eq 0 && test -z "$rebase_root"
 +then
 +      test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
 +      test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
 +              die 'A rebase is in progress, try --continue, --skip or --abort.'
 +fi
 +
  # Make sure we do not have $GIT_DIR/rebase-apply
  if test -z "$do_merge"
  then
@@@ -412,7 -389,19 +413,7 @@@ els
        fi
  fi
  
 -# The tree must be really really clean.
 -if ! git update-index --ignore-submodules --refresh > /dev/null; then
 -      echo >&2 "cannot rebase: you have unstaged changes"
 -      git diff-files --name-status -r --ignore-submodules -- >&2
 -      exit 1
 -fi
 -diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
 -case "$diff" in
 -?*)   echo >&2 "cannot rebase: your index contains uncommitted changes"
 -      echo >&2 "$diff"
 -      exit 1
 -      ;;
 -esac
 +require_clean_work_tree "rebase" "Please commit or stash them."
  
  if test -z "$rebase_root"
  then
@@@ -550,8 -539,7 +551,8 @@@ f
  if test -z "$do_merge"
  then
        git format-patch -k --stdout --full-index --ignore-if-in-upstream \
 -              $root_flag "$revisions" |
 +              --src-prefix=a/ --dst-prefix=b/ \
 +              --no-renames $root_flag "$revisions" |
        git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
        move_to_original_branch
        ret=$?