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

Re: [RFC] Detached-HEAD reminder on commit?

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 2, 2008, 22:50 UTC
Message-ID
<7vabeqi2n3.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<g9kdn4$rgs$1@ger.gmane.org>
Jakub Narebski <jnareb@gmail.com> writes:
Show 10 quoted lines
> Perhaps instead of poposed patch we should simply put empty lines
> to emphasize that we are on no branch:
>
>         # Please enter the commit message for your changes. Lines starting
>         # with '#' will be ignored, and an empty message aborts the commit.
>         #
>         # Not currently on any branch.
>         #
>         # Untracked files:
>         #   (use "git add <file>..." to include in what will be committed)
That sounds sensible, easy and safe enough.
 wt-status.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
diff --git i/wt-status.c w/wt-status.c
index 889e50f..97076e8 100644
--- i/wt-status.c
+++ w/wt-status.c
@@ -342,17 +342,17 @@ void wt_status_print(struct wt_status *s)
 
 	s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
 	if (s->branch) {
-		const char *on_what = "On branch ";
-		const char *branch_name = s->branch;
-		if (!prefixcmp(branch_name, "refs/heads/"))
-			branch_name += 11;
-		else if (!strcmp(branch_name, "HEAD")) {
-			branch_name = "";
-			branch_color = color(WT_STATUS_NOBRANCH);
-			on_what = "Not currently on any branch.";
+		if (!prefixcmp(s->branch, "refs/heads/")) {
+			color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+			color_fprintf_ln(s->fp, branch_color,
+					 "On branch %s", s->branch + 11);
+		} else if (!strcmp(s->branch, "HEAD")) {
+			color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+			color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+			color_fprintf_ln(s->fp, color(WT_STATUS_NOBRANCH),
+					 "Not currently on any branch.");
+			color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
 		}
-		color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
-		color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
 		if (!s->is_initial)
 			wt_status_print_tracking(s);
 	}
Previous: Jakub NarebskiNext: Nicolas Pitre
Message 31 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.