diff options
author | Junio C Hamano <junkio@cox.net> | 2005-08-27 23:53:27 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-08-29 12:52:02 -0700 |
commit | 48313592bf318139b39d6017a863f27420e3939a (patch) | |
tree | 10b79491f79ce17c773e37311a01697050cf2383 /git-rebase-script | |
parent | 2c04662d89eaa55cecb6effd743c17051d1458ec (diff) | |
download | git-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-x | git-rebase-script | 25 |
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 |