git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Subject: [PATCH 1/4] Rewrite rebase to use git-format-patch piped to git-am.
Date: Tue, 15 Nov 2005 15:33:27 -0800	[thread overview]
Message-ID: <7virutfpvc.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7voe4lfpxm.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Tue, 15 Nov 2005 15:32:05 -0800")

This does not handle binary files yet, but a patch or two to
git-apply should solve that problem.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 git-rebase.sh |   71 ++++++++++++---------------------------------------------
 1 files changed, 15 insertions(+), 56 deletions(-)

applies-to: efad0bc70473bdc02b8ac6a5e5f001519f1d5dfa
d64a7b926edfcebf9f5b116fedebd365e5c206f1
diff --git a/git-rebase.sh b/git-rebase.sh
index fa95009..56196e7 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -5,65 +5,24 @@
 
 . git-sh-setup || die "Not a git archive."
 
-usage="usage: $0 "'<upstream> [<head>]
-
-Uses output from git-cherry to rebase local commits to the new head of
-upstream tree.'
-
-case "$#,$1" in
-1,*..*)
-    upstream=$(expr "$1" : '\(.*\)\.\.') ours=$(expr "$1" : '.*\.\.\(.*\)$')
-    set x "$upstream" "$ours"
-    shift ;;
-esac
+# The other head is given
+other=$(git-rev-parse --verify "$1^0") || exit
 
+# The tree must be really really clean.
 git-update-index --refresh || exit
+diff=$(git-diff-index --cached --name-status -r HEAD)
+case "$different" in
+?*)	echo "$diff"
+	exit 1
+	;;
+esac
 
+# If the branch to rebase is given, first switch to it.
 case "$#" in
-1) ours_symbolic=HEAD ;;
-2) ours_symbolic="$2" ;;
-*) die "$usage" ;;
+2)
+	git-checkout "$2" || exit
 esac
 
-upstream=`git-rev-parse --verify "$1"` &&
-ours=`git-rev-parse --verify "$ours_symbolic"` || exit
-different1=$(git-diff-index --name-only --cached "$ours") &&
-different2=$(git-diff-index --name-only "$ours") &&
-test "$different1$different2" = "" ||
-die "Your working tree does not match $ours_symbolic."
-
-git-read-tree -m -u $ours $upstream &&
-new_head=$(git-rev-parse --verify "$upstream^0") &&
-git-update-ref HEAD "$new_head" || exit
-
-tmp=.rebase-tmp$$
-fail=$tmp-fail
-trap "rm -rf $tmp-*" 1 2 3 15
-
->$fail
-
-git-cherry -v $upstream $ours |
-while read sign commit msg
-do
-	case "$sign" in
-	-)
-		echo >&2 "* Already applied: $msg"
-		continue ;;
-	esac
-	echo >&2 "* Applying: $msg"
-	S=$(git-rev-parse --verify HEAD) &&
-	git-cherry-pick --replay $commit || {
-		echo >&2 "* Not applying the patch and continuing."
-		echo $commit >>$fail
-		git-reset --hard $S
-	}
-done
-if test -s $fail
-then
-	echo >&2 Some commits could not be rebased, check by hand:
-	cat >&2 $fail
-	echo >&2 "(the same list of commits are found in $tmp)"
-	exit 1
-else
-	rm -f $fail
-fi
+# Rewind the head to "$other"
+git-reset --hard "$other"
+git-format-patch -k --stdout "$other" ORIG_HEAD | git am -3 -k
---
0.99.9.GIT

  reply	other threads:[~2005-11-15 23:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-15 23:32 [PATCH 0/4] reworking git-rebase Junio C Hamano
2005-11-15 23:33 ` Junio C Hamano [this message]
2005-11-15 23:33 ` [PATCH 2/4] apply: allow-binary-replacement Junio C Hamano
2005-11-15 23:34 ` [PATCH 3/4] diff: --full-index Junio C Hamano
2005-11-15 23:34 ` [PATCH 4/4] rebase: make it usable for binary files as well Junio C Hamano
2005-11-16  9:26 ` [PATCH] git-am: --resolved Junio C Hamano
2005-11-17 10:30 ` [PATCH 0/4] reworking git-rebase Sven Verdoolaege
2005-11-17 10:57   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7virutfpvc.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).