{"thread":{"id":"41072","subject":"[PATCH v3 00/11] Untracked cache improvements","startedAt":"2015-12-23T21:03:48Z","lastAt":"2015-12-24T21:11:50Z","messageCount":18,"participants":["Christian Couder","Eric Sunshine","Duy Nguyen"],"isPatch":true,"patchVersion":3,"patchTotal":11},"messages":[{"id":"274963","messageId":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":null,"subject":"[PATCH v3 00/11] Untracked cache improvements","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:48Z","receivedAt":"2015-12-23T21:03:48Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Here is a new version of a patch series to improve the untracked cache\nfeature.\n\nThis v3 still implements core.untrackedCache as a simple bool config\nvariable. When it's true, Git should always try to use the untracked\ncache, and when false, Git should never use it.\n\nPatch 1/11 is a small bugfix that has been moved to the start of the\nseries so it might get applied independently.\n\nPatch 2/11 to 4/11 add some small features that are missing. They\nhaven't been changed since the previous series.\n\nPatchs 5/11 to 8/11 are some refactoring to prepare for the following\npatchs. Among them 7/11 is new, the others haven't changed.\n\nPatch 9/11 replaces patch 10/10 in the previous series. It deals with\nthe \"ident\" field in \"struct untracked_cache\". As suggested by Junio,\nwe keep paying attention to the location of the work tree that is\nstored in this field, but otherwise things are simplified a lot.\n\nPatch 10/11 which adds core.untrackedCache, contains a few\nsimplifications compared to v2.\n\nPatch 11/11 has not been changed.\n\nSo the changes compared to v2 are mostly small updates, and patchs\n7/11 and 9/11.\n\nThe patch series is also available there:\n\nhttps://github.com/chriscool/git/tree/uc-notifs34\n\nThanks to the reviewers and helpers.\n\nChristian Couder (11):\n  dir: free untracked cache when removing it\n  update-index: use enum for untracked cache options\n  update-index: add --test-untracked-cache\n  update-index: add untracked cache notifications\n  update-index: move 'uc' var declaration\n  dir: add add_untracked_cache()\n  dir: add new_untracked_cache()\n  dir: add remove_untracked_cache()\n  dir: simplify untracked cache \"ident\" field\n  config: add core.untrackedCache\n  t7063: add tests for core.untrackedCache\n\n Documentation/config.txt               |  7 ++++\n Documentation/git-update-index.txt     | 61 ++++++++++++++++++++++++-----\n builtin/update-index.c                 | 54 ++++++++++++++------------\n cache.h                                |  1 +\n config.c                               |  4 ++\n contrib/completion/git-completion.bash |  1 +\n dir.c                                  | 70 ++++++++++++++++++++++++++++------\n dir.h                                  |  2 +\n environment.c                          |  1 +\n t/t7063-status-untracked-cache.sh      | 52 ++++++++++++++++++++++---\n wt-status.c                            |  5 +++\n 11 files changed, 207 insertions(+), 51 deletions(-)\n\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274964","messageId":"1450904639-25592-2-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 01/11] dir: free untracked cache when removing it","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:49Z","receivedAt":"2015-12-23T21:03:49Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 7431938..a6fff87 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1123,6 +1123,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tadd_untracked_ident(the_index.untracked);\n \t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n \t} else if (!untracked_cache && the_index.untracked) {\n+\t\tfree_untracked_cache(the_index.untracked);\n \t\tthe_index.untracked = NULL;\n \t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n \t}\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274965","messageId":"1450904639-25592-3-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 02/11] update-index: use enum for untracked cache options","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:50Z","receivedAt":"2015-12-23T21:03:50Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 18 +++++++++++++-----\n 1 file changed, 13 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex a6fff87..1e546a3 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -35,6 +35,14 @@ static int mark_skip_worktree_only;\n #define UNMARK_FLAG 2\n static struct strbuf mtime_dir = STRBUF_INIT;\n \n+/* Untracked cache mode */\n+enum uc_mode {\n+\tUC_UNSPECIFIED = -1,\n+\tUC_DISABLE = 0,\n+\tUC_ENABLE,\n+\tUC_FORCE\n+};\n+\n __attribute__((format (printf, 1, 2)))\n static void report(const char *fmt, ...)\n {\n@@ -902,7 +910,7 @@ static int reupdate_callback(struct parse_opt_ctx_t *ctx,\n int cmd_update_index(int argc, const char **argv, const char *prefix)\n {\n \tint newfd, entries, has_errors = 0, line_termination = '\\n';\n-\tint untracked_cache = -1;\n+\tenum uc_mode untracked_cache = UC_UNSPECIFIED;\n \tint read_from_stdin = 0;\n \tint prefix_length = prefix ? strlen(prefix) : 0;\n \tint preferred_index_format = 0;\n@@ -997,7 +1005,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tOPT_BOOL(0, \"untracked-cache\", &untracked_cache,\n \t\t\tN_(\"enable/disable untracked cache\")),\n \t\tOPT_SET_INT(0, \"force-untracked-cache\", &untracked_cache,\n-\t\t\t    N_(\"enable untracked cache without testing the filesystem\"), 2),\n+\t\t\t    N_(\"enable untracked cache without testing the filesystem\"), UC_FORCE),\n \t\tOPT_END()\n \t};\n \n@@ -1104,10 +1112,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tthe_index.split_index = NULL;\n \t\tthe_index.cache_changed |= SOMETHING_CHANGED;\n \t}\n-\tif (untracked_cache > 0) {\n+\tif (untracked_cache > UC_DISABLE) {\n \t\tstruct untracked_cache *uc;\n \n-\t\tif (untracked_cache < 2) {\n+\t\tif (untracked_cache < UC_FORCE) {\n \t\t\tsetup_work_tree();\n \t\t\tif (!test_if_untracked_cache_is_supported())\n \t\t\t\treturn 1;\n@@ -1122,7 +1130,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tadd_untracked_ident(the_index.untracked);\n \t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n-\t} else if (!untracked_cache && the_index.untracked) {\n+\t} else if (untracked_cache == UC_DISABLE && the_index.untracked) {\n \t\tfree_untracked_cache(the_index.untracked);\n \t\tthe_index.untracked = NULL;\n \t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274966","messageId":"1450904639-25592-4-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 03/11] update-index: add --test-untracked-cache","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:51Z","receivedAt":"2015-12-23T21:03:51Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"It is nice to just be able to test if untracked cache is\nsupported without enabling it.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n Documentation/git-update-index.txt | 9 ++++++++-\n builtin/update-index.c             | 5 +++++\n 2 files changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex f4e5a85..a0ee0c9 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -18,7 +18,7 @@ SYNOPSIS\n \t     [--[no-]skip-worktree]\n \t     [--ignore-submodules]\n \t     [--[no-]split-index]\n-\t     [--[no-|force-]untracked-cache]\n+\t     [--[no-|test-|force-]untracked-cache]\n \t     [--really-refresh] [--unresolve] [--again | -g]\n \t     [--info-only] [--index-info]\n \t     [-z] [--stdin] [--index-version <n>]\n@@ -180,6 +180,13 @@ may not support it yet.\n \tsystem must change `st_mtime` field of a directory if files\n \tare added or deleted in that directory.\n \n+--test-untracked-cache::\n+\tOnly perform tests on the working directory to make sure\n+\tuntracked cache can be used. You have to manually enable\n+\tuntracked cache using `--force-untracked-cache` (or\n+\t`--untracked-cache` but this will run the tests again)\n+\tafterwards if you really want to use it.\n+\n --force-untracked-cache::\n \tFor safety, `--untracked-cache` performs tests on the working\n \tdirectory to make sure untracked cache can be used. These\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 1e546a3..62222dd 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -40,6 +40,7 @@ enum uc_mode {\n \tUC_UNSPECIFIED = -1,\n \tUC_DISABLE = 0,\n \tUC_ENABLE,\n+\tUC_TEST,\n \tUC_FORCE\n };\n \n@@ -1004,6 +1005,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"enable or disable split index\")),\n \t\tOPT_BOOL(0, \"untracked-cache\", &untracked_cache,\n \t\t\tN_(\"enable/disable untracked cache\")),\n+\t\tOPT_SET_INT(0, \"test-untracked-cache\", &untracked_cache,\n+\t\t\t    N_(\"test if the filesystem supports untracked cache\"), UC_TEST),\n \t\tOPT_SET_INT(0, \"force-untracked-cache\", &untracked_cache,\n \t\t\t    N_(\"enable untracked cache without testing the filesystem\"), UC_FORCE),\n \t\tOPT_END()\n@@ -1119,6 +1122,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\tsetup_work_tree();\n \t\t\tif (!test_if_untracked_cache_is_supported())\n \t\t\t\treturn 1;\n+\t\t\tif (untracked_cache == UC_TEST)\n+\t\t\t\treturn 0;\n \t\t}\n \t\tif (!the_index.untracked) {\n \t\t\tuc = xcalloc(1, sizeof(*uc));\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274967","messageId":"1450904639-25592-5-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 04/11] update-index: add untracked cache notifications","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:52Z","receivedAt":"2015-12-23T21:03:52Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Attempting to flip the untracked-cache feature on for a random index\nfile with\n\n    cd /random/unrelated/place\n    git --git-dir=/somewhere/else/.git update-index --untracked-cache\n\nwould not work as you might expect. Because flipping the feature on\nin the index also records the location of the corresponding working\ntree (/random/unrelated/place in the above example), when the index\nis subsequently used to keep track of files in the working tree in\n/somewhere/else, the feature is disabled.\n\nWith this patch \"git update-index --[test-]untracked-cache\" tells the\nuser in which directory tests are performed. This makes it easy to\nspot any problem.\n\nAlso in verbose mode, let's tell the user when the cache is enabled\nor disabled.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 16 +++++++++++-----\n 1 file changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 62222dd..c91e695 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -130,7 +130,7 @@ static int test_if_untracked_cache_is_supported(void)\n \tif (!mkdtemp(mtime_dir.buf))\n \t\tdie_errno(\"Could not make temporary directory\");\n \n-\tfprintf(stderr, _(\"Testing \"));\n+\tfprintf(stderr, _(\"Testing mtime in '%s' \"), xgetcwd());\n \tatexit(remove_test_directory);\n \txstat_mtime_dir(&st);\n \tfill_stat_data(&base, &st);\n@@ -1135,10 +1135,16 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tadd_untracked_ident(the_index.untracked);\n \t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n-\t} else if (untracked_cache == UC_DISABLE && the_index.untracked) {\n-\t\tfree_untracked_cache(the_index.untracked);\n-\t\tthe_index.untracked = NULL;\n-\t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+\t\tif (verbose)\n+\t\t\tprintf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n+\t} else if (untracked_cache == UC_DISABLE) {\n+\t\tif (the_index.untracked) {\n+\t\t\tfree_untracked_cache(the_index.untracked);\n+\t\t\tthe_index.untracked = NULL;\n+\t\t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+\t\t}\n+\t\tif (verbose)\n+\t\t\tprintf(_(\"Untracked cache disabled\\n\"));\n \t}\n \n \tif (active_cache_changed) {\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274968","messageId":"1450904639-25592-6-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 05/11] update-index: move 'uc' var declaration","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:53Z","receivedAt":"2015-12-23T21:03:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex c91e695..f667125 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1116,8 +1116,6 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tthe_index.cache_changed |= SOMETHING_CHANGED;\n \t}\n \tif (untracked_cache > UC_DISABLE) {\n-\t\tstruct untracked_cache *uc;\n-\n \t\tif (untracked_cache < UC_FORCE) {\n \t\t\tsetup_work_tree();\n \t\t\tif (!test_if_untracked_cache_is_supported())\n@@ -1126,7 +1124,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\t\treturn 0;\n \t\t}\n \t\tif (!the_index.untracked) {\n-\t\t\tuc = xcalloc(1, sizeof(*uc));\n+\t\t\tstruct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n \t\t\tstrbuf_init(&uc->ident, 100);\n \t\t\tuc->exclude_per_dir = \".gitignore\";\n \t\t\t/* should be the same flags used by git-status */\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274970","messageId":"1450904639-25592-7-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 06/11] dir: add add_untracked_cache()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:54Z","receivedAt":"2015-12-23T21:03:54Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Factor out code into add_untracked_cache(), which will be used\nin a later commit.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 11 +----------\n dir.c                  | 14 ++++++++++++++\n dir.h                  |  1 +\n 3 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex f667125..093725a 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1123,16 +1123,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\t\tif (untracked_cache == UC_TEST)\n \t\t\t\treturn 0;\n \t\t}\n-\t\tif (!the_index.untracked) {\n-\t\t\tstruct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n-\t\t\tstrbuf_init(&uc->ident, 100);\n-\t\t\tuc->exclude_per_dir = \".gitignore\";\n-\t\t\t/* should be the same flags used by git-status */\n-\t\t\tuc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n-\t\t\tthe_index.untracked = uc;\n-\t\t}\n-\t\tadd_untracked_ident(the_index.untracked);\n-\t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+\t\tadd_untracked_cache();\n \t\tif (verbose)\n \t\t\tprintf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n \t} else if (untracked_cache == UC_DISABLE) {\ndiff --git a/dir.c b/dir.c\nindex d2a8f06..0f7e293 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1938,6 +1938,20 @@ void add_untracked_ident(struct untracked_cache *uc)\n \tstrbuf_addch(&uc->ident, 0);\n }\n \n+void add_untracked_cache(void)\n+{\n+\tif (!the_index.untracked) {\n+\t\tstruct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n+\t\tstrbuf_init(&uc->ident, 100);\n+\t\tuc->exclude_per_dir = \".gitignore\";\n+\t\t/* should be the same flags used by git-status */\n+\t\tuc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n+\t\tthe_index.untracked = uc;\n+\t}\n+\tadd_untracked_ident(the_index.untracked);\n+\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+}\n+\n static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir,\n \t\t\t\t\t\t      int base_len,\n \t\t\t\t\t\t      const struct pathspec *pathspec)\ndiff --git a/dir.h b/dir.h\nindex 7b5855d..ee94c76 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -308,4 +308,5 @@ void free_untracked_cache(struct untracked_cache *);\n struct untracked_cache *read_untracked_extension(const void *data, unsigned long sz);\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_ident(struct untracked_cache *);\n+void add_untracked_cache(void);\n #endif\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274969","messageId":"1450904639-25592-8-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 07/11] dir: add new_untracked_cache()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:55Z","receivedAt":"2015-12-23T21:03:55Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"    Factor out code into new_untracked_cache(), which will be used\n    multiple times in a later commit.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n dir.c | 20 ++++++++++++--------\n 1 file changed, 12 insertions(+), 8 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 0f7e293..4227ba6 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1938,16 +1938,20 @@ void add_untracked_ident(struct untracked_cache *uc)\n \tstrbuf_addch(&uc->ident, 0);\n }\n \n+static void new_untracked_cache(void)\n+{\n+\tstruct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n+\tstrbuf_init(&uc->ident, 100);\n+\tuc->exclude_per_dir = \".gitignore\";\n+\t/* should be the same flags used by git-status */\n+\tuc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n+\tthe_index.untracked = uc;\n+}\n+\n void add_untracked_cache(void)\n {\n-\tif (!the_index.untracked) {\n-\t\tstruct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n-\t\tstrbuf_init(&uc->ident, 100);\n-\t\tuc->exclude_per_dir = \".gitignore\";\n-\t\t/* should be the same flags used by git-status */\n-\t\tuc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n-\t\tthe_index.untracked = uc;\n-\t}\n+\tif (!the_index.untracked)\n+\t\tnew_untracked_cache();\n \tadd_untracked_ident(the_index.untracked);\n \tthe_index.cache_changed |= UNTRACKED_CHANGED;\n }\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274971","messageId":"1450904639-25592-9-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 08/11] dir: add remove_untracked_cache()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:56Z","receivedAt":"2015-12-23T21:03:56Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Factor out code into remove_untracked_cache(), which will be used\nin a later commit.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin/update-index.c | 6 +-----\n dir.c                  | 9 +++++++++\n dir.h                  | 1 +\n 3 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 093725a..3e5b4a6 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1127,11 +1127,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tif (verbose)\n \t\t\tprintf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n \t} else if (untracked_cache == UC_DISABLE) {\n-\t\tif (the_index.untracked) {\n-\t\t\tfree_untracked_cache(the_index.untracked);\n-\t\t\tthe_index.untracked = NULL;\n-\t\t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n-\t\t}\n+\t\tremove_untracked_cache();\n \t\tif (verbose)\n \t\t\tprintf(_(\"Untracked cache disabled\\n\"));\n \t}\ndiff --git a/dir.c b/dir.c\nindex 4227ba6..dba1ad0 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1956,6 +1956,15 @@ void add_untracked_cache(void)\n \tthe_index.cache_changed |= UNTRACKED_CHANGED;\n }\n \n+void remove_untracked_cache(void)\n+{\n+\tif (the_index.untracked) {\n+\t\tfree_untracked_cache(the_index.untracked);\n+\t\tthe_index.untracked = NULL;\n+\t\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+\t}\n+}\n+\n static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *dir,\n \t\t\t\t\t\t      int base_len,\n \t\t\t\t\t\t      const struct pathspec *pathspec)\ndiff --git a/dir.h b/dir.h\nindex ee94c76..3e5114d 100644\n--- a/dir.h\n+++ b/dir.h\n@@ -309,4 +309,5 @@ struct untracked_cache *read_untracked_extension(const void *data, unsigned long\n void write_untracked_extension(struct strbuf *out, struct untracked_cache *untracked);\n void add_untracked_ident(struct untracked_cache *);\n void add_untracked_cache(void);\n+void remove_untracked_cache(void);\n #endif\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274972","messageId":"1450904639-25592-10-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 09/11] dir: simplify untracked cache \"ident\" field","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:57Z","receivedAt":"2015-12-23T21:03:57Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"It is not a good idea to compare kernel versions and disable\nthe untracked cache if it changes as people may upgrade and\nstill want the untracked cache to work. So let's just\ncompare work tree locations to decide if we should disable\nit.\n\nAlso it's not useful to store many locations in the ident\nfield and compare to any of them. It can even be dangerous\nif GIT_WORK_TREE is used with different values. So let's\njust store one location, the location of the current work\ntree.\n\nIf this location changed and we still want an untracked\ncache, let's delete the cache and recreate it.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n dir.c | 49 ++++++++++++++++++++++++++++++++++---------------\n 1 file changed, 34 insertions(+), 15 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex dba1ad0..7596a3f 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1918,23 +1918,36 @@ static const char *get_ident_string(void)\n \treturn sb.buf;\n }\n \n-static int ident_in_untracked(const struct untracked_cache *uc)\n+static int ident_current_location_in_untracked(const struct untracked_cache *uc)\n {\n-\tconst char *end = uc->ident.buf + uc->ident.len;\n-\tconst char *p   = uc->ident.buf;\n+\tstruct strbuf cur_loc = STRBUF_INIT;\n+\tint res = 0;\n \n-\tfor (p = uc->ident.buf; p < end; p += strlen(p) + 1)\n-\t\tif (!strcmp(p, get_ident_string()))\n-\t\t\treturn 1;\n-\treturn 0;\n+\t/*\n+\t * Previous git versions may have saved many strings in the\n+\t * \"ident\" field, but it is insane to manage many locations,\n+\t * so just take care of the first one.\n+\t */\n+\n+\tstrbuf_addf(&cur_loc, \"Location %s, system \", get_git_work_tree());\n+\n+\tif (starts_with(uc->ident.buf, cur_loc.buf))\n+\t\tres = 1;\n+\n+\tstrbuf_release(&cur_loc);\n+\n+\treturn res;\n }\n \n-void add_untracked_ident(struct untracked_cache *uc)\n+static void set_untracked_ident(struct untracked_cache *uc)\n {\n-\tif (ident_in_untracked(uc))\n-\t\treturn;\n+\tstrbuf_reset(&uc->ident);\n \tstrbuf_addstr(&uc->ident, get_ident_string());\n-\t/* this strbuf contains a list of strings, save NUL too */\n+\n+\t/*\n+\t * This strbuf used to contain a list of NUL separated\n+\t * strings, so save NUL too for backward compatibility.\n+\t */\n \tstrbuf_addch(&uc->ident, 0);\n }\n \n@@ -1945,15 +1958,21 @@ static void new_untracked_cache(void)\n \tuc->exclude_per_dir = \".gitignore\";\n \t/* should be the same flags used by git-status */\n \tuc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n+\tset_untracked_ident(the_index.untracked);\n \tthe_index.untracked = uc;\n+\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n }\n \n void add_untracked_cache(void)\n {\n-\tif (!the_index.untracked)\n+\tif (!the_index.untracked) {\n \t\tnew_untracked_cache();\n-\tadd_untracked_ident(the_index.untracked);\n-\tthe_index.cache_changed |= UNTRACKED_CHANGED;\n+\t} else {\n+\t\tif (!ident_current_location_in_untracked(the_index.untracked)) {\n+\t\t\tfree_untracked_cache(the_index.untracked);\n+\t\t\tnew_untracked_cache();\n+\t\t}\n+\t}\n }\n \n void remove_untracked_cache(void)\n@@ -2021,7 +2040,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d\n \tif (dir->exclude_list_group[EXC_CMDL].nr)\n \t\treturn NULL;\n \n-\tif (!ident_in_untracked(dir->untracked)) {\n+\tif (!ident_current_location_in_untracked(dir->untracked)) {\n \t\twarning(_(\"Untracked cache is disabled on this system.\"));\n \t\treturn NULL;\n \t}\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274973","messageId":"1450904639-25592-11-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 10/11] config: add core.untrackedCache","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:58Z","receivedAt":"2015-12-23T21:03:58Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When we know that mtime is fully supported by the environment, we\nmight want the untracked cache to be always used by default without\nany mtime test or kernel version check being performed.\n\nAlso when we know that mtime is not supported by the environment,\nfor example because the repo is shared over a network file system,\nthen we might want 'git update-index --untracked-cache' to fail\nimmediately instead of performing tests (because it might work on\nsome systems using the repo over the network file system but not\nothers).\n\nThe normal way to achieve the above in Git is to use a config\nvariable. That's why this patch introduces \"core.untrackedCache\".\n\nTo keep things simple, this variable is a bool which default to\nfalse.\n\nWhen \"git status\" is run, it now adds or removes the untracked\ncache in the index to respect the value of this variable.\n\nThe job of `git update-index --[no-|force-]untracked-cache` was\nto add or remove the untracked cache from the index. This was a\nkind of configuration because this was persistant across git\ncommands. To make this kind of configuration compatible with the\nnew config variable, the simple thing to do, and what this patch\ndoes, is to make `git update-index --[no-|force-]untracked-cache`\nset or unset this config option.\n\nThis new behavior is a backward incompatible change, but that is\ndeliberate. The untracked cache feature has been experimental\nand is very unlikely used by beginners.\n\nWhen people will upgrade, this will remove any untracked cache\nthey used unless they set \"core.untrackedCache\" before upgrading.\nThis should be stated in the release notes.\n\nAlso `--untracked-cache` used to check that the underlying\noperating system and file system change `st_mtime` field of a\ndirectory if files are added or deleted in that directory. But\nthose tests take a long time and there is now\n`--test-untracked-cache` to perform them.\n\nThat's why, to be more consistent with other git commands, this\npatch prevents `--untracked-cache` to perform tests, so that\nafter this patch there is no difference any more between\n`--untracked-cache` and `--force-untracked-cache`.\n\nAll the changes to `--[no-|force-]untracked-cache` make it\npossible to deprecate those options in the future.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/config.txt               |  7 ++++\n Documentation/git-update-index.txt     | 58 +++++++++++++++++++++++++++-------\n builtin/update-index.c                 | 15 +++++----\n cache.h                                |  1 +\n config.c                               |  4 +++\n contrib/completion/git-completion.bash |  1 +\n environment.c                          |  1 +\n t/t7063-status-untracked-cache.sh      |  4 +--\n wt-status.c                            |  5 +++\n 9 files changed, 74 insertions(+), 22 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f617886..08f0510 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -308,6 +308,13 @@ core.trustctime::\n \tcrawlers and some backup systems).\n \tSee linkgit:git-update-index[1]. True by default.\n \n+core.untrackedCache::\n+\tDetermines if untracked cache will be enabled. Using\n+\t'git update-index --[no-|force-]untracked-cache' will set\n+\tthis variable. Before setting it to true, you should check\n+\tthat mtime is working properly on your system.\n+\tSee linkgit:git-update-index[1]. False by default.\n+\n core.checkStat::\n \tDetermines which stat fields to match between the index\n \tand work tree. The user can set this to 'default' or\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex a0ee0c9..bab6394 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -174,24 +174,29 @@ may not support it yet.\n \n --untracked-cache::\n --no-untracked-cache::\n-\tEnable or disable untracked cache extension. This could speed\n-\tup for commands that involve determining untracked files such\n-\tas `git status`. The underlying operating system and file\n-\tsystem must change `st_mtime` field of a directory if files\n-\tare added or deleted in that directory.\n+\tEnable or disable untracked cache extension. Please use\n+\t`--test-untracked-cache` before enabling it.\n++\n+These options are mostly aliases for setting the `core.untrackedCache`\n+configuration variable to 'true' or 'false' in the local config file\n+(see linkgit:git-config[1]). You can equivalently just set those\n+configuration values directly. These options are just provided for\n+backwards compatibility with the older versions of Git where this was\n+the only way to enable or disable the untracked cache extension.\n \n --test-untracked-cache::\n \tOnly perform tests on the working directory to make sure\n \tuntracked cache can be used. You have to manually enable\n-\tuntracked cache using `--force-untracked-cache` (or\n-\t`--untracked-cache` but this will run the tests again)\n-\tafterwards if you really want to use it.\n+\tuntracked cache using `--untracked-cache` or\n+\t`--force-untracked-cache` or the `core.untrackedCache`\n+\tconfiguration variable afterwards if you really want to use\n+\tit.\n \n --force-untracked-cache::\n-\tFor safety, `--untracked-cache` performs tests on the working\n-\tdirectory to make sure untracked cache can be used. These\n-\ttests can take a few seconds. `--force-untracked-cache` can be\n-\tused to skip the tests.\n+\tSame as `--untracked-cache`. Provided for backwards\n+\tcompatibility with older versions of Git where\n+\t`--untracked-cache` used to imply `--test-untracked-cache` but\n+\tthis option would enable the extension unconditionally.\n \n \\--::\n \tDo not interpret any more arguments as options.\n@@ -382,6 +387,33 @@ Although this bit looks similar to assume-unchanged bit, its goal is\n different from assume-unchanged bit's. Skip-worktree also takes\n precedence over assume-unchanged bit when both are set.\n \n+Untracked cache\n+---------------\n+\n+This cache could speed up commands that involve determining untracked\n+files such as `git status`.\n+\n+This feature works by recording the mtime of the working tree\n+directories and then omitting reading directories and stat calls\n+against files in those directories whose mtime hasn't changed. For\n+this to work the underlying operating system and file system must\n+change the `st_mtime` field of directories if files in the directory\n+are added, modified or deleted.\n+\n+You can test whether the filesystem supports that with the\n+`--test-untracked-cache` option. The `--untracked-cache` option used\n+to implicitly perform that test in older versions of Git, but that's\n+no longer the case.\n+\n+It is recommended to use the `core.untrackedCache` configuration\n+variable (see linkgit:git-config[1]) to enable or disable this feature\n+instead of using the `--[no-|force-]untracked-cache` which are going\n+to set or unset this configuration variable anyway.\n+\n+When the `core.untrackedCache` configuration variable is changed, the\n+untracked cache is added or removed from the index the next time \"git\n+status\" is run, while when `--[no-|force-]untracked-cache` are used,\n+the untracked cache is immediately added to the index.\n \n Configuration\n -------------\n@@ -407,6 +439,8 @@ It can be useful when the inode change time is regularly modified by\n something outside Git (file system crawlers and backup systems use\n ctime for marking files processed) (see linkgit:git-config[1]).\n \n+The untracked cache extension is enabled by the `core.untrackedCache`\n+configuration variable (see linkgit:git-config[1]).\n \n SEE ALSO\n --------\ndiff --git a/builtin/update-index.c b/builtin/update-index.c\nindex 3e5b4a6..9bb70dc 100644\n--- a/builtin/update-index.c\n+++ b/builtin/update-index.c\n@@ -1115,18 +1115,19 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n \t\tthe_index.split_index = NULL;\n \t\tthe_index.cache_changed |= SOMETHING_CHANGED;\n \t}\n+\tif (untracked_cache == UC_TEST) {\n+\t\tsetup_work_tree();\n+\t\treturn !test_if_untracked_cache_is_supported();\n+\t}\n \tif (untracked_cache > UC_DISABLE) {\n-\t\tif (untracked_cache < UC_FORCE) {\n-\t\t\tsetup_work_tree();\n-\t\t\tif (!test_if_untracked_cache_is_supported())\n-\t\t\t\treturn 1;\n-\t\t\tif (untracked_cache == UC_TEST)\n-\t\t\t\treturn 0;\n-\t\t}\n+\t\tif (!use_untracked_cache && git_config_set(\"core.untrackedCache\", \"true\"))\n+\t\t\tdie(\"could not set core.untrackedCache to true\");\n \t\tadd_untracked_cache();\n \t\tif (verbose)\n \t\t\tprintf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n \t} else if (untracked_cache == UC_DISABLE) {\n+\t\tif (use_untracked_cache && git_config_set(\"core.untrackedCache\", \"false\"))\n+\t\t\tdie(\"could not set core.untrackedCache to false\");\n \t\tremove_untracked_cache();\n \t\tif (verbose)\n \t\t\tprintf(_(\"Untracked cache disabled\\n\"));\ndiff --git a/cache.h b/cache.h\nindex c63fcc1..8d09858 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -619,6 +619,7 @@ extern void set_alternate_index_output(const char *);\n /* Environment bits from configuration mechanism */\n extern int trust_executable_bit;\n extern int trust_ctime;\n+extern int use_untracked_cache;\n extern int check_stat;\n extern int quote_path_fully;\n extern int has_symlinks;\ndiff --git a/config.c b/config.c\nindex 86a5eb2..b52916d 100644\n--- a/config.c\n+++ b/config.c\n@@ -691,6 +691,10 @@ static int git_default_core_config(const char *var, const char *value)\n \t\ttrust_ctime = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"core.untrackedcache\")) {\n+\t\tuse_untracked_cache = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"core.checkstat\")) {\n \t\tif (!strcasecmp(value, \"default\"))\n \t\t\tcheck_stat = 1;\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6956807..84bcec3 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2055,6 +2055,7 @@ _git_config ()\n \t\tcore.sparseCheckout\n \t\tcore.symlinks\n \t\tcore.trustctime\n+\t\tcore.untrackedCache\n \t\tcore.warnAmbiguousRefs\n \t\tcore.whitespace\n \t\tcore.worktree\ndiff --git a/environment.c b/environment.c\nindex 2da7fe2..9ca71b1 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -14,6 +14,7 @@\n \n int trust_executable_bit = 1;\n int trust_ctime = 1;\n+int use_untracked_cache;\n int check_stat = 1;\n int has_symlinks = 1;\n int minimum_abbrev = 4, default_abbrev = 7;\ndiff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh\nindex 0e8d0d4..253160a 100755\n--- a/t/t7063-status-untracked-cache.sh\n+++ b/t/t7063-status-untracked-cache.sh\n@@ -8,10 +8,8 @@ avoid_racy() {\n \tsleep 1\n }\n \n-# It's fine if git update-index returns an error code other than one,\n-# it'll be caught in the first test.\n test_lazy_prereq UNTRACKED_CACHE '\n-\t{ git update-index --untracked-cache; ret=$?; } &&\n+\t{ git update-index --test-untracked-cache; ret=$?; } &&\n \ttest $ret -ne 1\n '\n \ndiff --git a/wt-status.c b/wt-status.c\nindex bba2596..6766f80 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -578,6 +578,11 @@ static void wt_status_collect_untracked(struct wt_status *s)\n \tif (!s->show_untracked_files)\n \t\treturn;\n \n+\tif (use_untracked_cache)\n+\t\tadd_untracked_cache();\n+\telse\n+\t\tremove_untracked_cache();\n+\n \tmemset(&dir, 0, sizeof(dir));\n \tif (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)\n \t\tdir.flags |=\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274974","messageId":"1450904639-25592-12-git-send-email-chriscool@tuxfamily.org","threadId":"41072","inReplyTo":"1450904639-25592-1-git-send-email-chriscool@tuxfamily.org","subject":"[PATCH v3 11/11] t7063: add tests for core.untrackedCache","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-23T21:03:59Z","receivedAt":"2015-12-23T21:03:59Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t7063-status-untracked-cache.sh | 48 +++++++++++++++++++++++++++++++++++++--\n 1 file changed, 46 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7063-status-untracked-cache.sh b/t/t7063-status-untracked-cache.sh\nindex 253160a..f0af41c 100755\n--- a/t/t7063-status-untracked-cache.sh\n+++ b/t/t7063-status-untracked-cache.sh\n@@ -18,6 +18,10 @@ if ! test_have_prereq UNTRACKED_CACHE; then\n \ttest_done\n fi\n \n+test_expect_success 'core.untrackedCache is unset' '\n+\ttest_must_fail git config --get core.untrackedCache\n+'\n+\n test_expect_success 'setup' '\n \tgit init worktree &&\n \tcd worktree &&\n@@ -28,6 +32,11 @@ test_expect_success 'setup' '\n \tgit update-index --untracked-cache\n '\n \n+test_expect_success 'core.untrackedCache is true' '\n+\tUC=$(git config core.untrackedCache) &&\n+\ttest \"$UC\" = \"true\"\n+'\n+\n test_expect_success 'untracked cache is empty' '\n \ttest-dump-untracked-cache >../actual &&\n \tcat >../expect <<EOF &&\n@@ -506,7 +515,7 @@ EOF\n \n test_expect_success 'verify untracked cache dump (sparse/subdirs)' '\n \ttest-dump-untracked-cache >../actual &&\n-\tcat >../expect <<EOF &&\n+\tcat >../expect-from-test-dump <<EOF &&\n info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0\n core.excludesfile 0000000000000000000000000000000000000000\n exclude_per_dir .gitignore\n@@ -525,7 +534,7 @@ file\n /dtwo/ 0000000000000000000000000000000000000000 recurse check_only valid\n two\n EOF\n-\ttest_cmp ../expect ../actual\n+\ttest_cmp ../expect-from-test-dump ../actual\n '\n \n test_expect_success 'test sparse status again with untracked cache and subdir' '\n@@ -569,4 +578,39 @@ EOF\n \ttest_cmp ../status.expect ../status.actual\n '\n \n+test_expect_success '--no-untracked-cache removes the cache' '\n+\tgit update-index --no-untracked-cache &&\n+\tUC=$(git config core.untrackedCache) &&\n+\ttest \"$UC\" = \"false\" &&\n+\ttest-dump-untracked-cache >../actual &&\n+\techo \"no untracked cache\" >../expect &&\n+\ttest_cmp ../expect ../actual\n+'\n+\n+test_expect_success 'git status does not change anything' '\n+\tgit status &&\n+\ttest-dump-untracked-cache >../actual &&\n+\ttest_cmp ../expect ../actual &&\n+\tUC=$(git config core.untrackedCache) &&\n+\ttest \"$UC\" = \"false\"\n+'\n+\n+test_expect_success 'setting core.untrackedCache and using git status creates the cache' '\n+\tgit config core.untrackedCache true &&\n+\ttest-dump-untracked-cache >../actual &&\n+\ttest_cmp ../expect ../actual &&\n+\tgit status &&\n+\ttest-dump-untracked-cache >../actual &&\n+\ttest_cmp ../expect-from-test-dump ../actual\n+'\n+\n+test_expect_success 'unsetting core.untrackedCache and using git status removes the cache' '\n+\tgit config --unset core.untrackedCache &&\n+\ttest-dump-untracked-cache >../actual &&\n+\ttest_cmp ../expect-from-test-dump ../actual &&\n+\tgit status &&\n+\ttest-dump-untracked-cache >../actual &&\n+\ttest_cmp ../expect ../actual\n+'\n+\n test_done\n-- \n2.7.0.rc2.11.g68ccdd4\n"},{"id":"274976","messageId":"CAPig+cQoho_EAjvS2z5Wa3jV2zd_bMzdZRP5PFyruqB=cXGigw@mail.gmail.com","threadId":"41072","inReplyTo":"1450904639-25592-8-git-send-email-chriscool@tuxfamily.org","subject":"Re: [PATCH v3 07/11] dir: add new_untracked_cache()","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-12-23T22:53:49Z","receivedAt":"2015-12-23T22:53:49Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Dec 23, 2015 at 4:03 PM, Christian Couder\n<christian.couder@gmail.com> wrote:\n>     Factor out code into new_untracked_cache(), which will be used\n>     multiple times in a later commit.\n\nOdd indentation: s/^\\s+//\n\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n> diff --git a/dir.c b/dir.c\n> @@ -1938,16 +1938,20 @@ void add_untracked_ident(struct untracked_cache *uc)\n>         strbuf_addch(&uc->ident, 0);\n>  }\n>\n> +static void new_untracked_cache(void)\n> +{\n> +       struct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n> +       strbuf_init(&uc->ident, 100);\n> +       uc->exclude_per_dir = \".gitignore\";\n> +       /* should be the same flags used by git-status */\n> +       uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n> +       the_index.untracked = uc;\n> +}\n\nThis and the previous patch both move the same code around. As a\nreviewer, I could easily see the two patches combined, and would not\nfind the unified patch onerous to review.\n\n>  void add_untracked_cache(void)\n>  {\n> -       if (!the_index.untracked) {\n> -               struct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n> -               strbuf_init(&uc->ident, 100);\n> -               uc->exclude_per_dir = \".gitignore\";\n> -               /* should be the same flags used by git-status */\n> -               uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n> -               the_index.untracked = uc;\n> -       }\n> +       if (!the_index.untracked)\n> +               new_untracked_cache();\n>         add_untracked_ident(the_index.untracked);\n>         the_index.cache_changed |= UNTRACKED_CHANGED;\n>  }\n> --\n> 2.7.0.rc2.11.g68ccdd4\n"},{"id":"274980","messageId":"CAP8UFD0phWoR3qf7wZ6vE0BmrPLQYRgqgRBn14jGPemgey7Nsg@mail.gmail.com","threadId":"41072","inReplyTo":"CAPig+cQoho_EAjvS2z5Wa3jV2zd_bMzdZRP5PFyruqB=cXGigw@mail.gmail.com","subject":"Re: [PATCH v3 07/11] dir: add new_untracked_cache()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-24T07:35:10Z","receivedAt":"2015-12-24T07:35:10Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Wed, Dec 23, 2015 at 11:53 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Wed, Dec 23, 2015 at 4:03 PM, Christian Couder\n> <christian.couder@gmail.com> wrote:\n>>     Factor out code into new_untracked_cache(), which will be used\n>>     multiple times in a later commit.\n>\n> Odd indentation: s/^\\s+//\n\nYeah, will fix.\n\n>> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n>> ---\n>> diff --git a/dir.c b/dir.c\n>> @@ -1938,16 +1938,20 @@ void add_untracked_ident(struct untracked_cache *uc)\n>>         strbuf_addch(&uc->ident, 0);\n>>  }\n>>\n>> +static void new_untracked_cache(void)\n>> +{\n>> +       struct untracked_cache *uc = xcalloc(1, sizeof(*uc));\n>> +       strbuf_init(&uc->ident, 100);\n>> +       uc->exclude_per_dir = \".gitignore\";\n>> +       /* should be the same flags used by git-status */\n>> +       uc->dir_flags = DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;\n>> +       the_index.untracked = uc;\n>> +}\n>\n> This and the previous patch both move the same code around. As a\n> reviewer, I could easily see the two patches combined, and would not\n> find the unified patch onerous to review.\n\nOk, I will squash them.\n\nBy the way it looks like I have overlooked some reviews by David and\nTosten from the previous round.\nSorry about that. I will take them into account in the next version.\n"},{"id":"274986","messageId":"CACsJy8BQi8LQSHsZ7UMduCdE2_AeNwxn3kppc1xTfaNsMN=OXA@mail.gmail.com","threadId":"41072","inReplyTo":"1450904639-25592-5-git-send-email-chriscool@tuxfamily.org","subject":"Re: [PATCH v3 04/11] update-index: add untracked cache notifications","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-12-24T10:01:50Z","receivedAt":"2015-12-24T10:01:50Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Dec 24, 2015 at 4:03 AM, Christian Couder\n<christian.couder@gmail.com> wrote:\n> Attempting to flip the untracked-cache feature on for a random index\n> file with\n>\n>     cd /random/unrelated/place\n>     git --git-dir=/somewhere/else/.git update-index --untracked-cache\n>\n> would not work as you might expect. Because flipping the feature on\n> in the index also records the location of the corresponding working\n> tree (/random/unrelated/place in the above example), when the index\n> is subsequently used to keep track of files in the working tree in\n> /somewhere/else, the feature is disabled.\n>\n> With this patch \"git update-index --[test-]untracked-cache\" tells the\n> user in which directory tests are performed. This makes it easy to\n> spot any problem.\n>\n> Also in verbose mode, let's tell the user when the cache is enabled\n> or disabled.\n>\n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n> ---\n>  builtin/update-index.c | 16 +++++++++++-----\n>  1 file changed, 11 insertions(+), 5 deletions(-)\n>\n> diff --git a/builtin/update-index.c b/builtin/update-index.c\n> index 62222dd..c91e695 100644\n> --- a/builtin/update-index.c\n> +++ b/builtin/update-index.c\n> @@ -130,7 +130,7 @@ static int test_if_untracked_cache_is_supported(void)\n>         if (!mkdtemp(mtime_dir.buf))\n>                 die_errno(\"Could not make temporary directory\");\n>\n> -       fprintf(stderr, _(\"Testing \"));\n> +       fprintf(stderr, _(\"Testing mtime in '%s' \"), xgetcwd());\n>         atexit(remove_test_directory);\n>         xstat_mtime_dir(&st);\n>         fill_stat_data(&base, &st);\n> @@ -1135,10 +1135,16 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n>                 }\n>                 add_untracked_ident(the_index.untracked);\n>                 the_index.cache_changed |= UNTRACKED_CHANGED;\n> -       } else if (untracked_cache == UC_DISABLE && the_index.untracked) {\n> -               free_untracked_cache(the_index.untracked);\n> -               the_index.untracked = NULL;\n> -               the_index.cache_changed |= UNTRACKED_CHANGED;\n> +               if (verbose)\n> +                       printf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n\nNit. If you use report(), then you can skip \"if (verbose)\" because\nit's done inside report().\n\n> +       } else if (untracked_cache == UC_DISABLE) {\n> +               if (the_index.untracked) {\n> +                       free_untracked_cache(the_index.untracked);\n> +                       the_index.untracked = NULL;\n> +                       the_index.cache_changed |= UNTRACKED_CHANGED;\n> +               }\n> +               if (verbose)\n> +                       printf(_(\"Untracked cache disabled\\n\"));\n>         }\n>\n>         if (active_cache_changed) {\n> --\n> 2.7.0.rc2.11.g68ccdd4\n>\n-- \nDuy\n"},{"id":"274987","messageId":"CACsJy8C0CwbFy+Ghk3EWTyhqPYcr6xE5jczumWW98cAAHdfmPg@mail.gmail.com","threadId":"41072","inReplyTo":"1450904639-25592-11-git-send-email-chriscool@tuxfamily.org","subject":"Re: [PATCH v3 10/11] config: add core.untrackedCache","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-12-24T10:13:22Z","receivedAt":"2015-12-24T10:13:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Dec 24, 2015 at 4:03 AM, Christian Couder\n<christian.couder@gmail.com> wrote:\n>  --force-untracked-cache::\n> -       For safety, `--untracked-cache` performs tests on the working\n> -       directory to make sure untracked cache can be used. These\n> -       tests can take a few seconds. `--force-untracked-cache` can be\n> -       used to skip the tests.\n> +       Same as `--untracked-cache`. Provided for backwards\n> +       compatibility with older versions of Git where\n> +       `--untracked-cache` used to imply `--test-untracked-cache` but\n> +       this option would enable the extension unconditionally.\n\nNit. The reason --force-untracked-cache remains can probably stay in\nthe commit message. Here we can simply say \"synonym of\n--untracked-cache, deprecated\" or something like that (or even \".. to\nbe deleted in version N.M\").\n-- \nDuy\n"},{"id":"274991","messageId":"CAP8UFD0penKjBBUW-9aPJ=T8x7WfhZGDtH1-jBsuJ4CTb2mrXw@mail.gmail.com","threadId":"41072","inReplyTo":"CACsJy8C0CwbFy+Ghk3EWTyhqPYcr6xE5jczumWW98cAAHdfmPg@mail.gmail.com","subject":"Re: [PATCH v3 10/11] config: add core.untrackedCache","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-24T21:10:29Z","receivedAt":"2015-12-24T21:10:29Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Dec 24, 2015 at 11:13 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Dec 24, 2015 at 4:03 AM, Christian Couder\n> <christian.couder@gmail.com> wrote:\n>>  --force-untracked-cache::\n>> -       For safety, `--untracked-cache` performs tests on the working\n>> -       directory to make sure untracked cache can be used. These\n>> -       tests can take a few seconds. `--force-untracked-cache` can be\n>> -       used to skip the tests.\n>> +       Same as `--untracked-cache`. Provided for backwards\n>> +       compatibility with older versions of Git where\n>> +       `--untracked-cache` used to imply `--test-untracked-cache` but\n>> +       this option would enable the extension unconditionally.\n>\n> Nit. The reason --force-untracked-cache remains can probably stay in\n> the commit message. Here we can simply say \"synonym of\n> --untracked-cache, deprecated\" or something like that (or even \".. to\n> be deleted in version N.M\").\n\nYeah, I think \"deprecated\" should be enough and clearer, but I will\nsee with AEvar who helped me on this.\n\nThanks,\nChristian.\n"},{"id":"274992","messageId":"CAP8UFD12kjUFvuaSMj3Q5sgDzCELejO7mEBuZ8g-=Cfa7sv5=A@mail.gmail.com","threadId":"41072","inReplyTo":"CACsJy8BQi8LQSHsZ7UMduCdE2_AeNwxn3kppc1xTfaNsMN=OXA@mail.gmail.com","subject":"Re: [PATCH v3 04/11] update-index: add untracked cache notifications","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2015-12-24T21:11:50Z","receivedAt":"2015-12-24T21:11:50Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Dec 24, 2015 at 11:01 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Dec 24, 2015 at 4:03 AM, Christian Couder\n> <christian.couder@gmail.com> wrote:\n>> @@ -1135,10 +1135,16 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)\n>>                 }\n>>                 add_untracked_ident(the_index.untracked);\n>>                 the_index.cache_changed |= UNTRACKED_CHANGED;\n>> -       } else if (untracked_cache == UC_DISABLE && the_index.untracked) {\n>> -               free_untracked_cache(the_index.untracked);\n>> -               the_index.untracked = NULL;\n>> -               the_index.cache_changed |= UNTRACKED_CHANGED;\n>> +               if (verbose)\n>> +                       printf(_(\"Untracked cache enabled for '%s'\\n\"), get_git_work_tree());\n>\n> Nit. If you use report(), then you can skip \"if (verbose)\" because\n> it's done inside report().\n\nOk, will do.\n\nThanks,\nChristian.\n"}]}