From f327dbced25a3c6fcc0b84d2d6adffa9343b09f0 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 13 Apr 2006 22:01:24 +0000 Subject: Shell utilities: Guard against expr' magic tokens. Some words, e.g., `match', are special to expr(1), and cause strange parsing effects. Track down all uses of expr and mangle the arguments so that this isn't a problem. Signed-off-by: Mark Wooding Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 5956f0654e..86dfe9cb96 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -94,7 +94,7 @@ case "$#" in ;; *) branch_name=`git symbolic-ref HEAD` || die "No current branch" - branch_name=`expr "$branch_name" : 'refs/heads/\(.*\)'` + branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` ;; esac branch=$(git-rev-parse --verify "${branch_name}^0") || exit -- cgit v1.2.1 From b176e6ba5bc37466ffcb6c8c0f38c47ec6e9e73a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 26 Apr 2006 12:07:42 -0700 Subject: rebase: typofix. Noticed by Sean. Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 86dfe9cb96..f7b2b9401a 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -107,7 +107,7 @@ onto=$(git-rev-parse --verify "${onto_name}^0") || exit # Check if we are already based on $onto, but this should be # done only when upstream and onto are the same. -if test "$upstream" = "onto" +if test "$upstream" = "$onto" then mb=$(git-merge-base "$onto" "$branch") if test "$mb" = "$onto" -- cgit v1.2.1 From 031321c654de3c19de45b2dacbdc990b5a694e34 Mon Sep 17 00:00:00 2001 From: sean Date: Wed, 26 Apr 2006 10:49:38 -0400 Subject: Add --continue and --abort options to git-rebase. git rebase [--onto ] [] git rebase --continue git rebase --abort Add "--continue" to restart the rebase process after manually resolving conflicts. The user is warned if there are still differences between the index and the working files. Add "--abort" to restore the original branch, and remove the .dotest working files. Some minor additions to the git-rebase documentation. [jc: fix that applies to the maintenance track has been dealt with separately.] Signed-off-by: Junio C Hamano --- git-rebase.sh | 62 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 24 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index f7b2b9401a..9e259028e0 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -4,37 +4,51 @@ # USAGE='[--onto ] []' -LONG_USAGE='git-rebase applies to (or optionally to ) commits -from that do not appear in . When is not -specified it defaults to the current branch (HEAD). - -When git-rebase is complete, will be updated to point to the -newly created line of commit objects, so the previous line will not be -accessible unless there are other references to it already. - -Assuming the following history: - - A---B---C topic - / - D---E---F---G master - -The result of the following command: - - git-rebase --onto master~1 master topic - - would be: - - A'\''--B'\''--C'\'' topic - / - D---E---F---G master +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 +It then attempts to create a new commit for each commit from the original + that does not exist in the branch. + +It is possible that a merge failure will prevent this process from being +completely automatic. You will have to resolve any such merge failure +and run git-rebase --continue. If you can not resolve the merge failure, +running git-rebase --abort will restore the original and remove +the working files found in the .dotest directory. + +Note that if is not specified on the command line, the +currently checked out branch is used. You must be in the top +directory of your project to start (or continue) a rebase. + +Example: git-rebase master~1 topic + + A---B---C topic A'\''--B'\''--C'\'' topic + / --> / + D---E---F---G master D---E---F---G master ' - . git-sh-setup unset newbase while case "$#" in 0) break ;; esac do case "$1" in + --continue) + diff=$(git-diff-files) + case "$diff" in + ?*) echo "You must edit all merge conflicts and then" + echo "mark them as resolved using git update-index" + exit 1 + ;; + esac + git am --resolved --3way + exit + ;; + --abort) + [ -d .dotest ] || die "No rebase in progress?" + git reset --hard ORIG_HEAD + rm -r .dotest + exit + ;; --onto) test 2 -le "$#" || usage newbase="$2" -- cgit v1.2.1 From cc120056a881101326488e3c5c2d3af2ce3a8de6 Mon Sep 17 00:00:00 2001 From: Sean Date: Sat, 13 May 2006 23:34:08 -0400 Subject: Make git rebase interactive help match documentation. Signed-off-by: Sean Estabrooks Signed-off-by: Junio C Hamano --- git-rebase.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 9e259028e0..6ff6088d18 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -12,9 +12,10 @@ It then attempts to create a new commit for each commit from the original It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure -and run git-rebase --continue. If you can not resolve the merge failure, -running git-rebase --abort will restore the original and remove -the working files found in the .dotest directory. +and run git rebase --continue. Another option is to bypass the commit +that caused the merge failure with git rebase --skip. To restore the +original and remove the .dotest working files, use the command +git rebase --abort instead. Note that if is not specified on the command line, the currently checked out branch is used. You must be in the top @@ -28,6 +29,11 @@ Example: git-rebase master~1 topic ' . git-sh-setup +RESOLVEMSG=" +When you have resolved this problem run \"git rebase --continue\". +If you would prefer to skip this patch, instead run \"git rebase --skip\". +To restore the original branch and stop rebasing run \"git rebase --abort\". +" unset newbase while case "$#" in 0) break ;; esac do @@ -40,7 +46,11 @@ do exit 1 ;; esac - git am --resolved --3way + git am --resolved --3way --resolvemsg="$RESOLVEMSG" + exit + ;; + --skip) + git am -3 --skip --resolvemsg="$RESOLVEMSG" exit ;; --abort) @@ -143,4 +153,5 @@ then fi git-format-patch -k --stdout --full-index "$upstream" ORIG_HEAD | -git am --binary -3 -k +git am --binary -3 -k --resolvemsg="$RESOLVEMSG" + -- cgit v1.2.1 From efbff23609654ac0542d3421d19eea8dbc1f80cd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 21 May 2006 03:16:38 -0700 Subject: git-rebase: use canonical A..B syntax to format-patch Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 6ff6088d18..e6b57b8ab9 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -152,6 +152,6 @@ then exit 0 fi -git-format-patch -k --stdout --full-index "$upstream" ORIG_HEAD | +git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD | git am --binary -3 -k --resolvemsg="$RESOLVEMSG" -- cgit v1.2.1 From 58634dbff8221f158118342975f6cd281af14fd9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 21 Jun 2006 03:04:41 -0700 Subject: rebase: Allow merge strategies to be used when rebasing This solves the problem of rebasing local commits against an upstream that has renamed files. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 183 insertions(+), 9 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index e6b57b8ab9..bce7bf84d6 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -34,7 +34,96 @@ When you have resolved this problem run \"git rebase --continue\". If you would prefer to skip this patch, instead run \"git rebase --skip\". To restore the original branch and stop rebasing run \"git rebase --abort\". " + +MRESOLVEMSG=" +When you have resolved this problem run \"git rebase --continue\". +To restore the original branch and stop rebasing run \"git rebase --abort\". +" unset newbase +strategy=recursive +do_merge= +dotest=$GIT_DIR/.dotest-merge +prec=4 + +continue_merge () { + test -n "$prev_head" || die "prev_head must be defined" + test -d "$dotest" || die "$dotest directory does not exist" + + unmerged=$(git-ls-files -u) + if test -n "$unmerged" + then + echo "You still have unmerged paths in your index" + echo "did you forget update-index?" + die "$MRESOLVEMSG" + fi + + if test -n "`git-diff-index HEAD`" + then + git-commit -C "`cat $dotest/current`" + else + echo "Previous merge succeeded automatically" + fi + + prev_head=`git-rev-parse HEAD^0` + + # save the resulting commit so we can read-tree on it later + echo "$prev_head" > "$dotest/`printf %0${prec}d $msgnum`.result" + echo "$prev_head" > "$dotest/prev_head" + + # onto the next patch: + msgnum=$(($msgnum + 1)) + printf "%0${prec}d" "$msgnum" > "$dotest/msgnum" +} + +call_merge () { + cmt="$(cat $dotest/`printf %0${prec}d $1`)" + echo "$cmt" > "$dotest/current" + git-merge-$strategy "$cmt^" -- HEAD "$cmt" + rv=$? + case "$rv" in + 0) + git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG" + ;; + 1) + test -d "$GIT_DIR/rr-cache" && git-rerere + die "$MRESOLVEMSG" + ;; + 2) + echo "Strategy: $rv $strategy failed, try another" 1>&2 + die "$MRESOLVEMSG" + ;; + *) + die "Unknown exit code ($rv) from command:" \ + "git-merge-$strategy $cmt^ -- HEAD $cmt" + ;; + esac +} + +finish_rb_merge () { + set -e + + msgnum=1 + echo "Finalizing rebased commits..." + git-reset --hard "`cat $dotest/onto`" + end="`cat $dotest/end`" + while test "$msgnum" -le "$end" + do + msgnum=`printf "%0${prec}d" "$msgnum"` + printf "%0${prec}d" "$msgnum" > "$dotest/msgnum" + + git-read-tree `cat "$dotest/$msgnum.result"` + git-checkout-index -q -f -u -a + git-commit -C "`cat $dotest/$msgnum`" + + echo "Committed $msgnum" + echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ + sed 's/^[a-f0-9]\+ //'` + msgnum=$(($msgnum + 1)) + done + rm -r "$dotest" + echo "All done." +} + while case "$#" in 0) break ;; esac do case "$1" in @@ -46,17 +135,43 @@ do exit 1 ;; esac + if test -d "$dotest" + then + prev_head="`cat $dotest/prev_head`" + end="`cat $dotest/end`" + msgnum="`cat $dotest/msgnum`" + onto="`cat $dotest/onto`" + continue_merge + while test "$msgnum" -le "$end" + do + call_merge "$msgnum" + continue_merge + done + finish_rb_merge + exit + fi git am --resolved --3way --resolvemsg="$RESOLVEMSG" exit ;; --skip) + if test -d "$dotest" + then + die "--skip is not supported when using --merge" + fi git am -3 --skip --resolvemsg="$RESOLVEMSG" exit ;; --abort) - [ -d .dotest ] || die "No rebase in progress?" + if test -d "$dotest" + then + rm -r "$dotest" + elif test -d .dotest + then + rm -r .dotest + else + die "No rebase in progress?" + fi git reset --hard ORIG_HEAD - rm -r .dotest exit ;; --onto) @@ -64,6 +179,23 @@ do newbase="$2" shift ;; + -M|-m|--m|--me|--mer|--merg|--merge) + do_merge=t + ;; + -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ + --strateg=*|--strategy=*|\ + -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) + case "$#,$1" in + *,*=*) + strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;; + 1,*) + usage ;; + *) + strategy="$2" + shift ;; + esac + do_merge=t + ;; -*) usage ;; @@ -75,16 +207,25 @@ do done # Make sure we do not have .dotest -if mkdir .dotest +if test -z "$do_merge" then - rmdir .dotest -else - echo >&2 ' + if mkdir .dotest + then + rmdir .dotest + else + echo >&2 ' It seems that I cannot create a .dotest directory, and I wonder if you are in the middle of patch application or another rebase. If that is not the case, please rm -fr .dotest and run me again. I am stopping in case you still have something valuable there.' - exit 1 + exit 1 + fi +else + if test -d "$dotest" + then + die "previous dotest directory $dotest still exists." \ + 'try git-rebase < --continue | --abort >' + fi fi # The tree must be really really clean. @@ -152,6 +293,39 @@ then exit 0 fi -git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD | -git am --binary -3 -k --resolvemsg="$RESOLVEMSG" +if test -z "$do_merge" +then + git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD | + git am --binary -3 -k --resolvemsg="$RESOLVEMSG" + exit $? +fi + +# start doing a rebase with git-merge +# this is rename-aware if the recursive (default) strategy is used + +mkdir -p "$dotest" +echo "$onto" > "$dotest/onto" +prev_head=`git-rev-parse HEAD^0` +echo "$prev_head" > "$dotest/prev_head" + +msgnum=0 +for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \ + | perl -e 'print reverse <>'` +do + msgnum=$(($msgnum + 1)) + echo "$cmt" > "$dotest/`printf "%0${prec}d" $msgnum`" +done + +printf "%0${prec}d" 1 > "$dotest/msgnum" +printf "%0${prec}d" "$msgnum" > "$dotest/end" + +end=$msgnum +msgnum=1 + +while test "$msgnum" -le "$end" +do + call_merge "$msgnum" + continue_merge +done +finish_rb_merge -- cgit v1.2.1 From 693c15dc282c36042eac8d215beae3067db7565c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 21 Jun 2006 03:04:42 -0700 Subject: rebase: error out for NO_PYTHON if they use recursive merge recursive merge relies on Python, and we can't perform rename-aware merges without the recursive merge. So bail out before trying it. The test won't work w/o recursive merge, either, so skip that, too. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index bce7bf84d6..b9ce1125d8 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -300,6 +300,15 @@ then exit $? fi +if test "@@NO_PYTHON@@" && test "$strategy" = "recursive" +then + die 'The recursive merge strategy currently relies on Python, +which this installation of git was not configured with. Please consider +a different merge strategy (e.g. octopus, resolve, stupid, ours) +or install Python and git with Python support.' + +fi + # start doing a rebase with git-merge # this is rename-aware if the recursive (default) strategy is used -- cgit v1.2.1 From 5887ac821f9df614cfcf3349960523e1c36f2de7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 22 Jun 2006 01:44:54 -0700 Subject: rebase --merge: fix for rebasing more than 7 commits. Instead of using 4-digit numbers to name commits being rebased, just use "cmt.$msgnum" string, with $msgnum as a decimal number without leading zero padding. This makes it possible to rebase more than 9999 commits, but of more practical importance is that the earlier code used "printf" to format already formatted $msgnum and barfed when it counted up to 0008. In other words, the old code was incapable of rebasing more than 7 commits, and this fixes that problem. Signed-off-by: Junio C Hamano --- git-rebase.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index b9ce1125d8..91594775e6 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -67,16 +67,16 @@ continue_merge () { prev_head=`git-rev-parse HEAD^0` # save the resulting commit so we can read-tree on it later - echo "$prev_head" > "$dotest/`printf %0${prec}d $msgnum`.result" + echo "$prev_head" > "$dotest/cmt.$msgnum.result" echo "$prev_head" > "$dotest/prev_head" # onto the next patch: msgnum=$(($msgnum + 1)) - printf "%0${prec}d" "$msgnum" > "$dotest/msgnum" + echo "$msgnum" >"$dotest/msgnum" } call_merge () { - cmt="$(cat $dotest/`printf %0${prec}d $1`)" + cmt="$(cat $dotest/cmt.$1)" echo "$cmt" > "$dotest/current" git-merge-$strategy "$cmt^" -- HEAD "$cmt" rv=$? @@ -108,15 +108,12 @@ finish_rb_merge () { end="`cat $dotest/end`" while test "$msgnum" -le "$end" do - msgnum=`printf "%0${prec}d" "$msgnum"` - printf "%0${prec}d" "$msgnum" > "$dotest/msgnum" - - git-read-tree `cat "$dotest/$msgnum.result"` + git-read-tree `cat "$dotest/cmt.$msgnum.result"` git-checkout-index -q -f -u -a - git-commit -C "`cat $dotest/$msgnum`" + git-commit -C "`cat $dotest/cmt.$msgnum`" - echo "Committed $msgnum" - echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ + printf "Committed %0${prec}d" $msgnum + echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ sed 's/^[a-f0-9]\+ //'` msgnum=$(($msgnum + 1)) done @@ -322,11 +319,11 @@ for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \ | perl -e 'print reverse <>'` do msgnum=$(($msgnum + 1)) - echo "$cmt" > "$dotest/`printf "%0${prec}d" $msgnum`" + echo "$cmt" > "$dotest/cmt.$msgnum" done -printf "%0${prec}d" 1 > "$dotest/msgnum" -printf "%0${prec}d" "$msgnum" > "$dotest/end" +echo 1 >"$dotest/msgnum" +echo $msgnum >"$dotest/end" end=$msgnum msgnum=1 -- cgit v1.2.1 From 9a99c087da7cd6b4a41c19df3053542f645315c5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Jun 2006 18:29:47 -0700 Subject: rebase: allow --merge option to handle patches merged upstream Enhance t3401-rebase-partial to test with --merge as well as the standard am -3 strategy. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 91594775e6..53fb14ed88 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -82,7 +82,10 @@ call_merge () { rv=$? case "$rv" in 0) - git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG" + if test -n "`git-diff-index HEAD`" + then + git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG" + fi ;; 1) test -d "$GIT_DIR/rr-cache" && git-rerere @@ -110,9 +113,13 @@ finish_rb_merge () { do git-read-tree `cat "$dotest/cmt.$msgnum.result"` git-checkout-index -q -f -u -a - git-commit -C "`cat $dotest/cmt.$msgnum`" - - printf "Committed %0${prec}d" $msgnum + if test -n "`git-diff-index HEAD`" + then + git-commit -C "`cat $dotest/cmt.$msgnum`" + printf "Committed %0${prec}d" $msgnum + else + printf "Already applied: %0${prec}d" $msgnum + fi echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ sed 's/^[a-f0-9]\+ //'` msgnum=$(($msgnum + 1)) -- cgit v1.2.1 From 9e4bc7dd1bb9d92491c475cec55147fa0b3f954d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Jun 2006 18:29:48 -0700 Subject: rebase: cleanup rebasing with --merge We no longer have to recommit each patch to remove the parent information we're rebasing since we're using the low-level merge strategies directly instead of git-merge. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 53fb14ed88..a95ada6b14 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -59,15 +59,16 @@ continue_merge () { if test -n "`git-diff-index HEAD`" then + printf "Committed: %0${prec}d" $msgnum git-commit -C "`cat $dotest/current`" else - echo "Previous merge succeeded automatically" + printf "Already applied: %0${prec}d" $msgnum fi + echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ + sed 's/^[a-f0-9]\+ //'` prev_head=`git-rev-parse HEAD^0` - # save the resulting commit so we can read-tree on it later - echo "$prev_head" > "$dotest/cmt.$msgnum.result" echo "$prev_head" > "$dotest/prev_head" # onto the next patch: @@ -82,10 +83,7 @@ call_merge () { rv=$? case "$rv" in 0) - if test -n "`git-diff-index HEAD`" - then - git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG" - fi + return ;; 1) test -d "$GIT_DIR/rr-cache" && git-rerere @@ -103,27 +101,6 @@ call_merge () { } finish_rb_merge () { - set -e - - msgnum=1 - echo "Finalizing rebased commits..." - git-reset --hard "`cat $dotest/onto`" - end="`cat $dotest/end`" - while test "$msgnum" -le "$end" - do - git-read-tree `cat "$dotest/cmt.$msgnum.result"` - git-checkout-index -q -f -u -a - if test -n "`git-diff-index HEAD`" - then - git-commit -C "`cat $dotest/cmt.$msgnum`" - printf "Committed %0${prec}d" $msgnum - else - printf "Already applied: %0${prec}d" $msgnum - fi - echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ - sed 's/^[a-f0-9]\+ //'` - msgnum=$(($msgnum + 1)) - done rm -r "$dotest" echo "All done." } -- cgit v1.2.1 From d5e673b60be2eb99153276366b6b5ff3277805df Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Jun 2006 18:29:49 -0700 Subject: rebase: allow --skip to work with --merge Now that we control the merge base selection, we won't be forced into rolling things in that we wanted to skip beforehand. Also, add a test to ensure this all works as intended. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index a95ada6b14..9ad1c44d48 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -137,7 +137,18 @@ do --skip) if test -d "$dotest" then - die "--skip is not supported when using --merge" + prev_head="`cat $dotest/prev_head`" + end="`cat $dotest/end`" + msgnum="`cat $dotest/msgnum`" + msgnum=$(($msgnum + 1)) + onto="`cat $dotest/onto`" + while test "$msgnum" -le "$end" + do + call_merge "$msgnum" + continue_merge + done + finish_rb_merge + exit fi git am -3 --skip --resolvemsg="$RESOLVEMSG" exit -- cgit v1.2.1 From 8096fae7269e7b3882394100151bc017446b01a1 Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Tue, 27 Jun 2006 18:54:26 +0200 Subject: Fix expr usage for FreeBSD Some implementations of "expr" (e.g. FreeBSD's) fail, if an argument starts with a dash. Signed-off-by: Dennis Stosberg Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 9ad1c44d48..0ac085e14a 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -179,7 +179,7 @@ do -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) case "$#,$1" in *,*=*) - strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;; + strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; 1,*) usage ;; *) -- cgit v1.2.1 From 66eb64cba64a26dbf2b1d4e319d6514696154fee Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 28 Jun 2006 02:11:06 -0700 Subject: rebase: get rid of outdated MRESOLVEMSG There was a time when rebase --skip didn't work when used with --merge, but that is no more so we don't need that message anymore. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 0ac085e14a..fd0e7c498d 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -34,11 +34,6 @@ When you have resolved this problem run \"git rebase --continue\". If you would prefer to skip this patch, instead run \"git rebase --skip\". To restore the original branch and stop rebasing run \"git rebase --abort\". " - -MRESOLVEMSG=" -When you have resolved this problem run \"git rebase --continue\". -To restore the original branch and stop rebasing run \"git rebase --abort\". -" unset newbase strategy=recursive do_merge= @@ -54,7 +49,7 @@ continue_merge () { then echo "You still have unmerged paths in your index" echo "did you forget update-index?" - die "$MRESOLVEMSG" + die "$RESOLVEMSG" fi if test -n "`git-diff-index HEAD`" @@ -87,11 +82,11 @@ call_merge () { ;; 1) test -d "$GIT_DIR/rr-cache" && git-rerere - die "$MRESOLVEMSG" + die "$RESOLVEMSG" ;; 2) echo "Strategy: $rv $strategy failed, try another" 1>&2 - die "$MRESOLVEMSG" + die "$RESOLVEMSG" ;; *) die "Unknown exit code ($rv) from command:" \ -- cgit v1.2.1 From f0ef05967f3b261fb16f5fdea6dd104c9bdb4c8c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 28 Jun 2006 03:24:23 -0700 Subject: rebase: check for errors from git-commit commit does not always succeed, so we'll have to check for it in the absence of set -e. This fixes a regression introduced in 9e4bc7dd1bb9d92491c475cec55147fa0b3f954d Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index fd0e7c498d..3945e06714 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -54,8 +54,13 @@ continue_merge () { if test -n "`git-diff-index HEAD`" then + if ! git-commit -C "`cat $dotest/current`" + then + echo "Commit failed, please do not call \"git commit\"" + echo "directly, but instead do one of the following: " + die "$RESOLVEMSG" + fi printf "Committed: %0${prec}d" $msgnum - git-commit -C "`cat $dotest/current`" else printf "Already applied: %0${prec}d" $msgnum fi -- cgit v1.2.1 From d9bffc08fd2cec626e3a390fa4cc47587a8c7f9e Mon Sep 17 00:00:00 2001 From: Michal Rokos Date: Sat, 8 Jul 2006 17:32:04 +0200 Subject: Using 'perl' in *.sh Some GIT's shell script are using bare 'perl' for perl invocation. Use @@PERL@@ symbol and replace it with PERL_PATH_SQ everywhere. Signed-off-by: Michal Rokos Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 3945e06714..1b9e986926 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -311,7 +311,7 @@ echo "$prev_head" > "$dotest/prev_head" msgnum=0 for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \ - | perl -e 'print reverse <>'` + | @@PERL@@ -e 'print reverse <>'` do msgnum=$(($msgnum + 1)) echo "$cmt" > "$dotest/cmt.$msgnum" -- cgit v1.2.1 From 8ef1c7c77d3e5950a839d9ae348827fa288a9a11 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Fri, 14 Jul 2006 00:47:23 -0400 Subject: Record rebase changes as 'rebase' in the reflog. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-rebase.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 1b9e986926..29028dd5fc 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -131,7 +131,8 @@ do finish_rb_merge exit fi - git am --resolved --3way --resolvemsg="$RESOLVEMSG" + git am --resolved --3way --resolvemsg="$RESOLVEMSG" \ + --reflog-action=rebase exit ;; --skip) @@ -150,7 +151,8 @@ do finish_rb_merge exit fi - git am -3 --skip --resolvemsg="$RESOLVEMSG" + git am -3 --skip --resolvemsg="$RESOLVEMSG" \ + --reflog-action=rebase exit ;; --abort) @@ -288,7 +290,8 @@ fi if test -z "$do_merge" then git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD | - git am --binary -3 -k --resolvemsg="$RESOLVEMSG" + git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \ + --reflog-action=rebase exit $? fi -- cgit v1.2.1 From 6d297f81373e19d86b8f02cb68120201d1b0ab1d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 8 Jul 2006 18:42:41 +0200 Subject: Status update on merge-recursive in C This is just an update for people being interested. Alex and me were busy with that project for a few days now. While it has progressed nicely, there are quite a couple TODOs in merge-recursive.c, just search for "TODO". For impatient people: yes, it passes all the tests, and yes, according to the evil test Alex did, it is faster than the Python script. But no, it is not yet finished. Biggest points are: - there are still three external calls - in the end, it should not be necessary to write the index more than once (just before exiting) - a lot of things can be refactored to make the code easier and shorter BTW we cannot just plug in git-merge-tree yet, because git-merge-tree does not handle renames at all. This patch is meant for testing, and as such, - it compile the program to git-merge-recur - it adjusts the scripts and tests to use git-merge-recur instead of git-merge-recursive - it provides "TEST", a script to execute the tests regarding -recursive - it inlines the changes to read-cache.c (read_cache_from(), discard_cache() and refresh_cache_entry()) Brought to you by Alex Riesen and Dscho Signed-off-by: Junio C Hamano --- git-rebase.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 1b9e986926..2a4c8c8a89 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -35,7 +35,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". To restore the original branch and stop rebasing run \"git rebase --abort\". " unset newbase -strategy=recursive +strategy=recur do_merge= dotest=$GIT_DIR/.dotest-merge prec=4 @@ -292,7 +292,7 @@ then exit $? fi -if test "@@NO_PYTHON@@" && test "$strategy" = "recursive" +if test "@@NO_PYTHON@@" && test "$strategy" = "recur" then die 'The recursive merge strategy currently relies on Python, which this installation of git was not configured with. Please consider -- cgit v1.2.1 From 06d30f4f3eea71bce4cf48db3ea384976b3983b7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 9 Jul 2006 00:42:26 -0700 Subject: recur vs recursive: help testing without touching too many stuff. During git-merge-recur development, you could set an environment variable GIT_USE_RECUR_FOR_RECURSIVE to use WIP recur in place of the recursive strategy. Signed-off-by: Junio C Hamano --- git-rebase.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 2a4c8c8a89..8c5da7219e 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -35,7 +35,13 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". To restore the original branch and stop rebasing run \"git rebase --abort\". " unset newbase -strategy=recur +case "${GIT_USE_RECUR_FOR_RECURSIVE}" in +'') + strategy=recursive ;; +?*) + strategy=recur ;; +esac + do_merge= dotest=$GIT_DIR/.dotest-merge prec=4 @@ -198,6 +204,11 @@ do shift done +case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in +recursive,?*) + strategy=recur ;; +esac + # Make sure we do not have .dotest if test -z "$do_merge" then @@ -292,7 +303,7 @@ then exit $? fi -if test "@@NO_PYTHON@@" && test "$strategy" = "recur" +if test "@@NO_PYTHON@@" && test "$strategy" = "recursive" then die 'The recursive merge strategy currently relies on Python, which this installation of git was not configured with. Please consider -- cgit v1.2.1 From 83c31614ceae2612b7cdba40e6401716fe854cd2 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Thu, 27 Jul 2006 10:32:25 +0100 Subject: rebase: Fix the detection of fast-forwarding of the current branch to upstream. Previously, a rebasing operation with on a branch that is just tracking an upstream branch would output a confusing "Nothing to do" due to no patches being given to git-am. The test brings the behaviour back into line with that of just before e646c9c8c0aa995eac284ea0a2117add19c4461c. Signed-off-by: Robert Shearman Signed-off-by: Junio C Hamano --- git-rebase.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 29028dd5fc..240032f32d 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -266,14 +266,11 @@ onto=$(git-rev-parse --verify "${onto_name}^0") || exit # Check if we are already based on $onto, but this should be # done only when upstream and onto are the same. -if test "$upstream" = "$onto" +mb=$(git-merge-base "$onto" "$branch") +if test "$upstream" = "$onto" && test "$mb" = "$onto" then - mb=$(git-merge-base "$onto" "$branch") - if test "$mb" = "$onto" - then - echo >&2 "Current branch $branch_name is up to date." - exit 0 - fi + echo >&2 "Current branch $branch_name is up to date." + exit 0 fi # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. @@ -281,7 +278,7 @@ git-reset --hard "$onto" # If the $onto is a proper descendant of the tip of the branch, then # we just fast forwarded. -if test "$mb" = "$onto" +if test "$mb" = "$branch" then echo >&2 "Fast-forwarded $branch to $newbase." exit 0 -- cgit v1.2.1 From d587ed13bc37550a6d21067127f6c057c5d5e7fc Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Thu, 27 Jul 2006 10:32:46 +0100 Subject: rebase: Make the fast-fowarding message more user-friendly by using branch names instead of SHA1 IDs. Signed-off-by: Robert Shearman Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 240032f32d..7d3a5d0e71 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -280,7 +280,7 @@ git-reset --hard "$onto" # we just fast forwarded. if test "$mb" = "$branch" then - echo >&2 "Fast-forwarded $branch to $newbase." + echo >&2 "Fast-forwarded $branch_name to $onto_name." exit 0 fi -- cgit v1.2.1 From a06f678eb998862ea83b73e46ece32f99132935b Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 24 Sep 2006 19:49:47 -0700 Subject: Deprecate merge-recursive.py This renames merge-recursive written in Python to merge-recursive-old, and makes merge-recur as a synonym to merge-recursive. We do not remove merge-recur yet, but we will remove merge-recur and merge-recursive-old in a few releases down the road. Signed-off-by: Junio C Hamano --- git-rebase.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 20f74d4167..a7373c0532 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -35,13 +35,7 @@ If you would prefer to skip this patch, instead run \"git rebase --skip\". To restore the original branch and stop rebasing run \"git rebase --abort\". " unset newbase -case "${GIT_USE_RECUR_FOR_RECURSIVE}" in -'') - strategy=recursive ;; -?*) - strategy=recur ;; -esac - +strategy=recursive do_merge= dotest=$GIT_DIR/.dotest-merge prec=4 @@ -206,11 +200,6 @@ do shift done -case "$strategy,${GIT_USE_RECUR_FOR_RECURSIVE}" in -recursive,?*) - strategy=recur ;; -esac - # Make sure we do not have .dotest if test -z "$do_merge" then @@ -303,11 +292,11 @@ then exit $? fi -if test "@@NO_PYTHON@@" && test "$strategy" = "recursive" +if test "@@NO_PYTHON@@" && test "$strategy" = "recursive-old" then - die 'The recursive merge strategy currently relies on Python, + die 'The recursive-old merge strategy is written in Python, which this installation of git was not configured with. Please consider -a different merge strategy (e.g. octopus, resolve, stupid, ours) +a different merge strategy (e.g. recursive, resolve, or stupid) or install Python and git with Python support.' fi -- cgit v1.2.1 From 91b489776c25866568c081e8cf4ae83fa41f8707 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 3 Oct 2006 17:29:26 +0100 Subject: git-rebase: Use --ignore-if-in-upstream option when executing git-format-patch. This reduces the number of conflicts when rebasing after a series of patches to the same piece of code is committed upstream. Signed-off-by: Robert Shearman Signed-off-by: Junio C Hamano --- git-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index a7373c0532..413636e208 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -286,7 +286,7 @@ fi if test -z "$do_merge" then - git-format-patch -k --stdout --full-index "$upstream"..ORIG_HEAD | + git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \ --reflog-action=rebase exit $? -- cgit v1.2.1 From b758789c202dc491555b698149afe4d4941f7cd5 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 3 Oct 2006 17:29:31 +0100 Subject: git-rebase: Add a -v option to show a diffstat of the changes upstream at the start of a rebase. Signed-off-by: Robert Shearman Signed-off-by: Junio C Hamano --- git-rebase.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 413636e208..546fa446fc 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano. # -USAGE='[--onto ] []' +USAGE='[-v] [--onto ] []' 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 @@ -39,6 +39,7 @@ strategy=recursive do_merge= dotest=$GIT_DIR/.dotest-merge prec=4 +verbose= continue_merge () { test -n "$prev_head" || die "prev_head must be defined" @@ -190,6 +191,9 @@ do esac do_merge=t ;; + -v|--verbose) + verbose=t + ;; -*) usage ;; @@ -273,6 +277,12 @@ then exit 0 fi +if test -n "$verbose" +then + echo "Changes from $mb to $onto:" + git-diff-tree --stat --summary "$mb" "$onto" +fi + # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. git-reset --hard "$onto" -- cgit v1.2.1 From 7cdbff14d4823c3a3d64c2011ab0b23f794efef8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 20 Nov 2006 00:49:31 -0800 Subject: remove merge-recursive-old This frees the Porcelain-ish that comes with the core Python-free. Signed-off-by: Junio C Hamano --- git-rebase.sh | 9 --------- 1 file changed, 9 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 546fa446fc..25530dfdc5 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -302,15 +302,6 @@ then exit $? fi -if test "@@NO_PYTHON@@" && test "$strategy" = "recursive-old" -then - die 'The recursive-old merge strategy is written in Python, -which this installation of git was not configured with. Please consider -a different merge strategy (e.g. recursive, resolve, or stupid) -or install Python and git with Python support.' - -fi - # start doing a rebase with git-merge # this is rename-aware if the recursive (default) strategy is used -- cgit v1.2.1 From f131dd492f098f9f565df93df13e35c734284590 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 8 Dec 2006 13:29:56 -0800 Subject: rerere: record (or avoid misrecording) resolved, skipped or aborted rebase/am Data in rr-cache isn't valid after a patch application is skipped or and aborted, so our next commit could be misrecorded as a resolution of that skipped/failed commit, which is wrong. git-am --skip, git-rebase --skip/--abort will automatically invoke git-rerere clear to avoid this. Also, since git-am --resolved indicates a resolution was succesful, remember to run git-rerere to record the resolution (and not surprise the user when the next commit is made). Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-rebase.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 25530dfdc5..2b4f3477fa 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -139,6 +139,10 @@ do --skip) if test -d "$dotest" then + if test -d "$GIT_DIR/rr-cache" + then + git-rerere clear + fi prev_head="`cat $dotest/prev_head`" end="`cat $dotest/end`" msgnum="`cat $dotest/msgnum`" @@ -157,6 +161,10 @@ do exit ;; --abort) + if test -d "$GIT_DIR/rr-cache" + then + git-rerere clear + fi if test -d "$dotest" then rm -r "$dotest" -- cgit v1.2.1 From 228e2eb67e9f15983519f472cc1566a3dd857f9c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 22 Dec 2006 15:21:55 -0800 Subject: merge and reset: adjust for "reset --hard" messages An earlier commit made "reset --hard" chattier but leaking its message from "git rebase" (which calls it when first rewinding the current branch to prepare replaying our own changes) without explanation was confusing, so add an extra message to mention it. Inside restorestate in merge (which is rarely exercised codepath, where more than one strategies are attempted), resetting to the original state uses "reset --hard" -- this can be squelched entirely. Signed-off-by: Junio C Hamano --- git-rebase.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 2b4f3477fa..ece31425d0 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -292,6 +292,7 @@ then fi # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. +echo "First, rewinding head to replay your work on top of it..." git-reset --hard "$onto" # If the $onto is a proper descendant of the tip of the branch, then -- cgit v1.2.1 From f94741324e26af42093a89e955ff9a923abff951 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 28 Dec 2006 02:34:48 -0500 Subject: Use GIT_REFLOG_ACTION environment variable instead. Junio rightly pointed out that the --reflog-action parameter was starting to get out of control, as most porcelain code needed to hand it to other porcelain and plumbing alike to ensure the reflog contained the top-level user action and not the lower-level actions it invoked. At Junio's suggestion we are introducing the new set_reflog_action function to all shell scripts, allowing them to declare early on what their default reflog name should be, but this setting only takes effect if the caller has not already set the GIT_REFLOG_ACTION environment variable. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-rebase.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index ece31425d0..5c7c4a6901 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -28,6 +28,7 @@ Example: git-rebase master~1 topic D---E---F---G master D---E---F---G master ' . git-sh-setup +set_reflog_action rebase RESOLVEMSG=" When you have resolved this problem run \"git rebase --continue\". @@ -132,8 +133,7 @@ do finish_rb_merge exit fi - git am --resolved --3way --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am --resolved --3way --resolvemsg="$RESOLVEMSG" exit ;; --skip) @@ -156,8 +156,7 @@ do finish_rb_merge exit fi - git am -3 --skip --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am -3 --skip --resolvemsg="$RESOLVEMSG" exit ;; --abort) @@ -306,8 +305,7 @@ fi if test -z "$do_merge" then git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | - git am --binary -3 -k --resolvemsg="$RESOLVEMSG" \ - --reflog-action=rebase + git am --binary -3 -k --resolvemsg="$RESOLVEMSG" exit $? fi -- cgit v1.2.1 From 0bb733c91cb472a1a5b62381ff4037c6fb124e38 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 28 Dec 2006 02:34:56 -0500 Subject: Use branch names in 'git-rebase -m' conflict hunks. If a three-way merge in git-rebase generates a conflict then we should take advantage of git-merge-recursive's ability to include the branch name of each side of the conflict hunk by setting the GITHEAD_* environment variables. In the case of rebase there aren't really two clear branches; we have the branch we are rebasing onto, and we have the branch we are currently rebasing. Since most conflicts will be arising between the user's current branch and the branch they are rebasing onto we assume the stuff that isn't in the current commit is the "onto" branch and the stuff in the current commit is the "current" branch. This assumption may however come up wrong if the user resolves one conflict in such a way that it conflicts again on a future commit also being rebased. In this case the user's prior resolution will appear to be in the "onto" part of the hunk. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-rebase.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 5c7c4a6901..828c59ce61 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -81,10 +81,18 @@ continue_merge () { call_merge () { cmt="$(cat $dotest/cmt.$1)" echo "$cmt" > "$dotest/current" - git-merge-$strategy "$cmt^" -- HEAD "$cmt" + hd=$(git-rev-parse --verify HEAD) + cmt_name=$(git-symbolic-ref HEAD) + msgnum=$(cat $dotest/msgnum) + end=$(cat $dotest/end) + eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' + eval GITHEAD_$hd='"$(cat $dotest/onto_name)"' + export GITHEAD_$cmt GITHEAD_$hd + git-merge-$strategy "$cmt^" -- "$hd" "$cmt" rv=$? case "$rv" in 0) + unset GITHEAD_$cmt GITHEAD_$hd return ;; 1) @@ -314,6 +322,7 @@ fi mkdir -p "$dotest" echo "$onto" > "$dotest/onto" +echo "$onto_name" > "$dotest/onto_name" prev_head=`git-rev-parse HEAD^0` echo "$prev_head" > "$dotest/prev_head" -- cgit v1.2.1 From 7eff28a9b42cb0d3aad932338b2e645fc6ed8fa9 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 30 Dec 2006 23:32:38 -0500 Subject: Disallow working directory commands in a bare repository. If the user tries to run a porcelainish command which requires a working directory in a bare repository they may get unexpected results which are difficult to predict and may differ from command to command. Instead we should detect that the current repository is a bare repository and refuse to run the command there, as there is no working directory associated with it. [jc: updated Shawn's original somewhat -- bugs are mine.] Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-rebase.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 828c59ce61..98f9558145 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -29,6 +29,7 @@ Example: git-rebase master~1 topic ' . git-sh-setup set_reflog_action rebase +require_work_tree RESOLVEMSG=" When you have resolved this problem run \"git rebase --continue\". -- cgit v1.2.1 From 533b70390e540de4e0faed4823ee561c8368e5ec Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 12 Jan 2007 12:52:03 -0800 Subject: Allow whole-tree operations to be started from a subdirectory This updates five commands (merge, pull, rebase, revert and cherry-pick) so that they can be started from a subdirectory. This may not actually be what we want to do. These commands are inherently whole-tree operations, and an inexperienced user may mistakenly expect a "git pull" from a subdirectory would merge only the subdirectory the command started from. Signed-off-by: Junio C Hamano --- git-rebase.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 98f9558145..c8bd0f99d1 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -27,9 +27,12 @@ Example: git-rebase master~1 topic / --> / D---E---F---G master D---E---F---G master ' + +SUBDIRECTORY_OK=Yes . git-sh-setup set_reflog_action rebase require_work_tree +cd_to_toplevel RESOLVEMSG=" When you have resolved this problem run \"git rebase --continue\". -- cgit v1.2.1 From bcf316187699c5e97bf47c1b8a00c844bf809fbc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 20 Jan 2007 19:11:29 -0800 Subject: git-rebase: allow rebasing a detached HEAD. Signed-off-by: Junio C Hamano --- git-rebase.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index c8bd0f99d1..99cedadda1 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -275,8 +275,12 @@ case "$#" in git-checkout "$2" || usage ;; *) - branch_name=`git symbolic-ref HEAD` || die "No current branch" - branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` + if branch_name=`git symbolic-ref -q HEAD` + then + branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'` + else + branch_name=HEAD ;# detached + fi ;; esac branch=$(git-rev-parse --verify "${branch_name}^0") || exit -- cgit v1.2.1 From 6e598c326dc4217c387fd797d182dc2ac0a0fc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=A5gedal?= Date: Wed, 31 Jan 2007 17:12:03 +0100 Subject: Improved error message from git-rebase If the index wasn't clean, git-rebase would simply show the output from git-diff-index with no further comment to the user. Signed-off-by: Junio C Hamano --- git-rebase.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 99cedadda1..9d2f71d15c 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -249,7 +249,8 @@ fi git-update-index --refresh || exit diff=$(git-diff-index --cached --name-status -r HEAD) case "$diff" in -?*) echo "$diff" +?*) echo "cannot rebase: your index is not up-to-date" + echo "$diff" exit 1 ;; esac -- cgit v1.2.1 From 67dad687ad15d26d8e26f4d27874af0bc0965ce2 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Thu, 8 Feb 2007 15:57:08 +0200 Subject: add -C[NUM] to git-am Add -C[NUM] to git-am and git-rebase so that patches can be applied even if context has changed a bit. Signed-off-by: Michael S. Tsirkin Signed-off-by: Junio C Hamano --- git-rebase.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 9d2f71d15c..b51d19d12e 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -45,6 +45,7 @@ do_merge= dotest=$GIT_DIR/.dotest-merge prec=4 verbose= +git_am_opt= continue_merge () { test -n "$prev_head" || die "prev_head must be defined" @@ -213,6 +214,10 @@ do -v|--verbose) verbose=t ;; + -C*) + git_am_opt=$1 + shift + ;; -*) usage ;; @@ -322,7 +327,7 @@ fi if test -z "$do_merge" then git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | - git am --binary -3 -k --resolvemsg="$RESOLVEMSG" + git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" exit $? fi -- cgit v1.2.1 From a1bf91e081de236af34bf8acd484881ce146fc93 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 22 Mar 2007 02:54:59 -0700 Subject: git-rebase: make 'rebase HEAD branch' work as expected. When you want to amend the commit message of 3 commits before the tip of the current branch, say 'master', A--B--C--D--E(master) it is sometimes handy to make your head detached at that commit with: $ git checkout HEAD~3 ;# check out B $ git commit --amend ;# without modifying contents... to create: .B'(HEAD) / A--B--C--D--E(master) and then rebase 'master' branch onto HEAD with this: $ git rebase HEAD master to result in: .B'-C'-D'-E(master=HEAD) / A--B--C--D--E However, the current code interprets HEAD after it switches to the branch 'master', which means the rebase will not do anything. You have to say something unwieldly like this instead: $ git rebase $(git rev-parse HEAD) master This fixes it by expanding the $onto commit name before switching to the target branch. Signed-off-by: Junio C Hamano --- git-rebase.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index b51d19d12e..aadd580f8d 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -265,6 +265,10 @@ upstream_name="$1" upstream=`git rev-parse --verify "${upstream_name}^0"` || die "invalid upstream $upstream_name" +# Make sure the branch to rebase onto is valid. +onto_name=${newbase-"$upstream_name"} +onto=$(git-rev-parse --verify "${onto_name}^0") || exit + # If a hook exists, give it a chance to interrupt if test -x "$GIT_DIR/hooks/pre-rebase" then @@ -291,10 +295,6 @@ case "$#" in esac branch=$(git-rev-parse --verify "${branch_name}^0") || exit -# Make sure the branch to rebase onto is valid. -onto_name=${newbase-"$upstream_name"} -onto=$(git-rev-parse --verify "${onto_name}^0") || exit - # Now we are rebasing commits $upstream..$branch on top of $onto # Check if we are already based on $onto, but this should be -- cgit v1.2.1 From 06aff47b225506c4603a6f5ec5b4b16aa6a9d7ba Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sun, 25 Mar 2007 01:56:13 +0100 Subject: Use diff* with --exit-code in git-am, git-rebase and git-merge-ours This simplifies the shell code, reduces its memory footprint, and speeds things up. The performance improvements should be noticable when git-rebase works on big commits. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- git-rebase.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index aadd580f8d..1d96f32685 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -59,7 +59,7 @@ continue_merge () { die "$RESOLVEMSG" fi - if test -n "`git-diff-index HEAD`" + if ! git-diff-index --quiet HEAD then if ! git-commit -C "`cat $dotest/current`" then @@ -124,13 +124,11 @@ while case "$#" in 0) break ;; esac do case "$1" in --continue) - diff=$(git-diff-files) - case "$diff" in - ?*) echo "You must edit all merge conflicts and then" + git-diff-files --quiet || { + echo "You must edit all merge conflicts and then" echo "mark them as resolved using git update-index" exit 1 - ;; - esac + } if test -d "$dotest" then prev_head="`cat $dotest/prev_head`" -- cgit v1.2.1 From dc61b10d987d32522803044eccaa801ffbca4bfe Mon Sep 17 00:00:00 2001 From: Alex Riesen Date: Sat, 14 Apr 2007 00:19:05 +0200 Subject: Use rev-list --reverse in git-rebase.sh ...and drop the last perl dependency in the script. Signed-off-by: Alex Riesen Signed-off-by: Junio C Hamano --- git-rebase.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 1d96f32685..2dc2c4fe9b 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -339,8 +339,7 @@ prev_head=`git-rev-parse HEAD^0` echo "$prev_head" > "$dotest/prev_head" msgnum=0 -for cmt in `git-rev-list --no-merges "$upstream"..ORIG_HEAD \ - | @@PERL@@ -e 'print reverse <>'` +for cmt in `git-rev-list --reverse --no-merges "$upstream"..ORIG_HEAD` do msgnum=$(($msgnum + 1)) echo "$cmt" > "$dotest/cmt.$msgnum" -- cgit v1.2.1 From fefe49d134b4dadf3a184ba7a8e48388f3c15a24 Mon Sep 17 00:00:00 2001 From: James Bowes Date: Sat, 5 May 2007 16:48:54 -0400 Subject: Add colour support in rebase and merge tree diff stats output. The rebase and merge commands used diff-tree to display the summary stats of what files had changed from the operation. diff-tree does not read the diff ui configuration options, so the diff.color setting was not used. Have rebase and merge call diff rather than diff-tree, which does read the diff ui options. Signed-off-by: James Bowes Signed-off-by: Junio C Hamano --- git-rebase.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 2dc2c4fe9b..61770b5a28 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -307,7 +307,8 @@ fi if test -n "$verbose" then echo "Changes from $mb to $onto:" - git-diff-tree --stat --summary "$mb" "$onto" + # We want color (if set), but no pager + GIT_PAGER='' git-diff --stat --summary "$mb" "$onto" fi # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. -- cgit v1.2.1 From 9b07873a52cc0243c2eddfac2e9c514152b96fb7 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 2 Jun 2007 19:59:49 +0200 Subject: git-rebase: suggest to use git-add instead of git-update-index The command is part of the main porcelain making git-add more appropriate. Signed-off-by: Jonas Fonseca Signed-off-by: Junio C Hamano --- git-rebase.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 61770b5a28..2aa3a011db 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -55,7 +55,7 @@ continue_merge () { if test -n "$unmerged" then echo "You still have unmerged paths in your index" - echo "did you forget update-index?" + echo "did you forget to use git add?" die "$RESOLVEMSG" fi @@ -126,7 +126,7 @@ do --continue) git-diff-files --quiet || { echo "You must edit all merge conflicts and then" - echo "mark them as resolved using git update-index" + echo "mark them as resolved using git add" exit 1 } if test -d "$dotest" -- cgit v1.2.1 From 1b1dce4bae760248a1fc3e29548a72c446e77270 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 25 Jun 2007 01:11:14 +0100 Subject: Teach rebase an interactive mode Don't you just hate the fact sometimes, that git-rebase just applies the patches, without any possibility to edit them, or rearrange them? With "--interactive", git-rebase now lets you edit the list of patches, so that you can reorder, edit and delete patches. Such a list will typically look like this: pick deadbee The oneline of this commit pick fa1afe1 The oneline of the next commit ... By replacing the command "pick" with the command "edit", you can amend that patch and/or its commit message, and by replacing it with "squash" you can tell rebase to fold that patch into the patch before that. It is derived from the script sent to the list in Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-rebase.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 2aa3a011db..388752661f 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Junio C Hamano. # -USAGE='[-v] [--onto ] []' +USAGE='[--interactive | -i] [-v] [--onto ] []' 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 @@ -120,6 +120,16 @@ finish_rb_merge () { echo "All done." } +is_interactive () { + test -f "$dotest"/interactive || + while case $#,"$1" in 0,|*,-i|*,--interactive) break ;; esac + do + shift + done && test -n "$1" +} + +is_interactive "$@" && exec git-rebase--interactive "$@" + while case "$#" in 0) break ;; esac do case "$1" in -- cgit v1.2.1 From 5be60078c935ed08ee8eb5a32680bdfb6bb5bdf3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 2 Jul 2007 22:52:14 -0700 Subject: Rewrite "git-frotz" to "git frotz" This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano --- git-rebase.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 388752661f..c590661179 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -51,7 +51,7 @@ continue_merge () { test -n "$prev_head" || die "prev_head must be defined" test -d "$dotest" || die "$dotest directory does not exist" - unmerged=$(git-ls-files -u) + unmerged=$(git ls-files -u) if test -n "$unmerged" then echo "You still have unmerged paths in your index" @@ -59,7 +59,7 @@ continue_merge () { die "$RESOLVEMSG" fi - if ! git-diff-index --quiet HEAD + if ! git diff-index --quiet HEAD then if ! git-commit -C "`cat $dotest/current`" then @@ -71,10 +71,10 @@ continue_merge () { else printf "Already applied: %0${prec}d" $msgnum fi - echo ' '`git-rev-list --pretty=oneline -1 HEAD | \ + echo ' '`git rev-list --pretty=oneline -1 HEAD | \ sed 's/^[a-f0-9]\+ //'` - prev_head=`git-rev-parse HEAD^0` + prev_head=`git rev-parse HEAD^0` # save the resulting commit so we can read-tree on it later echo "$prev_head" > "$dotest/prev_head" @@ -86,8 +86,8 @@ continue_merge () { call_merge () { cmt="$(cat $dotest/cmt.$1)" echo "$cmt" > "$dotest/current" - hd=$(git-rev-parse --verify HEAD) - cmt_name=$(git-symbolic-ref HEAD) + hd=$(git rev-parse --verify HEAD) + cmt_name=$(git symbolic-ref HEAD) msgnum=$(cat $dotest/msgnum) end=$(cat $dotest/end) eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"' @@ -101,7 +101,7 @@ call_merge () { return ;; 1) - test -d "$GIT_DIR/rr-cache" && git-rerere + test -d "$GIT_DIR/rr-cache" && git rerere die "$RESOLVEMSG" ;; 2) @@ -134,7 +134,7 @@ while case "$#" in 0) break ;; esac do case "$1" in --continue) - git-diff-files --quiet || { + git diff-files --quiet || { echo "You must edit all merge conflicts and then" echo "mark them as resolved using git add" exit 1 @@ -162,7 +162,7 @@ do then if test -d "$GIT_DIR/rr-cache" then - git-rerere clear + git rerere clear fi prev_head="`cat $dotest/prev_head`" end="`cat $dotest/end`" @@ -183,7 +183,7 @@ do --abort) if test -d "$GIT_DIR/rr-cache" then - git-rerere clear + git rerere clear fi if test -d "$dotest" then @@ -259,8 +259,8 @@ else fi # The tree must be really really clean. -git-update-index --refresh || exit -diff=$(git-diff-index --cached --name-status -r HEAD) +git update-index --refresh || exit +diff=$(git diff-index --cached --name-status -r HEAD) case "$diff" in ?*) echo "cannot rebase: your index is not up-to-date" echo "$diff" @@ -275,7 +275,7 @@ upstream=`git rev-parse --verify "${upstream_name}^0"` || # Make sure the branch to rebase onto is valid. onto_name=${newbase-"$upstream_name"} -onto=$(git-rev-parse --verify "${onto_name}^0") || exit +onto=$(git rev-parse --verify "${onto_name}^0") || exit # If a hook exists, give it a chance to interrupt if test -x "$GIT_DIR/hooks/pre-rebase" @@ -301,13 +301,13 @@ case "$#" in fi ;; esac -branch=$(git-rev-parse --verify "${branch_name}^0") || exit +branch=$(git rev-parse --verify "${branch_name}^0") || exit # Now we are rebasing commits $upstream..$branch on top of $onto # Check if we are already based on $onto, but this should be # done only when upstream and onto are the same. -mb=$(git-merge-base "$onto" "$branch") +mb=$(git merge-base "$onto" "$branch") if test "$upstream" = "$onto" && test "$mb" = "$onto" then echo >&2 "Current branch $branch_name is up to date." @@ -318,7 +318,7 @@ if test -n "$verbose" then echo "Changes from $mb to $onto:" # We want color (if set), but no pager - GIT_PAGER='' git-diff --stat --summary "$mb" "$onto" + GIT_PAGER='' git diff --stat --summary "$mb" "$onto" fi # Rewind the head to "$onto"; this saves our current head in ORIG_HEAD. @@ -335,7 +335,7 @@ fi if test -z "$do_merge" then - git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | + git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" exit $? fi @@ -346,11 +346,11 @@ fi mkdir -p "$dotest" echo "$onto" > "$dotest/onto" echo "$onto_name" > "$dotest/onto_name" -prev_head=`git-rev-parse HEAD^0` +prev_head=`git rev-parse HEAD^0` echo "$prev_head" > "$dotest/prev_head" msgnum=0 -for cmt in `git-rev-list --reverse --no-merges "$upstream"..ORIG_HEAD` +for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD` do msgnum=$(($msgnum + 1)) echo "$cmt" > "$dotest/cmt.$msgnum" -- cgit v1.2.1 From 1308c17b3e6bd3f5636f5b9bcadb2fbdf559009d Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 4 Jul 2007 22:09:10 +0200 Subject: Allow rebase to run if upstream is completely merged Consider this history: o--o-...-B <- origin \ \ x--x--M--x--x <- master In this situation, rebase considers master fully up-to-date and would not do anything. However, if there were additional commits on origin, the rebase would run and move the commits x on top of origin. Here we change rebase to short-circuit out only if the history since origin is strictly linear. Consequently, the above as well as a history like this would be linearized: o--o <- origin \ x--x \ \ x--M--x--x <- master Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- git-rebase.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index c590661179..7a02f2975d 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -305,10 +305,12 @@ branch=$(git rev-parse --verify "${branch_name}^0") || exit # Now we are rebasing commits $upstream..$branch on top of $onto -# Check if we are already based on $onto, but this should be -# done only when upstream and onto are the same. +# Check if we are already based on $onto with linear history, +# but this should be done only when upstream and onto are the same. mb=$(git merge-base "$onto" "$branch") -if test "$upstream" = "$onto" && test "$mb" = "$onto" +if test "$upstream" = "$onto" && test "$mb" = "$onto" && + # linear history? + ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null then echo >&2 "Current branch $branch_name is up to date." exit 0 -- cgit v1.2.1 From b4372ef136b0a5a2c1dbd88a11dd72b478d0e0a5 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 6 Jul 2007 13:05:59 +0100 Subject: Enable "git rerere" by the config variable rerere.enabled Earlier, "git rerere" was enabled by creating the directory .git/rr-cache. That is definitely not in line with most other features, which are enabled by a config variable. So, check the config variable "rerere.enabled". If it is set to "false" explicitely, do not activate rerere, even if .git/rr-cache exists. This should help when you want to disable rerere temporarily. If "rerere.enabled" is not set at all, fall back to detection of the directory .git/rr-cache. [jc: with minimum tweaks] Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-rebase.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 7a02f2975d..cbafa14ed5 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -101,7 +101,7 @@ call_merge () { return ;; 1) - test -d "$GIT_DIR/rr-cache" && git rerere + git rerere die "$RESOLVEMSG" ;; 2) @@ -160,10 +160,7 @@ do --skip) if test -d "$dotest" then - if test -d "$GIT_DIR/rr-cache" - then - git rerere clear - fi + git rerere clear prev_head="`cat $dotest/prev_head`" end="`cat $dotest/end`" msgnum="`cat $dotest/msgnum`" @@ -181,10 +178,7 @@ do exit ;; --abort) - if test -d "$GIT_DIR/rr-cache" - then - git rerere clear - fi + git rerere clear if test -d "$dotest" then rm -r "$dotest" -- cgit v1.2.1 From 7afa845edc09d2818af5fe67a0eb45ec579d1260 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 1 Sep 2007 09:25:27 +0200 Subject: rebase -m: Fix incorrect short-logs of already applied commits. When a topic branch is rebased, some of whose commits are already cherry-picked upstream: o--X--A--B--Y <- master \ A--B--Z <- topic then 'git rebase -m master' would report: Already applied: 0001 Y Already applied: 0002 Y With this fix it reports the expected: Already applied: 0001 A Already applied: 0002 B As an added bonus, this change also avoids 'echo' of a commit message, which might contain escapements. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- git-rebase.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index cbafa14ed5..9cf005677c 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -59,20 +59,23 @@ continue_merge () { die "$RESOLVEMSG" fi + cmt=`cat $dotest/current` if ! git diff-index --quiet HEAD then - if ! git-commit -C "`cat $dotest/current`" + if ! git-commit -C "$cmt" then echo "Commit failed, please do not call \"git commit\"" echo "directly, but instead do one of the following: " die "$RESOLVEMSG" fi - printf "Committed: %0${prec}d" $msgnum + printf "Committed: %0${prec}d " $msgnum + git rev-list --pretty=oneline -1 HEAD | \ + sed 's/^[a-f0-9]\+ //' else - printf "Already applied: %0${prec}d" $msgnum + printf "Already applied: %0${prec}d " $msgnum + git rev-list --pretty=oneline -1 "$cmt" | \ + sed 's/^[a-f0-9]\+ //' fi - echo ' '`git rev-list --pretty=oneline -1 HEAD | \ - sed 's/^[a-f0-9]\+ //'` prev_head=`git rev-parse HEAD^0` # save the resulting commit so we can read-tree on it later -- cgit v1.2.1 From c7965afd3dac7b9b6c1d4da27d3757e7d41aa060 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 1 Sep 2007 02:17:28 -0700 Subject: Avoid one-or-more (\+) non BRE in sed scripts. Signed-off-by: Junio C Hamano --- git-rebase.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'git-rebase.sh') diff --git a/git-rebase.sh b/git-rebase.sh index 9cf005677c..3bd66b0a04 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -69,13 +69,10 @@ continue_merge () { die "$RESOLVEMSG" fi printf "Committed: %0${prec}d " $msgnum - git rev-list --pretty=oneline -1 HEAD | \ - sed 's/^[a-f0-9]\+ //' else printf "Already applied: %0${prec}d " $msgnum - git rev-list --pretty=oneline -1 "$cmt" | \ - sed 's/^[a-f0-9]\+ //' 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 -- cgit v1.2.1 From 059f446d57d51fbacdace3fbadf2414916c201dd Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Fri, 7 Sep 2007 10:20:50 -0400 Subject: git-rebase: support --whitespace=