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

Re: diff for deleted file only, when changed to directory

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 8, 2010, 09:56 UTC
Message-ID
<AANLkTinW4DjHnNORH3FRi7fQsYAf+Ky_Jr14ZxOu2So2@mail.gmail.com>
In-Reply-To
<AANLkTikMf5qRaqkdiOKP_PBf=Q68fMc2U5WVN-7SWFYC@mail.gmail.com>
2010/12/8 Bert Wesarg <bert.wesarg@googlemail.com>:
Show 30 quoted lines
> 2010/12/8 Jonathan Nieder <jrnieder@gmail.com>:
>> Bert Wesarg wrote:
>>
>>>                                                                git
>>> diff --cached -- foo shows me the diff for both the file foo and file
>>> foo/bar.
>> [...]
>>>                                              But for the case
>>> file->directory, I would like to see only the deleted diff, not
>>> recursing into the directory.
>>
>> If I understand correctly, this is a documentation bug and feature
>> request.
>>
>> The documentation bug: the "git diff" documentation says something
>> like
>>
>>        git diff [--options] [<tree>[..<tree>]] [--] [<path>...]
>>
>> but the <path>s after "--" are actually patterns (path specifiers).
>> See [1] ([RFD] git glossary: define pathspec, 2010-11-29).
>>
>> The feature request: there is no way to specify an "exact match"
>> or "negative match" when specifying paths.  At least "negative
>> match" has been suggested before.
>>
>
> Thanks for the pointers.
>
> I don't expect that we can change <foo> to match only files and not directories.
Try
diff --cached -- '[f]'

From top of my memory, directory matching does not work with wildcards. By putting wildcards to your patterns, dir should never be matched again. I haven't tested it though.

-- 
Duy
Previous: Bert Wesarg
Message 4 of 4 in “diff for deleted file only, when changed to directory”
  1. Bert WesargDec 8, 2010
  2. Jonathan NiederDec 8, 2010
  3. Bert WesargDec 8, 2010
  4. Nguyen Thai Ngoc DuyDec 8, 2010

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.