git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v8] var: support broken-down idents, signing key, multiple args, and -z

From
APAndrew Pleeter <andrewpleeter@gmail.com>
Date
Sep 26, 2026, 16:19 UTC
Message-ID
<20260926161951.30531-1-andrewpleeter@gmail.com>
In-Reply-To
<ddfd5232-b832-476c-8614-268f8e4bbe28@gmail.com>
Hi Phillip,

Sorry for the silence. I was replying on the GitGitGadget PR and did not realise those comments never reach the list. That is also why v6 switched to get_signing_key() without a word from me about your question.

You were right to keep asking about GIT_SIGNING_KEY. I am dropping it from the series. get_signing_key() returns a string whose meaning depends on gpg.format, and the variable gives the caller no way to tell which kind it got:

  gpg.format=openpgp, user.signingkey unset
    $ git var GIT_SIGNING_KEY
    C O Mitter <committer@example.com>
  gpg.format=openpgp, user.signingkey=DEADBEEF
    $ git var GIT_SIGNING_KEY
    DEADBEEF
  gpg.format=ssh, user.signingkey=/path/to/key.pub
    $ git var GIT_SIGNING_KEY
    /path/to/key.pub

So no, the key alone does not tell a caller whether to use gpg or ssh; they would have to read gpg.format as well. And in the default case the value is a committer ident rather than a key, because that is what get_signing_key() hands to gpg to look up. Better to drop it than ship a GIT_SIGNING_KEY that sometimes isn't one. I will revisit it when I can name a caller it serves.

On the exit code, your GIT_CONFIG_NOSYSTEM example convinced me. In v9, asking for several variables omits the ones with no value and exits 0. Non-zero is reserved for real errors such as an unknown variable name, so callers can detect those from the exit code alone. A single variable still exits 1 when it has no value.

The string_list conversion is split out as you suggested:
  1/4  var: represent multi-valued variables with a string_list
  2/4  var: add "-z" output mode
  3/4  var: accept more than one variable
  4/4  var: add broken-out identity variables

parse_options() sits in 2/4, since "-z" is what requires it. GIT_CONFIG_GLOBAL is now documented as multi-valued, and the tests use nul_to_q instead of test_cmp over files containing NUL.

One place I did not follow you: instead of a trailing delimiter for a multi-valued variable when argc > 1, each value gets its own entry:

  $ git var GIT_AUTHOR_IDENT GIT_CONFIG_GLOBAL
  GIT_AUTHOR_IDENT=A U Thor <author@example.com> 1112912053 -0700
  GIT_CONFIG_GLOBAL=/home/me/.config/git/config
  GIT_CONFIG_GLOBAL=/home/me/.gitconfig

Same shape as "git var -l", so one parser handles both. Happy to switch if you prefer the trailing delimiter. I should have raised it last time instead of just changing it.

Thanks, Andrew

Previous: Phillip WoodNext: Andrew Pleeter
Message 26 of 35 in “builtin/whoami: add new 'whoami' command”
  1. builtin/whoami: add new 'whoami' commandAndrew Pleeter via GitGitGadget, Aug 25, 2026
  2. brian m. carlsonAug 25, 2026
  3. Junio C HamanoAug 25, 2026
  4. builtin/ident: add new 'ident' commandAndrew Pleeter via GitGitGadget, Aug 31, 2026
  5. Jeff KingSep 1, 2026
  6. Junio C HamanoSep 1, 2026
  7. var: support broken-down idents, default key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 3, 2026
  8. Junio C HamanoSep 3, 2026
  9. Ben KnobleSep 3, 2026
  10. Phillip WoodSep 4, 2026
  11. Junio C HamanoSep 4, 2026
  12. Phillip WoodSep 8, 2026
  13. var: support broken-down idents, signing key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 8, 2026
  14. Phillip WoodSep 8, 2026
  15. var: support broken-down idents, signing key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 8, 2026
  16. Junio C HamanoSep 8, 2026
  17. var: support broken-down idents, signing key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 9, 2026
  18. Phillip WoodSep 9, 2026
  19. Junio C HamanoSep 9, 2026
  20. var: support broken-down idents, signing key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 10, 2026
  21. Junio C HamanoSep 14, 2026
  22. var: support broken-down idents, signing key, multiple args, and -zAndrew Pleeter via GitGitGadget, Sep 14, 2026
  23. Junio C HamanoSep 15, 2026
  24. Andrew PleeterSep 15, 2026
  25. Phillip WoodSep 22, 2026
  26. Andrew PleeterSep 26, 2026
  27. 0/4 var: -z output, multiple variables, and broken-out identsAndrew Pleeter, Sep 26, 2026
  28. Phillip WoodOct 2, 2026
  29. Andrew PleeterOct 2, 2026
  30. 1/4 var: represent multi-valued variables with a string_listAndrew Pleeter, Sep 26, 2026
  31. 2/4 var: add "-z" output modeAndrew Pleeter, Sep 26, 2026
  32. 3/4 var: accept more than one variableAndrew Pleeter, Sep 26, 2026
  33. Phillip WoodOct 2, 2026
  34. 4/4 var: add broken-out identity variablesAndrew Pleeter, Sep 26, 2026
  35. Phillip WoodOct 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.