git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-name-rev: allow --name-only in combination with --stdin

From
PBPieter de Bie <pdebie@ai.rug.nl>
Date
Jul 31, 2008, 13:20 UTC
Message-ID
<1217510434-94979-1-git-send-email-pdebie@ai.rug.nl>
Signed-off-by: Pieter de Bie <pdebie@ai.rug.nl>
---
	Or was there a specific reason not to allow this?
 Documentation/git-name-rev.txt |    3 +--
 builtin-name-rev.c             |   10 ++++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt
index 6e77ab1..c8a72dd 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 'git-describe' more closely.  This option
-	cannot be combined with --stdin.
+	of 'git-describe' 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 85612c4..0536af4 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -266,8 +266,14 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 					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;
 				}
 			}
-- 
1.6.0.rc1.163.gc85c5.dirty
Next: Junio C Hamano
Message 1 of 8 in “git-name-rev: allow --name-only in combination with --stdin”
  1. git-name-rev: allow --name-only in combination with --stdinPieter de Bie, Jul 31, 2008
  2. Junio C HamanoAug 1, 2008
  3. Johannes SchindelinAug 1, 2008
  4. builtin-name-rev: refactor stdin handling to its own functionPieter de Bie, Aug 1, 2008
  5. Junio C HamanoAug 1, 2008
  6. Junio C HamanoAug 2, 2008
  7. git-name-rev: don't use printf without formatRené Scharfe, Aug 3, 2008
  8. Junio C HamanoAug 3, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.