scripts: add "git.orderfile" for ordering diff hunks by pathname patterns
PATCH v2 1/1 scripts: add "git.orderfile" for ordering diff hunks by pathname patterns
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile scripts/git.orderfile
once, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
---
Notes:
v2:
- "Makefile" -> "Makefile*" [Gerd]
- add leading comment [Gerd]
- add "docs/*" (note, there are *.txt files outside of docs/, so keeping those too) [Max, Fam, Eric]
scripts/git.orderfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/git.orderfile
scripts/git.orderfile new file +20 -0
@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/* +*.txt +configure +GNUmakefile +makefile +Makefile* +*.mak +qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.c +*.c
Signature · 1 line
2.9.2
On Fri, Dec 02, 2016 at 10:01:52PM +0100, Laszlo Ersek wrote:
[...]
Quoted 5 lines
scripts/git.orderfile new file +5
-0+docs/* +*.txt +configure +GNUmakefile +makefile
scripts/git.orderfile line 19
Quoted 10 lines
scripts/git.orderfile new file +10
-0+Makefile* +*.mak +qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.c
Maybe we could include test/* here, so test code appears before the implementation?
Quoted 5 lines
+*.c
Signature · 1 line
2.9.2
Signature · 1 line
Eduardo
Quoted 12 lines · Eduardo Habkost
On Fri, Dec 02, 2016 at 10:01:52PM +0100, Laszlo Ersek wrote:
[...]Quoted 10 lines
scripts/git.orderfile new file +10
-0+docs/* +*.txt +configure +GNUmakefile +makefile +Makefile* +*.mak +qapi-schema*.json +qapi/*.json +include/qapi/visitor.h
Quoted 8 lines
scripts/git.orderfile line 19
Quoted 5 lines
scripts/git.orderfile new file +5
-0+include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.cMaybe we could include test/* here, so test code appears before the implementation?
Hmmm, I'm not so sure about that. I certainly don't subscribe to TDD, when you first write up the test case, and then add implementation to satisfy the tests.
I don't have much experience / history with the tests subdir. Briefly reviewing what I've done there (git log --author=lersek), I think I would either keep the test patches entirely separate from the QEMU code patches (thus there wouldn't be a patch modifying *.c files both under and outside of tests/). Or else, I would actually prefer tests/*.c to come later in the same patch. The tests are frequently written to provide good coverage for the actual QEMU code, so seeing the QEMU code first seems preferable. (The corner cases to cover could be completely arbitrary, originating from quirks of POSIX functions, and so on.)
Thanks
Laszlo
Quoted 6 lines
Quoted 5 lines
+*.c
Signature · 1 line
2.9.2
Quoted 36 lines · Laszlo Ersek
Quoted 12 lines · Eduardo Habkost
On Fri, Dec 02, 2016 at 10:01:52PM +0100, Laszlo Ersek wrote:
[...]Quoted 10 lines
scripts/git.orderfile new file +10
-0+docs/* +*.txt +configure +GNUmakefile +makefile +Makefile* +*.mak +qapi-schema*.json +qapi/*.json +include/qapi/visitor.hQuoted 8 lines
scripts/git.orderfile line 19
Quoted 5 lines
scripts/git.orderfile new file +5
-0+include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.cMaybe we could include test/* here, so test code appears before the implementation?
Hmmm, I'm not so sure about that. I certainly don't subscribe to TDD, when you first write up the test case, and then add implementation to satisfy the tests.
I don't have much experience / history with the tests subdir. Briefly reviewing what I've done there (git log --author=lersek), I think I would either keep the test patches entirely separate from the QEMU code patches (thus there wouldn't be a patch modifying *.c files both under and outside of tests/). Or else, I would actually prefer tests/*.c to come later in the same patch. The tests are frequently written to provide good coverage for the actual QEMU code, so seeing the QEMU code first seems preferable. (The corner cases to cover could be completely arbitrary, originating from quirks of POSIX functions, and so on.)
Quoted 10 lines
Thanks
LaszloQuoted 6 lines
Quoted 5 lines
+*.c
Signature · 1 line
2.9.2
We also don't formally embrace TDD, as any tests that are checked in _MUST_ pass. The patch order by definition then requires the feature first, and then the tests.
Personally I like TDD, but I don't think it's appropriate to put tests first in this instance, as we review with an eye for "Will this break the tree right now?" and not "What are we about to add to QEMU?"
--js
Quoted 43 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
Notes:
v2:
- "Makefile" -> "Makefile*" [Gerd]
- add leading comment [Gerd]
- add "docs/*" (note, there are *.txt files outside of docs/, so keeping those too) [Max, Fam, Eric]scripts/git.orderfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/git.orderfilescripts/git.orderfile new file +0
-0
scripts/git.orderfile line 5
Quoted 5 lines
scripts/git.orderfile new file +5
-0@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/*
do we need this now? .txt is just below.
scripts/git.orderfile line 11
Quoted 6 lines
scripts/git.orderfile new file +6
-0+*.txt +configure +GNUmakefile +makefile +Makefile* +*.mak
do these rules apply in each directory?
I think they do but then I don't think we should list directories below.
scripts/git.orderfile line 19
Quoted 8 lines
scripts/git.orderfile new file +8
-0+qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.c
is the exact order or qapi files that important? I'd rather we stuck to simple wildcards without special casing visitors etc.
Quoted 3 lines
scripts/git.orderfile new file +1
-0+*.cSignature · 1 line
2.9.2
Quoted 5 lines · Michael S. Tsirkin
Quoted 5 lines
scripts/git.orderfile new file +0
-0
Quoted 8 lines
scripts/git.orderfile line 5
Quoted 6 lines
scripts/git.orderfile new file +5
-0@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/*do we need this now? .txt is just below.
It is useful for non-.txt files there, such as the bitmaps.md.
Fam
Quoted 15 lines · Fam Zheng
Quoted 5 lines · Michael S. Tsirkin
Quoted 5 lines
scripts/git.orderfile new file +0
-0Quoted 8 lines
scripts/git.orderfile line 5
Quoted 6 lines
scripts/git.orderfile new file +5
-0@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/*do we need this now? .txt is just below.
Quoted 3 lines
It is useful for non-.txt files there, such as the bitmaps.md.
Fam
Let's add the .md suffix instead?
For example, I'm not sure we want .cfg files on top like this.
Signature · 1 line
MST
Quoted 38 lines · Michael S. Tsirkin
Quoted 37 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
Notes:
v2:
- "Makefile" -> "Makefile*" [Gerd]
- add leading comment [Gerd]
- add "docs/*" (note, there are *.txt files outside of docs/, so keeping those too) [Max, Fam, Eric]scripts/git.orderfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/git.orderfile
Quoted 13 lines
scripts/git.orderfile line 5
Quoted 11 lines
scripts/git.orderfile new file +5
-0@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/*do we need this now? .txt is just below.
I covered this exact question in the Notes section of the patch (see above).
Quoted 11 lines
scripts/git.orderfile line 11
Quoted 7 lines
scripts/git.orderfile new file +6
-0+*.txt +configure +GNUmakefile +makefile +Makefile* +*.makdo these rules apply in each directory?
I think they do but then I don't think we should list directories below.
I picked the below lines from Eric's feedback.
Quoted 4 lines
Quoted 4 lines
scripts/git.orderfile new file +4
-0+qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.h
Quoted 8 lines
scripts/git.orderfile line 19
Quoted 4 lines
scripts/git.orderfile new file +4
-0+scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.cis the exact order or qapi files that important? I'd rather we stuck to simple wildcards without special casing visitors etc.
Eric indicated this specific order was helpful for QAPI work.
Quoted 4 lines
Quoted 4 lines
scripts/git.orderfile new file +1
-0+*.cSignature · 1 line
2.9.2
I'm concerned that we're getting into bikeshedding with this thread. I think it is counter-productive to try to get every minute detail "right" (for some definition of "right") in the initial commit. *Whatever* we commit at this point will be an improvement relative to the current status; for example,
*.h
*.c
would be an improvement, simply by placing C source / implementation after headers. We don't need (and shouldn't try) to cover everything we can think of in this version.
I suggest we go ahead with this posting (or v1), then people can submit whatever improvements they deem fit, from their personal experience. I think the initial version should be minimal and non-controversial.
We've already spent a disproportionate amount of time discussing this item.
Thanks
Laszlo
Quoted 11 lines · Michael S. Tsirkin
scripts/git.orderfile line 5
Quoted 7 lines
+++ b/scripts/git.orderfile
scripts/git.orderfile new file +5
-0@@ -0,0 +1,20 @@ +# Apply this diff order to your git configuration with the command +# +# git config diff.orderFile scripts/git.orderfile + +docs/*do we need this now? .txt is just below.
Quoted 1 line
scripts/git.orderfile new file +1
-0+*.txt
I still think we want docs/* first, at which point this *.txt line currently only adds changes to qdict-test-data.txt (should that file be moved to live under tests/ ?)
Quoted 7 lines
scripts/git.orderfile line 11
Quoted 5 lines
scripts/git.orderfile new file +5
-0+configure +GNUmakefile +makefile +Makefile* +*.makdo these rules apply in each directory?
My understanding is that git applies similar logic to these lines as it does to .gitignore files: if not anchored, the pattern applies to any file in any directory; or you can start with leading / to force the match to be anchored to a specific directory.
Quoted 15 lines
I think they do but then I don't think we should list directories below.
scripts/git.orderfile line 19
Quoted 8 lines
scripts/git.orderfile new file +8
-0+qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.h +scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.cis the exact order or qapi files that important?
I'd rather we stuck to simple wildcards without
special casing visitors etc.
On the v1 thread, I had pointed out that I had special-cased visitor code in some of my patches, as an example, but I'm not sure that it is special enough to be needed for everyone. I'm fine doing one-off tweaks for patch series where a particular file should come first, without making the official file have to track all those one-off tweaks.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 16 lines · Laszlo Ersek
I picked the below lines from Eric's feedback.
Quoted 4 lines
Quoted 4 lines
scripts/git.orderfile new file +4
-0+qapi-schema*.json +qapi/*.json +include/qapi/visitor.h +include/qapi/visitor-impl.hQuoted 8 lines
scripts/git.orderfile line 19
Quoted 4 lines
scripts/git.orderfile new file +4
-0+scripts/qapi.py +scripts/*.py +*.h +qapi/qapi-visit-core.cis the exact order or qapi files that important?
I'd rather we stuck to simple wildcards without
special casing visitors etc.
Quoted 1 line
Eric indicated this specific order was helpful for QAPI work.
In fact, what I would recommend is that we do the minimal file now, and then subsequent series (such as if I have more QAPI work) can add their further tweaks as part of the series where those tweaks aid review. So I'd be just fine omitting the visitor special-casing if it helps get the patch in faster.
Quoted 5 lines
I suggest we go ahead with this posting (or v1), then people can submit whatever improvements they deem fit, from their personal experience. I think the initial version should be minimal and non-controversial.
We've already spent a disproportionate amount of time discussing this item.
Indeed, especially for something that still requires manual configuration from each developer to make use of it (it's a shame git doesn't yet have automatic support for .gitorderfile, like it does for .gitignore or .gitattributes).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
John Snow
Reviewed-byQuoted 7 lines · Laszlo Ersek
I suggest we go ahead with this posting (or v1), then people can submit whatever improvements they deem fit, from their personal experience. I think the initial version should be minimal and non-controversial.
We've already spent a disproportionate amount of time discussing this item.
ACK
Quoted 3 lines
Thanks
Laszlo
Quoted 6 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
Quoted 6 lines
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
Presumably, we'd also want this to be mentioned in HACKING?
Quoted 12 lines
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>
Quoted 1 line
---
Is it time to revive this patch?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 7 lines · Eric Blake
Quoted 6 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
Quoted 8 lines
Quoted 6 lines
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
Presumably, we'd also want this to be mentioned in HACKING?
Presumably. :)
Quoted 15 lines
Quoted 13 lines
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>Quoted 1 line
---
Quoted 1 line
Is it time to revive this patch?
Time for whom? :)
Cheers,
Laszlo
Quoted 24 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>
Quoted 1 line
---
Refloating 6+ months later, but..
Someone please merge this! :-)
E.
Quoted 27 lines · Emilio G. Cota
Quoted 24 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>Quoted 1 line
---
Quoted 5 lines
Refloating 6+ months later, but..
Someone please merge this! :-)
E.
Users should be aware that if they do this, the need to supply -O /dev/null to git pull-request. Otherwise the diffstat is all scrambled and you can't figure out what's included.
Signature · 1 line
MST
Quoted 30 lines · Michael S. Tsirkin
Quoted 29 lines · Emilio G. Cota
Quoted 24 lines · Laszlo Ersek
When passed to git-diff (and to every other git command producing diffs and/or diffstats) with "-O" or "diff.orderFile", this list of patterns will place the more declarative / abstract hunks first, while changes to imperative code / details will be near the end of the patches. This saves on scrolling / searching and makes for easier reviewing.
We intend to advise contributors in the Wiki to run
git config diff.orderFile
scripts/git.orderfileonce, as part of their initial setup, before formatting their first (or, for repeat contributors, next) patches.
See the "-O" option and the "diff.orderFile" configuration variable in git-diff(1) and git-config(1).
Cc "Michael S. Tsirkin" <[email protected]>Cc Eric Blake <[email protected]>Cc Fam Zheng <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc John Snow <[email protected]>Cc Max Reitz <[email protected]>Cc Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>Quoted 1 line
---
Refloating 6+ months later, but..
Quoted 8 lines
Quoted 3 lines
Someone please merge this! :-)
E.Users should be aware that if they do this, the need to supply -O
/dev/nullto git pull-request. Otherwise the diffstat is all scrambled and you can't figure out what's included.
I'd do the opposite: recommend passing '-O scripts/git.orderfile' to git-format patch, and leave the default for all other commands.
E.