git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð" <avarab@gmail.com>, git <git@vger.kernel.org>,
	"David Turner" <dturner@twopensource.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Torsten Bögershausen" <tboegi@web.de>,
	"Christian Couder" <chriscool@tuxfamily.org>,
	"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>
Subject: Fwd: [PATCH 7/8] config: add core.untrackedCache
Date: Fri, 18 Dec 2015 23:38:35 +0100	[thread overview]
Message-ID: <CAP8UFD2=hGbUFg_wX-0r6QgW+44ZiX8iJPX5c1FGG-4H8i163A@mail.gmail.com> (raw)
In-Reply-To: <CAP8UFD0LAQG+gQ5EhYYLjo5=tpW3_ah6GV-mgRbgTjjgNmdorA@mail.gmail.com>

Sorry I sent this privately to Peff by mistake (once again).

---------- Forwarded message ----------
From: Christian Couder <christian.couder@gmail.com>
Date: Fri, Dec 18, 2015 at 11:09 PM
Subject: Re: [PATCH 7/8] config: add core.untrackedCache
To: Jeff King <peff@peff.net>


On Thu, Dec 17, 2015 at 8:44 AM, Jeff King <peff@peff.net> wrote:
> On Tue, Dec 15, 2015 at 10:05:57PM -0800, Junio C Hamano wrote:
>>
>> To put it another way, the "bit" in the index (i.e. the presence of
>> the cached data) is "Am I using the feature now?".  The effect of
>> the feature has to (and is designed to) persist, as it is a cache
>> and you do not want a stale cache to give you wrong answers.

Sorry if I repeat myself or misunderstood something, but in what I
implemented we either use the UC fully or we remove it, so it cannot
be stale vs git operations (like other changes in the index Duy talks
about).

And as we are caching directory mtimes and as we are comparing each
cached mtime with the current mtime of the original directory before
trusting the cached content related to the directory, a UC that is
stale vs working tree operations could result in time lost but not in
bad cached content used.

Or maybe if we are very unlucky and have two directories with exactly
the same mtime and the same name but not the same content, and if we
move away the directory the UC was made from, and then put the other
one at the path where the first one was. Yeah in this case you may get
bad results because bad UC content is used. But note that this case
can already happen now. It is a case that is inherent in using the UC.

>> There
>> is no "Do I want to use the feature?" preference, in other words.
>>
>> And I do not mind creating such a preference bit as a configuration.
>>
>> That is why I suggested such a configuration to cause the equivalent
>> of "update-index --untracked-cache" when a new index is created from
>> scratch (as opposed to the case where the previously created cache
>> data is carried forward across read_cache() -> do things to the
>> index -> write_cache() flow).  Doing it that way will not have to
>> involve additional complexity that comes from the desire that
>> setting a single configuration on (or off) has to suddenly change
>> the behaviour of an index file that is already using (or not using)
>> the feature.
>
> I think we may actually be thinking of the same thing. Naively, I would
> expect:
>
>   - if there is untracked cache data in the index, we will make use of
>     it when enumerating untracked files (and my understanding is that if
>     it is stale, we can detect that)

I agree for "git status", but I am not sure that the UC is used in all
the code paths that enumerate untracked files.
I recall Duy mentioning that it was not used by "git add" and in some
other cases, but I might be wrong.

I also agree that we can detect when the UC content should not be used
because it is stale vs working tree operations (see above).

Now as Duy says the UC should never be stale vs git operations, but
that is easy to do if we just remove the UC when we stop using it.

>   - if core.untrackedCache is set, we will update and write out an
>     untracked cache when we are enumerating the untracked files

In the current patch this happens when "git status" is called,
actually in wt_status_collect_untracked(), again I am not sure about
all the other code paths.

>   - if there is cache data in the index but that config flag is not set,
>     presumably we would not update it (we could even explicitly drop it,
>     but my understanding is that is not necessary for correctness, but
>     only as a possible optimization).

In the current patch we drop the UC, also in
wt_status_collect_untracked(), if the config flag is not set (or set
to false).

It is necessary to drop it for correctness for the following reasons:

- git operations on (other parts of) the index must update the UC if
it exists according to Duy who gave the following example in a
previous email:

"... if file "foo" is tracked, then the user does "git rm --cached
foo", "foo" may become either untracked or ignored. So if you disable
UC while doing this removal, then re-enable UC again, "git-status" may
show incorrect output."

