From: Junio C Hamano Date: Fri, 13 Jul 2012 22:36:31 +0000 (-0700) Subject: Merge branch 'mz/rebase-no-mbox' X-Git-Tag: v1.7.12-rc0~44 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a1204bd7c3021cbaf1f4f485eb11f2e5a72355b3?hp=-c Merge branch 'mz/rebase-no-mbox' 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 --- a1204bd7c3021cbaf1f4f485eb11f2e5a72355b3 diff --combined git-rebase--interactive.sh index 5f566726ab,a5b018d4ac..3a3c382357 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@@ -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 6bd8eae648,6df06c4008..5bddfa9690 --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -3,8 -3,7 +3,8 @@@ # Copyright (c) 2005 Junio C Hamano. # -USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto ] [|--root] [] [--quiet | -q]' +USAGE='[--interactive | -i] [--exec | -x ] [-v] [--force-rebase | -f] + [--no-ff] [--onto ] [|--root] [] [--quiet | -q]' LONG_USAGE='git-rebase replaces with a new branch of the same name. When the --onto option is provided the new branch starts out with a HEAD equal to , otherwise it is equal to @@@ -31,8 -30,8 +31,8 @@@ Example: git-rebase master~1 topi SUBDIRECTORY_OK=Yes OPTIONS_KEEPDASHDASH= OPTIONS_SPEC="\ -git rebase [-i] [options] [--onto ] [] [] -git rebase [-i] [options] --onto --root [] +git rebase [-i] [options] [--exec ] [--onto ] [] [] +git rebase [-i] [options] [--exec ] --onto --root [] 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= @@@ -223,11 -220,6 +223,11 @@@ d onto="$2" shift ;; + -x) + test 2 -le "$#" || usage + cmd="${cmd}exec $2${LF}" + shift + ;; -i) interactive_rebase=explicit ;; @@@ -313,12 -305,6 +313,12 @@@ 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 @@@ -476,6 -463,9 +477,9 @@@ 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."