Git fork

resolve-undo: stop using `the_repository`

Stop using `the_repository` in the "resolve-undo" subsystem by passing
in the hash algorithm when reading or writing resolve-undo information.

While we could trivially update the caller to pass in the hash algorithm
used by the index itself, we instead pass in `the_hash_algo`. This is
mostly done to stay consistent with the rest of the code in that file,
which isn't prepared to handle arbitrary repositories, either.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
b81093ae 6c27d222

+13 -11
+2 -2
read-cache.c
··· 1754 1754 istate->cache_tree = cache_tree_read(data, sz); 1755 1755 break; 1756 1756 case CACHE_EXT_RESOLVE_UNDO: 1757 - istate->resolve_undo = resolve_undo_read(data, sz); 1757 + istate->resolve_undo = resolve_undo_read(data, sz, the_hash_algo); 1758 1758 break; 1759 1759 case CACHE_EXT_LINK: 1760 1760 if (read_link_extension(istate, data, sz)) ··· 3033 3033 istate->resolve_undo) { 3034 3034 strbuf_reset(&sb); 3035 3035 3036 - resolve_undo_write(&sb, istate->resolve_undo); 3036 + resolve_undo_write(&sb, istate->resolve_undo, the_hash_algo); 3037 3037 err = write_index_ext_header(f, eoie_c, CACHE_EXT_RESOLVE_UNDO, 3038 3038 sb.len) < 0; 3039 3039 hashwrite(f, sb.buf, sb.len);
+7 -7
resolve-undo.c
··· 1 - #define USE_THE_REPOSITORY_VARIABLE 2 1 #define DISABLE_SIGN_COMPARE_WARNINGS 3 2 4 3 #include "git-compat-util.h" ··· 34 33 ui->mode[stage - 1] = ce->ce_mode; 35 34 } 36 35 37 - void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo) 36 + void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo, 37 + const struct git_hash_algo *algop) 38 38 { 39 39 struct string_list_item *item; 40 40 for_each_string_list_item(item, resolve_undo) { ··· 50 50 for (i = 0; i < 3; i++) { 51 51 if (!ui->mode[i]) 52 52 continue; 53 - strbuf_add(sb, ui->oid[i].hash, the_hash_algo->rawsz); 53 + strbuf_add(sb, ui->oid[i].hash, algop->rawsz); 54 54 } 55 55 } 56 56 } 57 57 58 - struct string_list *resolve_undo_read(const char *data, unsigned long size) 58 + struct string_list *resolve_undo_read(const char *data, unsigned long size, 59 + const struct git_hash_algo *algop) 59 60 { 60 61 struct string_list *resolve_undo; 61 62 size_t len; 62 63 char *endptr; 63 64 int i; 64 - const unsigned rawsz = the_hash_algo->rawsz; 65 + const unsigned rawsz = algop->rawsz; 65 66 66 67 CALLOC_ARRAY(resolve_undo, 1); 67 68 resolve_undo->strdup_strings = 1; ··· 96 97 continue; 97 98 if (size < rawsz) 98 99 goto error; 99 - oidread(&ui->oid[i], (const unsigned char *)data, 100 - the_repository->hash_algo); 100 + oidread(&ui->oid[i], (const unsigned char *)data, algop); 101 101 size -= rawsz; 102 102 data += rawsz; 103 103 }
+4 -2
resolve-undo.h
··· 14 14 }; 15 15 16 16 void record_resolve_undo(struct index_state *, struct cache_entry *); 17 - void resolve_undo_write(struct strbuf *, struct string_list *); 18 - struct string_list *resolve_undo_read(const char *, unsigned long); 17 + void resolve_undo_write(struct strbuf *, struct string_list *, 18 + const struct git_hash_algo *algop); 19 + struct string_list *resolve_undo_read(const char *, unsigned long, 20 + const struct git_hash_algo *algop); 19 21 void resolve_undo_clear_index(struct index_state *); 20 22 int unmerge_index_entry(struct index_state *, const char *, struct resolve_undo_info *, unsigned); 21 23 void unmerge_index(struct index_state *, const struct pathspec *, unsigned);