summaryrefslogtreecommitdiff
path: root/range-diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'range-diff.c')
-rw-r--r--range-diff.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/range-diff.c b/range-diff.c
index f63b3ff..c45b6d8 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -1,5 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.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"
@@ -8,7 +11,9 @@
#include "linear-assignment.h"
#include "diffcore.h"
#include "commit.h"
+#include "pager.h"
#include "pretty.h"
+#include "repository.h"
#include "userdiff.h"
#include "apply.h"
#include "revision.h"
@@ -55,11 +60,11 @@ static int read_patches(const char *range, struct string_list *list,
"--output-indicator-context=#",
"--no-abbrev-commit",
"--pretty=medium",
- "--notes",
+ "--show-notes-by-default",
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 +99,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,15 +229,20 @@ 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 hashmap_entry *ha,
+ const struct hashmap_entry *hb,
+ const void *keydata)
{
+ const struct patch_util
+ *a = container_of(ha, const struct patch_util, e),
+ *b = container_of(hb, const struct patch_util, e);
return strcmp(a->diff, keydata ? keydata : b->diff);
}
static void find_exact_matches(struct string_list *a, struct string_list *b)
{
- struct hashmap map = HASHMAP_INIT((hashmap_cmp_fn)patch_util_cmp, NULL);
+ struct hashmap map = HASHMAP_INIT(patch_util_cmp, NULL);
int i;
/* First, add the patches of a to a hash map */
@@ -267,14 +277,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 +391,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 +420,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 +432,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 +476,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 +493,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 +596,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)