Merge branch 'mz/rebase-no-mbox'
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 Jul 2012 22:36:31 +0000 (15:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Jul 2012 22:36:31 +0000 (15:36 -0700)
Teach "am --rebasing" codepath to grab authorship, log message and
the patch text directly out of existing commits. This will help
rebasing commits that have confusing "diff" output in their log
messages.

* mz/rebase-no-mbox:
am: don't call mailinfo if $rebasing
am --rebasing: get patch body from commit, not from mailbox
rebase --root: print usage on too many args
rebase: don't source git-sh-setup twice

1  2 
git-rebase--interactive.sh
git-rebase.sh
index 5f566726abd51bed534806415207b989d377eeab,a5b018d4ac69405c39f775f38bc48d76a7f04da5..3a3c3823571162853e4e88876e7646287c7c1af5
@@@ -9,9 -9,7 +9,7 @@@
  #
  # The original idea comes from Eric W. Biederman, in
  # http://article.gmane.org/gmane.comp.version-control.git/22407
- . git-sh-setup
+ #
  # The file containing rebase commands, comments, and empty lines.
  # This file is created by "git rebase -i" then edited by the user.  As
  # the lines are processed, they are removed from the front of this
@@@ -684,27 -682,6 +682,27 @@@ rearrange_squash () 
        rm -f "$1.sq" "$1.rearranged"
  }
  
 +# Add commands after a pick or after a squash/fixup serie
 +# in the todo list.
 +add_exec_commands () {
 +      {
 +              first=t
 +              while read -r insn rest
 +              do
 +                      case $insn in
 +                      pick)
 +                              test -n "$first" ||
 +                              printf "%s" "$cmd"
 +                              ;;
 +                      esac
 +                      printf "%s %s\n" "$insn" "$rest"
 +                      first=
 +              done
 +              printf "%s" "$cmd"
 +      } <"$1" >"$1.new" &&
 +      mv "$1.new" "$1"
 +}
 +
  case "$action" in
  continue)
        # do we have anything to commit?
@@@ -878,8 -855,6 +876,8 @@@ f
  
  test -s "$todo" || echo noop >> "$todo"
  test -n "$autosquash" && rearrange_squash "$todo"
 +test -n "$cmd" && add_exec_commands "$todo"
 +
  cat >> "$todo" << EOF
  
  # Rebase $shortrevisions onto $shortonto
diff --combined git-rebase.sh
index 6bd8eae6480033b353d1d86403fc9f2067d8e502,6df06c400804776e32b4625ff5820115c0cf1497..5bddfa9690e8dfbedd07e31dc7e768b60f156213
@@@ -3,8 -3,7 +3,8 @@@
  # Copyright (c) 2005 Junio C Hamano.
  #
  
 -USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
 +USAGE='[--interactive | -i] [--exec | -x <cmd>] [-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>
@@@ -31,8 -30,8 +31,8 @@@ Example:       git-rebase master~1 topi
  SUBDIRECTORY_OK=Yes
  OPTIONS_KEEPDASHDASH=
  OPTIONS_SPEC="\
 -git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]
 -git rebase [-i] [options] --onto <newbase> --root [<branch>]
 +git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] [<upstream>] [<branch>]
 +git rebase [-i] [options] [--exec <cmd>] --onto <newbase> --root [<branch>]
  git-rebase [-i] --continue | --abort | --skip
  --
   Available options are
@@@ -44,7 -43,6 +44,7 @@@ s,strategy=!       use the given merge 
  no-ff!             cherry-pick all commits, even if unchanged
  m,merge!           use merging strategies to rebase
  i,interactive!     let the user edit the list of commits to rebase
 +x,exec=!           add exec lines after each commit of the editable list
  k,keep-empty     preserve empty commits during rebase
  f,force-rebase!    force rebase even if branch is up to date
  X,strategy-option=! pass the argument through to the merge strategy
@@@ -78,7 -76,6 +78,7 @@@ If you would prefer to skip this patch
  To check out the original branch and stop rebasing run \"git rebase --abort\".
  "
  unset onto
 +cmd=
  strategy=
  strategy_opts=
  do_merge=
                onto="$2"
                shift
                ;;
 +      -x)
 +              test 2 -le "$#" || usage
 +              cmd="${cmd}exec $2${LF}"
 +              shift
 +              ;;
        -i)
                interactive_rebase=explicit
                ;;
  done
  test $# -gt 2 && usage
  
 +if test -n "$cmd" &&
 +   test "$interactive_rebase" != explicit
 +then
 +      die "--exec option must be used with --interactive option"
 +fi
 +
  if test -n "$action"
  then
        test -z "$in_progress" && die "No rebase in progress?"
@@@ -414,6 -400,7 +414,7 @@@ els
        test -z "$onto" && die "You must specify --onto when using --root"
        unset upstream_name
        unset upstream
+       test $# -gt 1 && usage
        upstream_arg=--root
  fi
  
@@@ -464,7 -451,7 +465,7 @@@ case "$#" i
                die "fatal: no such branch: $1"
        fi
        ;;
*)
0)
        # Do not need to switch branches, we are already on it.
        if branch_name=`git symbolic-ref -q HEAD`
        then
        fi
        orig_head=$(git rev-parse --verify "${branch_name}^0") || exit
        ;;
+ *)
+       die "BUG: unexpected number of arguments left to parse"
+       ;;
  esac
  
  require_clean_work_tree "rebase" "Please commit or stash them."