{"thread":{"id":"976","subject":"'git commit' duplicates parents?","startedAt":"2005-06-19T16:27:35Z","lastAt":"2005-06-20T18:52:38Z","messageCount":12,"participants":["Jeff Garzik","Linus Torvalds","Dan Holmsand"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"5043","messageId":"42B59CF7.3080509@pobox.com","threadId":"976","inReplyTo":null,"subject":"'git commit' duplicates parents?","fromName":"Jeff Garzik","fromEmail":"jgarzik@pobox.com","sentAt":"2005-06-19T16:27:35Z","receivedAt":"2005-06-19T16:27:35Z","isPatch":false,"sender":{"key":"jgarzik@pobox.com","avatar":null},"body":"\nI just checked in a change with 'git commit' (no arguments).  Two \nstrange things occurred:\n\n1) git-whatchanged does not list the change at all.  However,\n\ta) I verified that my change is indeed top-of-tree\n\tb) git-changes-script (attached) does show the change\n\n2) git-changes-script shows the parents in a readable fashion, and it \nshows two duplicate parent entries.  In contrast, other changes do not \nhave two parents:\n\nmy change:\n> commit 4864989199fa62c7044be2258550ddc561411ab6\n\t\t^^^ top of tree aka .git/HEAD\n> tree b40996c7a0a5446875aa3664045af7e377451bf6\n> parent 7df551254add79a445d2e47e8f849cef8fee6e38\n> parent 7df551254add79a445d2e47e8f849cef8fee6e38\n> author Jeff Garzik <jgarzik@pretzel.yyz.us> Sun, 19 Jun 2005 20:06:28 -0400\n> committer Jeff Garzik <jgarzik@pobox.com> Sun, 19 Jun 2005 20:06:28 -0400\n> \n> fc4/fc:  fix warnings/errors caused by recent changes\n\na random change not committed by 'git commit':\n> commit 7df551254add79a445d2e47e8f849cef8fee6e38\n> tree 468a43ac3f94b9bf8618b102a7d609e29d3900f5\n> parent f7d7fc0322c1770fe7ee836ca2732c2f88e2e1a4\n> author David S. Miller <davem@davemloft.net> Sun, 19 Jun 2005 13:01:10 -0700\n> committer David S. Miller <davem@davemloft.net> Sun, 19 Jun 2005 13:01:10 -0700\n> \n> [TCP]: Fix sysctl_tcp_low_latency\n> \n> When enabled, this should disable UCOPY prequeue'ing altogether,\n> but it does not due to a missing test.\n> \n> Signed-off-by: David S. Miller <davem@davemloft.net>\n\n\n\n\n#!/bin/bash\n#\n# Make a log of changes in a GIT branch.\n#\n# This script was originally written by (c) Ross Vandegrift.\n# Adapted to his scripts set by (c) Petr Baudis, 2005.\n# Major optimizations by (c) Phillip Lougher.\n# Rendered trivial by Linus Torvalds.\n# Added -L|-R option by James Bottomley\n#\n# options:\n# script [-L <dir> | -R <dir> |-r <from_sha1> [ -r <to_sha1] ] [<sha1>]\n#\n# With no options shows all the revisions from HEAD to the root\n# -L shows all the changes in the local tree compared to the tree at <dir>\n# -R shows all the changes in the remote tree at <dir> compared to the local\n# -r shows all the changes in one commit or between two\n\ntmpfile=/tmp/git_changes.$$\nr1=\nr2=\n\nshowcommit() {\n\tcommit=\"$1\"\n\techo commit ${commit%:*};\n\tgit-cat-file commit $commit | \\\n\t\twhile read key rest; do\n\t\t\tcase \"$key\" in\n\t\t\t\"author\"|\"committer\")\n\t\t\t\tdate=(${rest#*> })\n\t\t\t\tsec=${date[0]}; tz=${date[1]}\n\t\t\t\tdtz=${tz/+/+ }; dtz=${dtz/-/- }\n\t\t\t\tpdate=\"$(date -Rud \"1970-01-01 UTC + $sec sec $dtz\" 2>/dev/null)\"\n\t\t\t\tif [ \"$pdate\" ]; then\n\t\t\t\t\techo $key $rest | sed \"s/>.*/> ${pdate/+0000/$tz}/\"\n\t\t\t\telse\n\t\t\t\t\techo $key $rest\n\t\t\t\tfi\n\t\t\t\t;;\n\t\t\t\"\")\n\t\t\t\techo; cat\n\t\t\t\t;;\n\t\t\t*)\n\t\t\t\techo $key $rest\n\t\t\t\t;;\n\t\t\tesac\n\n\t\tdone\n}\n\nwhile true; do\n\tcase \"$1\" in\n\t\t-R)\tshift;\n\t\t\tdiffsearch=+\n\t\t\tremote=\"$1\"\n\t\t\tshift;;\n\t\t-L)\tshift;\n\t\t\tdiffsearch=-\n\t\t\tremote=\"$1\"\n\t\t\tshift;;\n\t\t-r)\tshift;\n\t\t\tif [ -z \"$r1\" ]; then\n\t\t\t\tr1=\"$1\"\n\t\t\telse\n\t\t\t\tr2=\"$1\"\n\t\t\tfi\n\t\t\tshift;;\n\t\t*)\tbase=\"$1\"\n\t\t\tbreak;;\n\tesac\ndone\n\nif [ -n \"$r1\" ]; then\n\tif [ -z \"$r2\" ]; then\n\t\tshowcommit $r1\n\t\texit 0\n\tfi\n\tdiffsearch=+\n\tremote=`pwd`;\n\ttobase=\"$r2\";\n\tbase=\"$r1\"\nfi\n\t\nif [ -z \"$base\" ]; then\n\tbase=$(cat .git/HEAD) || exit 1\nfi\n\ngit-rev-tree $base | sort -rn  > ${tmpfile}.base\nif [ -n \"$remote\" ]; then\n\t[ -d $remote/.git ] || exit 1\n\tif [ -z \"$tobase\" ]; then\n\t\ttobase=$(cat $remote/.git/HEAD) || exit 1\n\tfi\n\tpushd $remote > /dev/null\n\tgit-rev-tree $tobase | sort -rn > ${tmpfile}.remote\n\tdiff -u ${tmpfile}.base ${tmpfile}.remote | grep \"^${diffsearch}[^${diffsearch}]\" | cut -c 1- > ${tmpfile}.diff\n\trm -f ${tmpfile}.base ${tmpfile}.remote\n\tmv ${tmpfile}.diff ${tmpfile}.base\n\tif [ $diffsearch = \"-\" ]; then\n\t\tpopd > /dev/null\n\tfi\nfi\n\n[ -s \"${tmpfile}.base\" ] || exit 0\n\ncat ${tmpfile}.base | while read time commit parents; do\n\tshowcommit $commit\n\techo -e \"\\n--------------------------\"\n\ndone\nrm -f ${tmpfile}.base\n"},{"id":"5044","messageId":"42B59E19.1010202@pobox.com","threadId":"976","inReplyTo":"42B59CF7.3080509@pobox.com","subject":"Re: 'git commit' duplicates parents?","fromName":"Jeff Garzik","fromEmail":"jgarzik@pobox.com","sentAt":"2005-06-19T16:32:25Z","receivedAt":"2005-06-19T16:32:25Z","isPatch":false,"sender":{"key":"jgarzik@pobox.com","avatar":null},"body":"Jeff Garzik wrote:\n> I just checked in a change with 'git commit' (no arguments).  Two \n> strange things occurred:\n\n\nFWIW you can see the problem yourself at\n\n'fc4-fix' branch of\nrsync://rsync.kernel.org/pub/scm/linux/kernel/git/jgarzik/misc-2.6.git\n\n(just one change checked in, the change referenced in the previous email)\n\n"},{"id":"5055","messageId":"Pine.LNX.4.58.0506191921270.2268@ppc970.osdl.org","threadId":"976","inReplyTo":"42B59CF7.3080509@pobox.com","subject":"Re: 'git commit' duplicates parents?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-20T02:24:36Z","receivedAt":"2005-06-20T02:24:36Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 19 Jun 2005, Jeff Garzik wrote:\n> \n> I just checked in a change with 'git commit' (no arguments).  Two \n> strange things occurred:\n> \n> 1) git-whatchanged does not list the change at all.  However,\n> \ta) I verified that my change is indeed top-of-tree\n> \tb) git-changes-script (attached) does show the change\n\nYour commit is a merge. A corrupted one.\n\n> 2) git-changes-script shows the parents in a readable fashion, and it \n> shows two duplicate parent entries.  In contrast, other changes do not \n> have two parents:\n> \n> my change:\n> > commit 4864989199fa62c7044be2258550ddc561411ab6\n> \t\t^^^ top of tree aka .git/HEAD\n> > tree b40996c7a0a5446875aa3664045af7e377451bf6\n> > parent 7df551254add79a445d2e47e8f849cef8fee6e38\n> > parent 7df551254add79a445d2e47e8f849cef8fee6e38\n\nNotice: two times the same head.\n\nYou had a MERGE_HEAD in your tree, and \"git commit\" warned you about it in \nbig bold letters and told you what to do, but you ignored it.\n\n\"git commit\" said:\n\n                echo \"#\"\n                echo \"# It looks like your may be committing a MERGE.\"\n                echo \"# If this is not correct, please remove the file\"\n                echo \"# $GIT_DIR/MERGE_HEAD\"\n                echo \"# and try again\"\n                echo \"#\"\n\nand if you had just done as it asked you, you'd have been ok.\n\nAs to why you had a .git/MERGE_HEAD in your tree, it's probably because \nyour merge scripts haven't kept up with mine.\n\n\t\tLinus\n"},{"id":"5056","messageId":"42B629C0.6030008@pobox.com","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506191921270.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Jeff Garzik","fromEmail":"jgarzik@pobox.com","sentAt":"2005-06-20T02:28:16Z","receivedAt":"2005-06-20T02:28:16Z","isPatch":false,"sender":{"key":"jgarzik@pobox.com","avatar":null},"body":"Linus Torvalds wrote:\n> As to why you had a .git/MERGE_HEAD in your tree, it's probably because \n> your merge scripts haven't kept up with mine.\n\nNope, I use vanilla latest ones.  FWIW my setup is 100% vanilla git plus \ntwo small scripts, 'git-switch-tree' and 'git-new-branch', which switch \naround .git/HEAD.\n\nDoing some experimenting, it seems that git-pull-script does not remove \nMERGE_HEAD and ORIG_HEAD after its done.\n\nThis is reproducible by updating vanilla linux-2.6.git using vanilla \ngit-pull-script.  Just a standard update-to-latest-kernel, with no \nconflicts/merges/etc.\n\n\tJeff\n\n\n"},{"id":"5064","messageId":"Pine.LNX.4.58.0506191926530.2268@ppc970.osdl.org","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506191921270.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-20T02:33:55Z","receivedAt":"2005-06-20T02:33:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 19 Jun 2005, Linus Torvalds wrote:\n> \n> Your commit is a merge. A corrupted one.\n\nBtw, if possibly, you should just undo it. It's \"valid\" in the sense that\nhaving the same parent duplicated will just be considered to be a merge by\na paritcularly strange person, but it's definitely not good practice, and\nsince it _is_ technically a merge, programs that avoid showing merges\n(like \"git-whatchanged\" - because it doesn't know what it should show as \nthe \"difference\") won't show it.\n\nOther programs, like \"git-diff-tree -m\", which show _all_ sides of a \nmerge, will show the diff twice (because it shows the diff against all \nparents). Which is also why you see it twice in your git-changes-script.\n\nAgain, \"git commit\" _did_ warn about this, I'm sure, but I actually see \nwhy that stupid MERGE_HEAD file was there - a null merge won't remove a \nstale MERGE_HEAD, so it's probably because you did a \"git pull\" that was a \ntrivial merge, and that would have left that turd around..\n\n\t\tLinus\n"},{"id":"5065","messageId":"42B62C85.10701@pobox.com","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506191926530.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Jeff Garzik","fromEmail":"jgarzik@pobox.com","sentAt":"2005-06-20T02:40:05Z","receivedAt":"2005-06-20T02:40:05Z","isPatch":false,"sender":{"key":"jgarzik@pobox.com","avatar":null},"body":"Linus Torvalds wrote:\n> Btw, if possibly, you should just undo it. It's \"valid\" in the sense that\n\nAny crap like this, I undo it manually (cat previous head to .git/HEAD)\n\n\n> Again, \"git commit\" _did_ warn about this, I'm sure, but I actually see \n> why that stupid MERGE_HEAD file was there - a null merge won't remove a \n> stale MERGE_HEAD, so it's probably because you did a \"git pull\" that was a \n> trivial merge, and that would have left that turd around..\n\nProbably PEBCAK...  my missing the big \"MERGE_HEAD exists\" warning \ncaused the problem, it sounds like.\n\nI simply assumed that the vanilla git scripts would clean up after \nthemselves :)\n\n\tJeff\n\n\n\n"},{"id":"5067","messageId":"Pine.LNX.4.58.0506191958010.2268@ppc970.osdl.org","threadId":"976","inReplyTo":"42B62C85.10701@pobox.com","subject":"Re: 'git commit' duplicates parents?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-20T03:00:03Z","receivedAt":"2005-06-20T03:00:03Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 19 Jun 2005, Jeff Garzik wrote:\n> \n> I simply assumed that the vanilla git scripts would clean up after \n> themselves :)\n\nHey, they definitely should. I've pushed out the fixes so far (just pushed\nout the \".cmitmsg/.editmsg\" cleanup).\n\nKeep the complaints coming when something doesn't work the way it should.  \nI'll continue to try to blame your incompetence as much as I humanly can,\nbut hey, some of it is occasionally mine too... ;(\n\n\t\tLinus\n"},{"id":"5073","messageId":"42B690EA.2080605@gmail.com","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506191958010.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Dan Holmsand","fromEmail":"holmsand@gmail.com","sentAt":"2005-06-20T09:48:26Z","receivedAt":"2005-06-20T09:48:26Z","isPatch":false,"sender":{"key":"holmsand@gmail.com","avatar":"https://gravatar.com/avatar/5c722084bafd85e754a02efad01fe69107eb6f393253c49232c5c9f7faa974df?d=mp&s=160"},"body":"Linus Torvalds wrote:\n> Keep the complaints coming when something doesn't work the way it should.  \n> I'll continue to try to blame your incompetence as much as I humanly can,\n> but hey, some of it is occasionally mine too... ;(\n\nWell, since it's obviously complaint time :-)\n\ngit-resolve-script still seems a bit too eager to write MERGE_HEAD and \nORIG_HEAD - they only make sense if there's actually been any merging \ndone, don't they?\n\nPatch below shows what I mean.\n\n/dan\n\n---\n\n[PATCH] Make git-resolve-script less eager to write MERGE_HEAD\n\nMERGE_HEAD and ORIG_HEAD should only be written if there's actually\nbeen any merging done.\n\nSigned-off-by: Dan Holmsand <holmsand@gmail.com>\n\n\ndiff --git a/git-resolve-script b/git-resolve-script\n--- a/git-resolve-script\n+++ b/git-resolve-script\n@@ -12,8 +12,6 @@ merge_repo=\"$3\"\n : ${GIT_OBJECT_DIRECTORY=\"${SHA1_FILE_DIRECTORY-\"$GIT_DIR/objects\"}\"}\n \n rm -f \"$GIT_DIR\"/MERGE_HEAD \"$GIT_DIR\"/ORIG_HEAD\n-echo $head > \"$GIT_DIR\"/ORIG_HEAD\n-echo $merge > \"$GIT_DIR\"/MERGE_HEAD\n \n #\n # The remote name is just used for the message,\n@@ -32,15 +30,13 @@ fi\n \n if [ \"$common\" == \"$merge\" ]; then\n \techo \"Already up-to-date. Yeeah!\"\n-\trm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n \texit 0\n fi\n if [ \"$common\" == \"$head\" ]; then\n \techo \"Updating from $head to $merge.\"\n \tgit-read-tree -u -m $head $merge || exit 1\n \techo $merge > \"$GIT_DIR\"/HEAD\n-\tgit-diff-tree -p ORIG_HEAD HEAD | git-apply --stat\n-\trm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n+\tgit-diff-tree -p $head HEAD | git-apply --stat\n \texit 0\n fi\n echo \"Trying to merge $merge into $head\"\n@@ -51,6 +47,8 @@ if [ $? -ne 0 ]; then\n \techo \"Simple merge failed, trying Automatic merge\"\n \tgit-merge-cache -o git-merge-one-file-script -a\n \tif [ $? -ne 0 ]; then\n+\t\techo $merge > \"$GIT_DIR\"/MERGE_HEAD\n+\t\techo $head > \"$GIT_DIR\"/ORIG_HEAD\n \t\techo \"Automatic merge failed, fix up by hand\"\n \t\texit 1\n \tfi\n@@ -60,4 +58,3 @@ result_commit=$(echo \"$merge_msg\" | git-\n echo \"Committed merge $result_commit\"\n echo $result_commit > \"$GIT_DIR\"/HEAD\n git-diff-tree -p $head $result_commit | git-apply --stat\n-rm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n"},{"id":"5080","messageId":"Pine.LNX.4.58.0506200808090.2268@ppc970.osdl.org","threadId":"976","inReplyTo":"42B690EA.2080605@gmail.com","subject":"Re: 'git commit' duplicates parents?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-20T15:11:29Z","receivedAt":"2005-06-20T15:11:29Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 20 Jun 2005, Dan Holmsand wrote:\n> \n> git-resolve-script still seems a bit too eager to write MERGE_HEAD and \n> ORIG_HEAD - they only make sense if there's actually been any merging \n> done, don't they?\n> \n> Patch below shows what I mean.\n\nI considered this, but decided that MERGE_HEAD is potentially very useful\nfor some of the other failure exits. There's a few \"exit 1\"'s in there,\nfor example when the \"git-read-tree -m\"  fails because of a dirty\nworkspace.\n\nOf course, you can always re-do the merge completely (and maybe that's \nwhat people end up doing), but at least in theory you can fix it up and \njust re-resolve. But in order to do that, you need to know what the \nMERGE_HEAD was...\n\nSo I'm not sure what the right answer is, which is why my fix was the \nminimally invasive one that only removes the heads on success..\n\n\t\tLinus\n"},{"id":"5085","messageId":"42B6FAE5.6060904@gmail.com","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506200808090.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Dan Holmsand","fromEmail":"holmsand@gmail.com","sentAt":"2005-06-20T17:20:37Z","receivedAt":"2005-06-20T17:20:37Z","isPatch":false,"sender":{"key":"holmsand@gmail.com","avatar":"https://gravatar.com/avatar/5c722084bafd85e754a02efad01fe69107eb6f393253c49232c5c9f7faa974df?d=mp&s=160"},"body":"Linus Torvalds wrote:\n> \n> On Mon, 20 Jun 2005, Dan Holmsand wrote:\n> \n>>git-resolve-script still seems a bit too eager to write MERGE_HEAD and \n>>ORIG_HEAD - they only make sense if there's actually been any merging \n>>done, don't they?\n>>\n>>Patch below shows what I mean.\n> \n> \n> I considered this, but decided that MERGE_HEAD is potentially very useful\n> for some of the other failure exits. There's a few \"exit 1\"'s in there,\n> for example when the \"git-read-tree -m\"  fails because of a dirty\n> workspace.\n\nYeah, but that was exactly what I was after...\n\nAs far as I understand it, the git-read-tree -u -m doesn't actually do\nanything when the workspace is dirty - so there's actually no merging \ngoing on, right?\n\nIf you react to the dirty-workspace-warnings in such a failed merge by \n\"git commit-ing\" (and not noting the MERGE_HEAD warning, which has been \nknown to happen), you'll end up with an unwanted parent in the commit.\n\nOr am I just being stupid :-?\n\n/dan\n"},{"id":"5087","messageId":"Pine.LNX.4.58.0506201040140.2268@ppc970.osdl.org","threadId":"976","inReplyTo":"42B6FAE5.6060904@gmail.com","subject":"Re: 'git commit' duplicates parents?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-20T17:44:01Z","receivedAt":"2005-06-20T17:44:01Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 20 Jun 2005, Dan Holmsand wrote:\n> \n> Yeah, but that was exactly what I was after...\n> \n> As far as I understand it, the git-read-tree -u -m doesn't actually do\n> anything when the workspace is dirty - so there's actually no merging \n> going on, right?\n\nNo, but you can trivially do so by hand afterwards.\n\nFor example, git-read-tree -u -m will complain and say \"file xyz is \ndirty, cannot merge\" (or something), and what you might decide to do is \njust\n\n\tgit-checkout-cache -f -u xyz\n\tgit resolve $(cat .git/HEAD) $(cat .git/MERGE_HEAD) \"...\"\n\nand note how you needed to know what the merge head was in order to do \nthis.\n\n[ Side note: I should make \"git-resolve-script\" run \"git-rev-parse\" on its\n  arguments, so that it would expand HEAD and MERGE_HEAD on its own. Maybe \n  somebody who is interested in this script might want to do that? Hint \n  hint. ]\n\nNote how we could make both of us happy by saving that temporary \nMERGE_HEAD information somewhere _else_ instead. Maybe the answer is to \nonly use \"MERGE_HEAD\" for the \"merge manually\" case, and use something \nelse for the \"this was the merge you tried to do last\" case?\n\n\t\tLinus\n"},{"id":"5088","messageId":"42B71076.1050904@gmail.com","threadId":"976","inReplyTo":"Pine.LNX.4.58.0506201040140.2268@ppc970.osdl.org","subject":"Re: 'git commit' duplicates parents?","fromName":"Dan Holmsand","fromEmail":"holmsand@gmail.com","sentAt":"2005-06-20T18:52:38Z","receivedAt":"2005-06-20T18:52:38Z","isPatch":false,"sender":{"key":"holmsand@gmail.com","avatar":"https://gravatar.com/avatar/5c722084bafd85e754a02efad01fe69107eb6f393253c49232c5c9f7faa974df?d=mp&s=160"},"body":"Linus Torvalds wrote:\n> \n> [ Side note: I should make \"git-resolve-script\" run \"git-rev-parse\" on its\n>   arguments, so that it would expand HEAD and MERGE_HEAD on its own. Maybe \n>   somebody who is interested in this script might want to do that? Hint \n>   hint. ]\n\nGot it. Included below.\n\n> Note how we could make both of us happy by saving that temporary \n> MERGE_HEAD information somewhere _else_ instead. Maybe the answer is to \n> only use \"MERGE_HEAD\" for the \"merge manually\" case, and use something \n> else for the \"this was the merge you tried to do last\" case?\n\nI like the \"everybody happy\" idea...\n\nHow about \"LAST_MERGE\"? And something like this?\n\n/dan\n\n---\n\n[PATCH] git-resolve-script: Add LAST_MERGE and use git-rev-parse\n\nMake git-resolve-script only write MERGE_HEAD if a merge actually\noccurred. All merge failures leave ORIG_HEAD and LAST_MERGE\nbehind (instead of ORIG_HEAD and MERGE_HEAD).\n\nUse git-rev-parse to expand arguments (and check for bad ones).\n\nSigned-off-by: Dan Holmsand <holmsand@gmail.com>\n\n\ndiff --git a/git-resolve-script b/git-resolve-script\n--- a/git-resolve-script\n+++ b/git-resolve-script\n@@ -4,26 +4,31 @@\n #\n # Resolve two trees.\n #\n-head=\"$1\"\n-merge=\"$2\"\n+head=$(git-rev-parse --revs-only \"$1\")\n+merge=$(git-rev-parse --revs-only \"$2\")\n merge_repo=\"$3\"\n \n : ${GIT_DIR=.git}\n : ${GIT_OBJECT_DIRECTORY=\"${SHA1_FILE_DIRECTORY-\"$GIT_DIR/objects\"}\"}\n \n-rm -f \"$GIT_DIR\"/MERGE_HEAD \"$GIT_DIR\"/ORIG_HEAD\n-echo $head > \"$GIT_DIR\"/ORIG_HEAD\n-echo $merge > \"$GIT_DIR\"/MERGE_HEAD\n+dropheads() {\n+\trm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\" \\\n+\t\t\"$GIT_DIR/LAST_MERGE\" || exit 1\n+}\n \n #\n # The remote name is just used for the message,\n # but we do want it.\n #\n-if [ \"$merge_repo\" == \"\" ]; then\n+if [ -z \"$head\" -o -z \"$merge\" -o -z \"$merge_repo\" ]; then\n \techo \"git-resolve-script <head> <remote> <merge-repo-name>\"\n \texit 1\n fi\n \n+dropheads\n+echo $head > \"$GIT_DIR\"/ORIG_HEAD\n+echo $merge > \"$GIT_DIR\"/LAST_MERGE\n+\n common=$(git-merge-base $head $merge)\n if [ -z \"$common\" ]; then\n \techo \"Unable to find common commit between\" $merge $head\n@@ -32,7 +37,7 @@ fi\n \n if [ \"$common\" == \"$merge\" ]; then\n \techo \"Already up-to-date. Yeeah!\"\n-\trm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n+\tdropheads\n \texit 0\n fi\n if [ \"$common\" == \"$head\" ]; then\n@@ -40,7 +45,7 @@ if [ \"$common\" == \"$head\" ]; then\n \tgit-read-tree -u -m $head $merge || exit 1\n \techo $merge > \"$GIT_DIR\"/HEAD\n \tgit-diff-tree -p ORIG_HEAD HEAD | git-apply --stat\n-\trm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n+\tdropheads\n \texit 0\n fi\n echo \"Trying to merge $merge into $head\"\n@@ -51,6 +56,7 @@ if [ $? -ne 0 ]; then\n \techo \"Simple merge failed, trying Automatic merge\"\n \tgit-merge-cache -o git-merge-one-file-script -a\n \tif [ $? -ne 0 ]; then\n+\t\techo $merge > \"$GIT_DIR\"/MERGE_HEAD\n \t\techo \"Automatic merge failed, fix up by hand\"\n \t\texit 1\n \tfi\n@@ -60,4 +66,4 @@ result_commit=$(echo \"$merge_msg\" | git-\n echo \"Committed merge $result_commit\"\n echo $result_commit > \"$GIT_DIR\"/HEAD\n git-diff-tree -p $head $result_commit | git-apply --stat\n-rm -f -- \"$GIT_DIR/ORIG_HEAD\" \"$GIT_DIR/MERGE_HEAD\"\n+dropheads\n"}]}