diff: convert get_stat_data to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 30, 2017 at 10:30 UTC 362d7659150511cb8ef0f4af690d39881f53822d
1 file changed +13 -13
diff-lib.c
+13 -13
@@ -264,12 +264,12 @@ static void diff_index_show_file(struct rev_info *revs,
264 }
265
266 static int get_stat_data(const struct cache_entry *ce,
267 - const unsigned char **sha1p,
267 + const struct object_id **oidp,
268 unsigned int *modep,
269 int cached, int match_missing,
270 unsigned *dirty_submodule, struct diff_options *diffopt)
271 {
272 - const unsigned char *sha1 = ce->oid.hash;
272 + const struct object_id *oid = &ce->oid;
273 unsigned int mode = ce->ce_mode;
274
275 if (!cached && !ce_uptodate(ce)) {
@@ -280,7 +280,7 @@ static int get_stat_data(const struct cache_entry *ce,
280 return -1;
281 else if (changed) {
282 if (match_missing) {
283 - *sha1p = sha1;
283 + *oidp = oid;
284 *modep = mode;
285 return 0;
286 }
@@ -290,11 +290,11 @@ static int get_stat_data(const struct cache_entry *ce,
290 0, dirty_submodule);
291 if (changed) {
292 mode = ce_mode_from_stat(ce, st.st_mode);
293 - sha1 = null_sha1;
293 + oid = &null_oid;
294 }
295 }
296
297 - *sha1p = sha1;
297 + *oidp = oid;
298 *modep = mode;
299 return 0;
300 }
@@ -303,7 +303,7 @@ static void show_new_file(struct rev_info *revs,
303 const struct cache_entry *new,
304 int cached, int match_missing)
305 {
306 - const unsigned char *sha1;
306 + const struct object_id *oid;
307 unsigned int mode;
308 unsigned dirty_submodule = 0;
309
@@ -311,11 +311,11 @@ static void show_new_file(struct rev_info *revs,
311 * New file in the index: it might actually be different in
312 * the working tree.
313 */
314 - if (get_stat_data(new, &sha1, &mode, cached, match_missing,
314 + if (get_stat_data(new, &oid, &mode, cached, match_missing,
315 &dirty_submodule, &revs->diffopt) < 0)
316 return;
317
318 - diff_index_show_file(revs, "+", new, sha1, !is_null_sha1(sha1), mode, dirty_submodule);
318 + diff_index_show_file(revs, "+", new, oid->hash, !is_null_oid(oid), mode, dirty_submodule);
319 }
320
321 static int show_modified(struct rev_info *revs,
@@ -325,10 +325,10 @@ static int show_modified(struct rev_info *revs,
325 int cached, int match_missing)
326 {
327 unsigned int mode, oldmode;
328 - const unsigned char *sha1;
328 + const struct object_id *oid;
329 unsigned dirty_submodule = 0;
330
331 - if (get_stat_data(new, &sha1, &mode, cached, match_missing,
331 + if (get_stat_data(new, &oid, &mode, cached, match_missing,
332 &dirty_submodule, &revs->diffopt) < 0) {
333 if (report_missing)
334 diff_index_show_file(revs, "-", old,
@@ -338,7 +338,7 @@ static int show_modified(struct rev_info *revs,
338 }
339
340 if (revs->combine_merges && !cached &&
341 - (hashcmp(sha1, old->oid.hash) || oidcmp(&old->oid, &new->oid))) {
341 + (oidcmp(oid, &old->oid) || oidcmp(&old->oid, &new->oid))) {
342 struct combine_diff_path *p;
343 int pathlen = ce_namelen(new);
344
@@ -362,12 +362,12 @@ static int show_modified(struct rev_info *revs,
362 }
363
364 oldmode = old->ce_mode;
365 - if (mode == oldmode && !hashcmp(sha1, old->oid.hash) && !dirty_submodule &&
365 + if (mode == oldmode && !oidcmp(oid, &old->oid) && !dirty_submodule &&
366 !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
367 return 0;
368
369 diff_change(&revs->diffopt, oldmode, mode,
370 - old->oid.hash, sha1, 1, !is_null_sha1(sha1),
370 + old->oid.hash, oid->hash, 1, !is_null_oid(oid),
371 old->name, 0, dirty_submodule);
372 return 0;
373 }