From: Pieter de Bie Date: Thu, 31 Jul 2008 13:20:34 +0000 (+0200) Subject: git-name-rev: allow --name-only in combination with --stdin X-Git-Tag: v1.5.6.5~8 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b003c00b7b5e352569061fec0b1e1bd0d0fa8b6a;p=git.git git-name-rev: allow --name-only in combination with --stdin Signed-off-by: Pieter de Bie Signed-off-by: Junio C Hamano --- diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index ffac3f8f5..83d8e4a9f 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -38,8 +38,7 @@ OPTIONS Instead of printing both the SHA-1 and the name, print only the name. If given with --tags the usual tag prefix of "tags/" is also omitted from the name, matching the output - of linkgit:git-describe[1] more closely. This option - cannot be combined with --stdin. + of linkgit:git-describe[1] more closely. --no-undefined:: Die with error code != 0 when a reference is undefined, diff --git a/builtin-name-rev.c b/builtin-name-rev.c index b75c73b22..ff7d638dc 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -204,8 +204,13 @@ static void name_rev_line(char *p, struct name_ref_data *data) if (!name) continue; - fwrite(p_start, p - p_start + 1, 1, stdout); - printf(" (%s)", name); + 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); + } p_start = p + 1; } }