From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
"David Turner" <dturner@twopensource.com>,
"Christian Couder" <chriscool@tuxfamily.org>
Subject: [RFC/PATCH] config: add core.trustmtime
Date: Wed, 25 Nov 2015 07:35:23 +0100 [thread overview]
Message-ID: <1448433323-21037-1-git-send-email-chriscool@tuxfamily.org> (raw)
When we know that mtime is fully supported by the environment, we
don't want any slow down because we used --untracked-cache rather
than --force-untracked-cache, and we don't want untracked cache to
stop working because we updated a kernel.
Also when we know that mtime is not supported by the environment,
for example because the repo is shared over a network file system,
then we might want 'git update-index --untracked-cache' to fail
immediately instead of it testing if it works (because it might
work on some systems using the repo over the network file system
but not others).
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
At Booking.com we know that mtime works everywhere and we don't
want the untracked cache to stop working when a kernel is upgraded
or when the repo is copied to a machine with a different kernel.
I will add tests later if people are ok with this.
Documentation/config.txt | 8 ++++++++
Documentation/git-update-index.txt | 6 +++++-
builtin/update-index.c | 6 +++++-
cache.h | 1 +
config.c | 7 +++++++
contrib/completion/git-completion.bash | 1 +
dir.c | 2 +-
environment.c | 1 +
8 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index b4b0194..186ad17 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -308,6 +308,14 @@ core.trustctime::
crawlers and some backup systems).
See linkgit:git-update-index[1]. True by default.
+core.trustmtime::
+ If unset or set to 'default' or 'check', Git will test if
+ mtime is working properly before using features that need a
+ working mtime. If false, Git will refuse to use such
+ features. If set to true, Git will blindly use such features
+ without testing if they work.
+ See linkgit:git-update-index[1].
+
core.checkStat::
Determines which stat fields to match between the index
and work tree. The user can set this to 'default' or
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 1a296bc..8b4c5af 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -182,7 +182,9 @@ may not support it yet.
For safety, `--untracked-cache` performs tests on the working
directory to make sure untracked cache can be used. These
tests can take a few seconds. `--force-untracked-cache` can be
- used to skip the tests.
+ used to skip the tests. If you always want to skip those
+ tests, you can set the `core.trustmtime` configuration
+ variable to 'true', (see linkgit:git-config[1]).
\--::
Do not interpret any more arguments as options.
@@ -398,6 +400,8 @@ It can be useful when the inode change time is regularly modified by
something outside Git (file system crawlers and backup systems use
ctime for marking files processed) (see linkgit:git-config[1]).
+Untracked cache needs a fully working mtime, so it will look at
+`core.trustmtime` configuration variable (see linkgit:git-config[1]).
SEE ALSO
--------
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 7431938..c64439f 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -1107,9 +1107,13 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
if (untracked_cache > 0) {
struct untracked_cache *uc;
+ if (trust_mtime == 0) {
+ fprintf_ln(stderr,_("core.trustmtime is set to false"));
+ return 1;
+ }
if (untracked_cache < 2) {
setup_work_tree();
- if (!test_if_untracked_cache_is_supported())
+ if (trust_mtime != 1 && !test_if_untracked_cache_is_supported())
return 1;
}
if (!the_index.untracked) {
diff --git a/cache.h b/cache.h
index 736abc0..69a6197 100644
--- a/cache.h
+++ b/cache.h
@@ -601,6 +601,7 @@ extern void set_alternate_index_output(const char *);
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
extern int trust_ctime;
+extern int trust_mtime;
extern int check_stat;
extern int quote_path_fully;
extern int has_symlinks;
diff --git a/config.c b/config.c
index 248a21a..d720b1f 100644
--- a/config.c
+++ b/config.c
@@ -691,6 +691,13 @@ static int git_default_core_config(const char *var, const char *value)
trust_ctime = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "core.trustmtime")) {
+ if (!strcasecmp(value, "default") || !strcasecmp(value, "check"))
+ trust_mtime = -1;
+ else
+ trust_mtime = git_config_maybe_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "core.checkstat")) {
if (!strcasecmp(value, "default"))
check_stat = 1;
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 482ca84..39d1c9b 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2038,6 +2038,7 @@ _git_config ()
core.sparseCheckout
core.symlinks
core.trustctime
+ core.trustmtime
core.warnAmbiguousRefs
core.whitespace
core.worktree
diff --git a/dir.c b/dir.c
index d2a8f06..b06df1b 100644
--- a/dir.c
+++ b/dir.c
@@ -1994,7 +1994,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
if (dir->exclude_list_group[EXC_CMDL].nr)
return NULL;
- if (!ident_in_untracked(dir->untracked)) {
+ if (trust_mtime != 1 && !ident_in_untracked(dir->untracked)) {
warning(_("Untracked cache is disabled on this system."));
return NULL;
}
diff --git a/environment.c b/environment.c
index 2da7fe2..c899947 100644
--- a/environment.c
+++ b/environment.c
@@ -14,6 +14,7 @@
int trust_executable_bit = 1;
int trust_ctime = 1;
+int trust_mtime = -1;
int check_stat = 1;
int has_symlinks = 1;
int minimum_abbrev = 4, default_abbrev = 7;
--
2.6.3.380.g494b52d
next reply other threads:[~2015-11-25 6:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 6:35 Christian Couder [this message]
2015-11-25 9:00 ` [RFC/PATCH] config: add core.trustmtime Ævar Arnfjörð Bjarmason
2015-11-25 19:51 ` Duy Nguyen
2015-11-26 5:21 ` Christian Couder
2015-11-26 17:53 ` Duy Nguyen
2015-11-27 1:35 ` Ævar Arnfjörð Bjarmason
2015-11-30 19:05 ` Junio C Hamano
2015-11-30 19:12 ` Duy Nguyen
2015-12-01 5:57 ` Torsten Bögershausen
2015-12-02 19:28 ` Duy Nguyen
2015-12-07 5:42 ` Christian Couder
2015-11-25 10:25 ` Johannes Schindelin
2015-11-25 10:39 ` 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=1448433323-21037-1-git-send-email-chriscool@tuxfamily.org \
--to=christian.couder@gmail.com \
--cc=avarab@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=dturner@twopensource.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
/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).