aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-06-14 03:27:21 -0400
committerJunio C Hamano <gitster@pobox.com>2008-06-14 11:39:16 -0700
commit44d86e910d61dab4f059d86705599bbb2747b10f (patch)
tree177b3233ec2c4f1629d421201b650cf5a6059f96
parent74f16b0c6fece88f585f9556fa1d3a7406e7a42e (diff)
downloadgit-44d86e910d61dab4f059d86705599bbb2747b10f.tar.gz
git-44d86e910d61dab4f059d86705599bbb2747b10f.tar.xz
avoid whitespace on empty line in automatic usage message
When outputting a usage message with a blank line in the header, we would output a line with four spaces. Make this truly a blank line. This helps us remove trailing whitespace from a test vector. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--parse-options.c8
-rwxr-xr-xt/t1502-rev-parse-parseopt.sh2
2 files changed, 7 insertions, 3 deletions
diff --git a/parse-options.c b/parse-options.c
index acf3fe3a1..8071711e5 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -312,8 +312,12 @@ void usage_with_options_internal(const char * const *usagestr,
fprintf(stderr, "usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
- while (*usagestr)
- fprintf(stderr, " %s\n", *usagestr++);
+ while (*usagestr) {
+ fprintf(stderr, "%s%s\n",
+ **usagestr ? " " : "",
+ *usagestr);
+ usagestr++;
+ }
if (opts->type != OPTION_GROUP)
fputc('\n', stderr);
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index d24a47d11..7cdd70a18 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -5,7 +5,7 @@ test_description='test git rev-parse --parseopt'
cat > expect.err <<EOF
usage: some-command [options] <args>...
-
+
some-command does foo and bar!
-h, --help show the help