aboutsummaryrefslogtreecommitdiff
path: root/git-rebase-script
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-08-27 23:53:27 -0700
committerJunio C Hamano <junkio@cox.net>2005-08-29 12:52:02 -0700
commit48313592bf318139b39d6017a863f27420e3939a (patch)
tree10b79491f79ce17c773e37311a01697050cf2383 /git-rebase-script
parent2c04662d89eaa55cecb6effd743c17051d1458ec (diff)
downloadgit-48313592bf318139b39d6017a863f27420e3939a.tar.gz
git-48313592bf318139b39d6017a863f27420e3939a.tar.xz
Redo "revert" using three-way merge machinery.
The reverse patch application using "git apply" sometimes is too rigid. Since the user would get used to resolving conflicting merges by hand during the normal merge experience, using the same machinery would be more helpful rather than just giving up. Cherry-picking and reverting are essentially the same operation. You pick one commit, and apply the difference that commit introduces to its own commit ancestry chain to the current tree. Revert applies the diff in reverse while cherry-pick applies it forward. They share the same logic, just different messages and merge direction. Rewrite "git rebase" using "git cherry-pick". Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-rebase-script')
-rwxr-xr-xgit-rebase-script25
1 files changed, 16 insertions, 9 deletions
diff --git a/git-rebase-script b/git-rebase-script
index a335b9917..b0893cc10 100755
--- a/git-rebase-script
+++ b/git-rebase-script
@@ -37,25 +37,32 @@ git-rev-parse --verify "$upstream^0" >"$GIT_DIR/HEAD" || exit
tmp=.rebase-tmp$$
fail=$tmp-fail
-trap "rm -rf $tmp-*" 0 1 2 3 15
+trap "rm -rf $tmp-*" 1 2 3 15
>$fail
-git-cherry $upstream $ours |
-while read sign commit
+git-cherry -v $upstream $ours |
+while read sign commit msg
do
case "$sign" in
- -) continue ;;
+ -)
+ echo >&2 "* Already applied: $msg"
+ continue ;;
esac
+ echo >&2 "* Applying: $msg"
S=`cat "$GIT_DIR/HEAD"` &&
- GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
- git-commit-script -C "$commit" || {
+ git-cherry-pick-script --replay $commit || {
+ echo >&2 "* Not applying the patch and continuing."
echo $commit >>$fail
- git-read-tree --reset -u $S
+ git-reset-script --hard $S
}
done
if test -s $fail
then
- echo Some commits could not be rebased, check by hand:
- cat $fail
+ 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