Note that git-branch will not automatically checkout the new branch
[gitweb.git] / builtin-stripspace.c
index 0c970aa945a5ae615a2a7af2b2c0c75fb14f0b8e..916355ca5d04ec571d4100c98b969b693c830a18 100644 (file)
@@ -76,13 +76,20 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
 {
        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);
-       if (read_pipe(0, &buffer, &size))
+       if (read_fd(0, &buffer, &size)) {
+               free(buffer);
                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);