Skip to content

Commit 75691ea

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 2182abd commit 75691ea

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ struct index_state {
324324
drop_cache_tree : 1;
325325
struct hashmap name_hash;
326326
struct hashmap dir_hash;
327-
unsigned char sha1[20];
327+
struct object_id oid;
328328
struct untracked_cache *untracked;
329329
uint64_t fsmonitor_last_update;
330330
struct ewah_bitmap *fsmonitor_dirty;

read-cache.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
18061806
if (verify_hdr(hdr, mmap_size) < 0)
18071807
goto unmap;
18081808

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);
18101810
istate->version = ntohl(hdr->hdr_version);
18111811
istate->cache_nr = ntohl(hdr->hdr_entries);
18121812
istate->cache_alloc = alloc_nr(istate->cache_nr);
@@ -1902,10 +1902,10 @@ int read_index_from(struct index_state *istate, const char *path,
19021902
base_oid_hex = oid_to_hex(&split_index->base_oid);
19031903
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
19041904
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))
19061906
die("broken index, expect %s in %s, got %s",
19071907
base_oid_hex, base_path,
1908-
sha1_to_hex(split_index->base->sha1));
1908+
oid_to_hex(&split_index->base->oid));
19091909

19101910
freshen_shared_index(base_path, 0);
19111911
merge_base_index(istate);
@@ -2194,7 +2194,7 @@ static int verify_index_from(const struct index_state *istate, const char *path)
21942194
if (n != the_hash_algo->rawsz)
21952195
goto out;
21962196

2197-
if (hashcmp(istate->sha1, hash))
2197+
if (hashcmp(istate->oid.hash, hash))
21982198
goto out;
21992199

22002200
close(fd);
@@ -2373,7 +2373,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
23732373
return -1;
23742374
}
23752375

2376-
if (ce_flush(&c, newfd, istate->sha1))
2376+
if (ce_flush(&c, newfd, istate->oid.hash))
23772377
return -1;
23782378
if (close_tempfile_gently(tempfile)) {
23792379
error(_("could not close '%s'"), tempfile->filename.buf);
@@ -2497,10 +2497,10 @@ static int write_shared_index(struct index_state *istate,
24972497
return ret;
24982498
}
24992499
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)));
25012501
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));
25042504
}
25052505

25062506
return ret;

t/helper/test-dump-split-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int cmd__dump_split_index(int ac, const char **av)
1414
int i;
1515

1616
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));
1818
si = the_index.split_index;
1919
if (!si) {
2020
printf("not a split index\n");

unpack-trees.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
12871287
o->result.split_index = o->src_index->split_index;
12881288
if (o->result.split_index)
12891289
o->result.split_index->refcount++;
1290-
hashcpy(o->result.sha1, o->src_index->sha1);
1290+
oidcpy(&o->result.oid, &o->src_index->oid);
12911291
o->merge_size = len;
12921292
mark_all_ce_unused(o->src_index);
12931293

0 commit comments

Comments
 (0)