summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b003c00)
raw | patch | inline | side by side (parent: b003c00)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sun, 3 Aug 2008 13:44:33 +0000 (15:44 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 3 Aug 2008 19:48:41 +0000 (12:48 -0700) |
printf() without an explicit format string is not a good coding practise,
unless the printed string is guaranteed to not contain percent signs. While
fixing this, we might as well combine the calls to fwrite() and printf().
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unless the printed string is guaranteed to not contain percent signs. While
fixing this, we might as well combine the calls to fwrite() and printf().
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-name-rev.c | patch | blob | history |
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index ff7d638dc2b71c9c29441b842b49ccf03a9b4618..5352bc87b9ab5177922039cfec48a2fda8bd50a6 100644 (file)
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
unsigned char sha1[40];
const char *name = NULL;
char c = *(p+1);
+ int p_len = p - p_start + 1;
forty = 0;
if (!name)
continue;
- if (data->name_only) {
- fwrite(p_start, p - p_start + 1 - 40, 1, stdout);
- printf(name);
- } else {
- fwrite(p_start, p - p_start + 1, 1, stdout);
- printf(" (%s)", name);
- }
+ if (data->name_only)
+ printf("%.*s%s", p_len - 40, p_start, name);
+ else
+ printf("%.*s (%s)", p_len, p_start, name);
p_start = p + 1;
}
}