aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-10-03 19:13:04 -0700
committerJunio C Hamano <junkio@cox.net>2005-10-03 19:13:04 -0700
commitd53174dbae060153176279f8b4797e3a35421c95 (patch)
treec6ecca7cb0a161c759b419c17b729457ff0768c5
parentb23f02ee7aa3fc1cdaf6aebde9b731f22671251b (diff)
parentf5a5e9b9f4f08544660fd55cd211bdd57c55b32f (diff)
downloadgit-d53174dbae060153176279f8b4797e3a35421c95.tar.gz
git-d53174dbae060153176279f8b4797e3a35421c95.tar.xz
Merge branch 'fixes'
-rw-r--r--sha1_name.c21
-rw-r--r--symbolic-ref.c2
2 files changed, 16 insertions, 7 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 8920de1c4..f64755fbc 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -91,14 +91,23 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne
last = mid;
}
if (first < num) {
- unsigned char now[20];
+ unsigned char now[20], next[20];
nth_packed_object_sha1(p, first, now);
if (match_sha(len, match, now)) {
- if (!found) {
- memcpy(found_sha1, now, 20);
- found++;
+ if (nth_packed_object_sha1(p, first+1, next) ||
+ !match_sha(len, match, next)) {
+ /* unique within this pack */
+ if (!found) {
+ memcpy(found_sha1, now, 20);
+ found++;
+ }
+ else if (memcmp(found_sha1, now, 20)) {
+ found = 2;
+ break;
+ }
}
- else if (memcmp(found_sha1, now, 20)) {
+ else {
+ /* not even unique within this pack */
found = 2;
break;
}
@@ -121,7 +130,7 @@ static int find_unique_short_object(int len, char *canonical,
if (!has_unpacked && !has_packed)
return -1;
if (1 < has_unpacked || 1 < has_packed)
- return -1;
+ return error("short SHA1 %.*s is ambiguous.", len, canonical);
if (has_unpacked != has_packed) {
memcpy(sha1, (has_packed ? packed_sha1 : unpacked_sha1), 20);
return 0;
diff --git a/symbolic-ref.c b/symbolic-ref.c
index af087d211..a72d7accb 100644
--- a/symbolic-ref.c
+++ b/symbolic-ref.c
@@ -3,7 +3,7 @@
static const char git_symbolic_ref_usage[] =
"git-symbolic-ref name [ref]";
-static int check_symref(const char *HEAD)
+static void check_symref(const char *HEAD)
{
unsigned char sha1[20];
const char *git_HEAD = strdup(git_path("%s", HEAD));