@matheusbsbs / matheus-bagliano / commits / bc32fed551
Fork 0

pack-objects: pass fullname down to add_object_entry()

Instead of giving a hash for grouping, pass fullname to add_object_entry(). I want to add "do not try deltifying this object" bit to object_entry based on the settings in .gitattributes, and hashing the name down too early would interfere with that plan. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed May 19, 2007 at 00:19 UTC bc32fed5516375ef78bc0f6270eb57bf1bb12d47
1 file changed +14 -13
builtin-pack-objects.c
+14 -13
@@ -723,6 +723,9 @@ static unsigned name_hash(const char *name)
723 unsigned char c;
724 unsigned hash = 0;
725
726 + if (!name)
727 + return 0;
728 +
729 /*
730 * This effectively just creates a sortable number from the
731 * last sixteen non-whitespace characters. Last characters
@@ -737,12 +740,13 @@ static unsigned name_hash(const char *name)
740 }
741
742 static int add_object_entry(const unsigned char *sha1, enum object_type type,
740 - unsigned hash, int exclude)
743 + const char *name, int exclude)
744 {
745 struct object_entry *entry;
746 struct packed_git *p, *found_pack = NULL;
747 off_t found_offset = 0;
748 int ix;
749 + unsigned hash = name_hash(name);
750
751 ix = nr_objects ? locate_object_entry_hash(sha1) : -1;
752 if (ix >= 0) {
@@ -931,10 +935,9 @@ static void add_pbase_object(struct tree_desc *tree,
935 if (cmp < 0)
936 return;
937 if (name[cmplen] != '/') {
934 - unsigned hash = name_hash(fullname);
938 add_object_entry(entry.sha1,
939 S_ISDIR(entry.mode) ? OBJ_TREE : OBJ_BLOB,
937 - hash, 1);
940 + fullname, 1);
941 return;
942 }
943 if (S_ISDIR(entry.mode)) {
@@ -994,10 +997,11 @@ static int check_pbase_path(unsigned hash)
997 return 0;
998 }
999
997 -static void add_preferred_base_object(const char *name, unsigned hash)
1000 +static void add_preferred_base_object(const char *name)
1001 {
1002 struct pbase_tree *it;
1003 int cmplen;
1004 + unsigned hash = name_hash(name);
1005
1006 if (!num_preferred_base || check_pbase_path(hash))
1007 return;
@@ -1005,7 +1009,7 @@ static void add_preferred_base_object(const char *name, unsigned hash)
1009 cmplen = name_cmp_len(name);
1010 for (it = pbase_tree; it; it = it->next) {
1011 if (cmplen == 0) {
1008 - add_object_entry(it->pcache.sha1, OBJ_TREE, 0, 1);
1012 + add_object_entry(it->pcache.sha1, OBJ_TREE, NULL, 1);
1013 }
1014 else {
1015 struct tree_desc tree;
@@ -1446,7 +1450,6 @@ static void read_object_list_from_stdin(void)
1450 {
1451 char line[40 + 1 + PATH_MAX + 2];
1452 unsigned char sha1[20];
1449 - unsigned hash;
1453
1454 for (;;) {
1455 if (!fgets(line, sizeof(line), stdin)) {
@@ -1469,22 +1472,20 @@ static void read_object_list_from_stdin(void)
1472 if (get_sha1_hex(line, sha1))
1473 die("expected sha1, got garbage:\n %s", line);
1474
1472 - hash = name_hash(line+41);
1473 - add_preferred_base_object(line+41, hash);
1474 - add_object_entry(sha1, 0, hash, 0);
1475 + add_preferred_base_object(line+41);
1476 + add_object_entry(sha1, 0, line+41, 0);
1477 }
1478 }
1479
1480 static void show_commit(struct commit *commit)
1481 {
1480 - add_object_entry(commit->object.sha1, OBJ_COMMIT, 0, 0);
1482 + add_object_entry(commit->object.sha1, OBJ_COMMIT, NULL, 0);
1483 }
1484
1485 static void show_object(struct object_array_entry *p)
1486 {
1485 - unsigned hash = name_hash(p->name);
1486 - add_preferred_base_object(p->name, hash);
1487 - add_object_entry(p->item->sha1, p->item->type, hash, 0);
1487 + add_preferred_base_object(p->name);
1488 + add_object_entry(p->item->sha1, p->item->type, p->name, 0);
1489 }
1490
1491 static void show_edge(struct commit *commit)