From: t.gummerer@gmail.com
To: Yurii Shevtsov <ungetch@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC][GSoC] make "git diff --no-index $directory $file" DWIM better.
Date: Sun, 15 Mar 2015 18:34:52 +0100 [thread overview]
Message-ID: <20150315173451.GB17591@hank> (raw)
In-Reply-To: <CAHLaBN+93mp6PQmtfjOHSvfW7iwDXwPitGQ5W1am9KBm9EZV2Q@mail.gmail.com>
Hi,
On 03/15, Yurii Shevtsov wrote:
> Changes 'git diff --no-index $directory $file' behaviour.
> Now it is transformed to 'git diff --no-index $directory/&file $file'
> instead of throwing an error.
The commit message should describe why the change is made, see
Documentation/SubmittingPatches, section (2)
> Signed-off-by: Yurii Shevtsov <ungetch <at> gmail.com>
Please use your full email here, without replacing @ with <at>
> ---
> diff-no-index.c | 21 +++++++++++++++++++--
You should probably add a test for the new behaviour in
t/t4053-diff-no-index.sh.
> 1 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/diff-no-index.c b/diff-no-index.c
> index 265709b..4e71b36 100644
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -97,8 +97,25 @@ static int queue_diff(struct diff_options *o,
> if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
> return -1;
>
> - if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
> - return error("file/directory conflict: %s, %s", name1, name2);
> + if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) {
> + struct strbuf dirnfile;
> + const char *dir, *file;
> + char *filename;
> + int ret = 0;
> +
> + dir = S_ISDIR(mode1) ? name1 : name2;
> + file = (dir == name1) ? name2 : name1;
This makes git diff --no-index $directory $file the same as
git diff --no-index $file $directory. Shouldn't these commands give
different results? (See the behaviour of diff in this case, and
compare it to the behaviour you introduced here)
> + strbuf_init(&dirnfile, strlen(name1) + strlen(name2) + 2);
> + strbuf_addstr(&dirnfile, dir);
> + if (dirnfile.buf[dirnfile.len - 1] != '/')
> + strbuf_addch(&dirnfile, '/');
> + filename = strrchr(file, '/');
> + strbuf_addstr(&dirnfile, filename ? (filename + 1) : file);
> + ret = queue_diff(o, dirnfile.buf, file);
> + strbuf_release(&dirnfile);
> +
> + return ret;
> + }
Your MUA seems to have replaced tabs with spaces in this email. The
easiest way to get the formatting correct is the git send-email tool.
You should also try to sending the mail to yourself first and see if
it applies correctly with git am.
>
> if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
> struct strbuf buffer1 = STRBUF_INIT;
> --
>
> I hope I understood task correct. I think this patch requires writing
> additional tests, so that's what I'm going to do now.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-03-15 17:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-15 15:35 [PATCH/RFC][GSoC] make "git diff --no-index $directory $file" DWIM better Yurii Shevtsov
2015-03-15 17:30 ` Matthieu Moy
2015-03-16 3:50 ` Junio C Hamano
2015-03-16 16:23 ` Yurii Shevtsov
2015-03-16 17:14 ` Junio C Hamano
2015-03-16 17:47 ` Yurii Shevtsov
2015-03-16 19:20 ` Junio C Hamano
2015-03-15 17:34 ` t.gummerer [this message]
[not found] ` <CAHLaBNLQ8-JzEBjypvJDDzhW8SwfzujuOknC_QWar+cL18cR3A@mail.gmail.com>
2015-03-15 18:13 ` t.gummerer
2015-03-15 18:04 ` Eric Sunshine
[not found] ` <CAHLaBN+RVpDrG9OewUS7LCYaEOvVqsTY3znapgMj7VrMJWHaDw@mail.gmail.com>
2015-03-15 21:28 ` Eric Sunshine
2015-03-15 22:00 ` Junio C Hamano
2015-03-15 20:17 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150315173451.GB17591@hank \
--to=t.gummerer@gmail.com \
--cc=git@vger.kernel.org \
--cc=ungetch@gmail.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.
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 NNTP newsgroup(s).