Re: [PATCH 4/8] rev-parse: teach "git rev-parse --symbolic" to print the full ref name
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 28, 2007, 07:28 UTC
- Message-ID
- <7v3avvy9yc.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <11935038083369-git-send-email-prohaska@zib.de>
Steffen Prohaska <prohaska@zib.de> writes:
> "git rev-parse --symbolic" used to return the ref name as it was > specified on the command line. This is changed to returning the > full matched ref name, i.e. "git rev-parse --symbolic master" > now typically returns "refs/heads/master".
This is to expose "dwim_ref" logic, so it might be a good idea to introduce a new option --dwim-ref for this purpose.
git rev-parse --symbolic master^2
is designed to give "master^2" or fail if "master" is not a merge. Similarly, you would diagnose a failure if somebody asks to show
git rev-parse --dwim-ref master~4
instead of giving "refs/heads/master~4".
Show 7 quoted lines
> +static void show_rev(int type, const unsigned char *sha1, const char *name, const char* real_name)
> @@ -131,7 +133,7 @@ static void show_default(void)
>
> def = NULL;
> if (!get_sha1(s, sha1)) {
> - show_rev(NORMAL, sha1, s);
> + show_rev(NORMAL, sha1, s, 0);A null pointer constant in git sources is spelled "NULL" not "0".
Show 5 quoted lines
> @@ -213,6 +215,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
> {
> int i, as_is = 0, verify = 0;
> unsigned char sha1[20];
> + char* real_name = 0;Pointer sign '*' in git sources go next to the name not the type, as:
char *real_name = NULL;