{"thread":{"id":"35886","subject":"[PATCH 0/3] Wider exposure for index-v4","startedAt":"2014-02-15T19:23:12Z","lastAt":"2014-02-21T22:02:53Z","messageCount":10,"participants":["Thomas Gummerer","Duy Nguyen","Eric Sunshine","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"234863","messageId":"1392492197-7724-1-git-send-email-t.gummerer@gmail.com","threadId":"35886","inReplyTo":null,"subject":"[PATCH 0/3] Wider exposure for index-v4","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-15T19:23:12Z","receivedAt":"2014-02-15T19:23:12Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Hi,\n\nsince index-v5 didn't seem to generate enough interest to be merged, I\nhave a few patches that give users users easier access to index-v4.\nUntil now users have to go into the source code and compile git\nthemselves to use index-v4 by default, or use git-update-index to\nchange the index file to the new version.\n\nWith this patches it's possible to set the default index file format\neither in gitconfig or in an environment variable.  It also simplifies\ntesting index-v4 by adding a Makefile knob to use it for running the\ntest suite.  For safety, existing repositories are not changed when\nthe environment or the config variables are set.\n\nI'm not sure about the precedence in patch 3, right now the environment\nvariable has precedence, but it should be easy to give the config\noption precedence over that.\n\nThomas Gummerer (3):\nintroduce GIT_INDEX_VERSION environment variable\ntest-lib: allow setting the index format version\nread-cache: add index.version config variable\n\nDocumentation/config.txt              |  4 +++\nDocumentation/git.txt                 |  5 ++++\nMakefile                              |  7 +++++\nread-cache.c                          | 36 +++++++++++++++++++++++-\nt/t1600-index.sh                      | 52 +++++++++++++++++++++++++++++++++++\nt/t2104-update-index-skip-worktree.sh |  2 ++\nt/test-lib-functions.sh               |  5 ++++\nt/test-lib.sh                         |  3 ++\n8 files changed, 113 insertions(+), 1 deletion(-)\ncreate mode 100755 t/t1600-index.sh\n\n--\n1.8.3.2\n"},{"id":"234865","messageId":"1392492197-7724-2-git-send-email-t.gummerer@gmail.com","threadId":"35886","inReplyTo":"1392492197-7724-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 1/3] introduce GIT_INDEX_VERSION environment variable","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-15T19:23:13Z","receivedAt":"2014-02-15T19:23:13Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Respect a GIT_INDEX_VERSION environment variable, when a new index is\ninitialized.  Setting the environment variable will not cause existing\nindex files to be converted to another format, but will only affect\nnewly written index files.  This can be used to initialize repositories\nwith index-v4.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/git.txt |  5 +++++\n read-cache.c          | 18 +++++++++++++++++-\n t/t1600-index.sh      | 24 ++++++++++++++++++++++++\n 3 files changed, 46 insertions(+), 1 deletion(-)\n create mode 100755 t/t1600-index.sh\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex aec3726..bc9eeea 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -712,6 +712,11 @@ Git so take care if using Cogito etc.\n \tindex file. If not specified, the default of `$GIT_DIR/index`\n \tis used.\n \n+'GIT_INDEX_VERSION'::\n+\tThis environment variable allows the specification of an index\n+\tversion for new repositories.  It won't affect existing index\n+\tfiles.  By default index file version 3 is used.\n+\n 'GIT_OBJECT_DIRECTORY'::\n \tIf the object storage directory is specified via this\n \tenvironment variable then the sha1 directories are created\ndiff --git a/read-cache.c b/read-cache.c\nindex 3f735f3..3993e12 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1223,6 +1223,22 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall\n \n #define INDEX_FORMAT_DEFAULT 3\n \n+static unsigned int get_index_format_default()\n+{\n+\tchar *envversion = getenv(\"GIT_INDEX_VERSION\");\n+\tif (!envversion) {\n+\t\treturn INDEX_FORMAT_DEFAULT;\n+\t} else {\n+\t\tunsigned int version = strtol(envversion, NULL, 10);\n+\t\tif (version < INDEX_FORMAT_LB || version > INDEX_FORMAT_UB) {\n+\t\t\twarning(_(\"GIT_INDEX_VERSION set, but the value is invalid.\\n\"\n+\t\t\t\t  \"Using version %i\"), INDEX_FORMAT_DEFAULT);\n+\t\t\tversion = INDEX_FORMAT_DEFAULT;\n+\t\t}\n+\t\treturn version;\n+\t}\n+}\n+\n /*\n  * dev/ino/uid/gid/size are also just tracked to the low 32 bits\n  * Again - this is just a (very strong in practice) heuristic that\n@@ -1799,7 +1815,7 @@ int write_index(struct index_state *istate, int newfd)\n \t}\n \n \tif (!istate->version)\n-\t\tistate->version = INDEX_FORMAT_DEFAULT;\n+\t\tistate->version = get_index_format_default();\n \n \t/* demote version 3 to version 2 when the latter suffices */\n \tif (istate->version == 3 || istate->version == 2)\ndiff --git a/t/t1600-index.sh b/t/t1600-index.sh\nnew file mode 100755\nindex 0000000..37fd84d\n--- /dev/null\n+++ b/t/t1600-index.sh\n@@ -0,0 +1,24 @@\n+#!/bin/sh\n+\n+test_description='index file specific tests'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\techo 1 >a\n+'\n+\n+test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '\n+\t(\n+\t\tGIT_INDEX_VERSION=1 &&\n+\t\texport GIT_INDEX_VERSION &&\n+\t\tgit add a 2>&1 | sed \"s/[0-9]//\" >actual.err &&\n+\t\tsed -e \"s/ Z$/ /\" <<-\\EOF >expect.err &&\n+\t\t\twarning: GIT_INDEX_VERSION set, but the value is invalid.\n+\t\t\tUsing version Z\n+\t\tEOF\n+\t\ttest_i18ncmp expect.err actual.err\n+\t)\n+'\n+\n+test_done\n-- \n1.8.5.2.300.ge613be6.dirty\n"},{"id":"234864","messageId":"1392492197-7724-3-git-send-email-t.gummerer@gmail.com","threadId":"35886","inReplyTo":"1392492197-7724-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 2/3] test-lib: allow setting the index format version","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-15T19:23:14Z","receivedAt":"2014-02-15T19:23:14Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Allow adding a TEST_GIT_INDEX_VERSION variable to config.mak to set the\nindex version with which the test suite should be run.\n\nIf it isn't set, the default version given in the source code is\nused (currently version 3).\n\nTo avoid breakages with index versions other than [23], also set the\nindex version under which t2104 is run to 3.  This test only tests\nfunctionality specific to version 2 and 3 of the index file and would\nfail if the test suite is run with any other version.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Makefile                              | 7 +++++++\n t/t2104-update-index-skip-worktree.sh | 2 ++\n t/test-lib-functions.sh               | 5 +++++\n t/test-lib.sh                         | 3 +++\n 4 files changed, 17 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 287e6f8..c98d28f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -342,6 +342,10 @@ all::\n # Define DEFAULT_HELP_FORMAT to \"man\", \"info\" or \"html\"\n # (defaults to \"man\") if you want to have a different default when\n # \"git help\" is called without a parameter specifying the format.\n+#\n+# Define TEST_GIT_INDEX_FORMAT to 2, 3 or 4 to run the test suite\n+# with a different indexfile format.  If it isn't set the index file\n+# format used is index-v[23].\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -2223,6 +2227,9 @@ endif\n ifdef GIT_PERF_MAKE_OPTS\n \t@echo GIT_PERF_MAKE_OPTS=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_PERF_MAKE_OPTS)))'\\' >>$@\n endif\n+ifdef TEST_GIT_INDEX_VERSION\n+\t@echo TEST_GIT_INDEX_VERSION=\\''$(subst ','\\'',$(subst ','\\'',$(TEST_GIT_INDEX_VERSION)))'\\' >>$@\n+endif\n \n ### Detect Python interpreter path changes\n ifndef NO_PYTHON\ndiff --git a/t/t2104-update-index-skip-worktree.sh b/t/t2104-update-index-skip-worktree.sh\nindex 1d0879b..29c1fb1 100755\n--- a/t/t2104-update-index-skip-worktree.sh\n+++ b/t/t2104-update-index-skip-worktree.sh\n@@ -7,6 +7,8 @@ test_description='skip-worktree bit test'\n \n . ./test-lib.sh\n \n+test_set_index_version 3\n+\n cat >expect.full <<EOF\n H 1\n H 2\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex aeae3ca..0bf1e63 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -32,6 +32,11 @@ test_set_editor () {\n \texport EDITOR\n }\n \n+test_set_index_version () {\n+    GIT_INDEX_VERSION=\"$1\"\n+    export GIT_INDEX_VERSION\n+}\n+\n test_decode_color () {\n \tawk '\n \t\tfunction name(n) {\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 1cf78d5..e6cf5b0 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -108,6 +108,9 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME\n export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME\n export EDITOR\n \n+GIT_INDEX_VERSION=\"$TEST_GIT_INDEX_VERSION\"\n+export GIT_INDEX_VERSION\n+\n # Add libc MALLOC and MALLOC_PERTURB test\n # only if we are not executing the test with valgrind\n if expr \" $GIT_TEST_OPTS \" : \".* --valgrind \" >/dev/null ||\n-- \n1.8.5.2.300.ge613be6.dirty\n"},{"id":"234866","messageId":"1392492197-7724-4-git-send-email-t.gummerer@gmail.com","threadId":"35886","inReplyTo":"1392492197-7724-1-git-send-email-t.gummerer@gmail.com","subject":"[PATCH 3/3] read-cache: add index.version config variable","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-15T19:23:15Z","receivedAt":"2014-02-15T19:23:15Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Add a config variable that allows setting the default index version when\ninitializing a new index file.  Similar to the GIT_INDEX_VERSION\nenvironment variable this only affects new index files.\n\nSigned-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n---\n Documentation/config.txt |  4 ++++\n read-cache.c             | 27 ++++++++++++++++++++++-----\n t/t1600-index.sh         | 27 +++++++++++++++++++++++++++\n 3 files changed, 53 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1655455..033939a 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1591,6 +1591,10 @@ imap::\n \tThe configuration variables in the 'imap' section are described\n \tin linkgit:git-imap-send[1].\n \n+index.version::\n+\tSpecify the version with which new index files should be\n+\tinitialized.  This does not affect existing repositories.\n+\n init.templatedir::\n \tSpecify the directory from which templates will be copied.\n \t(See the \"TEMPLATE DIRECTORY\" section of linkgit:git-init[1].)\ndiff --git a/read-cache.c b/read-cache.c\nindex 3993e12..ca9b68c 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1223,20 +1223,37 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall\n \n #define INDEX_FORMAT_DEFAULT 3\n \n+static int index_format_config(const char *var, const char *value, void *cb)\n+{\n+\tunsigned int *version = cb;\n+\tif (!strcmp(var, \"index.version\")) {\n+\t\t*version = git_config_int(var, value);\n+\t\treturn 0;\n+\t}\n+\treturn 1;\n+}\n+\n+\n static unsigned int get_index_format_default()\n {\n \tchar *envversion = getenv(\"GIT_INDEX_VERSION\");\n+\tunsigned int version = INDEX_FORMAT_DEFAULT;\n \tif (!envversion) {\n-\t\treturn INDEX_FORMAT_DEFAULT;\n-\t} else {\n-\t\tunsigned int version = strtol(envversion, NULL, 10);\n+\t\tgit_config(index_format_config, &version);\n \t\tif (version < INDEX_FORMAT_LB || version > INDEX_FORMAT_UB) {\n-\t\t\twarning(_(\"GIT_INDEX_VERSION set, but the value is invalid.\\n\"\n+\t\t\twarning(_(\"index.version set, but the value is invalid.\\n\"\n \t\t\t\t  \"Using version %i\"), INDEX_FORMAT_DEFAULT);\n-\t\t\tversion = INDEX_FORMAT_DEFAULT;\n+\t\t\treturn INDEX_FORMAT_DEFAULT;\n \t\t}\n \t\treturn version;\n \t}\n+\tversion = strtol(envversion, NULL, 10);\n+\tif (version < INDEX_FORMAT_LB || version > INDEX_FORMAT_UB) {\n+\t\twarning(_(\"GIT_INDEX_VERSION set, but the value is invalid.\\n\"\n+\t\t\t  \"Using version %i\"), INDEX_FORMAT_DEFAULT);\n+\t\tversion = INDEX_FORMAT_DEFAULT;\n+\t}\n+\treturn version;\n }\n \n /*\ndiff --git a/t/t1600-index.sh b/t/t1600-index.sh\nindex 37fd84d..bf34985 100755\n--- a/t/t1600-index.sh\n+++ b/t/t1600-index.sh\n@@ -21,4 +21,31 @@ test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '\n \t)\n '\n \n+test_expect_success 'out of bounds index.version issuses warning' '\n+\t(\n+\t\tunset GIT_INDEX_VERSION &&\n+\t\trm .git/index &&\n+\t\tgit config --add index.version 1 &&\n+\t\tgit add a 2>&1 | sed \"s/[0-9]//\" >actual.err &&\n+\t\tsed -e \"s/ Z$/ /\" <<-\\EOF >expect.err &&\n+\t\t\twarning: index.version set, but the value is invalid.\n+\t\t\tUsing version Z\n+\t\tEOF\n+\t\ttest_i18ncmp expect.err actual.err\n+\t)\n+'\n+\n+test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '\n+\t(\n+\t\trm .git/index &&\n+\t\tGIT_INDEX_VERSION=4 &&\n+\t\texport GIT_INDEX_VERSION &&\n+\t\tgit config --add index.version 2 &&\n+\t\tgit add a 2>&1 &&\n+\t\techo 4 >expect &&\n+\t\ttest-index-version <.git/index >actual &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_done\n-- \n1.8.5.2.300.ge613be6.dirty\n"},{"id":"234868","messageId":"CACsJy8BDerqeua6zjGhniy_kxruDk9WuTJY-2zi6m4EpE9=CBg@mail.gmail.com","threadId":"35886","inReplyTo":"1392492197-7724-1-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 0/3] Wider exposure for index-v4","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-16T01:16:41Z","receivedAt":"2014-02-16T01:16:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Feb 16, 2014 at 2:23 AM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n> Hi,\n>\n> since index-v5 didn't seem to generate enough interest to be merged, I\n\nI thought there were some comments last time that you were going to\naddress and resubmit?\n\n> have a few patches that give users users easier access to index-v4.\n> Until now users have to go into the source code and compile git\n> themselves to use index-v4 by default, or use git-update-index to\n> change the index file to the new version.\n\nNot objecting this, but I think something like [1] would give v4 more\nexposure. Reading the patch again, I think putting that detection code\nin unpack_trees() or git-merge may make more sense because people will\nbe advised about upgrading to v4 at the next fast-forward.\n\n[1] http://article.gmane.org/gmane.comp.version-control.git/216307\n\n> With this patches it's possible to set the default index file format\n> either in gitconfig or in an environment variable.  It also simplifies\n> testing index-v4 by adding a Makefile knob to use it for running the\n> test suite.  For safety, existing repositories are not changed when\n> the environment or the config variables are set.\n>\n> I'm not sure about the precedence in patch 3, right now the environment\n> variable has precedence, but it should be easy to give the config\n> option precedence over that.\n>\n> Thomas Gummerer (3):\n> introduce GIT_INDEX_VERSION environment variable\n> test-lib: allow setting the index format version\n> read-cache: add index.version config variable\n>\n> Documentation/config.txt              |  4 +++\n> Documentation/git.txt                 |  5 ++++\n> Makefile                              |  7 +++++\n> read-cache.c                          | 36 +++++++++++++++++++++++-\n> t/t1600-index.sh                      | 52 +++++++++++++++++++++++++++++++++++\n> t/t2104-update-index-skip-worktree.sh |  2 ++\n> t/test-lib-functions.sh               |  5 ++++\n> t/test-lib.sh                         |  3 ++\n> 8 files changed, 113 insertions(+), 1 deletion(-)\n> create mode 100755 t/t1600-index.sh\n>\n> --\n> 1.8.3.2\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\n\n-- \nDuy\n"},{"id":"234869","messageId":"CAPig+cTAd4DL3WaCBJ82q5i-7EObER5BrQX92LQozeJqKTaOZQ@mail.gmail.com","threadId":"35886","inReplyTo":"1392492197-7724-4-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 3/3] read-cache: add index.version config variable","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-02-16T02:10:00Z","receivedAt":"2014-02-16T02:10:00Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Feb 15, 2014 at 2:23 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n> Add a config variable that allows setting the default index version when\n> initializing a new index file.  Similar to the GIT_INDEX_VERSION\n> environment variable this only affects new index files.\n>\n> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>\n> ---\n> index 37fd84d..bf34985 100755\n> --- a/t/t1600-index.sh\n> +++ b/t/t1600-index.sh\n> @@ -21,4 +21,31 @@ test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '\n>         )\n>  '\n>\n> +test_expect_success 'out of bounds index.version issuses warning' '\n\ns/issuses/issues/\n\n> +       (\n> +               unset GIT_INDEX_VERSION &&\n> +               rm .git/index &&\n> +               git config --add index.version 1 &&\n> +               git add a 2>&1 | sed \"s/[0-9]//\" >actual.err &&\n> +               sed -e \"s/ Z$/ /\" <<-\\EOF >expect.err &&\n> +                       warning: index.version set, but the value is invalid.\n> +                       Using version Z\n> +               EOF\n> +               test_i18ncmp expect.err actual.err\n> +       )\n> +'\n> +\n> +test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '\n> +       (\n> +               rm .git/index &&\n> +               GIT_INDEX_VERSION=4 &&\n> +               export GIT_INDEX_VERSION &&\n> +               git config --add index.version 2 &&\n> +               git add a 2>&1 &&\n> +               echo 4 >expect &&\n> +               test-index-version <.git/index >actual &&\n> +               test_cmp expect actual\n> +       )\n> +'\n> +\n>  test_done\n> --\n> 1.8.5.2.300.ge613be6.dirty\n"},{"id":"234883","messageId":"87wqgvmjgs.fsf@hank.lan","threadId":"35886","inReplyTo":"CACsJy8BDerqeua6zjGhniy_kxruDk9WuTJY-2zi6m4EpE9=CBg@mail.gmail.com","subject":"Re: [PATCH 0/3] Wider exposure for index-v4","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-16T10:37:39Z","receivedAt":"2014-02-16T10:37:39Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Sun, Feb 16, 2014 at 2:23 AM, Thomas Gummerer <t.gummerer@gmail.com> wrote:\n>> Hi,\n>>\n>> since index-v5 didn't seem to generate enough interest to be merged, I\n>\n> I thought there were some comments last time that you were going to\n> address and resubmit?\n\nYes, there were some comments to the last round, which I already fixed\nlocally, I'd just have to rebase it to make sure it stell applies\ncleanly.  No responses from Junio to [1] and [2] gave me the impression\nthat it's not going to be applied.  I would be happy to rebase and\nsubmit if there is a chance for it getting in.\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/238414/focus=239065\n[2] http://thread.gmane.org/gmane.comp.version-control.git/232488/focus=233504\n\n>> have a few patches that give users users easier access to index-v4.\n>> Until now users have to go into the source code and compile git\n>> themselves to use index-v4 by default, or use git-update-index to\n>> change the index file to the new version.\n>\n> Not objecting this, but I think something like [1] would give v4 more\n> exposure. Reading the patch again, I think putting that detection code\n> in unpack_trees() or git-merge may make more sense because people will\n> be advised about upgrading to v4 at the next fast-forward.\n\nThanks, I forgot about this patch.  I still think at least the first two\npatches of this series make sense in addition to your patch, allowing\ndevelopers to easily run the test suite with index-v4.\n\n> [1] http://article.gmane.org/gmane.comp.version-control.git/216307\n>\n>> With this patches it's possible to set the default index file format\n>> either in gitconfig or in an environment variable.  It also simplifies\n>> testing index-v4 by adding a Makefile knob to use it for running the\n>> test suite.  For safety, existing repositories are not changed when\n>> the environment or the config variables are set.\n>>\n>> I'm not sure about the precedence in patch 3, right now the environment\n>> variable has precedence, but it should be easy to give the config\n>> option precedence over that.\n>>\n>> Thomas Gummerer (3):\n>> introduce GIT_INDEX_VERSION environment variable\n>> test-lib: allow setting the index format version\n>> read-cache: add index.version config variable\n>>\n>> Documentation/config.txt              |  4 +++\n>> Documentation/git.txt                 |  5 ++++\n>> Makefile                              |  7 +++++\n>> read-cache.c                          | 36 +++++++++++++++++++++++-\n>> t/t1600-index.sh                      | 52 +++++++++++++++++++++++++++++++++++\n>> t/t2104-update-index-skip-worktree.sh |  2 ++\n>> t/test-lib-functions.sh               |  5 ++++\n>> t/test-lib.sh                         |  3 ++\n>> 8 files changed, 113 insertions(+), 1 deletion(-)\n>> create mode 100755 t/t1600-index.sh\n>>\n>> --\n>> 1.8.3.2\n>>\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n>\n>\n> --\n> Duy\n"},{"id":"235043","messageId":"xmqqsirg9c4z.fsf@gitster.dls.corp.google.com","threadId":"35886","inReplyTo":"1392492197-7724-2-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 1/3] introduce GIT_INDEX_VERSION environment variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-19T00:31:08Z","receivedAt":"2014-02-19T00:31:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Gummerer <t.gummerer@gmail.com> writes:\n\n> diff --git a/Documentation/git.txt b/Documentation/git.txt\n> index aec3726..bc9eeea 100644\n> --- a/Documentation/git.txt\n> +++ b/Documentation/git.txt\n> @@ -712,6 +712,11 @@ Git so take care if using Cogito etc.\n>  \tindex file. If not specified, the default of `$GIT_DIR/index`\n>  \tis used.\n>  \n> +'GIT_INDEX_VERSION'::\n> +\tThis environment variable allows the specification of an index\n> +\tversion for new repositories.  It won't affect existing index\n> +\tfiles.  By default index file version 3 is used.\n> +\n\nThis is half-correct, isn't it?  In-code variable may say version 3\nbut we demote it to version 2 unless we absolutely need to use the\nversion 3 ugliness.\n\n> diff --git a/read-cache.c b/read-cache.c\n> index 3f735f3..3993e12 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -1223,6 +1223,22 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall\n>  \n>  #define INDEX_FORMAT_DEFAULT 3\n>  \n> +static unsigned int get_index_format_default()\n> +{\n> +\tchar *envversion = getenv(\"GIT_INDEX_VERSION\");\n> +\tif (!envversion) {\n> +\t\treturn INDEX_FORMAT_DEFAULT;\n> +\t} else {\n> +\t\tunsigned int version = strtol(envversion, NULL, 10);\n\nIf we are using strtol() to parse it carefully, we should make sure\nit parses to the end by giving a non-NULL second argument and\nchecking where the parsing stopped.\n\n> diff --git a/t/t1600-index.sh b/t/t1600-index.sh\n> new file mode 100755\n> index 0000000..37fd84d\n> --- /dev/null\n> +++ b/t/t1600-index.sh\n> @@ -0,0 +1,24 @@\n> +#!/bin/sh\n> +\n> +test_description='index file specific tests'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success 'setup' '\n> +\techo 1 >a\n> +'\n> +\n> +test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '\n> +\t(\n> +\t\tGIT_INDEX_VERSION=1 &&\n> +\t\texport GIT_INDEX_VERSION &&\n> +\t\tgit add a 2>&1 | sed \"s/[0-9]//\" >actual.err &&\n> +\t\tsed -e \"s/ Z$/ /\" <<-\\EOF >expect.err &&\n> +\t\t\twarning: GIT_INDEX_VERSION set, but the value is invalid.\n> +\t\t\tUsing version Z\n> +\t\tEOF\n> +\t\ttest_i18ncmp expect.err actual.err\n> +\t)\n> +'\n\nIf we already have an index in version N when this test starts, what\nshould happen?\n\nWill queue on 'pu', with some suggested fixups.\n\nThanks.\n"},{"id":"235044","messageId":"xmqqlhx89c45.fsf@gitster.dls.corp.google.com","threadId":"35886","inReplyTo":"1392492197-7724-3-git-send-email-t.gummerer@gmail.com","subject":"Re: [PATCH 2/3] test-lib: allow setting the index format version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-19T00:31:38Z","receivedAt":"2014-02-19T00:31:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Gummerer <t.gummerer@gmail.com> writes:\n\n> Allow adding a TEST_GIT_INDEX_VERSION variable to config.mak to set the\n> index version with which the test suite should be run.\n> ...\n> diff --git a/Makefile b/Makefile\n> index 287e6f8..c98d28f 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -342,6 +342,10 @@ all::\n>  # Define DEFAULT_HELP_FORMAT to \"man\", \"info\" or \"html\"\n>  # (defaults to \"man\") if you want to have a different default when\n>  # \"git help\" is called without a parameter specifying the format.\n> +#\n> +# Define TEST_GIT_INDEX_FORMAT to 2, 3 or 4 to run the test suite\n\ns/_FORMAT/_VERSION/, I would think.\n\nWill queue on 'pu' with a fix-up on top.\n\nThanks.\n"},{"id":"235156","messageId":"87d2ig5dki.fsf@hank.lan","threadId":"35886","inReplyTo":"xmqqsirg9c4z.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH 1/3] introduce GIT_INDEX_VERSION environment variable","fromName":"Thomas Gummerer","fromEmail":"t.gummerer@gmail.com","sentAt":"2014-02-21T22:02:53Z","receivedAt":"2014-02-21T22:02:53Z","isPatch":true,"sender":{"key":"t.gummerer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/191004?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Thomas Gummerer <t.gummerer@gmail.com> writes:\n>\n>> diff --git a/Documentation/git.txt b/Documentation/git.txt\n>> index aec3726..bc9eeea 100644\n>> --- a/Documentation/git.txt\n>> +++ b/Documentation/git.txt\n>> @@ -712,6 +712,11 @@ Git so take care if using Cogito etc.\n>>  \tindex file. If not specified, the default of `$GIT_DIR/index`\n>>  \tis used.\n>>  \n>> +'GIT_INDEX_VERSION'::\n>> +\tThis environment variable allows the specification of an index\n>> +\tversion for new repositories.  It won't affect existing index\n>> +\tfiles.  By default index file version 3 is used.\n>> +\n>\n> This is half-correct, isn't it?  In-code variable may say version 3\n> but we demote it to version 2 unless we absolutely need to use the\n> version 3 ugliness.\n\nYes, you're right, to be correct we should say [23] instead of 3 here\nmaybe?\n\n>> diff --git a/read-cache.c b/read-cache.c\n>> index 3f735f3..3993e12 100644\n>> --- a/read-cache.c\n>> +++ b/read-cache.c\n>> @@ -1223,6 +1223,22 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall\n>>  \n>>  #define INDEX_FORMAT_DEFAULT 3\n>>  \n>> +static unsigned int get_index_format_default()\n>> +{\n>> +\tchar *envversion = getenv(\"GIT_INDEX_VERSION\");\n>> +\tif (!envversion) {\n>> +\t\treturn INDEX_FORMAT_DEFAULT;\n>> +\t} else {\n>> +\t\tunsigned int version = strtol(envversion, NULL, 10);\n>\n> If we are using strtol() to parse it carefully, we should make sure\n> it parses to the end by giving a non-NULL second argument and\n> checking where the parsing stopped.\n\nThanks, makes sense, will fix it in the re-roll.\n\n>> diff --git a/t/t1600-index.sh b/t/t1600-index.sh\n>> new file mode 100755\n>> index 0000000..37fd84d\n>> --- /dev/null\n>> +++ b/t/t1600-index.sh\n>> @@ -0,0 +1,24 @@\n>> +#!/bin/sh\n>> +\n>> +test_description='index file specific tests'\n>> +\n>> +. ./test-lib.sh\n>> +\n>> +test_expect_success 'setup' '\n>> +\techo 1 >a\n>> +'\n>> +\n>> +test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '\n>> +\t(\n>> +\t\tGIT_INDEX_VERSION=1 &&\n>> +\t\texport GIT_INDEX_VERSION &&\n>> +\t\tgit add a 2>&1 | sed \"s/[0-9]//\" >actual.err &&\n>> +\t\tsed -e \"s/ Z$/ /\" <<-\\EOF >expect.err &&\n>> +\t\t\twarning: GIT_INDEX_VERSION set, but the value is invalid.\n>> +\t\t\tUsing version Z\n>> +\t\tEOF\n>> +\t\ttest_i18ncmp expect.err actual.err\n>> +\t)\n>> +'\n>\n> If we already have an index in version N when this test starts, what\n> should happen?\n\nI think we shouldn't print anything, since we won't change the file\nformat.  I'll add another test for that.\n\n> Will queue on 'pu', with some suggested fixups.\n\nThanks, I think both fixups in 'pu' make sense, so I'll include them in\nthe re-roll.\n\n> Thanks.\n"}]}