cache: convert struct cache_entry to use struct object_id

Convert struct cache_entry to use struct object_id by applying the following semantic patch and the object_id transforms from contrib, plus the actual change to the struct: @@ struct cache_entry E1; @@ - E1.sha1 + E1.oid.hash @@ struct cache_entry *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 Sep 5, 2016 at 20:07 UTC 99d1a9861ae88595e7386c453b6b38573a8a570c
26 files changed +79 -69
builtin/apply.c
+5 -5
@@ -3220,7 +3220,7 @@ static int read_file_or_gitlink(const struct cache_entry *ce, struct strbuf *buf
3220 {
3221 if (!ce)
3222 return 0;
3223 - return read_blob_object(buf, ce->sha1, ce->ce_mode);
3223 + return read_blob_object(buf, ce->oid.hash, ce->ce_mode);
3224 }
3225
3226 static struct patch *in_fn_table(struct apply_state *state, const char *name)
@@ -3959,7 +3959,7 @@ static int get_current_sha1(const char *path, unsigned char *sha1)
3959 pos = cache_name_pos(path, strlen(path));
3960 if (pos < 0)
3961 return -1;
3962 - hashcpy(sha1, active_cache[pos]->sha1);
3962 + hashcpy(sha1, active_cache[pos]->oid.hash);
3963 return 0;
3964 }
3965
@@ -4211,7 +4211,7 @@ static void add_index_file(struct apply_state *state,
4211 const char *s;
4212
4213 if (!skip_prefix(buf, "Subproject commit ", &s) ||
4214 - get_sha1_hex(s, ce->sha1))
4214 + get_sha1_hex(s, ce->oid.hash))
4215 die(_("corrupt patch for submodule %s"), path);
4216 } else {
4217 if (!state->cached) {
@@ -4220,7 +4220,7 @@ static void add_index_file(struct apply_state *state,
4220 path);
4221 fill_stat_cache_info(ce, &st);
4222 }
4223 - if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
4223 + if (write_sha1_file(buf, size, blob_type, ce->oid.hash) < 0)
4224 die(_("unable to create backing store for newly created file %s"), path);
4225 }
4226 if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
@@ -4335,7 +4335,7 @@ static void add_conflicted_stages_file(struct apply_state *state,
4335 ce->ce_mode = create_ce_mode(mode);
4336 ce->ce_flags = create_ce_flags(stage);
4337 ce->ce_namelen = namelen;
4338 - hashcpy(ce->sha1, patch->threeway_stage[stage - 1].hash);
4338 + oidcpy(&ce->oid, &patch->threeway_stage[stage - 1]);
4339 if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
4340 die(_("unable to add cache entry for %s"), patch->new_name);
4341 }
builtin/blame.c
+1 -1
@@ -2410,7 +2410,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
2410 }
2411 size = cache_entry_size(len);
2412 ce = xcalloc(1, size);
2413 - hashcpy(ce->sha1, origin->blob_sha1);
2413 + hashcpy(ce->oid.hash, origin->blob_sha1);
2414 memcpy(ce->name, path, len);
2415 ce->ce_flags = create_ce_flags(0);
2416 ce->ce_namelen = len;
builtin/checkout.c
+3 -3
@@ -76,7 +76,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
76
77 len = base->len + strlen(pathname);
78 ce = xcalloc(1, cache_entry_size(len));
79 - hashcpy(ce->sha1, sha1);
79 + hashcpy(ce->oid.hash, sha1);
80 memcpy(ce->name, base->buf, base->len);
81 memcpy(ce->name + base->len, pathname, len - base->len);
82 ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
@@ -92,7 +92,7 @@ static int update_some(const unsigned char *sha1, struct strbuf *base,
92 if (pos >= 0) {
93 struct cache_entry *old = active_cache[pos];
94 if (ce->ce_mode == old->ce_mode &&
95 - !hashcmp(ce->sha1, old->sha1)) {
95 + !oidcmp(&ce->oid, &old->oid)) {
96 old->ce_flags |= CE_UPDATE;
97 free(ce);
98 return 0;
@@ -186,7 +186,7 @@ static int checkout_merged(int pos, struct checkout *state)
186 stage = ce_stage(ce);
187 if (!stage || strcmp(path, ce->name))
188 break;
189 - hashcpy(threeway[stage - 1], ce->sha1);
189 + hashcpy(threeway[stage - 1], ce->oid.hash);
190 if (stage == 2)
191 mode = create_ce_mode(ce->ce_mode);
192 pos++;
builtin/fsck.c
+1 -1
@@ -722,7 +722,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
722 mode = active_cache[i]->ce_mode;
723 if (S_ISGITLINK(mode))
724 continue;
725 - blob = lookup_blob(active_cache[i]->sha1);
725 + blob = lookup_blob(active_cache[i]->oid.hash);
726 if (!blob)
727 continue;
728 obj = &blob->object;
builtin/grep.c
+2 -1
@@ -398,7 +398,8 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
398 if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
399 if (ce_stage(ce) || ce_intent_to_add(ce))
400 continue;
401 - hit |= grep_sha1(opt, ce->sha1, ce->name, 0, ce->name);
401 + hit |= grep_sha1(opt, ce->oid.hash, ce->name, 0,
402 + ce->name);
403 }
404 else
405 hit |= grep_file(opt, ce->name);
builtin/ls-files.c
+1 -1
@@ -187,7 +187,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
187 printf("%s%06o %s %d\t",
188 tag,
189 ce->ce_mode,
190 - find_unique_abbrev(ce->sha1,abbrev),
190 + find_unique_abbrev(ce->oid.hash,abbrev),
191 ce_stage(ce));
192 }
193 write_eolinfo(ce, ce->name);
builtin/merge-index.c
+1 -1
@@ -22,7 +22,7 @@ static int merge_entry(int pos, const char *path)
22 if (strcmp(ce->name, path))
23 break;
24 found++;
25 - sha1_to_hex_r(hexbuf[stage], ce->sha1);
25 + sha1_to_hex_r(hexbuf[stage], ce->oid.hash);
26 xsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), "%o", ce->ce_mode);
27 arguments[stage] = hexbuf[stage];
28 arguments[stage + 4] = ownbuf[stage];
builtin/read-tree.c
+1 -1
@@ -78,7 +78,7 @@ static void debug_stage(const char *label, const struct cache_entry *ce,
78 else
79 printf("%06o #%d %s %.8s\n",
80 ce->ce_mode, ce_stage(ce), ce->name,
81 - sha1_to_hex(ce->sha1));
81 + oid_to_hex(&ce->oid));
82 }
83
84 static int debug_merge(const struct cache_entry * const *stages,
builtin/rm.c
+1 -1
@@ -199,7 +199,7 @@ static int check_local_mod(unsigned char *head, int index_only)
199 if (no_head
200 || get_tree_entry(head, name, sha1, &mode)
201 || ce->ce_mode != create_ce_mode(mode)
202 - || hashcmp(ce->sha1, sha1))
202 + || hashcmp(ce->oid.hash, sha1))
203 staged_changes = 1;
204
205 /*
builtin/submodule--helper.c
+3 -2
@@ -296,7 +296,8 @@ static int module_list(int argc, const char **argv, const char *prefix)
296 if (ce_stage(ce))
297 printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1));
298 else
299 - printf("%06o %s %d\t", ce->ce_mode, sha1_to_hex(ce->sha1), ce_stage(ce));
299 + printf("%06o %s %d\t", ce->ce_mode,
300 + oid_to_hex(&ce->oid), ce_stage(ce));
301
302 utf8_fprintf(stdout, "%s\n", ce->name);
303 }
@@ -683,7 +684,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
684
685 strbuf_reset(&sb);
686 strbuf_addf(&sb, "%06o %s %d %d\t%s\n", ce->ce_mode,
686 - sha1_to_hex(ce->sha1), ce_stage(ce),
687 + oid_to_hex(&ce->oid), ce_stage(ce),
688 needs_cloning, ce->name);
689 string_list_append(&suc->projectlines, sb.buf);
690
builtin/update-index.c
+5 -5
@@ -275,7 +275,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
275 fill_stat_cache_info(ce, st);
276 ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
277
278 - if (index_path(ce->sha1, path, st,
278 + if (index_path(ce->oid.hash, path, st,
279 info_only ? 0 : HASH_WRITE_OBJECT)) {
280 free(ce);
281 return -1;
@@ -403,7 +403,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
403 size = cache_entry_size(len);
404 ce = xcalloc(1, size);
405
406 - hashcpy(ce->sha1, sha1);
406 + hashcpy(ce->oid.hash, sha1);
407 memcpy(ce->name, path, len);
408 ce->ce_flags = create_ce_flags(stage);
409 ce->ce_namelen = len;
@@ -601,7 +601,7 @@ static struct cache_entry *read_one_ent(const char *which,
601 size = cache_entry_size(namelen);
602 ce = xcalloc(1, size);
603
604 - hashcpy(ce->sha1, sha1);
604 + hashcpy(ce->oid.hash, sha1);
605 memcpy(ce->name, path, namelen);
606 ce->ce_flags = create_ce_flags(stage);
607 ce->ce_namelen = namelen;
@@ -658,7 +658,7 @@ static int unresolve_one(const char *path)
658 ret = -1;
659 goto free_return;
660 }
661 - if (!hashcmp(ce_2->sha1, ce_3->sha1) &&
661 + if (!oidcmp(&ce_2->oid, &ce_3->oid) &&
662 ce_2->ce_mode == ce_3->ce_mode) {
663 fprintf(stderr, "%s: identical in both, skipping.\n",
664 path);
@@ -743,7 +743,7 @@ static int do_reupdate(int ac, const char **av,
743 old = read_one_ent(NULL, head_sha1,
744 ce->name, ce_namelen(ce), 0);
745 if (old && ce->ce_mode == old->ce_mode &&
746 - !hashcmp(ce->sha1, old->sha1)) {
746 + !oidcmp(&ce->oid, &old->oid)) {
747 free(old);
748 continue; /* unchanged */
749 }
cache-tree.c
+2 -2
@@ -168,7 +168,7 @@ static int verify_cache(struct cache_entry **cache,
168 break;
169 }
170 fprintf(stderr, "%s: unmerged (%s)\n",
171 - ce->name, sha1_to_hex(ce->sha1));
171 + ce->name, oid_to_hex(&ce->oid));
172 }
173 }
174 if (funny)
@@ -349,7 +349,7 @@ static int update_one(struct cache_tree *it,
349 }
350 }
351 else {
352 - sha1 = ce->sha1;
352 + sha1 = ce->oid.hash;
353 mode = ce->ce_mode;
354 entlen = pathlen - baselen;
355 i++;
cache.h
+1 -1
@@ -173,7 +173,7 @@ struct cache_entry {
173 unsigned int ce_flags;
174 unsigned int ce_namelen;
175 unsigned int index; /* for link extension */
176 - unsigned char sha1[20];
176 + struct object_id oid;
177 char name[FLEX_ARRAY]; /* more */
178 };
179
diff-lib.c
+18 -13
@@ -155,7 +155,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
155 if (2 <= stage) {
156 int mode = nce->ce_mode;
157 num_compare_stages++;
158 - hashcpy(dpath->parent[stage-2].oid.hash, nce->sha1);
158 + oidcpy(&dpath->parent[stage - 2].oid,
159 + &nce->oid);
160 dpath->parent[stage-2].mode = ce_mode_from_stat(nce, mode);
161 dpath->parent[stage-2].status =
162 DIFF_STATUS_MODIFIED;
@@ -209,7 +210,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
210 continue;
211 }
212 diff_addremove(&revs->diffopt, '-', ce->ce_mode,
212 - ce->sha1, !is_null_sha1(ce->sha1),
213 + ce->oid.hash,
214 + !is_null_oid(&ce->oid),
215 ce->name, 0);
216 continue;
217 }
@@ -225,8 +227,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
227 continue;
228 }
229 oldmode = ce->ce_mode;
228 - old_sha1 = ce->sha1;
229 - new_sha1 = changed ? null_sha1 : ce->sha1;
230 + old_sha1 = ce->oid.hash;
231 + new_sha1 = changed ? null_sha1 : ce->oid.hash;
232 diff_change(&revs->diffopt, oldmode, newmode,
233 old_sha1, new_sha1,
234 !is_null_sha1(old_sha1),
@@ -261,7 +263,7 @@ static int get_stat_data(const struct cache_entry *ce,
263 int cached, int match_missing,
264 unsigned *dirty_submodule, struct diff_options *diffopt)
265 {
264 - const unsigned char *sha1 = ce->sha1;
266 + const unsigned char *sha1 = ce->oid.hash;
267 unsigned int mode = ce->ce_mode;
268
269 if (!cached && !ce_uptodate(ce)) {
@@ -324,12 +326,13 @@ static int show_modified(struct rev_info *revs,
326 &dirty_submodule, &revs->diffopt) < 0) {
327 if (report_missing)
328 diff_index_show_file(revs, "-", old,
327 - old->sha1, 1, old->ce_mode, 0);
329 + old->oid.hash, 1, old->ce_mode,
330 + 0);
331 return -1;
332 }
333
334 if (revs->combine_merges && !cached &&
332 - (hashcmp(sha1, old->sha1) || hashcmp(old->sha1, new->sha1))) {
335 + (hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) {
336 struct combine_diff_path *p;
337 int pathlen = ce_namelen(new);
338
@@ -343,22 +346,22 @@ static int show_modified(struct rev_info *revs,
346 memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));
347 p->parent[0].status = DIFF_STATUS_MODIFIED;
348 p->parent[0].mode = new->ce_mode;
346 - hashcpy(p->parent[0].oid.hash, new->sha1);
349 + oidcpy(&p->parent[0].oid, &new->oid);
350 p->parent[1].status = DIFF_STATUS_MODIFIED;
351 p->parent[1].mode = old->ce_mode;
349 - hashcpy(p->parent[1].oid.hash, old->sha1);
352 + oidcpy(&p->parent[1].oid, &old->oid);
353 show_combined_diff(p, 2, revs->dense_combined_merges, revs);
354 free(p);
355 return 0;
356 }
357
358 oldmode = old->ce_mode;
356 - if (mode == oldmode && !hashcmp(sha1, old->sha1) && !dirty_submodule &&
359 + if (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule &&
360 !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
361 return 0;
362
363 diff_change(&revs->diffopt, oldmode, mode,
361 - old->sha1, sha1, 1, !is_null_sha1(sha1),
364 + old->oid.hash, sha1, 1, !is_null_sha1(sha1),
365 old->name, 0, dirty_submodule);
366 return 0;
367 }
@@ -392,7 +395,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
395 struct diff_filepair *pair;
396 pair = diff_unmerge(&revs->diffopt, idx->name);
397 if (tree)
395 - fill_filespec(pair->one, tree->sha1, 1, tree->ce_mode);
398 + fill_filespec(pair->one, tree->oid.hash, 1,
399 + tree->ce_mode);
400 return;
401 }
402
@@ -408,7 +412,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
412 * Something removed from the tree?
413 */
414 if (!idx) {
411 - diff_index_show_file(revs, "-", tree, tree->sha1, 1, tree->ce_mode, 0);
415 + diff_index_show_file(revs, "-", tree, tree->oid.hash, 1,
416 + tree->ce_mode, 0);
417 return;
418 }
419
diff.c
+1 -1
@@ -2700,7 +2700,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
2700 * This is not the sha1 we are looking for, or
2701 * unreusable because it is not a regular file.
2702 */
2703 - if (hashcmp(sha1, ce->sha1) || !S_ISREG(ce->ce_mode))
2703 + if (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))
2704 return 0;
2705
2706 /*
dir.c
+4 -3
@@ -525,7 +525,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
525 return NULL;
526 if (!ce_skip_worktree(active_cache[pos]))
527 return NULL;
528 - data = read_sha1_file(active_cache[pos]->sha1, &type, &sz);
528 + data = read_sha1_file(active_cache[pos]->oid.hash, &type, &sz);
529 if (!data || type != OBJ_BLOB) {
530 free(data);
531 return NULL;
@@ -533,7 +533,7 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size,
533 *size = xsize_t(sz);
534 if (sha1_stat) {
535 memset(&sha1_stat->stat, 0, sizeof(sha1_stat->stat));
536 - hashcpy(sha1_stat->sha1, active_cache[pos]->sha1);
536 + hashcpy(sha1_stat->sha1, active_cache[pos]->oid.hash);
537 }
538 return data;
539 }
@@ -713,7 +713,8 @@ static int add_excludes(const char *fname, const char *base, int baselen,
713 !ce_stage(active_cache[pos]) &&
714 ce_uptodate(active_cache[pos]) &&
715 !would_convert_to_git(fname))
716 - hashcpy(sha1_stat->sha1, active_cache[pos]->sha1);
716 + hashcpy(sha1_stat->sha1,
717 + active_cache[pos]->oid.hash);
718 else
719 hash_sha1_file(buf, size, "blob", sha1_stat->sha1);
720 fill_stat_data(&sha1_stat->stat, &st);
entry.c
+5 -4
@@ -82,7 +82,7 @@ static int create_file(const char *path, unsigned int mode)
82 static void *read_blob_entry(const struct cache_entry *ce, unsigned long *size)
83 {
84 enum object_type type;
85 - void *new = read_sha1_file(ce->sha1, &type, size);
85 + void *new = read_sha1_file(ce->oid.hash, &type, size);
86
87 if (new) {
88 if (type == OBJ_BLOB)
@@ -127,7 +127,7 @@ static int streaming_write_entry(const struct cache_entry *ce, char *path,
127 if (fd < 0)
128 return -1;
129
130 - result |= stream_blob_to_fd(fd, ce->sha1, filter, 1);
130 + result |= stream_blob_to_fd(fd, ce->oid.hash, filter, 1);
131 *fstat_done = fstat_output(fd, state, statbuf);
132 result |= close(fd);
133
@@ -148,7 +148,8 @@ static int write_entry(struct cache_entry *ce,
148 struct stat st;
149
150 if (ce_mode_s_ifmt == S_IFREG) {
151 - struct stream_filter *filter = get_stream_filter(ce->name, ce->sha1);
151 + struct stream_filter *filter = get_stream_filter(ce->name,
152 + ce->oid.hash);
153 if (filter &&
154 !streaming_write_entry(ce, path, filter,
155 state, to_tempfile,
@@ -162,7 +163,7 @@ static int write_entry(struct cache_entry *ce,
163 new = read_blob_entry(ce, &size);
164 if (!new)
165 return error("unable to read sha1 file of %s (%s)",
165 - path, sha1_to_hex(ce->sha1));
166 + path, oid_to_hex(&ce->oid));
167
168 if (ce_mode_s_ifmt == S_IFLNK && has_symlinks && !to_tempfile) {
169 ret = symlink(new, path);
merge-recursive.c
+1 -1
@@ -382,7 +382,7 @@ static struct string_list *get_unmerged(void)
382 }
383 e = item->util;
384 e->stages[ce_stage(ce)].mode = ce->ce_mode;
385 - hashcpy(e->stages[ce_stage(ce)].oid.hash, ce->sha1);
385 + oidcpy(&e->stages[ce_stage(ce)].oid, &ce->oid);
386 }
387
388 return unmerged;
read-cache.c
+12 -12
@@ -161,7 +161,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
161 if (fd >= 0) {
162 unsigned char sha1[20];
163 if (!index_fd(sha1, fd, st, OBJ_BLOB, ce->name, 0))
164 - match = hashcmp(sha1, ce->sha1);
164 + match = hashcmp(sha1, ce->oid.hash);
165 /* index_fd() closed the file descriptor already */
166 }
167 return match;
@@ -178,7 +178,7 @@ static int ce_compare_link(const struct cache_entry *ce, size_t expected_size)
178 if (strbuf_readlink(&sb, ce->name, expected_size))
179 return -1;
180
181 - buffer = read_sha1_file(ce->sha1, &type, &size);
181 + buffer = read_sha1_file(ce->oid.hash, &type, &size);
182 if (buffer) {
183 if (size == sb.len)
184 match = memcmp(buffer, sb.buf, size);
@@ -202,7 +202,7 @@ static int ce_compare_gitlink(const struct cache_entry *ce)
202 */
203 if (resolve_gitlink_ref(ce->name, "HEAD", sha1) < 0)
204 return 0;
205 - return hashcmp(sha1, ce->sha1);
205 + return hashcmp(sha1, ce->oid.hash);
206 }
207
208 static int ce_modified_check_fs(const struct cache_entry *ce, struct stat *st)
@@ -262,7 +262,7 @@ static int ce_match_stat_basic(const struct cache_entry *ce, struct stat *st)
262
263 /* Racily smudged entry? */
264 if (!ce->ce_stat_data.sd_size) {
265 - if (!is_empty_blob_sha1(ce->sha1))
265 + if (!is_empty_blob_sha1(ce->oid.hash))
266 changed |= DATA_CHANGED;
267 }
268
@@ -624,7 +624,7 @@ void set_object_name_for_intent_to_add_entry(struct cache_entry *ce)
624 unsigned char sha1[20];
625 if (write_sha1_file("", 0, blob_type, sha1))
626 die("cannot create an empty blob in the object database");
627 - hashcpy(ce->sha1, sha1);
627 + hashcpy(ce->oid.hash, sha1);
628 }
629
630 int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags, int force_mode)
@@ -691,7 +691,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
691 return 0;
692 }
693 if (!intent_only) {
694 - if (index_path(ce->sha1, path, st, HASH_WRITE_OBJECT)) {
694 + if (index_path(ce->oid.hash, path, st, HASH_WRITE_OBJECT)) {
695 free(ce);
696 return error("unable to index file %s", path);
697 }
@@ -705,7 +705,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
705 /* It was suspected to be racily clean, but it turns out to be Ok */
706 was_same = (alias &&
707 !ce_stage(alias) &&
708 - !hashcmp(alias->sha1, ce->sha1) &&
708 + !oidcmp(&alias->oid, &ce->oid) &&
709 ce->ce_mode == alias->ce_mode);
710
711 if (pretend)
@@ -744,7 +744,7 @@ struct cache_entry *make_cache_entry(unsigned int mode,
744 size = cache_entry_size(len);
745 ce = xcalloc(1, size);
746
747 - hashcpy(ce->sha1, sha1);
747 + hashcpy(ce->oid.hash, sha1);
748 memcpy(ce->name, path, len);
749 ce->ce_flags = create_ce_flags(stage);
750 ce->ce_namelen = len;
@@ -1424,7 +1424,7 @@ static struct cache_entry *cache_entry_from_ondisk(struct ondisk_cache_entry *on
1424 ce->ce_flags = flags & ~CE_NAMEMASK;
1425 ce->ce_namelen = len;
1426 ce->index = 0;
1427 - hashcpy(ce->sha1, ondisk->sha1);
1427 + hashcpy(ce->oid.hash, ondisk->sha1);
1428 memcpy(ce->name, name, len);
1429 ce->name[len] = '\0';
1430 return ce;
@@ -1849,7 +1849,7 @@ static char *copy_cache_entry_to_ondisk(struct ondisk_cache_entry *ondisk,
1849 ondisk->uid = htonl(ce->ce_stat_data.sd_uid);
1850 ondisk->gid = htonl(ce->ce_stat_data.sd_gid);
1851 ondisk->size = htonl(ce->ce_stat_data.sd_size);
1852 - hashcpy(ondisk->sha1, ce->sha1);
1852 + hashcpy(ondisk->sha1, ce->oid.hash);
1853
1854 flags = ce->ce_flags & ~CE_NAMEMASK;
1855 flags |= (ce_namelen(ce) >= CE_NAMEMASK ? CE_NAMEMASK : ce_namelen(ce));
@@ -2038,7 +2038,7 @@ static int do_write_index(struct index_state *istate, int newfd,
2038 continue;
2039 if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
2040 ce_smudge_racily_clean_entry(ce);
2041 - if (is_null_sha1(ce->sha1)) {
2041 + if (is_null_oid(&ce->oid)) {
2042 static const char msg[] = "cache entry has null sha1: %s";
2043 static int allow = -1;
2044
@@ -2285,7 +2285,7 @@ void *read_blob_data_from_index(struct index_state *istate, const char *path, un
2285 }
2286 if (pos < 0)
2287 return NULL;
2288 - data = read_sha1_file(istate->cache[pos]->sha1, &type, &sz);
2288 + data = read_sha1_file(istate->cache[pos]->oid.hash, &type, &sz);
2289 if (!data || type != OBJ_BLOB) {
2290 free(data);
2291 return NULL;
rerere.c
+2 -1
@@ -980,7 +980,8 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
980 break;
981 i = ce_stage(ce) - 1;
982 if (!mmfile[i].ptr) {
983 - mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
983 + mmfile[i].ptr = read_sha1_file(ce->oid.hash, &type,
984 + &size);
985 mmfile[i].size = size;
986 }
987 }
resolve-undo.c
+1 -1
@@ -24,7 +24,7 @@ void record_resolve_undo(struct index_state *istate, struct cache_entry *ce)
24 if (!lost->util)
25 lost->util = xcalloc(1, sizeof(*ui));
26 ui = lost->util;
27 - hashcpy(ui->sha1[stage - 1], ce->sha1);
27 + hashcpy(ui->sha1[stage - 1], ce->oid.hash);
28 ui->mode[stage - 1] = ce->ce_mode;
29 }
30
revision.c
+1 -1
@@ -1275,7 +1275,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned flags)
1275 if (S_ISGITLINK(ce->ce_mode))
1276 continue;
1277
1278 - blob = lookup_blob(ce->sha1);
1278 + blob = lookup_blob(ce->oid.hash);
1279 if (!blob)
1280 die("unable to add index blob to traversal");
1281 add_pending_object_with_path(revs, &blob->object, "",
sha1_name.c
+1 -1
@@ -1435,7 +1435,7 @@ static int get_sha1_with_context_1(const char *name,
1435 memcmp(ce->name, cp, namelen))
1436 break;
1437 if (ce_stage(ce) == stage) {
1438 - hashcpy(sha1, ce->sha1);
1438 + hashcpy(sha1, ce->oid.hash);
1439 oc->mode = ce->ce_mode;
1440 free(new_path);
1441 return 0;
t/helper/test-dump-split-index.c
+1 -1
@@ -23,7 +23,7 @@ int cmd_main(int ac, const char **av)
23 for (i = 0; i < the_index.cache_nr; i++) {
24 struct cache_entry *ce = the_index.cache[i];
25 printf("%06o %s %d\t%s\n", ce->ce_mode,
26 - sha1_to_hex(ce->sha1), ce_stage(ce), ce->name);
26 + oid_to_hex(&ce->oid), ce_stage(ce), ce->name);
27 }
28 printf("replacements:");
29 if (si->replace_bitmap)
tree.c
+1 -1
@@ -26,7 +26,7 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b
26 ce->ce_namelen = baselen + len;
27 memcpy(ce->name, base, baselen);
28 memcpy(ce->name + baselen, pathname, len+1);
29 - hashcpy(ce->sha1, sha1);
29 + hashcpy(ce->oid.hash, sha1);
30 return add_cache_entry(ce, opt);
31 }
32
unpack-trees.c
+4 -4
@@ -625,7 +625,7 @@ static struct cache_entry *create_ce_entry(const struct traverse_info *info, con
625 ce->ce_mode = create_ce_mode(n->mode);
626 ce->ce_flags = create_ce_flags(stage);
627 ce->ce_namelen = len;
628 - hashcpy(ce->sha1, n->oid->hash);
628 + oidcpy(&ce->oid, n->oid);
629 make_traverse_path(ce->name, info, n);
630
631 return ce;
@@ -1287,7 +1287,7 @@ static int same(const struct cache_entry *a, const struct cache_entry *b)
1287 if ((a->ce_flags | b->ce_flags) & CE_CONFLICTED)
1288 return 0;
1289 return a->ce_mode == b->ce_mode &&
1290 - !hashcmp(a->sha1, b->sha1);
1290 + !oidcmp(&a->oid, &b->oid);
1291 }
1292
1293
@@ -1393,7 +1393,7 @@ static int verify_clean_subdirectory(const struct cache_entry *ce,
1393 /* If we are not going to update the submodule, then
1394 * we don't care.
1395 */
1396 - if (!hashcmp(sha1, ce->sha1))
1396 + if (!hashcmp(sha1, ce->oid.hash))
1397 return 0;
1398 return verify_clean_submodule(ce, error_type, o);
1399 }
@@ -1665,7 +1665,7 @@ static void show_stage_entry(FILE *o,
1665 fprintf(o, "%s%06o %s %d\t%s\n",
1666 label,
1667 ce->ce_mode,
1668 - sha1_to_hex(ce->sha1),
1668 + oid_to_hex(&ce->oid),
1669 ce_stage(ce),
1670 ce->name);
1671 }