{"thread":{"id":"5908","subject":"[PATCH] git-revert with conflicts to behave as git-merge with conflicts","startedAt":"2006-10-12T21:52:42Z","lastAt":"2006-10-13T00:31:20Z","messageCount":5,"participants":["Luben Tuikov","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"28687","messageId":"20061012215242.16419.qmail@web31810.mail.mud.yahoo.com","threadId":"5908","inReplyTo":null,"subject":"[PATCH] git-revert with conflicts to behave as git-merge with conflicts","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-12T21:52:42Z","receivedAt":"2006-10-12T21:52:42Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"In a busy project, reverting a commit almost always results\nin a conflict between one or more files (depending on the\ncommit being reverted).  It is useful to record this\nconflict in the commit-to-be message of the resulting commit\n(after the resolve).  The process now becomes:\n\ngit-revert <SHA-1>\n<git complains and prints failed automatic>\n<user manually resolves>\ngit-update-index <resolved files>\ngit-commit -s\n\nAnd the commit message is now a merge of the revert commit\nmessage and the conflict commit message, giving the user a\nchance to edit it or add more information:\n---cut---\nRevert \"title of reverted commit\"\n\nThis reverts commit <SHA-1>\n\nConflicts:\n\n    <filename>\n    ...\n---cut---\n\nSigned-off-by: Luben Tuikov <ltuikov@yahoo.com>\n---\n git-commit.sh |    4 ++--\n git-revert.sh |   11 ++++++++++-\n 2 files changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 4bd0e46..81c3a0c 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -441,7 +441,7 @@ then\n elif test \"$use_commit\" != \"\"\n then\n \tgit-cat-file commit \"$use_commit\" | sed -e '1,/^$/d'\n-elif test -f \"$GIT_DIR/MERGE_HEAD\" && test -f \"$GIT_DIR/MERGE_MSG\"\n+elif test -f \"$GIT_DIR/MERGE_MSG\"\n then\n \tcat \"$GIT_DIR/MERGE_MSG\"\n elif test -f \"$GIT_DIR/SQUASH_MSG\"\n@@ -607,7 +607,7 @@ then\n \tcommit=$(cat \"$GIT_DIR\"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&\n \trlogm=$(sed -e 1q \"$GIT_DIR\"/COMMIT_MSG) &&\n \tgit-update-ref -m \"$rloga: $rlogm\" HEAD $commit \"$current\" &&\n-\trm -f -- \"$GIT_DIR/MERGE_HEAD\" &&\n+\trm -f -- \"$GIT_DIR/MERGE_HEAD\" \"$GIT_DIR/MERGE_MSG\" &&\n \tif test -f \"$NEXT_INDEX\"\n \tthen\n \t\tmv \"$NEXT_INDEX\" \"$THIS_INDEX\"\ndiff --git a/git-revert.sh b/git-revert.sh\nindex 4fd81b6..2e23cf4 100755\n--- a/git-revert.sh\n+++ b/git-revert.sh\n@@ -145,9 +145,18 @@ git-read-tree -m -u --aggressive $base $\n result=$(git-write-tree 2>/dev/null) || {\n     echo >&2 \"Simple $me fails; trying Automatic $me.\"\n     git-merge-index -o git-merge-one-file -a || {\n+\t    mv -f .msg .git/MERGE_MSG\n+\t    {\n+\t\techo '\n+Conflicts:\n+'\n+\t\tgit ls-files --unmerged |\n+\t\tsed -e 's/^[^\t]*\t/\t/' |\n+\t\tuniq\n+\t    } >>\"$GIT_DIR/MERGE_MSG\"\n \t    echo >&2 \"Automatic $me failed.  After resolving the conflicts,\"\n \t    echo >&2 \"mark the corrected paths with 'git-update-index <paths>'\"\n-\t    echo >&2 \"and commit with 'git commit -F .msg'\"\n+\t    echo >&2 \"and commit the result.\"\n \t    case \"$me\" in\n \t    cherry-pick)\n \t\techo >&2 \"You may choose to use the following when making\"\n-- \n1.4.3.rc2.g6f09-dirty\n\n"},{"id":"28694","messageId":"7vejtdkw4t.fsf@assigned-by-dhcp.cox.net","threadId":"5908","inReplyTo":"20061012215242.16419.qmail@web31810.mail.mud.yahoo.com","subject":"Re: [PATCH] git-revert with conflicts to behave as git-merge with conflicts","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-12T22:27:30Z","receivedAt":"2006-10-12T22:27:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luben Tuikov <ltuikov@yahoo.com> writes:\n\n> --- a/git-commit.sh\n> +++ b/git-commit.sh\n> @@ -441,7 +441,7 @@ then\n>  elif test \"$use_commit\" != \"\"\n>  then\n>  \tgit-cat-file commit \"$use_commit\" | sed -e '1,/^$/d'\n> -elif test -f \"$GIT_DIR/MERGE_HEAD\" && test -f \"$GIT_DIR/MERGE_MSG\"\n> +elif test -f \"$GIT_DIR/MERGE_MSG\"\n>  then\n>  \tcat \"$GIT_DIR/MERGE_MSG\"\n>  elif test -f \"$GIT_DIR/SQUASH_MSG\"\n\nIf you rely on MERGE_MSG then you would need to clean it after\ncommit is done.  Currently it does not and checks MERGE_HEAD,\nand cleans up MERGE_HEAD when it is done.  MERGE_MSG is not\ncleaned.\n"},{"id":"28703","messageId":"20061012231503.78452.qmail@web31803.mail.mud.yahoo.com","threadId":"5908","inReplyTo":"7vejtdkw4t.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-revert with conflicts to behave as git-merge with conflicts","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-12T23:15:03Z","receivedAt":"2006-10-12T23:15:03Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Junio C Hamano <junkio@cox.net> wrote:\n> Luben Tuikov <ltuikov@yahoo.com> writes:\n> \n> > --- a/git-commit.sh\n> > +++ b/git-commit.sh\n> > @@ -441,7 +441,7 @@ then\n> >  elif test \"$use_commit\" != \"\"\n> >  then\n> >  \tgit-cat-file commit \"$use_commit\" | sed -e '1,/^$/d'\n> > -elif test -f \"$GIT_DIR/MERGE_HEAD\" && test -f \"$GIT_DIR/MERGE_MSG\"\n> > +elif test -f \"$GIT_DIR/MERGE_MSG\"\n> >  then\n> >  \tcat \"$GIT_DIR/MERGE_MSG\"\n> >  elif test -f \"$GIT_DIR/SQUASH_MSG\"\n> \n> If you rely on MERGE_MSG then you would need to clean it after\n> commit is done.  Currently it does not and checks MERGE_HEAD,\n> and cleans up MERGE_HEAD when it is done.  MERGE_MSG is not\n> cleaned.\n\nIt is cleaned in the lines of the patch you deleted, the section\njust after the \"elif\" above:\n\n@@ -607,7 +607,7 @@ then\n        commit=$(cat \"$GIT_DIR\"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&\n        rlogm=$(sed -e 1q \"$GIT_DIR\"/COMMIT_MSG) &&\n        git-update-ref -m \"$rloga: $rlogm\" HEAD $commit \"$current\" &&\n-       rm -f -- \"$GIT_DIR/MERGE_HEAD\" &&\n+       rm -f -- \"$GIT_DIR/MERGE_HEAD\" \"$GIT_DIR/MERGE_MSG\" &&\n        if test -f \"$NEXT_INDEX\"\n        then\n                mv \"$NEXT_INDEX\" \"$THIS_INDEX\"\n\n   Luben\n"},{"id":"28706","messageId":"7vvempjcwy.fsf@assigned-by-dhcp.cox.net","threadId":"5908","inReplyTo":"20061012231503.78452.qmail@web31803.mail.mud.yahoo.com","subject":"Re: [PATCH] git-revert with conflicts to behave as git-merge with conflicts","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-13T00:07:57Z","receivedAt":"2006-10-13T00:07:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luben Tuikov <ltuikov@yahoo.com> writes:\n\n>> If you rely on MERGE_MSG then you would need to clean it after\n>> commit is done.  Currently it does not and checks MERGE_HEAD,\n>> and cleans up MERGE_HEAD when it is done.  MERGE_MSG is not\n>> cleaned.\n>\n> It is cleaned in the lines of the patch you deleted, the section\n> just after the \"elif\" above:\n\nOk, so I can apply that original one with your 'Oops' rolled\ninto one patch?\n"},{"id":"28707","messageId":"20061013003120.98769.qmail@web31813.mail.mud.yahoo.com","threadId":"5908","inReplyTo":"7vvempjcwy.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-revert with conflicts to behave as git-merge with conflicts","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-13T00:31:20Z","receivedAt":"2006-10-13T00:31:20Z","isPatch":true,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Junio C Hamano <junkio@cox.net> wrote:\n> Luben Tuikov <ltuikov@yahoo.com> writes:\n> \n> >> If you rely on MERGE_MSG then you would need to clean it after\n> >> commit is done.  Currently it does not and checks MERGE_HEAD,\n> >> and cleans up MERGE_HEAD when it is done.  MERGE_MSG is not\n> >> cleaned.\n> >\n> > It is cleaned in the lines of the patch you deleted, the section\n> > just after the \"elif\" above:\n> \n> Ok, so I can apply that original one with your 'Oops' rolled\n> into one patch?\n\nYes please.\n\n    Luben\n"}]}