git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: 'git commit' duplicates parents?

From
Dan Holmsand <holmsand@gmail.com>
Date
Jun 20, 2005, 09:48 UTC
Message-ID
<42B690EA.2080605@gmail.com>
In-Reply-To
<Pine.LNX.4.58.0506191958010.2268@ppc970.osdl.org>
Linus Torvalds wrote:
> Keep the complaints coming when something doesn't work the way it should.  
> I'll continue to try to blame your incompetence as much as I humanly can,
> but hey, some of it is occasionally mine too... ;(
Well, since it's obviously complaint time :-)

git-resolve-script still seems a bit too eager to write MERGE_HEAD and ORIG_HEAD - they only make sense if there's actually been any merging done, don't they?

Patch below shows what I mean.
/dan
---
[PATCH] Make git-resolve-script less eager to write MERGE_HEAD

MERGE_HEAD and ORIG_HEAD should only be written if there's actually been any merging done.

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
diff --git a/git-resolve-script b/git-resolve-script
--- a/git-resolve-script
+++ b/git-resolve-script
@@ -12,8 +12,6 @@ merge_repo="$3"
 : ${GIT_OBJECT_DIRECTORY="${SHA1_FILE_DIRECTORY-"$GIT_DIR/objects"}"}
 
 rm -f "$GIT_DIR"/MERGE_HEAD "$GIT_DIR"/ORIG_HEAD
-echo $head > "$GIT_DIR"/ORIG_HEAD
-echo $merge > "$GIT_DIR"/MERGE_HEAD
 
 #
 # The remote name is just used for the message,
@@ -32,15 +30,13 @@ fi
 
 if [ "$common" == "$merge" ]; then
 	echo "Already up-to-date. Yeeah!"
-	rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD"
 	exit 0
 fi
 if [ "$common" == "$head" ]; then
 	echo "Updating from $head to $merge."
 	git-read-tree -u -m $head $merge || exit 1
 	echo $merge > "$GIT_DIR"/HEAD
-	git-diff-tree -p ORIG_HEAD HEAD | git-apply --stat
-	rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD"
+	git-diff-tree -p $head HEAD | git-apply --stat
 	exit 0
 fi
 echo "Trying to merge $merge into $head"
@@ -51,6 +47,8 @@ if [ $? -ne 0 ]; then
 	echo "Simple merge failed, trying Automatic merge"
 	git-merge-cache -o git-merge-one-file-script -a
 	if [ $? -ne 0 ]; then
+		echo $merge > "$GIT_DIR"/MERGE_HEAD
+		echo $head > "$GIT_DIR"/ORIG_HEAD
 		echo "Automatic merge failed, fix up by hand"
 		exit 1
 	fi
@@ -60,4 +58,3 @@ result_commit=$(echo "$merge_msg" | git-
 echo "Committed merge $result_commit"
 echo $result_commit > "$GIT_DIR"/HEAD
 git-diff-tree -p $head $result_commit | git-apply --stat
-rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD"
Previous: Linus TorvaldsNext: Linus Torvalds
Message 8 of 12 in “'git commit' duplicates parents?”
  1. Jeff GarzikJun 19, 2005
  2. Jeff GarzikJun 19, 2005
  3. Linus TorvaldsJun 20, 2005
  4. Jeff GarzikJun 20, 2005
  5. Linus TorvaldsJun 20, 2005
  6. Jeff GarzikJun 20, 2005
  7. Linus TorvaldsJun 20, 2005
  8. Dan HolmsandJun 20, 2005
  9. Linus TorvaldsJun 20, 2005
  10. Dan HolmsandJun 20, 2005
  11. Linus TorvaldsJun 20, 2005
  12. Dan HolmsandJun 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.