summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-11-13 15:37:50 +0900
committerJunio C Hamano <gitster@pobox.com>2017-11-14 09:48:01 +0900
commit5b877eb77530f92d7f4e4dc3fcc30b5788cc8622 (patch)
treed3a47f11a8c97319f6d875c602ba9443e43fed59 /diff.c
parentd8df70f2739af78cab6d7f9b942e890da6fbd01d (diff)
downloadgit-jc/diff-blobfind.tar.gz
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 0763e89263..8861f89ab1 100644
--- a/diff.c
+++ b/diff.c
@@ -4082,6 +4082,7 @@ void diff_setup(struct diff_options *options)
options->interhunkcontext = diff_interhunk_context_default;
options->ws_error_highlight = ws_error_highlight_default;
options->flags.rename_empty = 1;
+ options->blobfind = NULL;
/* pathchange left =NULL by default */
options->change = diff_change;
@@ -4487,6 +4488,19 @@ static int parse_ws_error_highlight_opt(struct diff_options *opt, const char *ar
return 1;
}
+static int parse_blobfind_opt(struct diff_options *opt, const char *arg)
+{
+ struct object_id oid;
+
+ if (get_oid_blob(arg, &oid) || sha1_object_info(oid.hash, NULL) != OBJ_BLOB)
+ return error("object '%s' is not a blob", arg);
+
+ if (!opt->blobfind)
+ opt->blobfind = xcalloc(1, sizeof(*opt->blobfind));
+ oidset_insert(opt->blobfind, &oid);
+ return 1;
+}
+
int diff_opt_parse(struct diff_options *options,
const char **av, int ac, const char *prefix)
{
@@ -4736,7 +4750,8 @@ int diff_opt_parse(struct diff_options *options,
else if ((argcount = short_opt('O', av, &optarg))) {
options->orderfile = prefix_filename(prefix, optarg);
return argcount;
- }
+ } else if (skip_prefix(arg, "--blobfind=", &arg))
+ return parse_blobfind_opt(options, arg);
else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) {
int offending = parse_diff_filter_opt(optarg, options);
if (offending)
@@ -5770,6 +5785,9 @@ void diffcore_std(struct diff_options *options)
diffcore_skip_stat_unmatch(options);
if (!options->found_follow) {
/* See try_to_follow_renames() in tree-diff.c */
+
+ if (options->blobfind)
+ diffcore_blobfind(options);
if (options->break_opt != -1)
diffcore_break(options->break_opt);
if (options->detect_rename)