X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-rebase.sh;h=1b9ea48cd713d7f6b25e529d09743447635f6432;hb=109a8037a9c7d5dc5b93e637c663406159ab3a75;hp=fb4fef7b1d6f7abb08fca562ecaad6e36f671768;hpb=28bf4ba014c9b41679f41580fa9e1cc294b240d9;p=git.git diff --git a/git-rebase.sh b/git-rebase.sh index fb4fef7b1..10a238ae3 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 ] [|--root] [] [--quiet | -q]' +USAGE='[--interactive | -i] [-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 @@ -44,6 +44,7 @@ To restore the original branch and stop rebasing run \"git rebase --abort\". " unset newbase strategy=recursive +strategy_opts= do_merge= dotest="$GIT_DIR"/rebase-merge prec=4 @@ -79,6 +80,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 @@ -109,9 +111,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) @@ -151,6 +153,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. } @@ -192,14 +199,6 @@ test -f "$GIT_DIR"/rebase-apply/applying && 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 @@ -210,6 +209,7 @@ do 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" @@ -295,6 +295,23 @@ do -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) @@ -347,7 +364,7 @@ do --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) @@ -364,6 +381,13 @@ do 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 @@ -538,7 +562,8 @@ fi 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=$?