From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, jrnieder@gmail.com
Subject: Re: [PATCH 1/1] diffcore: add a pickaxe option to find a specific blob
Date: Thu, 28 Dec 2017 13:33:47 -0800 [thread overview]
Message-ID: <xmqqy3lmill0.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171228000003.34539-2-sbeller@google.com> (Stefan Beller's message of "Wed, 27 Dec 2017 16:00:03 -0800")
Stefan Beller <sbeller@google.com> writes:
> +static int parse_objfind_opt(struct diff_options *opt, const char *arg)
> +{
> + struct object_id oid;
> +
> + if (get_oid(arg, &oid))
> + return error("unable to resolve '%s'", arg);
> +
> + if (!opt->objfind)
> + opt->objfind = xcalloc(1, sizeof(*opt->objfind));
> +
> + opt->pickaxe = ""; /* trigger pickaxe */
Hmmm. This feels like an ugly hack to me. Do we declare that "git
log -S''" never matches anything right now (if that is the case the
I do not think there is any compatibility issues)?
> diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
> index 9476bd2108..0d0c697ae7 100644
> --- a/diffcore-pickaxe.c
> +++ b/diffcore-pickaxe.c
> @@ -124,13 +124,21 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,
> mmfile_t mf1, mf2;
> int ret;
>
> - if (!o->pickaxe[0])
> - return 0;
> -
> /* ignore unmerged */
> if (!DIFF_FILE_VALID(p->one) && !DIFF_FILE_VALID(p->two))
> return 0;
>
> + if (o->objfind) {
> + if ((DIFF_FILE_VALID(p->one) &&
> + oidset_contains(o->objfind, &p->one->oid)) ||
> + (DIFF_FILE_VALID(p->two) &&
> + oidset_contains(o->objfind, &p->two->oid)))
> + return 1;
> + }
> +
> + if (!o->pickaxe[0])
> + return 0;
> +
Very nice. With just one place, the code covers both cases with and
without pickaxe-all option in effect.
next prev parent reply other threads:[~2017-12-28 21:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-28 0:00 [PATCH 0/1] Add blob find pickaxe option Stefan Beller
2017-12-28 0:00 ` [PATCH 1/1] diffcore: add a pickaxe option to find a specific blob Stefan Beller
2017-12-28 21:33 ` Junio C Hamano [this message]
2017-12-28 21:43 ` Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy3lmill0.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).