- the user may have decided to unset the config flag because the mtime
features we rely on are in fact not well supported by the system.
(Though it's true that the user should have used "git update-index
--test-untracked-cache" before setting the config flag in the first
place, but maybe it was a mistake, or maybe the file system will be
accessed for some time by another system that will mount it or
something.)

> You could have a config option for "if there is a cache there, pretend
> it isn't and ignore it", but I don't see much point.

There is not much point indeed in such an option and it could be dangerous.

  parent reply	other threads:[~2015-12-18 22:38 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 17:15 [PATCH 0/8] Untracked cache improvements Christian Couder
2015-12-08 17:15 ` [PATCH 1/8] update-index: add untracked cache notifications Christian Couder
2015-12-08 19:03   ` Junio C Hamano
2015-12-11  8:51     ` Christian Couder
2015-12-08 17:15 ` [PATCH 2/8] update-index: use enum for untracked cache options Christian Couder
2015-12-08 19:11   ` Junio C Hamano
2015-12-10 10:37     ` Christian Couder
2015-12-10 18:46       ` Junio C Hamano
2015-12-11  9:10         ` Christian Couder
2015-12-11 17:44           ` Junio C Hamano
2015-12-12  9:25             ` Christian Couder
2015-12-08 17:15 ` [PATCH 3/8] update-index: add --test-untracked-cache Christian Couder
2015-12-08 17:15 ` [PATCH 4/8] update-index: move 'uc' var declaration Christian Couder
2015-12-08 17:15 ` [PATCH 5/8] dir: add add_untracked_cache() Christian Couder
2015-12-09  7:37   ` Torsten Bögershausen
2015-12-11  8:54     ` Christian Couder
2015-12-08 17:15 ` [PATCH 6/8] dir: add remove_untracked_cache() Christian Couder
2015-12-08 19:15   ` Junio C Hamano
2015-12-09  7:39   ` Torsten Bögershausen
2015-12-08 17:15 ` [PATCH 7/8] config: add core.untrackedCache Christian Couder
2015-12-08 19:28   ` Junio C Hamano
2015-12-08 22:43     ` Junio C Hamano
2015-12-14 12:18       ` Christian Couder
2015-12-14 19:44         ` Junio C Hamano
2015-12-14 21:30           ` Junio C Hamano
2015-12-15  9:34             ` Christian Couder
2015-12-15  9:49               ` Torsten Bögershausen
2015-12-15 16:42                 ` Christian Couder
2015-12-15 10:02               ` Duy Nguyen
2015-12-15 16:35                 ` Christian Couder
2015-12-15 13:04             ` Ævar Arnfjörð Bjarmason
2015-12-15 13:42               ` Christian Couder
2015-12-15 19:40               ` Junio C Hamano
2015-12-15 21:53                 ` Ævar Arnfjörð Bjarmason
2015-12-15 23:03                   ` Junio C Hamano
2015-12-16  1:10                     ` Ævar Arnfjörð Bjarmason
2015-12-16  2:46                     ` Jeff King
2015-12-16  5:20                       ` Junio C Hamano
2015-12-16  6:05                         ` Junio C Hamano
2015-12-17  7:44                           ` Jeff King
2015-12-17 12:26                             ` Duy Nguyen
     [not found]                               ` <CAP8UFD0S_rWKjWiq_enkN+QVtvnq9fuwAxuuVTXTxu-F1mw4dg@mail.gmail.com>
2015-12-18 22:40                                 ` Fwd: " Christian Couder
2015-12-21 18:30                               ` Junio C Hamano
2015-12-22  8:27                                 ` Duy Nguyen
2015-12-22 16:33                                   ` Junio C Hamano
2015-12-24  1:56                                     ` Junio C Hamano
2015-12-24  9:49                                       ` Duy Nguyen
2015-12-27 20:21                                         ` Junio C Hamano
2015-12-24 20:54                                       ` Christian Couder
     [not found]                             ` <CAP8UFD0LAQG+gQ5EhYYLjo5=tpW3_ah6GV-mgRbgTjjgNmdorA@mail.gmail.com>
2015-12-18 22:38                               ` Christian Couder [this message]
2015-12-17 12:36                   ` Duy Nguyen
2015-12-18 23:24                     ` Christian Couder
2015-12-09 13:19   ` Torsten Bögershausen
2015-12-08 17:15 ` [PATCH 8/8] t7063: add tests for core.untrackedCache Christian Couder

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='CAP8UFD2=hGbUFg_wX-0r6QgW+44ZiX8iJPX5c1FGG-4H8i163A@mail.gmail.com' \
    --to=christian.couder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=dturner@twopensource.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    --cc=tboegi@web.de \
    /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).