Update struct index_state to use struct object_id
Adjust struct index_state to use struct object_id instead of unsigned char [20]. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
May 2, 2018 at 00:25 UTC
75691ea3458a9eb9e80f6bdc2cc7c9321a9ac4ab
4 files changed
+11
-11
cache.h
+1
-1
@@ -324,7 +324,7 @@ struct index_state {
324
drop_cache_tree : 1;
325
struct hashmap name_hash;
326
struct hashmap dir_hash;
327
- unsigned char sha1[20];
327
+ struct object_id oid;
328
struct untracked_cache *untracked;
329
uint64_t fsmonitor_last_update;
330
struct ewah_bitmap *fsmonitor_dirty;
read-cache.c
+8
-8
@@ -1806,7 +1806,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
1806
if (verify_hdr(hdr, mmap_size) < 0)
1807
goto unmap;
1808
1809
- hashcpy(istate->sha1, (const unsigned char *)hdr + mmap_size - the_hash_algo->rawsz);
1809
+ hashcpy(istate->oid.hash, (const unsigned char *)hdr + mmap_size - the_hash_algo->rawsz);
1810
istate->version = ntohl(hdr->hdr_version);
1811
istate->cache_nr = ntohl(hdr->hdr_entries);
1812
istate->cache_alloc = alloc_nr(istate->cache_nr);
@@ -1902,10 +1902,10 @@ int read_index_from(struct index_state *istate, const char *path,
1902
base_oid_hex = oid_to_hex(&split_index->base_oid);
1903
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
1904
ret = do_read_index(split_index->base, base_path, 1);
1905
- if (hashcmp(split_index->base_oid.hash, split_index->base->sha1))
1905
+ if (oidcmp(&split_index->base_oid, &split_index->base->oid))
1906
die("broken index, expect %s in %s, got %s",
1907
base_oid_hex, base_path,
1908
- sha1_to_hex(split_index->base->sha1));
1908
+ oid_to_hex(&split_index->base->oid));
1909
1910
freshen_shared_index(base_path, 0);
1911
merge_base_index(istate);
@@ -2194,7 +2194,7 @@ static int verify_index_from(const struct index_state *istate, const char *path)
2194
if (n != the_hash_algo->rawsz)
2195
goto out;
2196
2197
- if (hashcmp(istate->sha1, hash))
2197
+ if (hashcmp(istate->oid.hash, hash))
2198
goto out;
2199
2200
close(fd);
@@ -2373,7 +2373,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
2373
return -1;
2374
}
2375
2376
- if (ce_flush(&c, newfd, istate->sha1))
2376
+ if (ce_flush(&c, newfd, istate->oid.hash))
2377
return -1;
2378
if (close_tempfile_gently(tempfile)) {
2379
error(_("could not close '%s'"), tempfile->filename.buf);
@@ -2497,10 +2497,10 @@ static int write_shared_index(struct index_state *istate,
2497
return ret;
2498
}
2499
ret = rename_tempfile(temp,
2500
- git_path("sharedindex.%s", sha1_to_hex(si->base->sha1)));
2500
+ git_path("sharedindex.%s", oid_to_hex(&si->base->oid)));
2501
if (!ret) {
2502
- hashcpy(si->base_oid.hash, si->base->sha1);
2503
- clean_shared_index_files(sha1_to_hex(si->base->sha1));
2502
+ oidcpy(&si->base_oid, &si->base->oid);
2503
+ clean_shared_index_files(oid_to_hex(&si->base->oid));
2504
}
2505
2506
return ret;
t/helper/test-dump-split-index.c
+1
-1
@@ -14,7 +14,7 @@ int cmd__dump_split_index(int ac, const char **av)
14
int i;
15
16
do_read_index(&the_index, av[1], 1);
17
- printf("own %s\n", sha1_to_hex(the_index.sha1));
17
+ printf("own %s\n", oid_to_hex(&the_index.oid));
18
si = the_index.split_index;
19
if (!si) {
20
printf("not a split index\n");
unpack-trees.c
+1
-1
@@ -1287,7 +1287,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1287
o->result.split_index = o->src_index->split_index;
1288
if (o->result.split_index)
1289
o->result.split_index->refcount++;
1290
- hashcpy(o->result.sha1, o->src_index->sha1);
1290
+ oidcpy(&o->result.oid, &o->src_index->oid);
1291
o->merge_size = len;
1292
mark_all_ce_unused(o->src_index);
1293