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

[PATCH 2/3] builtin-commit: shorten eye-sore overlong lines

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2009, 06:19 UTC
Message-ID
<7v63k64k9z.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<7viqo64kfo.fsf@gitster.siamese.dyndns.org>

This does not change anything other than the way the variable to hold an informative message thrown in the commit log buffer is assigned.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This does not really belong to the series in the sense that it is
   needed to implement the new semantics, but these long lines have always
   bothered me.
 builtin-commit.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 7aaa530..d861263 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -71,6 +71,29 @@ static int use_editor = 1, initial_commit, in_merge;
 static const char *only_include_assumed;
 static struct strbuf message;
 
+enum {
+	MSG_AMEND_CLEVER,
+	MSG_ASSUME_PARTIAL,
+};
+
+static void set_partial_commit_message(int msgnum)
+{
+	const char *msg;
+
+	switch (msgnum) {
+	case MSG_AMEND_CLEVER:
+		msg = "Clever... amending the last one with dirty index.";
+		break;
+	case MSG_ASSUME_PARTIAL:
+		msg = "Explicit paths specified without -i nor -o; assuming --only paths...";
+		break;
+	default:
+		die("Oops (%d) is not a valid message number", msgnum);
+		break;
+	}
+	only_include_assumed = msg;
+}
+
 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 {
 	struct strbuf *buf = opt->value;
@@ -788,9 +811,9 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	if (argc == 0 && (also || (only && !amend)))
 		die("No paths with --include/--only does not make sense.");
 	if (argc == 0 && only && amend)
-		only_include_assumed = "Clever... amending the last one with dirty index.";
+		set_partial_commit_message(MSG_AMEND_CLEVER);
 	if (argc > 0 && !also && !only)
-		only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
+		set_partial_commit_message(MSG_ASSUME_PARTIAL);
 	if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
 		cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
 	else if (!strcmp(cleanup_arg, "verbatim"))
-- 
1.6.1.265.g9a013
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 17 in “Short "git commit $file" syntax fails in the face of a resolved conflict”
  1. Asheesh LaroiaJan 21, 2009
  2. Michael J GruberJan 21, 2009
  3. Nathan YerglerJan 21, 2009
  4. Johannes SixtJan 22, 2009
  5. Nanako ShiraishiJan 23, 2009
  6. Asheesh LaroiaJan 23, 2009
  7. Junio C HamanoJan 23, 2009
  8. 1/3 Add "partial commit" tests during a conflicted mergeJunio C Hamano, Jan 23, 2009
  9. Johannes SixtJan 23, 2009
  10. Junio C HamanoJan 23, 2009
  11. Johannes SixtJan 23, 2009
  12. Junio C HamanoJan 23, 2009
  13. 2/3 builtin-commit: shorten eye-sore overlong linesJunio C Hamano, Jan 23, 2009
  14. 3/3 git commit: pathspec without -i/-o implies -i semantics during a mergeJunio C Hamano, Jan 23, 2009
  15. Pieter de BieJan 23, 2009
  16. Junio C HamanoJan 23, 2009
  17. Michael J GruberJan 22, 2009

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.