From: Junio C Hamano <gitster@pobox.com>
To: Jack Bates <bk874k@nottheoilrig.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Jack Bates <jack@nottheoilrig.com>
Subject: Re: [PATCH] diff: fix up SHA-1 abbreviations outside of repository
Date: Sun, 04 Dec 2016 23:19:46 -0800 [thread overview]
Message-ID: <xmqqr35m6dwt.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161204194747.7100-1-jack@nottheoilrig.com> (Jack Bates's message of "Sun, 4 Dec 2016 12:47:47 -0700")
Jack Bates <bk874k@nottheoilrig.com> writes:
> The three cases where "git diff" operates outside of a repository are 1)
> when we run it outside of a repository, 2) when one of the files we're
> comparing is outside of the repository we're in, and 3) the --no-index
> option. Commit 4f03666 ("diff: handle sha1 abbreviations outside of
> repository", 2016-10-20) only worked in the first case.
> ---
> builtin/diff.c | 4 +++-
> t/t4063-diff-no-index-abbrev.sh | 50 +++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 53 insertions(+), 1 deletion(-)
> create mode 100755 t/t4063-diff-no-index-abbrev.sh
>
> diff --git a/builtin/diff.c b/builtin/diff.c
> index 7f91f6d..ec7c432 100644
> --- a/builtin/diff.c
> +++ b/builtin/diff.c
> @@ -342,9 +342,11 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
> "--no-index" : "[--no-index]");
>
> }
> - if (no_index)
> + if (no_index) {
> /* If this is a no-index diff, just run it and exit there. */
> + startup_info->have_repository = 0;
> diff_no_index(&rev, argc, argv);
> + }
This kind of change makes me nervous (partly because I am not seeing
the whole code but only this part of the patch).
Some code may react to "have_repository" being zero and do the right
thing (which I think is what you are using from your previous "we
did one of the three cases" change here), but the codepath that led
to "have_repository" being set to non-zero previously must have done
a lot more than just flipping that field to non-zero, and setting
zero to this field alone would not "undo" what it did.
I wonder if we're better off if we made sure that diff_no_index()
works the same way regardless of the value of "have_repository"
field?
next prev parent reply other threads:[~2016-12-05 7:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-04 19:47 [PATCH] diff: fix up SHA-1 abbreviations outside of repository Jack Bates
2016-12-05 6:55 ` Jeff King
2016-12-05 7:19 ` Junio C Hamano [this message]
2016-12-05 7:26 ` Jeff King
2016-12-05 17:45 ` Jack Bates
2016-12-05 22:43 ` Junio C Hamano
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=xmqqr35m6dwt.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=bk874k@nottheoilrig.com \
--cc=git@vger.kernel.org \
--cc=jack@nottheoilrig.com \
--cc=peff@peff.net \
/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).