From: Linus Torvalds Date: Sat, 13 Aug 2005 17:50:56 +0000 (-0700) Subject: [PATCH] Make sure git-resolve-script always works on commits X-Git-Tag: v0.99.5~22^2~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=02a4a32c2da9a89eb9ebc58325adcb47775c9ed5;p=git.git [PATCH] Make sure git-resolve-script always works on commits You can resolve a tag, and it does the right thing except that it might end up writing the tag itself into the resulting HEAD, which will confuse subsequent operations no end. This makes sure that when we resolve two heads, we will have turned them into proper commits before we start acting on them. This also fixes the parsing of "treeish^0", which would incorrectly resolve to "treeish" instead of causing an error. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- diff --git a/git-resolve-script b/git-resolve-script index 52dd83ba..4641119e 100755 --- a/git-resolve-script +++ b/git-resolve-script @@ -6,8 +6,8 @@ # . git-sh-setup-script || die "Not a git archive" -head=$(git-rev-parse --verify "$1") -merge=$(git-rev-parse --verify "$2") +head=$(git-rev-parse --verify "$1"^0) || exit +merge=$(git-rev-parse --verify "$2"^0) || exit merge_msg="$3" dropheads() { diff --git a/sha1_name.c b/sha1_name.c index 5d1e441e..df45b172 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -208,13 +208,9 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1) } else parent = -1; - if (0 <= parent) { - ret = get_parent(name, len, sha1, parent); - if (!ret) - return 0; - else if(parent>0) - return ret; - } + if (parent >= 0) + return get_parent(name, len, sha1, parent); + ret = get_sha1_basic(name, len, sha1); if (!ret) return 0;