summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2fd955c)
raw | patch | inline | side by side (parent: 2fd955c)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 2 Nov 2005 23:19:13 +0000 (15:19 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 3 Nov 2005 00:50:58 +0000 (16:50 -0800) |
One caller of deref_tag() was not careful enough to make sure
what deref_tag() returned was not NULL (i.e. we found a tag
object that points at an object we do not have). Fix it, and
warn about refs that point at such an incomplete tag where
needed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
what deref_tag() returned was not NULL (i.e. we found a tag
object that points at an object we do not have). Fix it, and
warn about refs that point at such an incomplete tag where
needed.
Signed-off-by: Junio C Hamano <junkio@cox.net>
commit.c | patch | blob | history | |
fetch-pack.c | patch | blob | history | |
name-rev.c | patch | blob | history | |
send-pack.c | patch | blob | history | |
server-info.c | patch | blob | history | |
sha1_name.c | patch | blob | history | |
tag.c | patch | blob | history | |
tag.h | patch | blob | history | |
upload-pack.c | patch | blob | history |
diff --git a/commit.c b/commit.c
index 8f403180e5903bfa3da9df76b2cda213135c58d3..a8c9bfc8baf21a3d42164faa1577f74326b51df6 100644 (file)
--- a/commit.c
+++ b/commit.c
struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
int quiet)
{
- struct object *obj = deref_tag(parse_object(sha1));
+ struct object *obj = deref_tag(parse_object(sha1), NULL, 0);
if (!obj)
return NULL;
diff --git a/fetch-pack.c b/fetch-pack.c
index 3df991100bdd51f4527703d1ce1d016b611f0d5a..cb2171523c6f30911b1d80d622d709b7f39fdb97 100644 (file)
--- a/fetch-pack.c
+++ b/fetch-pack.c
static int rev_list_insert_ref(const char *path, const unsigned char *sha1)
{
- struct object *o = deref_tag(parse_object(sha1));
+ struct object *o = deref_tag(parse_object(sha1), path, 0);
- if (o->type == commit_type)
+ if (o && o->type == commit_type)
rev_list_push((struct commit *)o, SEEN);
return 0;
* Don't mark them common yet; the server has to be told so first.
*/
for (ref = *refs; ref; ref = ref->next) {
- struct object *o = deref_tag(lookup_object(ref->old_sha1));
+ struct object *o = deref_tag(lookup_object(ref->old_sha1),
+ NULL, 0);
if (!o || o->type != commit_type || !(o->flags & COMPLETE))
continue;
diff --git a/name-rev.c b/name-rev.c
index 21fecdf542a05e9bfa80990061ed3d0d3c849823..59194f1349ff4df860dd9ee4a3f183e17b72b6fc 100644 (file)
--- a/name-rev.c
+++ b/name-rev.c
continue;
}
- o = deref_tag(parse_object(sha1));
+ o = deref_tag(parse_object(sha1), *argv, 0);
if (!o || o->type != commit_type) {
fprintf(stderr, "Could not get commit for %s. Skipping.\n",
*argv);
diff --git a/send-pack.c b/send-pack.c
index 9f9a6e70b8789f63891c5b6e07822c546af8eec4..3eeb18f7c7d32412003ea665a47081dc06d84c95 100644 (file)
--- a/send-pack.c
+++ b/send-pack.c
/* Both new and old must be commit-ish and new is descendant of
* old. Otherwise we require --force.
*/
- o = deref_tag(parse_object(old_sha1));
+ o = deref_tag(parse_object(old_sha1), NULL, 0);
if (!o || o->type != commit_type)
return 0;
old = (struct commit *) o;
- o = deref_tag(parse_object(new_sha1));
+ o = deref_tag(parse_object(new_sha1), NULL, 0);
if (!o || o->type != commit_type)
return 0;
new = (struct commit *) o;
diff --git a/server-info.c b/server-info.c
index ba5359108deb4f010be366ef65974ec7db123098..0cba8e19f7582fa5771ed6ab94a76e1d87efc53a 100644 (file)
--- a/server-info.c
+++ b/server-info.c
fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path);
if (o->type == tag_type) {
- o = deref_tag(o);
- fprintf(info_ref_fp, "%s %s^{}\n",
- sha1_to_hex(o->sha1), path);
+ o = deref_tag(o, path, 0);
+ if (o)
+ fprintf(info_ref_fp, "%s %s^{}\n",
+ sha1_to_hex(o->sha1), path);
}
return 0;
}
diff --git a/sha1_name.c b/sha1_name.c
index fe409fbce4978535bdf38773fd4e2924a68733b9..be1755a70b2c53fc102db41a62e6099fa0adac1b 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
if (!o)
return -1;
if (!type_string) {
- o = deref_tag(o);
+ o = deref_tag(o, name, sp - name - 2);
if (!o || (!o->parsed && !parse_object(o->sha1)))
return -1;
memcpy(sha1, o->sha1, 20);
index b1ab75ff0164b0090f43ba55d2a70239ca2fdb7a..e574c4b7a496d3a1d113801214197a04d5c74d42 100644 (file)
--- a/tag.c
+++ b/tag.c
const char *tag_type = "tag";
-struct object *deref_tag(struct object *o)
+struct object *deref_tag(struct object *o, const char *warn, int warnlen)
{
while (o && o->type == tag_type)
o = parse_object(((struct tag *)o)->tagged->sha1);
+ if (!o && warn) {
+ if (!warnlen)
+ warnlen = strlen(warn);
+ error("missing object referenced by '%.*s'", warnlen, warn);
+ }
return o;
}
index 36e532401fe253a61a26f8b0adfba2cf1009fb3d..7a0cb0070d46ba8c49d71029dc0704188805ea62 100644 (file)
--- a/tag.h
+++ b/tag.h
extern struct tag *lookup_tag(const unsigned char *sha1);
extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size);
extern int parse_tag(struct tag *item);
-extern struct object *deref_tag(struct object *);
+extern struct object *deref_tag(struct object *, const char *, int);
#endif /* TAG_H */
diff --git a/upload-pack.c b/upload-pack.c
index c5eff21363245e1febe03aa8d4309f8cbb0cd7fa..be63132804252e9a2f94ce1166ef9fa319a845fd 100644 (file)
--- a/upload-pack.c
+++ b/upload-pack.c
nr_our_refs++;
}
if (o->type == tag_type) {
- o = deref_tag(o);
+ o = deref_tag(o, refname, 0);
packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
}
return 0;