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

Re: [PATCH] git commit: Repaint the output format bikeshed (again)

From
JKJeff King <jrk@wrek.org>
Date
Oct 1, 2008, 22:06 UTC
Message-ID
<20081001220604.GB18058@coredump.intra.peff.net>
In-Reply-To
<48E3E66E.7020501@op5.se>
On Wed, Oct 01, 2008 at 11:06:54PM +0200, Andreas Ericsson wrote:
> of the commit result output. To make it read properly
> we get rid of "Created", which I just can't fit into
> a sentence without putting the branch-name last.

All of the other proposals indicate the hash and subject as the object of creation. IOW, "created: <hash>: subject" or similar.

Show 5 quoted lines
> Having taken inspiration from the "git reset" command,
> output for the three conceivable cases now look thus:
>
>  normal commit
>  <branch> is now at b930c4a (i386: Snib the sprock)
I think I still like your other proposal:
  [branch] created b930c4a: "i386: Snib the sprock"

better. But in the interests of just agreeing on something, I am willing to accept this. FWIW, the git-reset command doesn't use any delimiter for the message:

   <branch> is now at <hash> <subject>
So perhaps they should be the same. I don't think it overly matters.
>  detached commit
>  DETACHED HEAD is now at b930c4a (i386: Snib the sprock)

You mentioned the shouty caps before. I think "detached HEAD" is probably caps enough, but not enough to argue for it (I just want to mention as an informal vote if Shawn wants to mark it up while applying).

>  initial commit
>  History has begun anew. Root-commit created.
>  <branch> is now at bc930c4a (i386: Snib the sprock)
Heh.
Show 6 quoted lines
> "Created" is a problem when one wants to put branch-name before the
> subject line, because the subject has to follow the hash (it doesn't
> describe the pre-state of the branch/detached head), but the newly
> added commit. "Created, on branch, hash (subject)" just looks
> stilted and stupid, so I had to change it. Hopefully this can be
> accepted. If not, count me out.

That was the reason for the helper function that was deleted. It actually created a format string like "Created %h on <branch>: %s" and properly escaped the percents in <branch>. So you would have to keep it if you wanted to interleave the data (but I think what you have is better -- the branch name or the detached status is the thing that should be first).

> I'm not sure if the last "else" case setting branch = head; can
> ever happen, but I figured it can't hurt to make sure. Feel free
> to modify commentary around it or the entire section when applying.

It should definitely be there, if only for the sanity of future expansion (and because I can technically put whatever ref I want into HEAD :) ).

> -		printf("%s\n", buf.buf);
> -		strbuf_release(&buf);
> +		printf("%s\n", strbuf_detach(&buf, NULL));

This change is bogus. "release" frees a strbuf. "detach" says "Give me the buffer, and I will take care of freeing it later myself". So you introduced a leak.

-Peff
Previous: Andreas EricssonNext: Jeff King
Message 58 of 67 in “[RFC] Detached-HEAD reminder on commit?”
  1. Pieter de BieSep 2, 2008
  2. Robin RosenbergSep 2, 2008
  3. Nicolas PitreSep 2, 2008
  4. Matthieu MoySep 2, 2008
  5. Nicolas PitreSep 2, 2008
  6. Junio C HamanoSep 2, 2008
  7. Stephan BeyerSep 2, 2008
  8. Johan HerlandSep 2, 2008
  9. Jeff KingSep 2, 2008
  10. Jeff KingSep 2, 2008
  11. Johan HerlandSep 3, 2008
  12. Junio C HamanoSep 3, 2008
  13. Johan HerlandSep 3, 2008
  14. Jeff KingSep 3, 2008
  15. Jeff KingSep 3, 2008
  16. Andreas EricssonSep 3, 2008
  17. Daniel BarkalowSep 3, 2008
  18. Jeff KingSep 3, 2008
  19. Junio C HamanoSep 3, 2008
  20. Jeff KingSep 3, 2008
  21. Wincent ColaiutaSep 3, 2008
  22. Jeff KingSep 3, 2008
  23. Nicolas PitreSep 3, 2008
  24. Junio C HamanoSep 2, 2008
  25. Nicolas PitreSep 2, 2008
  26. Avery PennarunSep 4, 2008
  27. Junio C HamanoSep 4, 2008
  28. Junio C HamanoSep 5, 2008
  29. Pieter de BieSep 2, 2008
  30. Jakub NarebskiSep 2, 2008
  31. Junio C HamanoSep 2, 2008
  32. Nicolas PitreSep 2, 2008
  33. Pieter de BieSep 3, 2008
  34. Builtin-commit: show on which branch a commit was addedPieter de Bie, Sep 5, 2008
  35. Junio C HamanoSep 7, 2008
  36. Junio C HamanoSep 7, 2008
  37. 1/2 pretty.c: add %% format specifierPieter de Bie, Sep 7, 2008
  38. 2/2 builtin-commit: show on which branch a commit was addedPieter de Bie, Sep 7, 2008
  39. Jeff KingSep 21, 2008
  40. Pieter de BieSep 29, 2008
  41. Jeff KingSep 29, 2008
  42. Andreas EricssonSep 30, 2008
  43. Jeff KingSep 30, 2008
  44. Andreas EricssonSep 30, 2008
  45. git commit: Reformat output somewhatAndreas Ericsson, Sep 30, 2008
  46. Wincent ColaiutaSep 30, 2008
  47. Jeff KingSep 30, 2008
  48. Andreas EricssonSep 30, 2008
  49. Jeff KingOct 1, 2008
  50. Andreas EricssonOct 1, 2008
  51. Shawn O. PearceOct 1, 2008
  52. Andreas EricssonOct 1, 2008
  53. Jeff KingOct 1, 2008
  54. Shawn O. PearceOct 1, 2008
  55. Jeff KingOct 1, 2008
  56. Shawn O. PearceOct 1, 2008
  57. git commit: Repaint the output format bikeshed (again)Andreas Ericsson, Oct 1, 2008
  58. Jeff KingOct 1, 2008
  59. Jeff KingOct 1, 2008
  60. Andreas EricssonOct 2, 2008
  61. Jeff KingOct 2, 2008
  62. Shawn O. PearceOct 3, 2008
  63. Jeff KingOct 3, 2008
  64. Shawn O. PearceOct 3, 2008
  65. Jeff KingOct 4, 2008
  66. Wincent ColaiutaOct 2, 2008
  67. Jeff KingOct 1, 2008

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.