All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Holmsand <holmsand@gmail.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: 'git commit' duplicates parents?
Date: Mon, 20 Jun 2005 20:52:38 +0200	[thread overview]
Message-ID: <42B71076.1050904@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0506201040140.2268@ppc970.osdl.org>

[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]

Linus Torvalds wrote:
> 
> [ Side note: I should make "git-resolve-script" run "git-rev-parse" on its
>   arguments, so that it would expand HEAD and MERGE_HEAD on its own. Maybe 
>   somebody who is interested in this script might want to do that? Hint 
>   hint. ]

Got it. Included below.

> Note how we could make both of us happy by saving that temporary 
> MERGE_HEAD information somewhere _else_ instead. Maybe the answer is to 
> only use "MERGE_HEAD" for the "merge manually" case, and use something 
> else for the "this was the merge you tried to do last" case?

I like the "everybody happy" idea...

How about "LAST_MERGE"? And something like this?

/dan

---

[PATCH] git-resolve-script: Add LAST_MERGE and use git-rev-parse

Make git-resolve-script only write MERGE_HEAD if a merge actually
occurred. All merge failures leave ORIG_HEAD and LAST_MERGE
behind (instead of ORIG_HEAD and MERGE_HEAD).

Use git-rev-parse to expand arguments (and check for bad ones).

Signed-off-by: Dan Holmsand <holmsand@gmail.com>

[-- Attachment #2: git-resolve-script.patch2.txt --]
[-- Type: text/plain, Size: 2096 bytes --]

diff --git a/git-resolve-script b/git-resolve-script
--- a/git-resolve-script
+++ b/git-resolve-script
@@ -4,26 +4,31 @@
 #
 # Resolve two trees.
 #
-head="$1"
-merge="$2"
+head=$(git-rev-parse --revs-only "$1")
+merge=$(git-rev-parse --revs-only "$2")
 merge_repo="$3"
 
 : ${GIT_DIR=.git}
 : ${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
+dropheads() {
+	rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD" \
+		"$GIT_DIR/LAST_MERGE" || exit 1
+}
 
 #
 # The remote name is just used for the message,
 # but we do want it.
 #
-if [ "$merge_repo" == "" ]; then
+if [ -z "$head" -o -z "$merge" -o -z "$merge_repo" ]; then
 	echo "git-resolve-script <head> <remote> <merge-repo-name>"
 	exit 1
 fi
 
+dropheads
+echo $head > "$GIT_DIR"/ORIG_HEAD
+echo $merge > "$GIT_DIR"/LAST_MERGE
+
 common=$(git-merge-base $head $merge)
 if [ -z "$common" ]; then
 	echo "Unable to find common commit between" $merge $head
@@ -32,7 +37,7 @@ fi
 
 if [ "$common" == "$merge" ]; then
 	echo "Already up-to-date. Yeeah!"
-	rm -f -- "$GIT_DIR/ORIG_HEAD" "$GIT_DIR/MERGE_HEAD"
+	dropheads
 	exit 0
 fi
 if [ "$common" == "$head" ]; then
@@ -40,7 +45,7 @@ if [ "$common" == "$head" ]; then
 	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"
+	dropheads
 	exit 0
 fi
 echo "Trying to merge $merge into $head"
@@ -51,6 +56,7 @@ 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 "Automatic merge failed, fix up by hand"
 		exit 1
 	fi
@@ -60,4 +66,4 @@ 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"
+dropheads

      reply	other threads:[~2005-06-20 18:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-19 16:27 'git commit' duplicates parents? Jeff Garzik
2005-06-19 16:32 ` Jeff Garzik
2005-06-20  2:24 ` Linus Torvalds
2005-06-20  2:28   ` Jeff Garzik
2005-06-20  2:33   ` Linus Torvalds
2005-06-20  2:40     ` Jeff Garzik
2005-06-20  3:00       ` Linus Torvalds
2005-06-20  9:48         ` Dan Holmsand
2005-06-20 15:11           ` Linus Torvalds
2005-06-20 17:20             ` Dan Holmsand
2005-06-20 17:44               ` Linus Torvalds
2005-06-20 18:52                 ` Dan Holmsand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42B71076.1050904@gmail.com \
    --to=holmsand@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.