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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Shawn O. Pearce" <spearce@xxxxxxxxxxx> writes:

> 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@xxxxxxxxxxx>
> ...
> 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)

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux