Skip to contentSkip to conversation

--diff-filter=T does not list x changes

PATCH In review Anders Melchiorsen 5 participants 13 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw
Quoted 1 line

From documentation, I would expect --diff-filter to list changes in

the execute bit, but it does not. I hear on #git that this is intended, though I still do not know how to filter on the execute bit. Is it impossible?

Testcase:

  mkdir t && cd t && git init
  touch a && git add -A && git commit -m1
  chmod +x a && git add -A && git commit -m2
  git log --diff-filter=T        # <--- shows nothing
  rm -f a && ln -s b a && git add -A && git commit -m3
  git log --diff-filter=T

Anders

#1 lore raw
Quoted 4 lines · Anders Melchiorsen

From documentation, I would expect --diff-filter to list changes in the execute bit, but it does not. I hear on #git that this is intended, though I still do not know how to filter on the execute bit. Is it impossible?

Looking at the code, I think it's impossible, and one would have to add a new --diff-filter letter. However, at the very least, the documentation should clarify this situation. The --diff-filter explanation says:

Select only files [...] have their type (mode) changed (T) [...]

which to me indicates that your test case should work.

-Peff

#2 lore raw
Quoted 7 lines · Jeff King
Quoted 4 lines · Anders Melchiorsen

From documentation, I would expect --diff-filter to list changes in the execute bit, but it does not. I hear on #git that this is intended, though I still do not know how to filter on the execute bit. Is it impossible?

Quoted 8 lines

Looking at the code, I think it's impossible, and one would have to add a new --diff-filter letter. However, at the very least, the documentation should clarify this situation. The --diff-filter explanation says:

Select only files [...] have their type (mode) changed (T) [...]

which to me indicates that your test case should work.

That documentation is quite loosely written. Typechange diff is what T has always meant, and it never was about the executable bit. The word "mode" in that sentence only means the upper bits S_IFREG/S_IFLNK (iow, masked by S_IFMT).

#3 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 3 lines · Jeff King

Select only files [...] have their type (mode) changed (T) [...]

which to me indicates that your test case should work.

That documentation is quite loosely written. Typechange diff is what T has always meant, and it never was about the executable bit. The word "mode" in that sentence only means the upper bits S_IFREG/S_IFLNK (iow, masked by S_IFMT).

I hope you agree that this reading is not obvious from the documentation, so I will send a patch later fixing up the prose (if nobody beats me to it).

How about adding a diff-filter=X for the executable bit? I could probably look at that during the weekend.

Anders.

#4 lore raw
Quoted 9 lines · Anders Melchiorsen
Quoted 4 lines · Junio C Hamano

That documentation is quite loosely written. Typechange diff is what T has always meant, and it never was about the executable bit. The word "mode" in that sentence only means the upper bits S_IFREG/S_IFLNK (iow, masked by S_IFMT).

I hope you agree that this reading is not obvious from the documentation,...

Yup, didn't I already say that the documentation is buggy?

Quoted 1 line

How about adding a diff-filter=X for the executable bit?

I do not think it is a good idea for two reasons. Backward compatibility and sane design.

For one thing, "diff --name-status" never shows X, so you would introduce an unnecessary inconsistency. If you change "--name-status" to avoid that, you would be breaking people's existing scripts that expect to see "M" for such a change.

Even if you were forgiven by these people whose scripts are broken by your change, you need to decide between "M" and "X" when both contents and executable bit are changed. The least surprising logic would probably be to show "X" when _only_ executable bit is changed and show "M" when contents changed (even when executable bit also did), but that feels quite arbitrary. And the other way around isn't any better.

#5 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · Anders Melchiorsen

I hope you agree that this reading is not obvious from the documentation,...

Yup, didn't I already say that the documentation is buggy?

Possibly, though not in this thread.

Quoted 9 lines
Quoted 1 line

How about adding a diff-filter=X for the executable bit?

I do not think it is a good idea for two reasons. Backward compatibility and sane design.

For one thing, "diff --name-status" never shows X, so you would introduce an unnecessary inconsistency. If you change "--name-status" to avoid that, you would be breaking people's existing scripts that expect to see "M" for such a change.

(I noticed that X is already used in diff-filter, but will keep it for this discussion)

I was thinking that X could be a subset of M. So only if you specifically ask for diff-filter=X (and not M) would you get this new functionality. That should keep it compatible. It would then pick files that have had their x flipped, regardless of their change in content. With diff-filter=M, it would work as it does today.

If name-status output must be consistent, it could even output M for these changes. That would still be unambiguous (but probably confusing).

...

As you say that this is an unnecessary inconsistency, I wonder whether you have a different way to pick out the commits that toggle the x bit? That is a problem that I am facing, with no solution shown so far ...

Anders.

#6 lore raw
Quoted 2 lines · Anders Melchiorsen

... way to pick out the commits that toggle the x
bit? That is a problem that I am facing, with no solution shown so far ...

Are you interested in executable-bit only change, or any change that contains changes to the executable-bit? If I were looking for the latter, probably finding "^:100664 100775 " (or the other way around) in log --raw (or whatchanged) output would be what I would do --- the mode changes are rare enough in a sane project, so I wouldn't mind having to do such scripting as needed.

There are other "commit pickers" such as -S<strting> and --diff-filter that do not absolutely have to exist (iow, they could also be scripted), but what they pick earned easy shortcuts because the need is very common. Once you can demonstrate that the need to pick executable-bit changes is also very common, _and_ if you can come up with a clean solution, we might add a commit picker that looks for changes in executable-ness in the future. I dunno.

#7 lore raw

PATCH 1/1 Documentation: diff-filter=T only tests for symlink changes

