]> git.ipfire.org Git - thirdparty/git.git/blobdiff - range-diff.c
treewide: remove cache.h inclusion due to object.h changes
[thirdparty/git.git] / range-diff.c
index f63b3ffc200a8b71df3d7287322321ac70be2595..a2994331a14938ecc45789b5e2ee50a34df20f6c 100644 (file)
@@ -1,5 +1,8 @@
 #include "cache.h"
+#include "environment.h"
+#include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
@@ -57,9 +60,9 @@ static int read_patches(const char *range, struct string_list *list,
                     "--pretty=medium",
                     "--notes",
                     NULL);
+       strvec_push(&cp.args, range);
        if (other_arg)
                strvec_pushv(&cp.args, other_arg->v);
-       strvec_push(&cp.args, range);
        cp.out = -1;
        cp.no_stdin = 1;
        cp.git_cmd = 1;
@@ -94,7 +97,7 @@ static int read_patches(const char *range, struct string_list *list,
                                strbuf_reset(&buf);
                        }
                        CALLOC_ARRAY(util, 1);
-                       if (get_oid(p, &util->oid)) {
+                       if (repo_get_oid(the_repository, p, &util->oid)) {
                                error(_("could not parse commit '%s'"), p);
                                FREE_AND_NULL(util);
                                string_list_clear(list, 1);
@@ -224,8 +227,10 @@ cleanup:
        return ret;
 }
 
-static int patch_util_cmp(const void *dummy, const struct patch_util *a,
-                         const struct patch_util *b, const char *keydata)
+static int patch_util_cmp(const void *cmp_data UNUSED,
+                         const struct patch_util *a,
+                         const struct patch_util *b,
+                         const char *keydata)
 {
        return strcmp(a->diff, keydata ? keydata : b->diff);
 }
@@ -267,14 +272,18 @@ static void find_exact_matches(struct string_list *a, struct string_list *b)
        hashmap_clear(&map);
 }
 
-static int diffsize_consume(void *data, char *line, unsigned long len)
+static int diffsize_consume(void *data,
+                            char *line UNUSED,
+                            unsigned long len UNUSED)
 {
        (*(int *)data)++;
        return 0;
 }
 
-static void diffsize_hunk(void *data, long ob, long on, long nb, long nn,
-                         const char *funcline, long funclen)
+static void diffsize_hunk(void *data,
+                         long ob UNUSED, long on UNUSED,
+                         long nb UNUSED, long nn UNUSED,
+                         const char *func UNUSED, long funclen UNUSED)
 {
        diffsize_consume(data, NULL, 0);
 }
@@ -377,11 +386,14 @@ static void output_pair_header(struct diff_options *diffopt,
        const char *color_new = diff_get_color_opt(diffopt, DIFF_FILE_NEW);
        const char *color_commit = diff_get_color_opt(diffopt, DIFF_COMMIT);
        const char *color;
+       int abbrev = diffopt->abbrev;
+
+       if (abbrev < 0)
+               abbrev = DEFAULT_ABBREV;
 
        if (!dashes->len)
                strbuf_addchars(dashes, '-',
-                               strlen(find_unique_abbrev(oid,
-                                                         DEFAULT_ABBREV)));
+                               strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
 
        if (!b_util) {
                color = color_old;
@@ -403,7 +415,7 @@ static void output_pair_header(struct diff_options *diffopt,
                strbuf_addf(buf, "%*s:  %s ", patch_no_width, "-", dashes->buf);
        else
                strbuf_addf(buf, "%*d:  %s ", patch_no_width, a_util->i + 1,
-                           find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));
+                           repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
 
        if (status == '!')
                strbuf_addf(buf, "%s%s", color_reset, color);
@@ -415,7 +427,7 @@ static void output_pair_header(struct diff_options *diffopt,
                strbuf_addf(buf, " %*s:  %s", patch_no_width, "-", dashes->buf);
        else
                strbuf_addf(buf, " %*d:  %s", patch_no_width, b_util->i + 1,
-                           find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));
+                           repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
 
        commit = lookup_commit_reference(the_repository, oid);
        if (commit) {
@@ -459,7 +471,7 @@ static void patch_diff(const char *a, const char *b,
        diff_flush(diffopt);
 }
 
-static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
+static struct strbuf *output_prefix_cb(struct diff_options *opt UNUSED, void *data)
 {
        return data;
 }
@@ -476,7 +488,7 @@ static void output(struct string_list *a, struct string_list *b,
        if (range_diff_opts->diffopt)
                memcpy(&opts, range_diff_opts->diffopt, sizeof(opts));
        else
-               diff_setup(&opts);
+               repo_diff_setup(the_repository, &opts);
 
        opts.no_free = 1;
        if (!opts.output_format)
@@ -579,7 +591,7 @@ int is_range_diff_range(const char *arg)
        int i, positive = 0, negative = 0;
        struct rev_info revs;
 
-       init_revisions(&revs, NULL);
+       repo_init_revisions(the_repository, &revs, NULL);
        if (setup_revisions(3, argv, &revs, NULL) == 1) {
                for (i = 0; i < revs.pending.nr; i++)
                        if (revs.pending.objects[i].item->flags & UNINTERESTING)