summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 62bb996)
raw | patch | inline | side by side (parent: 62bb996)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Tue, 28 Jun 2005 16:58:23 +0000 (09:58 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Tue, 28 Jun 2005 16:58:23 +0000 (09:58 -0700) |
(And teach sha1_file and unpack-object know how to unpack them too, of
course)
course)
pack-objects.c | patch | blob | history | |
sha1_file.c | patch | blob | history | |
unpack-objects.c | patch | blob | history |
diff --git a/pack-objects.c b/pack-objects.c
index 62ed265437bd7430ca9645151a2aa2d7c3aa4062..90b27c60c3a889d7534e17af51b3e8b79b1d2b24 100644 (file)
--- a/pack-objects.c
+++ b/pack-objects.c
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;
};
* 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';
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);
diff --git a/sha1_file.c b/sha1_file.c
index 5695c962fe20a60940a5203bc3c33c0a201241e0..e27affb2885717974b5612d4a41a91ed390d7ff7 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
case 'B':
strcpy(type, "blob");
break;
+ case 'G':
+ strcpy(type, "tag");
+ break;
default:
die("corrupted pack file");
}
case 'B':
strcpy(type, "blob");
break;
+ case 'G':
+ strcpy(type, "tag");
+ break;
default:
die("corrupted pack file");
}
diff --git a/unpack-objects.c b/unpack-objects.c
index a792b92ece0770e5c2305b26d70eb26ee51d26c7..57f3c9b6bb4790149a50f3855f42b5eb479b09d8 100644 (file)
--- a/unpack-objects.c
+++ b/unpack-objects.c
case 'C': type_s = "commit"; break;
case 'T': type_s = "tree"; break;
case 'B': type_s = "blob"; break;
+ case 'G': type_s = "tag"; break;
default: goto err_finish;
}
if (write_sha1_file(buffer, size, type_s, sha1) < 0)
size = (pack[1] << 24) + (pack[2] << 16) + (pack[3] << 8) + pack[4];
left = pack_size - offset - 5;
switch (*pack) {
- case 'C': case 'T': case 'B':
+ case 'C': case 'T': case 'B': case 'G':
unpack_non_delta_entry(entry, *pack, pack+5, size, left);
break;
case 'D':