From: Junio C Hamano <gitster@pobox.com>
To: Jack Bates <bk874k@nottheoilrig.com>
Cc: git@vger.kernel.org, Jack Bates <jack@nottheoilrig.com>
Subject: Re: [PATCH] diff: handle --no-abbrev outside of repository
Date: Mon, 28 Nov 2016 15:03:17 -0800 [thread overview]
Message-ID: <xmqqbmwzi4wa.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161128182508.10570-1-jack@nottheoilrig.com> (Jack Bates's message of "Mon, 28 Nov 2016 11:25:08 -0700")
Jack Bates <bk874k@nottheoilrig.com> writes:
> The "git diff --no-index" codepath doesn't handle the --no-abbrev
> option.
>
> Signed-off-by: Jack Bates <jack@nottheoilrig.com>
> ---
This patch also needs a new test to protect the fix from future
breakages.
It is unfortunate that parsing of these options that are done in
diff_opt_parse() are not used by most of the codepaths; they instead
rely on revision.c parser to parse them into revs->abbrev and then
copied to revs->diffopt.abbrev in setup_revisions(). We would want
to rethink the structure of the code around this, and possibly move
towards using setup_revisions() more when appropriate and removing
diff_opt_parse() or something like that; the three-way fallback
codepath in builtin/am.c is the only other caller of this function
and it uses it to parse a fixed "--diff-filter=AM" option into
rev_info.diffopt and manually sets up rev_info as if revision parser
was given "diff --cached HEAD", which we should be able to replace
with a call to setup_revisions() of "--diff-filter=AM --cached HEAD",
I would suspect. But that is a much larger change.
In any case, for now, the fix in this patch is a single best step
that moves us forward.
Thanks.
> diff.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/diff.c b/diff.c
> index ec87283..0447eff 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -3106,7 +3106,8 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
> abbrev = FALLBACK_DEFAULT_ABBREV;
> if (abbrev > GIT_SHA1_HEXSZ)
> die("BUG: oid abbreviation out of range: %d", abbrev);
> - hex[abbrev] = '\0';
> + if (abbrev)
> + hex[abbrev] = '\0';
> return hex;
> }
> }
> @@ -4024,6 +4025,8 @@ int diff_opt_parse(struct diff_options *options,
> offending, optarg);
> return argcount;
> }
> + else if (!strcmp(arg, "--no-abbrev"))
> + options->abbrev = 0;
> else if (!strcmp(arg, "--abbrev"))
> options->abbrev = DEFAULT_ABBREV;
> else if (skip_prefix(arg, "--abbrev=", &arg)) {
next prev parent reply other threads:[~2016-11-28 23:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 18:25 [PATCH] diff: handle --no-abbrev outside of repository Jack Bates
2016-11-28 23:03 ` Junio C Hamano [this message]
2016-11-29 7:06 ` Jeff King
2016-12-02 18:48 ` [PATCH v2] " Jack Bates
2016-12-05 6:01 ` Jeff King
2016-12-05 6:15 ` Jeff King
2016-12-05 6:58 ` Jeff King
2016-12-06 1:01 ` [PATCH v3] diff: handle --no-abbrev in no-index case Jack Bates
2016-12-06 16:53 ` [PATCH v4] " Jack Bates
2016-12-06 16:56 ` Jack Bates
2016-12-06 17:00 ` Jack Bates
2016-12-08 22:53 ` Junio C Hamano
2016-12-09 0:22 ` Jack Bates
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=xmqqbmwzi4wa.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=bk874k@nottheoilrig.com \
--cc=git@vger.kernel.org \
--cc=jack@nottheoilrig.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).