2

After

git config for-each-ref.count 2

running

git for-each-ref refs/heads

shows lots of output, while

git for-each-ref --count=2 refs/heads

only shows two, as required.

It seems as if git for-each-ref does not use options set with git-config. If it does, how can I get it to work?

Harald
  • 4,575
  • 5
  • 33
  • 72
  • 2
    `git for-each-ref` is a *plumbing command* and as such, it would be inappropriate for it to have any settings. It's meant to behave the same for every user, when run from scripts that use it, regardless of that user's configuration setting. (What made you expect `git config for-each-ref.count` to do something here?) – torek Sep 21 '22 at 12:21
  • Thanks, didn't know about 'plumbing command'. – Harald Sep 21 '22 at 12:23
  • Git's notion of plumbing vs porcelain is useful, but Git is not entirely self-consistent here. For instance `git status` is both (!) as it has `--porcelain` and `--porcelain=v2` options. (I still don't get why the "make porcelain command behave as plumbing" option is generally spelled `--porcelain` in Git...) – torek Sep 21 '22 at 12:25
  • BTW I asked the question about expectations in case there's something that can be made clearer in the Git documentation, although in this case I suspect the syntax you suggested was on some bogus web page somewhere... – torek Sep 21 '22 at 12:36
  • No, no bogus web page. I am using magit and wanted it to sort branches on the status page (https://emacs.stackexchange.com/q/70029/12065). I found in its source that it uses `for-each-ref`, read the man page of `for-each-ref` and tried to configure it. I searched for 'config' and 'option' in the page as well as skimmed over `git-config` docs to find a hint as to why `for-each-ref` doesn't care. If anything could be improved, a line like 'this is a plumbing command and does not read the config' would need to be added to each such git command. – Harald Sep 21 '22 at 12:44
  • 1
    BTW: even if I would have been aware of the distinction between 'plumbing' and 'porcelain', `git config --help` would have told me this: `The configuration variables are used by both the Git plumbing and the porcelains` :-/ – Harald Sep 21 '22 at 12:46
  • OK - that's exactly the kind of improvement I'm looking for, where someone can clarify the wording in some actual man page included with Git! Thanks... – torek Sep 22 '22 at 04:07

1 Answers1

0

I do not see a for-each-ref.count setting in git config.

And I do not see any reference to count in builtin/for-each-ref.c, except as an option (not a git config setting).

Those are the main reasons why git for-each-ref (be it plumbing or not) would not use that particular (non-existent) option set with git-config.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250