All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Shawn Pearce <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/5] Log ref updates made by fetch.
Date: Fri, 19 May 2006 00:56:10 -0700	[thread overview]
Message-ID: <7vodxuih2d.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20060519072926.GE22257@spearce.org> (Shawn Pearce's message of "Fri, 19 May 2006 03:29:26 -0400")

Shawn Pearce <spearce@spearce.org> writes:

> diff --git a/refs.c b/refs.c
> index 31cf276..d3ddc82 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -142,6 +142,8 @@ static int do_for_each_ref(const char *b
>  			namelen = strlen(de->d_name);
>  			if (namelen > 255)
>  				continue;
> +			if (namelen>5 && !strcmp(de->d_name+namelen-5,".lock"))
> +				continue;
>  			memcpy(path + baselen, de->d_name, namelen+1);
>  			if (stat(git_path("%s", path), &st) < 0)
>  				continue;

Now this got me worried.  Until now I did not realize that we
are clobbering refnames that ends with ".lock" if another ref
with the name without ".locK" is updated.  Because we do not
forbid a name that ends with ".lock" to be used as a refname,
this is an accident waiting to happen.

Not your fault, though.  It was like this ever since the initial
version of refs.c was accepted by Linus.

We could do one of two things: officially forbid any refname
that ends with ".lock", or fix the lockfile naming convention.

Nobody should be relying on what the actual lockfile-to-be-
renamed-to-become-the-real-file is called.  I suspect we would
want to fix refs.c::ref_lock_file_name() to use a name that
would never be used as a refname.

We could make it begin with ".", so the lock file for the master
".git/refs/heads/master" would become ".git/refs/heads/.master",
for example.  That way, we cannot clobber a valid unrelated ref
(".master" is not a valid ref name), and as an added bonus, you
do not even have to have the above hunk.

Hmm?

  reply	other threads:[~2006-05-19  7:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-19  7:29 [PATCH 4/5] Log ref updates made by fetch Shawn Pearce
2006-05-19  7:56 ` Junio C Hamano [this message]
2006-05-19  8:03   ` Shawn Pearce

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=7vodxuih2d.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.