summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-05-24 00:32:31 -0400
committerShawn O. Pearce <spearce@spearce.org>2007-05-24 00:50:19 -0400
commitaac65ed1bc63619d32516079995f5cbe4bb46492 (patch)
tree47ca2263c1c34a67e7ea0a9f5751272ae41c2832 /fast-import.c
parent654aaa37ab5c70650bdd16d57b56c2d0f9aa43cf (diff)
downloadgit-aac65ed1bc63619d32516079995f5cbe4bb46492.tar.gz
Fix possible coredump with fast-import --import-marks
When e8438420bb7d368bec3647b90c557b9931582267 allowed us to reload the marks table on subsequent runs of fast-import we really broke things, as we set pack_id to MAX_PACK_ID for any objects we imported into the marks table. Creating a branch from that mark should fail as we attempt to read the object through a non-existant packed_git pointer. Instead we have to use the normal Git object system to locate the older commit, as we ourselves do not have a reference to the packed_git it resides in. This bug only occurred because t9300 was not complete enough. When we added the --import-marks feature we didn't actually test its implementation enough to verify the function worked as intended. I have corrected that, and included the changes as part of this fix. Prior versions of fast-import fail the new test(s); this commit allows them to pass. Credit for this bug find goes to Simon Hausmann <simon@lst.de> as he recently identified a similiar bug in the tree lazy-loading path. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fast-import.c b/fast-import.c
index f5107df74d..17554f6849 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1709,14 +1709,16 @@ static void cmd_from(struct branch *b)
} else if (*from == ':') {
uintmax_t idnum = strtoumax(from + 1, NULL, 10);
struct object_entry *oe = find_mark(idnum);
- unsigned long size;
- char *buf;
if (oe->type != OBJ_COMMIT)
die("Mark :%" PRIuMAX " not a commit", idnum);
hashcpy(b->sha1, oe->sha1);
- buf = gfi_unpack_entry(oe, &size);
- cmd_from_commit(b, buf, size);
- free(buf);
+ if (oe->pack_id != MAX_PACK_ID) {
+ unsigned long size;
+ char *buf = gfi_unpack_entry(oe, &size);
+ cmd_from_commit(b, buf, size);
+ free(buf);
+ } else
+ cmd_from_existing(b);
} else if (!get_sha1(from, b->sha1))
cmd_from_existing(b);
else