{"thread":{"id":"9171","subject":"[PATCH] Teach \"git stripspace\" the --strip-comments option","startedAt":"2007-07-23T11:58:27Z","lastAt":"2007-07-23T11:58:27Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48304","messageId":"Pine.LNX.4.64.0707231258100.14781@racer.site","threadId":"9171","inReplyTo":null,"subject":"[PATCH] Teach \"git stripspace\" the --strip-comments option","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-23T11:58:27Z","receivedAt":"2007-07-23T11:58:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWith --strip-comments (or short -s), git stripspace now removes lines\nbeginning with a '#', too.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Documentation/git-stripspace.txt |    5 ++++-\n builtin-stripspace.c             |    7 ++++++-\n t/t0030-stripspace.sh            |    5 +++++\n 3 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-stripspace.txt b/Documentation/git-stripspace.txt\nindex 1306d7b..5212358 100644\n--- a/Documentation/git-stripspace.txt\n+++ b/Documentation/git-stripspace.txt\n@@ -8,7 +8,7 @@ git-stripspace - Filter out empty lines\n \n SYNOPSIS\n --------\n-'git-stripspace' < <stream>\n+'git-stripspace' [-s | --strip-comments] < <stream>\n \n DESCRIPTION\n -----------\n@@ -16,6 +16,9 @@ Remove multiple empty lines, and empty lines at beginning and end.\n \n OPTIONS\n -------\n+-s\\|--strip-comments::\n+\tIn addition to empty lines, also strip lines starting with '#'.\n+\n <stream>::\n \tByte stream to act on.\n \ndiff --git a/builtin-stripspace.c b/builtin-stripspace.c\nindex 5571687..916355c 100644\n--- a/builtin-stripspace.c\n+++ b/builtin-stripspace.c\n@@ -76,6 +76,11 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)\n {\n \tchar *buffer;\n \tunsigned long size;\n+\tint strip_comments = 0;\n+\n+\tif (argc > 1 && (!strcmp(argv[1], \"-s\") ||\n+\t\t\t\t!strcmp(argv[1], \"--strip-comments\")))\n+\t\tstrip_comments = 1;\n \n \tsize = 1024;\n \tbuffer = xmalloc(size);\n@@ -84,7 +89,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)\n \t\tdie(\"could not read the input\");\n \t}\n \n-\tsize = stripspace(buffer, size, 0);\n+\tsize = stripspace(buffer, size, strip_comments);\n \twrite_or_die(1, buffer, size);\n \tif (size)\n \t\tputc('\\n', stdout);\ndiff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh\nindex b1c9003..cad95f3 100755\n--- a/t/t0030-stripspace.sh\n+++ b/t/t0030-stripspace.sh\n@@ -392,4 +392,9 @@ test_expect_success \\\n     git diff expect actual\n '\n \n+test_expect_success 'strip comments, too' '\n+\ttest ! -z \"$(echo \"# comment\" | git stripspace)\" &&\n+\ttest -z \"$(echo \"# comment\" | git stripspace -s)\"\n+'\n+\n test_done\n-- \n1.5.3.rc2.32.g35c5b\n"}]}