Browse Source

[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 <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Linus Torvalds 20 years ago committed by Junio C Hamano
parent
commit
02a4a32c2d
  1. 4
      git-resolve-script
  2. 10
      sha1_name.c

4
git-resolve-script

@ -6,8 +6,8 @@
# #
. git-sh-setup-script || die "Not a git archive" . git-sh-setup-script || die "Not a git archive"


head=$(git-rev-parse --verify "$1") head=$(git-rev-parse --verify "$1"^0) || exit
merge=$(git-rev-parse --verify "$2") merge=$(git-rev-parse --verify "$2"^0) || exit
merge_msg="$3" merge_msg="$3"


dropheads() { dropheads() {

10
sha1_name.c

@ -208,13 +208,9 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1)
} else } else
parent = -1; parent = -1;


if (0 <= parent) { if (parent >= 0)
ret = get_parent(name, len, sha1, parent); return get_parent(name, len, sha1, parent);
if (!ret)
return 0;
else if(parent>0)
return ret;
}
ret = get_sha1_basic(name, len, sha1); ret = get_sha1_basic(name, len, sha1);
if (!ret) if (!ret)
return 0; return 0;

Loading…
Cancel
Save