scripts: add "git.orderfile" for ordering diff hunks by pathname patterns
PATCH 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:
I think I managed to incorporate everyone's feedback!
scripts/git.orderfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/git.orderfile
scripts/git.orderfile new file +15 -0
@@ -0,0 +1,15 @@ +*.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
scripts/git.orderfile
Quoted 8 lines
git config diff.orderFile
scripts/git.orderfilescripts/git.orderfile new file +0
-0@@ -0,0 +1,15 @@
Is it possible to have comments in here? So we can place the git config command above into into this file too?
scripts/git.orderfile line 5
Quoted 5 lines
scripts/git.orderfile new file +5
-0+*.txt +configure +GNUmakefile +makefile +Makefile
We also have Makefile.objs and Makefile.target, so "Makefile*" (like the first version had IIRC) should work better.
scripts/git.orderfile line 14
Quoted 9 lines
scripts/git.orderfile new file +9
-0+*.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
I guess there is more which could be placed here (i.e. files holding infrastructure which makes sense to see first). But we can easily refine that incrementally. That is the point to have this file in the repo in the first place ;)
cheers,
Gerd
Quoted 11 lines · Gerd Hoffmann
scripts/git.orderfile
Quoted 8 lines
git config diff.orderFile
scripts/git.orderfilescripts/git.orderfile new file +0
-0@@ -0,0 +1,15 @@Is it possible to have comments in here? So we can place the git config command above into into this file too?
The documentation is silent on this, and I didn't want to experiment, so I checked the git source code. Yes, comments seem to be supported, see the prepare_order() function in "diffcore-order.c":
/* cp to ep has one line */ if (*cp == '\n' || *cp == '#') ; /* comment */
How about the following comment:
# Apply this diff order to your git configuration with the command #
# git config diff.orderFile scripts/git.orderfile
?
Thanks
Laszlo
Quoted 28 lines
scripts/git.orderfile line 5
Quoted 5 lines
scripts/git.orderfile new file +5
-0+*.txt +configure +GNUmakefile +makefile +MakefileWe also have Makefile.objs and Makefile.target, so "Makefile*" (like the first version had IIRC) should work better.
scripts/git.orderfile line 14
Quoted 9 lines
scripts/git.orderfile new file +9
-0+*.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.cI guess there is more which could be placed here (i.e. files holding infrastructure which makes sense to see first). But we can easily refine that incrementally. That is the point to have this file in the repo in the first place ;)
cheers,
Gerd
Quoted 3 lines
# Apply this diff order to your git configuration with the command #
# git config diff.orderFilescripts/git.orderfile
Looks good to me.
cheers,
Gerd
Quoted 38 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 Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
Notes:
I think I managed to incorporate everyone's feedback!scripts/git.orderfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/git.orderfilescripts/git.orderfile new file +0
-0
scripts/git.orderfile line 1
Quoted 1 line
scripts/git.orderfile new file +1
-0@@ -0,0 +1,15 @@ +*.txt
We also have *.md. (OK, OK, we have a single docs/bitmaps.md, but maybe it's going to be more in the future. :-))
Max
Quoted 15 lines
scripts/git.orderfile new file +14
-0+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
Quoted 33 lines · Max Reitz
Quoted 32 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 Stefan Hajnoczi <[email protected]>Signed-off-by Laszlo Ersek <[email protected]>---
Notes:
I think I managed to incorporate everyone's feedback!scripts/git.orderfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/git.orderfile
Quoted 10 lines
scripts/git.orderfile line 1
Quoted 7 lines
scripts/git.orderfile new file +1
-0@@ -0,0 +1,15 @@ +*.txtWe also have *.md. (OK, OK, we have a single
docs/bitmaps.md, but maybe it's going to be more in the future. :-))
Maybe just insert 'docs/*' here? I'm not sure if it works for the subdirs, though.
Fam
Quoted 20 lines
Max
Quoted 15 lines
scripts/git.orderfile new file +14
-0+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
Quoted 9 lines · Fam Zheng
Quoted 6 lines
scripts/git.orderfile line 1
Quoted 3 lines
+++ b/scripts/git.orderfile
scripts/git.orderfile new file +1
-0@@ -0,0 +1,15 @@ +*.txtWe also have *.md. (OK, OK, we have a single
docs/bitmaps.md, but maybe it's going to be more in the future. :-))Maybe just insert 'docs/*' here? I'm not sure if it works for the subdirs, though.
Yes, you can specify subdirs. I think the way git works is that for each line in the orderfile, it finds all matches in the set of files that have a diff, then progresses to the next line on any remaining files.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org