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

Re: [PATCH] Cross-reference the manpages for git-name-rev and git-describe

From
Junio C Hamano <junkio@cox.net>
Date
May 22, 2007, 06:13 UTC
Message-ID
<7vhcq59yiy.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070521072025.GO3141@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 38 quoted lines
> Teach git-describe how to run name-rev
>
> Often users want to know not which tagged version a commit came
> after, but which tagged version a commit is contained within.
> This latter task is the job of git-name-rev, but most users are
> looking to git-describe to do the job.
>
> Junio suggested we make `git describe --contains` run the correct
> tool, `git name-rev`, and that's exactly what we do here.  The output
> of name-rev was adjusted slightly through the new --name-only option,
> allowing describe to execv into name-rev and maintain its current
> output format.
>
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ...
> diff --git a/builtin-describe.c b/builtin-describe.c
> index 165917e..efbd43f 100644
> --- a/builtin-describe.c
> +++ b/builtin-describe.c
> ...
> @@ -272,6 +276,17 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
>  
>  	save_commit_buffer = 0;
>  
> +	if (contains) {
> +		const char **nr = xmalloc((4 + argc - i) * sizeof(char*));
> +		nr[0] = "name-rev";
> +		nr[1] = "--name-only";
> +		nr[2] = "--tags";
> +		memcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));
> +		nr[3 + argc - i] = NULL;
> +		execv_git_cmd(nr);
> +		die("unable to start %s", nr[0]);
> +	}
> +
>  	if (argc <= i)
>  		describe("HEAD", 1);
>  	else

Sorry for a belated question, but is there a reason not to do this (on top)?

diff --git a/builtin-describe.c b/builtin-describe.c
index efbd43f..2a32af6 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -283,8 +283,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 		nr[2] = "--tags";
 		memcpy(nr + 3, argv + i, (argc - i) * sizeof(char*));
 		nr[3 + argc - i] = NULL;
-		execv_git_cmd(nr);
-		die("unable to start %s", nr[0]);
+		return cmd_name_rev(3 + argc - i, nr, prefix);
 	}
 
 	if (argc <= i)
Previous: Matthieu MoyNext: Shawn O. Pearce
Message 16 of 17 in “Commits gone AWOL, but not reported by git-fsck --unreachable”
  1. Robin H. JohnsonMay 19, 2007
  2. Jeff KingMay 19, 2007
  3. Robin H. JohnsonMay 19, 2007
  4. Jeff KingMay 19, 2007
  5. Anand KumriaMay 19, 2007
  6. Matthieu MoyMay 19, 2007
  7. Brian GernhardtMay 19, 2007
  8. Matthieu MoyMay 19, 2007
  9. Brian GernhardtMay 19, 2007
  10. Junio C HamanoMay 19, 2007
  11. Cross-reference the manpages for git-name-rev and git-describe (was Re: Commits gone AWOL, but not reported by git-fsck --unreachable)Matthieu Moy, May 20, 2007
  12. Shawn O. PearceMay 21, 2007
  13. Junio C HamanoMay 21, 2007
  14. Shawn O. PearceMay 21, 2007
  15. Matthieu MoyMay 21, 2007
  16. Junio C HamanoMay 22, 2007
  17. Shawn O. PearceMay 22, 2007

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.