Skip to contentSkip to conversation

Make commit help text more accurate for --verbose

PATCH In review Ramana Kumar 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make commit help text more accurate for --verbose

Commit message help text says lines starting with '#' will be ignored. The diff lines added by --verbose are also ignored, although they don't start with '#'s. Extend help text to describe behavior on diff lines when relevant.

---
 builtin/commit.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
builtin/commit.c +18 -7
index 66fdd22..b49fd7a 100644
@@ -658,17 +658,28 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
 		fprintf(fp,
 			"\n"
 			"# Please enter the commit message for your changes.");
-		if (cleanup_mode == CLEANUP_ALL)
+		if (cleanup_mode == CLEANUP_ALL && !verbose)
 			fprintf(fp,
 				" Lines starting\n"
 				"# with '#' will be ignored, and an empty"
 				" message aborts the commit.\n");
-		else /* CLEANUP_SPACE, that is. */
-			fprintf(fp,
-				" Lines starting\n"
-				"# with '#' will be kept; you may remove them"
-				" yourself if you want to.\n"
-				"# An empty message aborts the commit.\n");
+    else {
+      if (cleanup_mode == CLEANUP_ALL)
+        fprintf(fp,
+          " Lines starting\n"
+          "# with '#' will be ignored, as will"
+          " the diff and anything below it.\n");
+      else { /* CLEANUP_SPACE, that is. */
+        fprintf(fp,
+          " Lines starting\n"
+          "# with '#' will be kept; you may remove them"
+          " yourself if you want to.\n");
+        if (verbose)
+          fprintf(fp,
+            "# The diff and anything below it will be ignored.\n");
+      }
+      fprintf(fp, "# An empty message aborts the commit.\n");
+    }
 		if (only_include_assumed)
 			fprintf(fp, "# %s\n", only_include_assumed);
 
Signature · 1 line
1.7.2.2
#1 lore raw

Hi Ramana,

Some *style* comments below.

Quoted 9 lines · Ramana Kumar

               fprintf(fp,
                       "\n"
                       "# Please enter the commit message for your changes.");
-               if (cleanup_mode == CLEANUP_ALL)
+               if (cleanup_mode == CLEANUP_ALL && !verbose) fprintf(fp,
                               " Lines starting\n"
                               "# with '#' will be ignored, and an empty" " message aborts the commit.\n");

The Documentation/CodingStyle says to avoid using braces unncessary. But since this is not a single line statement, like:
if (foo)
foo = x;

Could you wrapp this into { } ?

Quoted 4 lines

-               else /* CLEANUP_SPACE, that is. */
-                       fprintf(fp,
-                               " Lines starting\n"
-                               "# with '#' will be kept; you may remove them"

Quoted 8 lines

-                               " yourself if you want to.\n"
-                               "# An empty message aborts the commit.\n");
+    else {
+      if (cleanup_mode == CLEANUP_ALL)
+        fprintf(fp,
+          " Lines starting\n"
+          "# with '#' will be ignored, as will"
+          " the diff and anything below it.\n");

Same thing here (and below) as pointed above.

Quoted 14 lines

+      else { /* CLEANUP_SPACE, that is. */
+        fprintf(fp,
+          " Lines starting\n"
+          "# with '#' will be kept; you may remove them"
+          " yourself if you want to.\n");
+        if (verbose)
+          fprintf(fp,
+            "# The diff and anything below it will be ignored.\n");
+      }
+      fprintf(fp, "# An empty message aborts the commit.\n");
+    }
               if (only_include_assumed)
                       fprintf(fp, "# %s\n", only_include_assumed);

#2 lore raw
Quoted 13 lines · Thiago Farina

Hi Ramana,

Some *style* comments below.

Quoted 9 lines · Ramana Kumar

               fprintf(fp,
                       "\n"
                       "# Please enter the commit message for your changes.");
-               if (cleanup_mode == CLEANUP_ALL)
+               if (cleanup_mode == CLEANUP_ALL && !verbose) fprintf(fp,
                               " Lines starting\n"
                               "# with '#' will be ignored, and an empty" " message aborts the commit.\n");

Quoted 6 lines

The Documentation/CodingStyle says to avoid using braces unncessary. But since this is not a single line statement, like:
if (foo)
 foo = x;

Could you wrapp this into { } ?

The braces are still unncessary if the function call is spread across a few lines. I haven't seen anything in the source that indicates that we prefer braces when a braceless if/else has an associated statement that exceeds 1 line.

#3 lore raw
Quoted 19 lines · Ævar Arnfjörð Bjarmason
Quoted 18 lines · Thiago Farina

Hi Ramana,

Some *style* comments below.

Quoted 9 lines · Ramana Kumar

               fprintf(fp,
                       "\n"
                       "# Please enter the commit message for your changes.");
-               if (cleanup_mode == CLEANUP_ALL)
+               if (cleanup_mode == CLEANUP_ALL && !verbose) fprintf(fp,
                               " Lines starting\n"
                               "# with '#' will be ignored, and an empty" " message aborts the commit.\n");

The Documentation/CodingStyle says to avoid using braces unncessary. But since this is not a single line statement, like:
if (foo)
 foo = x;

Quoted 6 lines
Quoted 1 line

Could you wrapp this into { } ?

The braces are still unncessary if the function call is spread across a few lines. I haven't seen anything in the source that indicates that we prefer braces when a braceless if/else has an associated statement that exceeds 1 line.

Any other suggestions to improve this patch?