git-name-rev: allow --name-only in combination with --stdin
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pieter de Bie committed
Jul 31, 2008 at 15:20 UTC
b003c00b7b5e352569061fec0b1e1bd0d0fa8b6a
2 files changed
+8
-4
Documentation/git-name-rev.txt
+1
-2
@@ -38,8 +38,7 @@ OPTIONS
38
Instead of printing both the SHA-1 and the name, print only
39
the name. If given with --tags the usual tag prefix of
40
"tags/" is also omitted from the name, matching the output
41
- of linkgit:git-describe[1] more closely. This option
42
- cannot be combined with --stdin.
41
+ of linkgit:git-describe[1] more closely.
42
43
--no-undefined::
44
Die with error code != 0 when a reference is undefined,
builtin-name-rev.c
+7
-2
@@ -204,8 +204,13 @@ static void name_rev_line(char *p, struct name_ref_data *data)
204
if (!name)
205
continue;
206
207
- fwrite(p_start, p - p_start + 1, 1, stdout);
208
- printf(" (%s)", name);
207
+ if (data->name_only) {
208
+ fwrite(p_start, p - p_start + 1 - 40, 1, stdout);
209
+ printf(name);
210
+ } else {
211
+ fwrite(p_start, p - p_start + 1, 1, stdout);
212
+ printf(" (%s)", name);
213
+ }
214
p_start = p + 1;
215
}
216
}