summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ae68fc)
raw | patch | inline | side by side (parent: 2ae68fc)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Mon, 23 Jul 2007 11:58:27 +0000 (12:58 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 27 Jul 2007 05:51:44 +0000 (22:51 -0700) |
With --strip-comments (or short -s), git stripspace now removes lines
beginning with a '#', too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
beginning with a '#', too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-stripspace.txt | patch | blob | history | |
builtin-stripspace.c | patch | blob | history | |
t/t0030-stripspace.sh | patch | blob | history |
index 1306d7bab70efb57cba62a98ebd2d67b06677c97..5212358306a684c006e8ca30c3f7e21fb3c97afb 100644 (file)
SYNOPSIS
--------
-'git-stripspace' < <stream>
+'git-stripspace' [-s | --strip-comments] < <stream>
DESCRIPTION
-----------
OPTIONS
-------
+-s\|--strip-comments::
+ In addition to empty lines, also strip lines starting with '#'.
+
<stream>::
Byte stream to act on.
diff --git a/builtin-stripspace.c b/builtin-stripspace.c
index 55716873dc4f4a8baa5f2b37d6dca1de488b38e4..916355ca5d04ec571d4100c98b969b693c830a18 100644 (file)
--- a/builtin-stripspace.c
+++ b/builtin-stripspace.c
{
char *buffer;
unsigned long size;
+ int strip_comments = 0;
+
+ if (argc > 1 && (!strcmp(argv[1], "-s") ||
+ !strcmp(argv[1], "--strip-comments")))
+ strip_comments = 1;
size = 1024;
buffer = xmalloc(size);
die("could not read the input");
}
- size = stripspace(buffer, size, 0);
+ size = stripspace(buffer, size, strip_comments);
write_or_die(1, buffer, size);
if (size)
putc('\n', stdout);
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index b1c900379b22076ad69fa5d585fc9cbc0dc27c21..cad95f35adad5864e99ef5cd1633c820ff25b6c0 100755 (executable)
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
git diff expect actual
'
+test_expect_success 'strip comments, too' '
+ test ! -z "$(echo "# comment" | git stripspace)" &&
+ test -z "$(echo "# comment" | git stripspace -s)"
+'
+
test_done