git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Schubert <mschub@elegosoft.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH] symbolic-ref: check format of given reference
Date: Tue, 19 Jun 2012 16:56:25 +0200	[thread overview]
Message-ID: <4FE09319.8000306@elegosoft.com> (raw)
In-Reply-To: <7vr4tc4lsc.fsf@alter.siamese.dyndns.org>

On 06/18/2012 06:39 PM, Junio C Hamano wrote:
> Michael Schubert <mschub@elegosoft.com> writes:
> 
>>>> Additionally, I had to reindent two lines to make git-am happy
>>>> (indent with spaces).
>>>
>>> I doubt that it is needed; the '-' lines show runs of HT followed by
>>> fewer than 8 SP, which should not trigger "indent with spaces".
>>
>> I've only noticed because git-am was telling me when I tried to
>> apply the patch.? Am I missing something?
> 
> Perhaps, but I cannot tell exactly what you are doing wrong.

Thunderbird replaced the tabs (but did not do that before). Sorry
for the noise.

> If you didn't touch lines you did not have to in a way to break
> indentation and cause "indent with spaces", "am" would not have
> complained (it only looks at "+" lines).
> 
> Attached is a patch based on your patch but removes the unnecessary
> re-indentation part, and "git am" happily applies it to my tree
> without complaining.  Does it apply for you (obviously to a revision
> without your patch) cleanly without complaint?

Works, Thanks.

> -- >8 --
> From: Michael Schubert <mschub@elegosoft.com>
> Date: Sun, 17 Jun 2012 22:26:37 +0200
> Subject: [PATCH] symbolic-ref: check format of given reference
> 
> Currently, it's possible to update HEAD with a nonsense reference since
> no strict validation is performed. Example:
> 
> 	$ git symbolic-ref HEAD 'refs/heads/master
>     >
>     >
>     > '
> 
> Fix this by checking the given reference with check_refname_format().
> 
> Signed-off-by: Michael Schubert <mschub@elegosoft.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  builtin/symbolic-ref.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
> index 801d62e..a529541 100644
> --- a/builtin/symbolic-ref.c
> +++ b/builtin/symbolic-ref.c
> @@ -44,13 +44,15 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
>  	git_config(git_default_config, NULL);
>  	argc = parse_options(argc, argv, prefix, options,
>  			     git_symbolic_ref_usage, 0);
> -	if (msg &&!*msg)
> +	if (msg && !*msg)
>  		die("Refusing to perform update with empty message");
>  	switch (argc) {
>  	case 1:
>  		check_symref(argv[0], quiet);
>  		break;
>  	case 2:
> +		if (check_refname_format(argv[1], 0))
> +			die("No valid reference format: '%s'", argv[1]);
>  		if (!strcmp(argv[0], "HEAD") &&
>  		    prefixcmp(argv[1], "refs/"))
>  			die("Refusing to point HEAD outside of refs/");
> 

      parent reply	other threads:[~2012-06-19 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-17 20:26 [PATCH] symbolic-ref: check format of given reference Michael Schubert
2012-06-17 20:55 ` Junio C Hamano
2012-06-18 12:02   ` Michael Schubert
2012-06-18 16:39     ` Junio C Hamano
2012-06-18 17:10       ` Junio C Hamano
2012-06-19 14:47         ` Jeff King
2012-06-19 14:52           ` Jeff King
2012-06-19 14:56       ` Michael Schubert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FE09319.8000306@elegosoft.com \
    --to=mschub@elegosoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).