fast-import: convert internal structs to struct object_id
Convert struct tree_entry_ms, struct branch, struct tag, and struct hash_list to use struct object_id by changing the definition and applying the following semantic patch, plus the standard object_id transforms: @@ struct tree_entry_ms E1; @@ - E1.sha1 + E1.oid.hash @@ struct tree_entry_ms *E1; @@ - E1->sha1 + E1->oid.hash @@ struct branch E1; @@ - E1.sha1 + E1.oid.hash @@ struct branch *E1; @@ - E1->sha1 + E1->oid.hash @@ struct tag E1; @@ - E1.sha1 + E1.oid.hash @@ struct tag *E1; @@ - E1->sha1 + E1->oid.hash @@ struct hash_list E1; @@ - E1.sha1 + E1.oid.hash @@ struct hash_list *E1; @@ - E1->sha1 + E1->oid.hash Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 1, 2017 at 02:29 UTC
d7e6b6a8dcc8a98a4dcf6bc291f1e68b1acaecae
1 file changed
+96
-86
fast-import.c
+96
-86
@@ -226,7 +226,7 @@ struct tree_entry {
226
struct atom_str *name;
227
struct tree_entry_ms {
228
uint16_t mode;
229
- unsigned char sha1[20];
229
+ struct object_id oid;
230
} versions[2];
231
};
232
@@ -252,19 +252,19 @@ struct branch {
252
unsigned active : 1;
253
unsigned delete : 1;
254
unsigned pack_id : PACK_ID_BITS;
255
- unsigned char sha1[20];
255
+ struct object_id oid;
256
};
257
258
struct tag {
259
struct tag *next_tag;
260
const char *name;
261
unsigned int pack_id;
262
- unsigned char sha1[20];
262
+ struct object_id oid;
263
};
264
265
struct hash_list {
266
struct hash_list *next;
267
- unsigned char sha1[20];
267
+ struct object_id oid;
268
};
269
270
typedef enum {
@@ -386,13 +386,15 @@ static void write_branch_report(FILE *rpt, struct branch *b)
386
fputs(" active", rpt);
387
if (b->branch_tree.tree)
388
fputs(" loaded", rpt);
389
- if (is_null_sha1(b->branch_tree.versions[1].sha1))
389
+ if (is_null_oid(&b->branch_tree.versions[1].oid))
390
fputs(" dirty", rpt);
391
fputc('\n', rpt);
392
393
- fprintf(rpt, " tip commit : %s\n", sha1_to_hex(b->sha1));
394
- fprintf(rpt, " old tree : %s\n", sha1_to_hex(b->branch_tree.versions[0].sha1));
395
- fprintf(rpt, " cur tree : %s\n", sha1_to_hex(b->branch_tree.versions[1].sha1));
393
+ fprintf(rpt, " tip commit : %s\n", oid_to_hex(&b->oid));
394
+ fprintf(rpt, " old tree : %s\n",
395
+ oid_to_hex(&b->branch_tree.versions[0].oid));
396
+ fprintf(rpt, " cur tree : %s\n",
397
+ oid_to_hex(&b->branch_tree.versions[1].oid));
398
fprintf(rpt, " commit clock: %" PRIuMAX "\n", b->last_commit);
399
400
fputs(" last pack : ", rpt);
@@ -470,7 +472,7 @@ static void write_crash_report(const char *err)
472
fputs("Annotated Tags\n", rpt);
473
fputs("--------------\n", rpt);
474
for (tg = first_tag; tg; tg = tg->next_tag) {
473
- fputs(sha1_to_hex(tg->sha1), rpt);
475
+ fputs(oid_to_hex(&tg->oid), rpt);
476
fputc(' ', rpt);
477
fputs(tg->name, rpt);
478
fputc('\n', rpt);
@@ -876,7 +878,7 @@ static struct tree_content *dup_tree_content(struct tree_content *s)
878
a = s->entries[i];
879
b = new_tree_entry();
880
memcpy(b, a, sizeof(*a));
879
- if (a->tree && is_null_sha1(b->versions[1].sha1))
881
+ if (a->tree && is_null_oid(&b->versions[1].oid))
882
b->tree = dup_tree_content(a->tree);
883
else
884
b->tree = NULL;
@@ -1041,12 +1043,14 @@ static void end_packfile(void)
1043
for (i = 0; i < branch_table_sz; i++) {
1044
for (b = branch_table[i]; b; b = b->table_next_branch) {
1045
if (b->pack_id == pack_id)
1044
- fprintf(pack_edges, " %s", sha1_to_hex(b->sha1));
1046
+ fprintf(pack_edges, " %s",
1047
+ oid_to_hex(&b->oid));
1048
}
1049
}
1050
for (t = first_tag; t; t = t->next_tag) {
1051
if (t->pack_id == pack_id)
1049
- fprintf(pack_edges, " %s", sha1_to_hex(t->sha1));
1052
+ fprintf(pack_edges, " %s",
1053
+ oid_to_hex(&t->oid));
1054
}
1055
fputc('\n', pack_edges);
1056
fflush(pack_edges);
@@ -1385,7 +1389,7 @@ static const char *get_mode(const char *str, uint16_t *modep)
1389
1390
static void load_tree(struct tree_entry *root)
1391
{
1388
- unsigned char *sha1 = root->versions[1].sha1;
1392
+ unsigned char *sha1 = root->versions[1].oid.hash;
1393
struct object_entry *myoe;
1394
struct tree_content *t;
1395
unsigned long size;
@@ -1426,8 +1430,8 @@ static void load_tree(struct tree_entry *root)
1430
e->versions[0].mode = e->versions[1].mode;
1431
e->name = to_atom(c, strlen(c));
1432
c += e->name->str_len + 1;
1429
- hashcpy(e->versions[0].sha1, (unsigned char *)c);
1430
- hashcpy(e->versions[1].sha1, (unsigned char *)c);
1433
+ hashcpy(e->versions[0].oid.hash, (unsigned char *)c);
1434
+ hashcpy(e->versions[1].oid.hash, (unsigned char *)c);
1435
c += 20;
1436
}
1437
free(buf);
@@ -1475,7 +1479,7 @@ static void mktree(struct tree_content *t, int v, struct strbuf *b)
1479
strbuf_addf(b, "%o %s%c",
1480
(unsigned int)(e->versions[v].mode & ~NO_DELTA),
1481
e->name->str_dat, '\0');
1478
- strbuf_add(b, e->versions[v].sha1, 20);
1482
+ strbuf_add(b, e->versions[v].oid.hash, 20);
1483
}
1484
}
1485
@@ -1486,7 +1490,7 @@ static void store_tree(struct tree_entry *root)
1490
struct last_object lo = { STRBUF_INIT, 0, 0, /* no_swap */ 1 };
1491
struct object_entry *le = NULL;
1492
1489
- if (!is_null_sha1(root->versions[1].sha1))
1493
+ if (!is_null_oid(&root->versions[1].oid))
1494
return;
1495
1496
if (!root->tree)
@@ -1499,7 +1503,7 @@ static void store_tree(struct tree_entry *root)
1503
}
1504
1505
if (!(root->versions[0].mode & NO_DELTA))
1502
- le = find_object(root->versions[0].sha1);
1506
+ le = find_object(root->versions[0].oid.hash);
1507
if (S_ISDIR(root->versions[0].mode) && le && le->pack_id == pack_id) {
1508
mktree(t, 0, &old_tree);
1509
lo.data = old_tree;
@@ -1508,14 +1512,14 @@ static void store_tree(struct tree_entry *root)
1512
}
1513
1514
mktree(t, 1, &new_tree);
1511
- store_object(OBJ_TREE, &new_tree, &lo, root->versions[1].sha1, 0);
1515
+ store_object(OBJ_TREE, &new_tree, &lo, root->versions[1].oid.hash, 0);
1516
1517
t->delta_depth = lo.depth;
1518
for (i = 0, j = 0, del = 0; i < t->entry_count; i++) {
1519
struct tree_entry *e = t->entries[i];
1520
if (e->versions[1].mode) {
1521
e->versions[0].mode = e->versions[1].mode;
1518
- hashcpy(e->versions[0].sha1, e->versions[1].sha1);
1522
+ oidcpy(&e->versions[0].oid, &e->versions[1].oid);
1523
t->entries[j++] = e;
1524
} else {
1525
release_tree_entry(e);
@@ -1533,8 +1537,8 @@ static void tree_content_replace(
1537
{
1538
if (!S_ISDIR(mode))
1539
die("Root cannot be a non-directory");
1536
- hashclr(root->versions[0].sha1);
1537
- hashcpy(root->versions[1].sha1, sha1);
1540
+ oidclr(&root->versions[0].oid);
1541
+ hashcpy(root->versions[1].oid.hash, sha1);
1542
if (root->tree)
1543
release_tree_content_recursive(root->tree);
1544
root->tree = newtree;
@@ -1568,10 +1572,10 @@ static int tree_content_set(
1572
if (!*slash1) {
1573
if (!S_ISDIR(mode)
1574
&& e->versions[1].mode == mode
1571
- && !hashcmp(e->versions[1].sha1, sha1))
1575
+ && !hashcmp(e->versions[1].oid.hash, sha1))
1576
return 0;
1577
e->versions[1].mode = mode;
1574
- hashcpy(e->versions[1].sha1, sha1);
1578
+ hashcpy(e->versions[1].oid.hash, sha1);
1579
if (e->tree)
1580
release_tree_content_recursive(e->tree);
1581
e->tree = subtree;
@@ -1592,7 +1596,7 @@ static int tree_content_set(
1596
if (S_ISDIR(e->versions[0].mode))
1597
e->versions[0].mode |= NO_DELTA;
1598
1595
- hashclr(root->versions[1].sha1);
1599
+ oidclr(&root->versions[1].oid);
1600
return 1;
1601
}
1602
if (!S_ISDIR(e->versions[1].mode)) {
@@ -1602,7 +1606,7 @@ static int tree_content_set(
1606
if (!e->tree)
1607
load_tree(e);
1608
if (tree_content_set(e, slash1 + 1, sha1, mode, subtree)) {
1605
- hashclr(root->versions[1].sha1);
1609
+ oidclr(&root->versions[1].oid);
1610
return 1;
1611
}
1612
return 0;
@@ -1614,7 +1618,7 @@ static int tree_content_set(
1618
e = new_tree_entry();
1619
e->name = to_atom(p, n);
1620
e->versions[0].mode = 0;
1617
- hashclr(e->versions[0].sha1);
1621
+ oidclr(&e->versions[0].oid);
1622
t->entries[t->entry_count++] = e;
1623
if (*slash1) {
1624
e->tree = new_tree_content(8);
@@ -1623,9 +1627,9 @@ static int tree_content_set(
1627
} else {
1628
e->tree = subtree;
1629
e->versions[1].mode = mode;
1626
- hashcpy(e->versions[1].sha1, sha1);
1630
+ hashcpy(e->versions[1].oid.hash, sha1);
1631
}
1628
- hashclr(root->versions[1].sha1);
1632
+ oidclr(&root->versions[1].oid);
1633
return 1;
1634
}
1635
@@ -1670,7 +1674,7 @@ static int tree_content_remove(
1674
if (tree_content_remove(e, slash1 + 1, backup_leaf, 0)) {
1675
for (n = 0; n < e->tree->entry_count; n++) {
1676
if (e->tree->entries[n]->versions[1].mode) {
1673
- hashclr(root->versions[1].sha1);
1677
+ oidclr(&root->versions[1].oid);
1678
return 1;
1679
}
1680
}
@@ -1689,8 +1693,8 @@ del_entry:
1693
release_tree_content_recursive(e->tree);
1694
e->tree = NULL;
1695
e->versions[1].mode = 0;
1692
- hashclr(e->versions[1].sha1);
1693
- hashclr(root->versions[1].sha1);
1696
+ oidclr(&e->versions[1].oid);
1697
+ oidclr(&root->versions[1].oid);
1698
return 1;
1699
}
1700
@@ -1735,7 +1739,7 @@ static int tree_content_get(
1739
1740
found_entry:
1741
memcpy(leaf, e, sizeof(*leaf));
1738
- if (e->tree && is_null_sha1(e->versions[1].sha1))
1742
+ if (e->tree && is_null_oid(&e->versions[1].oid))
1743
leaf->tree = dup_tree_content(e->tree);
1744
else
1745
leaf->tree = NULL;
@@ -1749,7 +1753,7 @@ static int update_branch(struct branch *b)
1753
unsigned char old_sha1[20];
1754
struct strbuf err = STRBUF_INIT;
1755
1752
- if (is_null_sha1(b->sha1)) {
1756
+ if (is_null_oid(&b->oid)) {
1757
if (b->delete)
1758
delete_ref(NULL, b->name, NULL, 0);
1759
return 0;
@@ -1760,20 +1764,21 @@ static int update_branch(struct branch *b)
1764
struct commit *old_cmit, *new_cmit;
1765
1766
old_cmit = lookup_commit_reference_gently(old_sha1, 0);
1763
- new_cmit = lookup_commit_reference_gently(b->sha1, 0);
1767
+ new_cmit = lookup_commit_reference_gently(b->oid.hash, 0);
1768
if (!old_cmit || !new_cmit)
1769
return error("Branch %s is missing commits.", b->name);
1770
1771
if (!in_merge_bases(old_cmit, new_cmit)) {
1772
warning("Not updating %s"
1773
" (new tip %s does not contain %s)",
1770
- b->name, sha1_to_hex(b->sha1), sha1_to_hex(old_sha1));
1774
+ b->name, oid_to_hex(&b->oid),
1775
+ sha1_to_hex(old_sha1));
1776
return -1;
1777
}
1778
}
1779
transaction = ref_transaction_begin(&err);
1780
if (!transaction ||
1776
- ref_transaction_update(transaction, b->name, b->sha1, old_sha1,
1781
+ ref_transaction_update(transaction, b->name, b->oid.hash, old_sha1,
1782
0, msg, &err) ||
1783
ref_transaction_commit(transaction, &err)) {
1784
ref_transaction_free(transaction);
@@ -1815,7 +1820,7 @@ static void dump_tags(void)
1820
strbuf_addf(&ref_name, "refs/tags/%s", t->name);
1821
1822
if (ref_transaction_update(transaction, ref_name.buf,
1818
- t->sha1, NULL, 0, msg, &err)) {
1823
+ t->oid.hash, NULL, 0, msg, &err)) {
1824
failure |= error("%s", err.buf);
1825
goto cleanup;
1826
}
@@ -2274,7 +2279,7 @@ static uintmax_t do_change_note_fanout(
2279
if (!tree_content_remove(orig_root, fullpath, &leaf, 0))
2280
die("Failed to remove path %s", fullpath);
2281
tree_content_set(orig_root, realpath,
2277
- leaf.versions[1].sha1,
2282
+ leaf.versions[1].oid.hash,
2283
leaf.versions[1].mode,
2284
leaf.tree);
2285
} else if (S_ISDIR(e->versions[1].mode)) {
@@ -2504,13 +2509,13 @@ static void file_change_cr(const char *s, struct branch *b, int rename)
2509
die("Path %s not in branch", s);
2510
if (!*d) { /* C "path/to/subdir" "" */
2511
tree_content_replace(&b->branch_tree,
2507
- leaf.versions[1].sha1,
2512
+ leaf.versions[1].oid.hash,
2513
leaf.versions[1].mode,
2514
leaf.tree);
2515
return;
2516
}
2517
tree_content_set(&b->branch_tree, d,
2513
- leaf.versions[1].sha1,
2518
+ leaf.versions[1].oid.hash,
2519
leaf.versions[1].mode,
2520
leaf.tree);
2521
}
@@ -2561,9 +2566,9 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2566
/* <commit-ish> */
2567
s = lookup_branch(p);
2568
if (s) {
2564
- if (is_null_sha1(s->sha1))
2569
+ if (is_null_oid(&s->oid))
2570
die("Can't add a note on empty branch.");
2566
- hashcpy(commit_sha1, s->sha1);
2571
+ hashcpy(commit_sha1, s->oid.hash);
2572
} else if (*p == ':') {
2573
uintmax_t commit_mark = parse_mark_ref_eol(p);
2574
struct object_entry *commit_oe = find_mark(commit_mark);
@@ -2616,8 +2621,8 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
2621
static void file_change_deleteall(struct branch *b)
2622
{
2623
release_tree_content_recursive(b->branch_tree.tree);
2619
- hashclr(b->branch_tree.versions[0].sha1);
2620
- hashclr(b->branch_tree.versions[1].sha1);
2624
+ oidclr(&b->branch_tree.versions[0].oid);
2625
+ oidclr(&b->branch_tree.versions[1].oid);
2626
load_tree(&b->branch_tree);
2627
b->num_notes = 0;
2628
}
@@ -2625,25 +2630,26 @@ static void file_change_deleteall(struct branch *b)
2630
static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
2631
{
2632
if (!buf || size < 46)
2628
- die("Not a valid commit: %s", sha1_to_hex(b->sha1));
2633
+ die("Not a valid commit: %s", oid_to_hex(&b->oid));
2634
if (memcmp("tree ", buf, 5)
2630
- || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
2631
- die("The commit %s is corrupt", sha1_to_hex(b->sha1));
2632
- hashcpy(b->branch_tree.versions[0].sha1,
2633
- b->branch_tree.versions[1].sha1);
2635
+ || get_sha1_hex(buf + 5, b->branch_tree.versions[1].oid.hash))
2636
+ die("The commit %s is corrupt", oid_to_hex(&b->oid));
2637
+ oidcpy(&b->branch_tree.versions[0].oid,
2638
+ &b->branch_tree.versions[1].oid);
2639
}
2640
2641
static void parse_from_existing(struct branch *b)
2642
{
2638
- if (is_null_sha1(b->sha1)) {
2639
- hashclr(b->branch_tree.versions[0].sha1);
2640
- hashclr(b->branch_tree.versions[1].sha1);
2643
+ if (is_null_oid(&b->oid)) {
2644
+ oidclr(&b->branch_tree.versions[0].oid);
2645
+ oidclr(&b->branch_tree.versions[1].oid);
2646
} else {
2647
unsigned long size;
2648
char *buf;
2649
2645
- buf = read_object_with_reference(b->sha1,
2646
- commit_type, &size, b->sha1);
2650
+ buf = read_object_with_reference(b->oid.hash,
2651
+ commit_type, &size,
2652
+ b->oid.hash);
2653
parse_from_commit(b, buf, size);
2654
free(buf);
2655
}
@@ -2658,23 +2664,23 @@ static int parse_from(struct branch *b)
2664
if (!skip_prefix(command_buf.buf, "from ", &from))
2665
return 0;
2666
2661
- hashcpy(sha1, b->branch_tree.versions[1].sha1);
2667
+ hashcpy(sha1, b->branch_tree.versions[1].oid.hash);
2668
2669
s = lookup_branch(from);
2670
if (b == s)
2671
die("Can't create a branch from itself: %s", b->name);
2672
else if (s) {
2667
- unsigned char *t = s->branch_tree.versions[1].sha1;
2668
- hashcpy(b->sha1, s->sha1);
2669
- hashcpy(b->branch_tree.versions[0].sha1, t);
2670
- hashcpy(b->branch_tree.versions[1].sha1, t);
2673
+ unsigned char *t = s->branch_tree.versions[1].oid.hash;
2674
+ oidcpy(&b->oid, &s->oid);
2675
+ hashcpy(b->branch_tree.versions[0].oid.hash, t);
2676
+ hashcpy(b->branch_tree.versions[1].oid.hash, t);
2677
} else if (*from == ':') {
2678
uintmax_t idnum = parse_mark_ref_eol(from);
2679
struct object_entry *oe = find_mark(idnum);
2680
if (oe->type != OBJ_COMMIT)
2681
die("Mark :%" PRIuMAX " not a commit", idnum);
2676
- if (hashcmp(b->sha1, oe->idx.sha1)) {
2677
- hashcpy(b->sha1, oe->idx.sha1);
2682
+ if (hashcmp(b->oid.hash, oe->idx.sha1)) {
2683
+ hashcpy(b->oid.hash, oe->idx.sha1);
2684
if (oe->pack_id != MAX_PACK_ID) {
2685
unsigned long size;
2686
char *buf = gfi_unpack_entry(oe, &size);
@@ -2683,15 +2689,15 @@ static int parse_from(struct branch *b)
2689
} else
2690
parse_from_existing(b);
2691
}
2686
- } else if (!get_sha1(from, b->sha1)) {
2692
+ } else if (!get_sha1(from, b->oid.hash)) {
2693
parse_from_existing(b);
2688
- if (is_null_sha1(b->sha1))
2694
+ if (is_null_oid(&b->oid))
2695
b->delete = 1;
2696
}
2697
else
2698
die("Invalid ref name or SHA1 expression: %s", from);
2699
2694
- if (b->branch_tree.tree && hashcmp(sha1, b->branch_tree.versions[1].sha1)) {
2700
+ if (b->branch_tree.tree && hashcmp(sha1, b->branch_tree.versions[1].oid.hash)) {
2701
release_tree_content_recursive(b->branch_tree.tree);
2702
b->branch_tree.tree = NULL;
2703
}
@@ -2711,17 +2717,19 @@ static struct hash_list *parse_merge(unsigned int *count)
2717
n = xmalloc(sizeof(*n));
2718
s = lookup_branch(from);
2719
if (s)
2714
- hashcpy(n->sha1, s->sha1);
2720
+ oidcpy(&n->oid, &s->oid);
2721
else if (*from == ':') {
2722
uintmax_t idnum = parse_mark_ref_eol(from);
2723
struct object_entry *oe = find_mark(idnum);
2724
if (oe->type != OBJ_COMMIT)
2725
die("Mark :%" PRIuMAX " not a commit", idnum);
2720
- hashcpy(n->sha1, oe->idx.sha1);
2721
- } else if (!get_sha1(from, n->sha1)) {
2726
+ hashcpy(n->oid.hash, oe->idx.sha1);
2727
+ } else if (!get_sha1(from, n->oid.hash)) {
2728
unsigned long size;
2723
- char *buf = read_object_with_reference(n->sha1,
2724
- commit_type, &size, n->sha1);
2729
+ char *buf = read_object_with_reference(n->oid.hash,
2730
+ commit_type,
2731
+ &size,
2732
+ n->oid.hash);
2733
if (!buf || size < 46)
2734
die("Not a valid commit: %s", from);
2735
free(buf);
@@ -2808,17 +2816,19 @@ static void parse_new_commit(const char *arg)
2816
2817
/* build the tree and the commit */
2818
store_tree(&b->branch_tree);
2811
- hashcpy(b->branch_tree.versions[0].sha1,
2812
- b->branch_tree.versions[1].sha1);
2819
+ oidcpy(&b->branch_tree.versions[0].oid,
2820
+ &b->branch_tree.versions[1].oid);
2821
2822
strbuf_reset(&new_data);
2823
strbuf_addf(&new_data, "tree %s\n",
2816
- sha1_to_hex(b->branch_tree.versions[1].sha1));
2817
- if (!is_null_sha1(b->sha1))
2818
- strbuf_addf(&new_data, "parent %s\n", sha1_to_hex(b->sha1));
2824
+ oid_to_hex(&b->branch_tree.versions[1].oid));
2825
+ if (!is_null_oid(&b->oid))
2826
+ strbuf_addf(&new_data, "parent %s\n",
2827
+ oid_to_hex(&b->oid));
2828
while (merge_list) {
2829
struct hash_list *next = merge_list->next;
2821
- strbuf_addf(&new_data, "parent %s\n", sha1_to_hex(merge_list->sha1));
2830
+ strbuf_addf(&new_data, "parent %s\n",
2831
+ oid_to_hex(&merge_list->oid));
2832
free(merge_list);
2833
merge_list = next;
2834
}
@@ -2831,7 +2841,7 @@ static void parse_new_commit(const char *arg)
2841
free(author);
2842
free(committer);
2843
2834
- if (!store_object(OBJ_COMMIT, &new_data, NULL, b->sha1, next_mark))
2844
+ if (!store_object(OBJ_COMMIT, &new_data, NULL, b->oid.hash, next_mark))
2845
b->pack_id = pack_id;
2846
b->last_commit = object_count_by_type[OBJ_COMMIT];
2847
}
@@ -2863,9 +2873,9 @@ static void parse_new_tag(const char *arg)
2873
die("Expected from command, got %s", command_buf.buf);
2874
s = lookup_branch(from);
2875
if (s) {
2866
- if (is_null_sha1(s->sha1))
2876
+ if (is_null_oid(&s->oid))
2877
die("Can't tag an empty branch.");
2868
- hashcpy(sha1, s->sha1);
2878
+ hashcpy(sha1, s->oid.hash);
2879
type = OBJ_COMMIT;
2880
} else if (*from == ':') {
2881
struct object_entry *oe;
@@ -2910,7 +2920,7 @@ static void parse_new_tag(const char *arg)
2920
strbuf_addbuf(&new_data, &msg);
2921
free(tagger);
2922
2913
- if (store_object(OBJ_TAG, &new_data, NULL, t->sha1, 0))
2923
+ if (store_object(OBJ_TAG, &new_data, NULL, t->oid.hash, 0))
2924
t->pack_id = MAX_PACK_ID;
2925
else
2926
t->pack_id = pack_id;
@@ -2922,9 +2932,9 @@ static void parse_reset_branch(const char *arg)
2932
2933
b = lookup_branch(arg);
2934
if (b) {
2925
- hashclr(b->sha1);
2926
- hashclr(b->branch_tree.versions[0].sha1);
2927
- hashclr(b->branch_tree.versions[1].sha1);
2935
+ oidclr(&b->oid);
2936
+ oidclr(&b->branch_tree.versions[0].oid);
2937
+ oidclr(&b->branch_tree.versions[1].oid);
2938
if (b->branch_tree.tree) {
2939
release_tree_content_recursive(b->branch_tree.tree);
2940
b->branch_tree.tree = NULL;
@@ -3143,8 +3153,8 @@ static void parse_ls(const char *p, struct branch *b)
3153
} else {
3154
struct object_entry *e = parse_treeish_dataref(&p);
3155
root = new_tree_entry();
3146
- hashcpy(root->versions[1].sha1, e->idx.sha1);
3147
- if (!is_null_sha1(root->versions[1].sha1))
3156
+ hashcpy(root->versions[1].oid.hash, e->idx.sha1);
3157
+ if (!is_null_oid(&root->versions[1].oid))
3158
root->versions[1].mode = S_IFDIR;
3159
load_tree(root);
3160
}
@@ -3166,7 +3176,7 @@ static void parse_ls(const char *p, struct branch *b)
3176
if (S_ISDIR(leaf.versions[1].mode))
3177
store_tree(&leaf);
3178
3169
- print_ls(leaf.versions[1].mode, leaf.versions[1].sha1, p);
3179
+ print_ls(leaf.versions[1].mode, leaf.versions[1].oid.hash, p);
3180
if (leaf.tree)
3181
release_tree_content_recursive(leaf.tree);
3182
if (!b || root != &b->branch_tree)