git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* diff-filter can't identify renaming if not done directly
@ 2020-12-04 14:59 Sofia Syria
  2020-12-04 16:39 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Sofia Syria @ 2020-12-04 14:59 UTC (permalink / raw)
  To: git

Hello,

quick question about using diff-filter in linux. In the scenario
that in my repository, I first copy file1 to file2, then move file2 to
file3 and delete file1, "git diff" returns:

diff --git a/file1 b/file3
similarity index 100%
rename from file1
rename to file3

 but running "git diff --diff-filter=r" doesn't return anything. Only
flag "t" will return the change. Can this be considered as a bug?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: diff-filter can't identify renaming if not done directly
  2020-12-04 14:59 diff-filter can't identify renaming if not done directly Sofia Syria
@ 2020-12-04 16:39 ` Jeff King
  2020-12-04 20:07   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2020-12-04 16:39 UTC (permalink / raw)
  To: Sofia Syria; +Cc: git

On Fri, Dec 04, 2020 at 03:59:03PM +0100, Sofia Syria wrote:

> quick question about using diff-filter in linux. In the scenario
> that in my repository, I first copy file1 to file2, then move file2 to
> file3 and delete file1, "git diff" returns:
> 
> diff --git a/file1 b/file3
> similarity index 100%
> rename from file1
> rename to file3
> 
>  but running "git diff --diff-filter=r" doesn't return anything. Only
> flag "t" will return the change. Can this be considered as a bug?

Lowercase filters exclude particular types. From "git help diff":

    --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
	   Select only files that are Added (A), Copied (C), Deleted
	   (D), Modified (M), Renamed (R), have their type (i.e. regular
	   file, symlink, submodule, ...) changed (T), are Unmerged (U),
	   are Unknown (X), or have had their pairing Broken (B). Any
	   combination of the filter characters (including none) can be
	   used. When * (All-or-none) is added to the combination, all
	   paths are selected if there is any file that matches other
	   criteria in the comparison; if there is no file that matches
	   other criteria, nothing is selected.

	   Also, these upper-case letters can be downcased to exclude.
	   E.g. --diff-filter=ad excludes added and deleted paths.

So "--diff-filter=R" asks to see only renames. But "--diff-filter=r"
asks to exclude them. And "--diff-filter=t" excludes typechanges, which
means that renames are still OK. Doing "--diff-filter=a", etc, would
still show it as well.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: diff-filter can't identify renaming if not done directly
  2020-12-04 16:39 ` Jeff King
@ 2020-12-04 20:07   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2020-12-04 20:07 UTC (permalink / raw)
  To: Jeff King; +Cc: Sofia Syria, git

Jeff King <peff@peff.net> writes:

> On Fri, Dec 04, 2020 at 03:59:03PM +0100, Sofia Syria wrote:
>
>> quick question about using diff-filter in linux. In the scenario
>> that in my repository, I first copy file1 to file2, then move file2 to
>> file3 and delete file1, "git diff" returns:
>> 
>> diff --git a/file1 b/file3
>> similarity index 100%
>> rename from file1
>> rename to file3
>> 
>>  but running "git diff --diff-filter=r" doesn't return anything. Only
>> flag "t" will return the change. Can this be considered as a bug?
>
> Lowercase filters exclude particular types. From "git help diff":
>
>     --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]
> 	   Select only files that are Added (A), Copied (C), Deleted
> 	   (D), Modified (M), Renamed (R), have their type (i.e. regular
> 	   file, symlink, submodule, ...) changed (T), are Unmerged (U),
> 	   are Unknown (X), or have had their pairing Broken (B). Any
> 	   combination of the filter characters (including none) can be
> 	   used. When * (All-or-none) is added to the combination, all
> 	   paths are selected if there is any file that matches other
> 	   criteria in the comparison; if there is no file that matches
> 	   other criteria, nothing is selected.
>
> 	   Also, these upper-case letters can be downcased to exclude.
> 	   E.g. --diff-filter=ad excludes added and deleted paths.
>
> So "--diff-filter=R" asks to see only renames. But "--diff-filter=r"
> asks to exclude them. And "--diff-filter=t" excludes typechanges, which
> means that renames are still OK. Doing "--diff-filter=a", etc, would
> still show it as well.

Correct.  I should have scanned my inbox to find that the same
question was asked twice and one of the copies already got a good
answer.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-04 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 14:59 diff-filter can't identify renaming if not done directly Sofia Syria
2020-12-04 16:39 ` Jeff King
2020-12-04 20:07   ` Junio C Hamano

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).