@matheusbsbs / matheus-bagliano / commits / a9cb3c6ecb
Fork 0

git-revert with conflicts to behave as git-merge with conflicts

In a busy project, reverting a commit almost always results in a conflict between one or more files (depending on the commit being reverted). It is useful to record this conflict in the commit-to-be message of the resulting commit (after the resolve). The process now becomes: git-revert <SHA-1> <git complains and prints failed automatic> <user manually resolves> git-update-index <resolved files> git-commit -s And the commit message is now a merge of the revert commit message and the conflict commit message, giving the user a chance to edit it or add more information: Signed-off-by: Luben Tuikov <ltuikov@yahoo.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Luben Tuikov committed Oct 12, 2006 at 14:52 UTC a9cb3c6ecb97c4734423045f47899e03f135d3bd
2 files changed +12 -3
git-commit.sh
+2 -2
@@ -466,7 +466,7 @@ then
466 elif test "$use_commit" != ""
467 then
468 git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
469 -elif test -f "$GIT_DIR/MERGE_HEAD" && test -f "$GIT_DIR/MERGE_MSG"
469 +elif test -f "$GIT_DIR/MERGE_MSG"
470 then
471 cat "$GIT_DIR/MERGE_MSG"
472 elif test -f "$GIT_DIR/SQUASH_MSG"
@@ -632,7 +632,7 @@ then
632 commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
633 rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
634 git-update-ref -m "$rloga: $rlogm" HEAD $commit "$current" &&
635 - rm -f -- "$GIT_DIR/MERGE_HEAD" &&
635 + rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
636 if test -f "$NEXT_INDEX"
637 then
638 mv "$NEXT_INDEX" "$THIS_INDEX"
git-revert.sh
+10 -1
@@ -141,9 +141,18 @@ git-read-tree -m -u --aggressive $base $head $next &&
141 result=$(git-write-tree 2>/dev/null) || {
142 echo >&2 "Simple $me fails; trying Automatic $me."
143 git-merge-index -o git-merge-one-file -a || {
144 + mv -f .msg "$GIT_DIR/MERGE_MSG"
145 + {
146 + echo '
147 +Conflicts:
148 +'
149 + git ls-files --unmerged |
150 + sed -e 's/^[^ ]* / /' |
151 + uniq
152 + } >>"$GIT_DIR/MERGE_MSG"
153 echo >&2 "Automatic $me failed. After resolving the conflicts,"
154 echo >&2 "mark the corrected paths with 'git-update-index <paths>'"
146 - echo >&2 "and commit with 'git commit -F .msg'"
155 + echo >&2 "and commit the result."
156 case "$me" in
157 cherry-pick)
158 echo >&2 "You may choose to use the following when making"