summaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 16:58:23 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 16:58:23 (GMT)
commita69d09436687746a898f86f32c180083f323b616 (patch)
tree33d636080914a5306158b33563e9a09fd6bf68d1 /pack-objects.c
parent62bb99606d0377fc14f206cbdf95acb57149d87a (diff)
downloadgit-a69d09436687746a898f86f32c180083f323b616.zip
git-a69d09436687746a898f86f32c180083f323b616.tar.gz
git-a69d09436687746a898f86f32c180083f323b616.tar.bz2
Teach packing about "tag" objects
(And teach sha1_file and unpack-object know how to unpack them too, of course)
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 62ed265..90b27c6 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -6,21 +6,21 @@
static const char pack_usage[] = "git-pack-objects [--window=N] [--depth=N] base-name < object-list";
-enum object_type {
- OBJ_NONE,
- OBJ_COMMIT,
- OBJ_TREE,
- OBJ_BLOB,
- OBJ_DELTA
-};
-
+/*
+ * The object type is a single-character shorthand:
+ * - 'C' for "Commit"
+ * - 'T' for "Tree"
+ * - 'B' for "Blob"
+ * - 'G' for "taG"
+ * - 'D' for "Delta"
+ */
struct object_entry {
unsigned char sha1[20];
unsigned long size;
unsigned long offset;
unsigned int depth;
unsigned int hash;
- enum object_type type;
+ unsigned char type;
unsigned long delta_size;
struct object_entry *delta;
};
@@ -67,7 +67,7 @@ static unsigned long write_object(struct sha1file *f, struct object_entry *entry
* length, except for deltas that has the 20 bytes of delta sha
* instead.
*/
- header[0] = ".CTB"[entry->type];
+ header[0] = entry->type;
hdrlen = 5;
if (entry->delta) {
header[0] = 'D';
@@ -164,11 +164,13 @@ static void check_object(struct object_entry *entry)
if (!sha1_object_info(entry->sha1, type, &entry->size)) {
if (!strcmp(type, "commit")) {
- entry->type = OBJ_COMMIT;
+ entry->type = 'C';
} else if (!strcmp(type, "tree")) {
- entry->type = OBJ_TREE;
+ entry->type = 'T';
} else if (!strcmp(type, "blob")) {
- entry->type = OBJ_BLOB;
+ entry->type = 'B';
+ } else if (!strcmp(type, "tag")) {
+ entry->type = 'G';
} else
die("unable to pack object %s of type %s",
sha1_to_hex(entry->sha1), type);