git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC][GSoC] make "git diff --no-index $directory $file" DWIM better.

From
YSYurii Shevtsov <ungetch@gmail.com>
Date
Mar 16, 2015, 16:23 UTC
Message-ID
<CAHLaBNJxRx9jkNHCM+djq7KEZBV2n5PFZN0-UUtzhO=ikR+Kuw@mail.gmail.com>
In-Reply-To
<xmqqr3spsir2.fsf@gitster.dls.corp.google.com>
Show 44 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>>> --- 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);
>>
>> I'm surprised to see this error message totally go away. The idea of the
>> microproject was to DWIM (do what I mean) better, but the dwim should
>> apply only when $directory/$file actually exists. Otherwise, the error
>> message should actually be raised.
>
> I actually think this check, when we really fixed "diff --no-index"
> to work sensibly, should go away and be replaced with something
> sensible.  As it stands now, even before we think about dwimming
> "diff D/ F" into "diff D/F F", a simple formulation like this will
> error out.
>
>     $ mkdir -p a/sub b
>     $ touch a/file b/file b/sub a/sub/file
>     $ git diff --no-index a b
>     error: file/directory conflict: a/sub, b/sub
>
> Admittedly, that is how ordinary "diff -r" works, but I am not sure
> if we want to emulate that aspect of GNU diff.  If the old tree a
> has a directory 'sub' with 'file' under it (i.e. a/sub/file) where
> the new tree has a file at 'sub', then the recursive diff can show
> the removal of sub/file and creation of sub, no?  That is what we
> show for normal "git diff".
>
> But I _think_ fixing that is way outside the scope of GSoC Micro.
>
> And patching this function, because it is recursively called from
> within it, to "dwim" is simply wrong.  When we see a/sub that is a
> directory and b/sub that is a file, we do *NOT* want to rewrite the
> comparison to comparison between a/sub/sub and b/sub.
>
> What needs to be fixed for the Micro is the top-level call to
> queue_diff() that is made blindly between paths[0] and paths[1]
> without checking what kind of things these are.

So you want me to convert args ("diff D/ F" into "diff D/F F") before calling queue_diff()? But why? queue_diff() already check args' types and decides which comparison to do. If I understood you right, it would require calling get_mode() in diff_no_index(), while get_mode() will be called again in queue_diff().

Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 13 in “[GSoC] make "git diff --no-index $directory $file" DWIM better.”
  1. [GSoC] make "git diff --no-index $directory $file" DWIM better.Yurii Shevtsov, Mar 15, 2015
  2. Matthieu MoyMar 15, 2015
  3. Junio C HamanoMar 16, 2015
  4. Yurii ShevtsovMar 16, 2015
  5. Junio C HamanoMar 16, 2015
  6. Yurii ShevtsovMar 16, 2015
  7. Junio C HamanoMar 16, 2015
  8. t.gummerer@gmail.comMar 15, 2015
  9. Eric SunshineMar 15, 2015
  10. Junio C HamanoMar 15, 2015
  11. t.gummerer@gmail.comMar 15, 2015
  12. Eric SunshineMar 15, 2015
  13. Junio C HamanoMar 15, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.