diff: convert reuse_worktree_file 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 fb4a1c0dc89db00989b357fd3c1bee4b5ede6ed3
1 file changed +5 -5
diff.c
+5 -5
@@ -2717,7 +2717,7 @@ void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
2717 * the work tree has that object contents, return true, so that
2718 * prepare_temp_file() does not have to inflate and extract.
2719 */
2720 -static int reuse_worktree_file(const char *name, const unsigned char *sha1, int want_file)
2720 +static int reuse_worktree_file(const char *name, const struct object_id *oid, int want_file)
2721 {
2722 const struct cache_entry *ce;
2723 struct stat st;
@@ -2748,7 +2748,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
2748 * objects however would tend to be slower as they need
2749 * to be individually opened and inflated.
2750 */
2751 - if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1))
2751 + if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(oid->hash))
2752 return 0;
2753
2754 /*
@@ -2768,7 +2768,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
2768 * This is not the sha1 we are looking for, or
2769 * unreusable because it is not a regular file.
2770 */
2771 - if (hashcmp(sha1, ce->oid.hash) || !S_ISREG(ce->ce_mode))
2771 + if (oidcmp(oid, &ce->oid) || !S_ISREG(ce->ce_mode))
2772 return 0;
2773
2774 /*
@@ -2842,7 +2842,7 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
2842 return diff_populate_gitlink(s, size_only);
2843
2844 if (!s->oid_valid ||
2845 - reuse_worktree_file(s->path, s->oid.hash, 0)) {
2845 + reuse_worktree_file(s->path, &s->oid, 0)) {
2846 struct strbuf buf = STRBUF_INIT;
2847 struct stat st;
2848 int fd;
@@ -3008,7 +3008,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
3008
3009 if (!S_ISGITLINK(one->mode) &&
3010 (!one->oid_valid ||
3011 - reuse_worktree_file(name, one->oid.hash, 1))) {
3011 + reuse_worktree_file(name, &one->oid, 1))) {
3012 struct stat st;
3013 if (lstat(name, &st) < 0) {
3014 if (errno == ENOENT)