On Sun, Sep 08, 2019 at 10:01:33PM -0600, Eric Freese wrote: > On Sun, Sep 9, 2019 at 4:34 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: > > > I guess with "%(if)...%(then)...%(else)...%(end)" you might be able > > to do either one of --include/--exclude without supporting the > > other, e.g. "--include='%(if)%(symref)%(then)%(else)not a > > symref%(end)" would be usable as "I do not want to see symrefs" in a > > system that supports only "--include" without "--exclude". > > This has made me realize that I can get the behavior I need by using `%(if)`. > > Exclude symrefs: > "%(if)%(symref)%(then)%(else)%(refname)%(end)" > > Only symrefs: > "%(if)%(symref)%(then)%(refname)%(end)" > > However, this still prints an empty line for each ref that does not match the > condition. This can be cleaned up by piping through `grep .`, but what would > you think of adding a new optional flag to git-for-each-ref to prevent it from > printing empty expanded format strings? Yeah, I think that is a much nicer direction, in that it covers many more cases. I'm tempted to suggest it should even be the default, since the blank lines are mostly useless (by definition they carry no information except the single bit of "there was a ref that didn't have any output for your format"). My only reservation is that for-each-ref is plumbing, and it's _possible_ somebody is counting up the blank lines as part of some workflow (say, counting up tags and non-tags). It seems kind of unlikely, though. Much more likely is having an output format that has some non-blank elements and some blank, but the proposal wouldn't change the behavior there at all. -Peff