With the previous text, one could get the understanding that diff-filter=T also tested for changes in the executable bit.

---

Quoted 7 lines · Junio C Hamano

There are other "commit pickers" such as -S<strting> and --diff-filter that do not absolutely have to exist (iow, they could also be scripted), but what they pick earned easy shortcuts because the need is very common. Once you can demonstrate that the need to pick executable-bit changes is also very common, _and_ if you can come up with a clean solution, we might add a commit picker that looks for changes in executable-ness in the future. I dunno.

You are right that this should be a rare need.

I didn't mean to push for this feature. I just offered to implement it, as I needed it myself and din't see other ways. A script will work fine for me, I should have thought of that.

The documentation patch that I promised is here.

Thanks,
Anders.

 Documentation/diff-options.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/diff-options.txt +1 -1
index 7788d4f..7604a13 100644
@@ -137,7 +137,7 @@ endif::git-format-patch[]
 --diff-filter=[ACDMRTUXB*]::
 	Select only files that are Added (`A`), Copied (`C`),
 	Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-	type (mode) changed (`T`), are Unmerged (`U`), are
+	type (symlink/regular file) changed (`T`), are Unmerged (`U`), are
 	Unknown (`X`), or have had their pairing Broken (`B`).
 	Any combination of the filter characters may be used.
 	When `*` (All-or-none) is added to the combination, all
Signature · 1 line
1.6.0.2.514.g23abd3
#8 lore raw

Re: [PATCH] Documentation: diff-filter=T only tests for symlink changes

Quoting Anders Melchiorsen <[email protected]>:

Quoted 15 lines
Documentation/diff-options.txt +1 -1
index 7788d4f..7604a13 100644
@@ -137,7 +137,7 @@ endif::git-format-patch[]
 --diff-filter=[ACDMRTUXB*]::
 	Select only files that are Added (`A`), Copied (`C`),
 	Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-	type (mode) changed (`T`), are Unmerged (`U`), are
+	type (symlink/regular file) changed (`T`), are Unmerged (`U`), are
 	Unknown (`X`), or have had their pairing Broken (`B`).
 	Any combination of the filter characters may be used.
 	When `*` (All-or-none) is added to the combination, all
Signature · 1 line
1.6.0.2.514.g23abd3

Are symlinks and regular files the only kind of object you can see in diff? What happens when a file or directory changes to a submodule?

Signature · 2 lines
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
#9 lore raw

Re: [PATCH] Documentation: diff-filter=T only tests for symlink changes

Quoted 12 lines · Nanako Shiraishi

Quoting Anders Melchiorsen <[email protected]>:

Quoted 10 lines
Documentation/diff-options.txt +1 -1
index 7788d4f..7604a13 100644
@@ -137,7 +137,7 @@ endif::git-format-patch[]
 --diff-filter=[ACDMRTUXB*]::
 	Select only files that are Added (`A`), Copied (`C`),
 	Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-	type (mode) changed (`T`), are Unmerged (`U`), are
+	type (symlink/regular file) changed (`T`), are Unmerged (`U`), are
Quoted 8 lines
Quoted 5 lines
Documentation/diff-options.txt +0 -0
 	Unknown (`X`), or have had their pairing Broken (`B`).
 	Any combination of the filter characters may be used.
 	When `*` (All-or-none) is added to the combination, all
Signature · 1 line
1.6.0.2.514.g23abd3

Are symlinks and regular files the only kind of object you can see in diff? What happens when a file or directory changes to a submodule?

Oops. I've already applied Anders's patch, but you are right. A change from a blob to submodule also shows up as a typechange event.

Perhaps we should just remove the parenthesised comment from there instead. I'll rewind and rebuild, as I haven't pushed the results out yet (lucky me).

#10 lore raw

Re: [PATCH] Documentation: diff-filter=T only tests for symlink changes

In reply to Anders Melchiorsen

Quoting Junio C Hamano <[email protected]>:

Quoted 24 lines
Quoted 12 lines · Nanako Shiraishi

Quoting Anders Melchiorsen <[email protected]>:

Quoted 10 lines
Documentation/diff-options.txt +1 -1
index 7788d4f..7604a13 100644
@@ -137,7 +137,7 @@ endif::git-format-patch[]
 --diff-filter=[ACDMRTUXB*]::
 	Select only files that are Added (`A`), Copied (`C`),
 	Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-	type (mode) changed (`T`), are Unmerged (`U`), are
+	type (symlink/regular file) changed (`T`), are Unmerged (`U`), are
Quoted 8 lines
Quoted 5 lines
Documentation/diff-options.txt +0 -0
 	Unknown (`X`), or have had their pairing Broken (`B`).
 	Any combination of the filter characters may be used.
 	When `*` (All-or-none) is added to the combination, all
Signature · 1 line
1.6.0.2.514.g23abd3

Are symlinks and regular files the only kind of object you can see in diff? What happens when a file or directory changes to a submodule?

Quoted 6 lines

Oops. I've already applied Anders's patch, but you are right. A change from a blob to submodule also shows up as a typechange event.

Perhaps we should just remove the parenthesised comment from there instead. I'll rewind and rebuild, as I haven't pushed the results out yet (lucky me).

I see that you pushed out this change already, and you changed your mind and described them all. I think the result reads better.

Signature · 2 lines
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
#11 lore raw

Re: [PATCH] Documentation: diff-filter=T only tests for symlink changes

Quoted 2 lines · Nanako Shiraishi

I see that you pushed out this change already, and you changed your mind and described them all. I think the result reads better.

While we are fixing up that paragraph, this part could also use some elaboration:

Unknown (X), or have had their pairing Broken (B).

I would do it, but I have no idea what these two mean.

Regards,
Anders