From: Junio C Hamano <junkio@cox.net>
To: Petr Baudis <pasky@ucw.cz>
Cc: Kay Sievers <kay.sievers@vrfy.org>, git@vger.kernel.org
Subject: Re: Broken adding of cache entries
Date: Sat, 07 May 2005 17:43:03 -0700 [thread overview]
Message-ID: <7vll6q8s4o.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20050507224116.GF9495@pasky.ji.cz> (Petr Baudis's message of "Sun, 8 May 2005 00:41:16 +0200")
>>>>> "PB" == Petr Baudis <pasky@ucw.cz> writes:
PB> What about
PB> ... suggested changes removed.
PB> then? (Completely untested and everything.)
It is clear that it is untested. In the sequence Kay had
trouble with:
$ rm -fr path; date >path
$ git-update-cache --add path
$ rm -f path; mkdir path; date >path/file
$ git-update-cache --add path/file
The cache_name_compare function you are looking at is called
with "path" and "path/file", and compares the name strings (up
to the length of the shorter one), and when they are the same,
then compares the lengths of them. At that point, the if()
statements have already answered that "path" comes before
"path/file" and your changes will _not_ change the behavior of
that function.
That said, I understand the behaviour you would want to see, and
I tend to agree that this should be prevented from happening in
the first place when git-update-cache happens. Let me think a
bit more about it.
PB> I'd still prefer add_cache_entry() to just replace the original entry
PB> (as it does otherwise).
I do not think it should just silently replace; instead it
should make the user take notice, because this is an unusual
situation. In other words, it should refuse until the user
makes a conscious decision to tell it that the user is removing
it and then placing something completely different.
This implies (I am thinking aloud here):
$ find fs -type f -print | xargs git-update-cache --add
$ rm -fr fs
$ date >fs
$ git-update-cache --add fs
would refuse to add "fs" because it notices it has some entry
whose "name" field starts with "fs/". Likewise, for the
opposite sequence:
$ date >fs
$ git-update-cache --add fs
$ rm -f fs; mkdir fs; date >fs/file
$ find fs -type f -print | xargs git-update-cache --add
Telling git-update-cache about anything that contains a '/' in
its name would first check if an entry whose name is exactly one
of the leading path prefix, and refuses the operation if it
finds one.
The above logic should work and it would also work if we decide
to just replace without refusing as well. I'll code it up and
see which one I like; maybe it will end up as an option.
next prev parent reply other threads:[~2005-05-08 0:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1115408460.32065.37.camel@localhost.localdomain>
[not found] ` <20050506231447.GG32629@pasky.ji.cz>
[not found] ` <1115421933.32065.111.camel@localhost.localdomain>
[not found] ` <20050506233003.GJ32629@pasky.ji.cz>
[not found] ` <1115423450.32065.138.camel@localhost.localdomain>
[not found] ` <20050507001409.GP32629@pasky.ji.cz>
[not found] ` <1115431767.32065.182.camel@localhost.localdomain>
2005-05-07 15:28 ` Broken adding of cache entries Petr Baudis
2005-05-07 18:42 ` Junio C Hamano
2005-05-07 19:22 ` Junio C Hamano
2005-05-07 22:41 ` Petr Baudis
2005-05-08 0:43 ` Junio C Hamano [this message]
2005-05-08 1:50 ` Junio C Hamano
2005-05-08 5:22 ` Junio C Hamano
2005-05-08 16:59 ` Petr Baudis
2005-05-08 21:06 ` Junio C Hamano
2005-05-08 21:22 ` Petr Baudis
2005-05-08 22:18 ` Junio C Hamano
2005-05-08 22:22 ` Junio C Hamano
2005-05-08 22:42 ` Junio C Hamano
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=7vll6q8s4o.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=kay.sievers@vrfy.org \
--cc=pasky@ucw.cz \
/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