diff: convert diff_flush_patch_id to struct object_id
authorBrandon Williams <bmwill@google.com>
Tue, 30 May 2017 17:30:54 +0000 (10:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Jun 2017 00:36:07 +0000 (09:36 +0900)
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diff.h
patch-ids.c
diff --git a/diff.c b/diff.c
index a8ceeb024c408b3fd2e0b605b2682369b81ca7f9..dd325e61606bb24b24b9fb72a2e30164d93adef1 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4584,7 +4584,7 @@ static void patch_id_add_mode(git_SHA_CTX *ctx, unsigned mode)
 }
 
 /* returns 0 upon success, and writes result into sha1 */
-static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
+static int diff_get_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
@@ -4656,9 +4656,9 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,
                if (diff_filespec_is_binary(p->one) ||
                    diff_filespec_is_binary(p->two)) {
                        git_SHA1_Update(&ctx, oid_to_hex(&p->one->oid),
-                                       40);
+                                       GIT_SHA1_HEXSZ);
                        git_SHA1_Update(&ctx, oid_to_hex(&p->two->oid),
-                                       40);
+                                       GIT_SHA1_HEXSZ);
                        continue;
                }
 
@@ -4671,15 +4671,15 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1,
                                     p->one->path);
        }
 
-       git_SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(oid->hash, &ctx);
        return 0;
 }
 
-int diff_flush_patch_id(struct diff_options *options, unsigned char *sha1, int diff_header_only)
+int diff_flush_patch_id(struct diff_options *options, struct object_id *oid, int diff_header_only)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
-       int result = diff_get_patch_id(options, sha1, diff_header_only);
+       int result = diff_get_patch_id(options, oid, diff_header_only);
 
        for (i = 0; i < q->nr; i++)
                diff_free_filepair(q->queue[i]);
diff --git a/diff.h b/diff.h
index fcf334bb6f6e9c5a4caa0b01c3404e268d7d7f0c..150f1c5a1ca3cd8a81093b79962379464c9a23e5 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -354,7 +354,7 @@ extern int run_diff_files(struct rev_info *revs, unsigned int option);
 extern int run_diff_index(struct rev_info *revs, int cached);
 
 extern int do_diff_cache(const struct object_id *, struct diff_options *);
-extern int diff_flush_patch_id(struct diff_options *, unsigned char *, int);
+extern int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
 
 extern int diff_result_code(struct diff_options *, int);
 
index aab26cbbb9aa34105e4bd94a388aea05c3eff5be..a70a291d829ee23dde67f2df142f184b0983a70e 100644 (file)
@@ -22,7 +22,7 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
        else
                diff_root_tree_sha1(commit->object.oid.hash, "", options);
        diffcore_std(options);
-       return diff_flush_patch_id(options, oid->hash, diff_header_only);
+       return diff_flush_patch_id(options, oid, diff_header_only);
 }
 
 /*