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

[PATCH 1/2] Contextually notify user about an initial commit

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Jun 19, 2017, 02:41 UTC
Message-ID
<20170619024123.5438-1-kaarticsivaraam91196@gmail.com>
In-Reply-To
<87shix8zik.fsf@gmail.com>

"git status" indicated "Initial commit" when HEAD points at an unborn branch. This message is shared with the commit log template "git commit" prepares for the user when creating a commit (i.e. "You are about to create the initial commit"), and is OK as long as the reader is aware of the nature of the message (i.e. it guides the user working toward the next commit), but was confusing to new users, especially the ones who do "git commit -m message" without having a chance to pay attention to the commit log template.

The "Initial commit" indication wasn't an issue in the commit template. Taking that into consideration, a good solution would be to contextually use different messages to indicate the user that there were no commits in this branch.

A few alternatives considered were,
* Waiting for initial commit
* Your current branch does not have any commits
* Current branch waiting for initial commit
Patch-derived-from: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
---
  Hope this would be final :)
 builtin/commit.c | 1 +
 wt-status.c      | 5 ++++-
 wt-status.h      | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index 1d805f5da..0f36d2ac3 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1648,6 +1648,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 		usage_with_options(builtin_commit_usage, builtin_commit_options);
 
 	status_init_config(&s, git_commit_config);
+	s.commit_template = 1;
 	status_format = STATUS_FORMAT_NONE; /* Ignore status.short */
 	s.colopts = 0;
 
diff --git a/wt-status.c b/wt-status.c
index 037548496..e6a9ee34f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1576,7 +1576,10 @@ static void wt_longstatus_print(struct wt_status *s)
 
 	if (s->is_initial) {
 		status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
-		status_printf_ln(s, color(WT_STATUS_HEADER, s), _("Initial commit"));
+		status_printf_ln(s, color(WT_STATUS_HEADER, s),
+				 s->commit_template
+				 ? _("Initial commit")
+				 : _("No commits yet"));
 		status_printf_ln(s, color(WT_STATUS_HEADER, s), "%s", "");
 	}
 
diff --git a/wt-status.h b/wt-status.h
index 6018c627b..782b2997f 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -76,6 +76,7 @@ struct wt_status {
 	char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
 	unsigned colopts;
 	int null_termination;
+	int commit_template;
 	int show_branch;
 	int hints;
 
-- 
2.11.0
Previous: Ævar Arnfjörð BjarmasonNext: Kaartic Sivaraam
Message 22 of 48 in “wt-status.c: Modified status message shown for a parent-less branch”
  1. wt-status.c: Modified status message shown for a parent-less branchKaartic Sivaraam, Jun 10, 2017
  2. Kaartic SivaraamJun 10, 2017
  3. Junio C HamanoJun 10, 2017
  4. Kaartic SivaraamJun 10, 2017
  5. Kaartic SivaraamJun 10, 2017
  6. Jeff KingJun 10, 2017
  7. Junio C HamanoJun 10, 2017
  8. Kaartic SivaraamJun 12, 2017
  9. Junio C HamanoJun 12, 2017
  10. Jeff KingJun 12, 2017
  11. Junio C HamanoJun 12, 2017
  12. Jeff KingJun 12, 2017
  13. Kaartic SivaraamJun 15, 2017
  14. Jeff KingJun 15, 2017
  15. Samuel LijinJun 15, 2017
  16. Jeff KingJun 15, 2017
  17. Kaartic SivaraamJun 16, 2017
  18. Jeff KingJun 16, 2017
  19. Kaartic SivaraamJun 18, 2017
  20. Contextually notify user about an initial commitKaartic Sivaraam, Jun 18, 2017
  21. Ævar Arnfjörð BjarmasonJun 18, 2017
  22. 1/2 Contextually notify user about an initial commitKaartic Sivaraam, Jun 19, 2017
  23. 2/2 Add test for the new status messageKaartic Sivaraam, Jun 19, 2017
  24. Junio C HamanoJun 19, 2017
  25. Kaartic SivaraamJun 19, 2017
  26. Jeff KingJun 19, 2017
  27. Kaartic SivaraamJun 19, 2017
  28. Junio C HamanoJun 19, 2017
  29. 2/2 Add test for the new status messageKaartic Sivaraam, Jun 19, 2017
  30. Jeff KingJun 19, 2017
  31. Kaartic SivaraamJun 19, 2017
  32. Junio C HamanoJun 19, 2017
  33. 1/3 Contextually notify user about an initial commitKaartic Sivaraam, Jun 20, 2017
  34. 2/3 Update test(s) that used old status messageKaartic Sivaraam, Jun 20, 2017
  35. 3/3 Add tests for the contextual initial status messageKaartic Sivaraam, Jun 20, 2017
  36. Ævar Arnfjörð BjarmasonJun 20, 2017
  37. Kaartic SivaraamJun 20, 2017
  38. Ævar Arnfjörð BjarmasonJun 20, 2017
  39. Kaartic SivaraamJun 21, 2017
  40. status: contextually notify user about an initial commitKaartic Sivaraam, Jun 21, 2017
  41. Kaartic SivaraamJun 21, 2017
  42. Ævar Arnfjörð BjarmasonJun 21, 2017
  43. Kaartic SivaraamJun 21, 2017
  44. Junio C HamanoJun 21, 2017
  45. status: contextually notify user about an initial commitKaartic Sivaraam, Jun 21, 2017
  46. Junio C HamanoJun 22, 2017
  47. Kaartic SivaraamJun 22, 2017
  48. Philip OakleyJun 10, 2017

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.