Skip to content

Commit

Permalink
git-name-rev: allow --name-only in combination with --stdin
Browse files Browse the repository at this point in the history
Signed-off-by: Pieter de Bie <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
pieter authored and gitster committed Aug 2, 2008
1 parent e8b55fa commit b003c00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions Documentation/git-name-rev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions builtin-name-rev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit b003c00

Please sign in to comment.