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

Re: [PATCH v2] builtin/ident: add new 'ident' command

From
Jeff King <peff@peff.net>
Date
Sep 1, 2026, 04:39 UTC
Message-ID
<20260901043944.GA1074757@coredump.intra.peff.net>
In-Reply-To
<pull.2388.v2.git.git.1788220746663.gitgitgadget@gmail.com>
On Mon, Aug 31, 2026 at 11:59:06PM +0000, Andrew Pleeter via GitGitGadget wrote:
Show 7 quoted lines
> While existing plumbing commands like 'git var' and 'git config' expose
> individual pieces of identity and configuration, discovering what identity
> and signing key will actually be attached to a new commit requires multiple
> independent queries and manual correlation. 'git config' only reads raw
> values without performing environment overrides or GECOS detection, while
> 'git var' returns full ident strings with timestamps without exposing
> commit signing status.

This is just my gut reaction, but: would it be simpler to teach git var to provide those broken-down pieces than to introduce a whole new command?

This works now:
  git var GIT_COMMITTER_IDENT
but why not:
  git var GIT_COMMITTER_NAME
  git var GIT_COMMITTER_EMAIL
  git var GIT_COMMITTER_DATE

Those are well-known names already; they're what we use for reading in the broken-down values from the environment. And likewise for GIT_AUTHOR_*.

Let's see what else is in your feature list:
> 'git ident' provides a unified command with additive, composable options:
>   - Identity scope selectors (-a / --author, -c / --committer) choose
>     which identities to format (defaulting to both when neither is specified).
I think that works by switching between the two var families above.
>   - Component selectors (-n / --name, -e / --email) choose which parts
>     to format (defaulting to full 'Name <email>' when neither or both are
>     specified).

We don't allow mix-and-match here (nor even multiple values!), so you'd have to do:

  ident="$(git var GIT_AUTHOR_NAME) <$(git var GIT_AUTHOR_EMAIL)"

I think it would be reasonable for git-var to accept multiple values and output them one per line (or with NULs via "-z"). That doesn't really make things easier in shell, but it might help scripts in other languages.

We _could_ go as far as providing a format language like we do in for-each-ref, etc, where we offer to shell-quote. And then you can do:

  eval "$(git var --shell-quote --format='
		name=%(GIT_AUTHOR_NAME)
		email=%(GIT_AUTHOR_EMAIL)
	')"

but IMHO that is probably going too far. It sometimes lets you simplify shell use of the tool at the expense of a weird and complicated interface (I kind of which we didn't have it in for-each-ref).

>   - -v / --verbose prepends 'Author: ' or 'Committer: ' role labels.
Seems like something that git-var might benefit from, too.
>   - -s / --signing-key resolves and outputs the commit signing key.
Likewise, this feels like it should be a git-var entry.
>   - --porcelain produces machine-readable key-value pairs.
>   - -z / --null terminates output records with NUL bytes.
Likewise.
My main feeling on suggesting this is that:
  1. We already have a lot of commands, and this one feels very
     specialized.
  2. Most of these suggestions could make git-var better for reading
     idents _and_ for reading its other variables.
-Peff
Previous: Andrew Pleeter via GitGitGadgetNext: Junio C Hamano
Message 5 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.