From: Thomas Gummerer <hidden> Date: 2016-06-15 22:59:55
Hi,
since index-v5 didn't seem to generate enough interest to be merged, I
have a few patches that give users users easier access to index-v4.
Until now users have to go into the source code and compile git
themselves to use index-v4 by default, or use git-update-index to
change the index file to the new version.
With this patches it's possible to set the default index file format
either in gitconfig or in an environment variable. It also simplifies
testing index-v4 by adding a Makefile knob to use it for running the
test suite. For safety, existing repositories are not changed when
the environment or the config variables are set.
I'm not sure about the precedence in patch 3, right now the environment
variable has precedence, but it should be easy to give the config
option precedence over that.
Thomas Gummerer (3):
introduce GIT_INDEX_VERSION environment variable
test-lib: allow setting the index format version
read-cache: add index.version config variable
Documentation/config.txt | 4 +++
Documentation/git.txt | 5 ++++
Makefile | 7 +++++
read-cache.c | 36 +++++++++++++++++++++++-
t/t1600-index.sh | 52 +++++++++++++++++++++++++++++++++++
t/t2104-update-index-skip-worktree.sh | 2 ++
t/test-lib-functions.sh | 5 ++++
t/test-lib.sh | 3 ++
8 files changed, 113 insertions(+), 1 deletion(-)
create mode 100755 t/t1600-index.sh
--
1.8.3.2
From: Thomas Gummerer <hidden> Date: 2016-06-15 22:59:55
Allow adding a TEST_GIT_INDEX_VERSION variable to config.mak to set the
index version with which the test suite should be run.
If it isn't set, the default version given in the source code is
used (currently version 3).
To avoid breakages with index versions other than [23], also set the
index version under which t2104 is run to 3. This test only tests
functionality specific to version 2 and 3 of the index file and would
fail if the test suite is run with any other version.
Signed-off-by: Thomas Gummerer <redacted>
---
Makefile | 7 +++++++
t/t2104-update-index-skip-worktree.sh | 2 ++
t/test-lib-functions.sh | 5 +++++
t/test-lib.sh | 3 +++
4 files changed, 17 insertions(+)
@@ -342,6 +342,10 @@ all::# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"# (defaults to "man") if you want to have a different default when# "git help" is called without a parameter specifying the format.+#+# Define TEST_GIT_INDEX_FORMAT to 2, 3 or 4 to run the test suite+# with a different indexfile format. If it isn't set the index file+# format used is index-v[23].GIT-VERSION-FILE:FORCE@$(SHELL_PATH)./GIT-VERSION-GEN
@@ -108,6 +108,9 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAMEexportGIT_COMMITTER_EMAILGIT_COMMITTER_NAMEexportEDITOR+GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION"+exportGIT_INDEX_VERSION+# Add libc MALLOC and MALLOC_PERTURB test# only if we are not executing the test with valgrindifexpr" $GIT_TEST_OPTS ":".* --valgrind ">/dev/null||
From: Thomas Gummerer <hidden> Date: 2016-06-15 22:59:55
Respect a GIT_INDEX_VERSION environment variable, when a new index is
initialized. Setting the environment variable will not cause existing
index files to be converted to another format, but will only affect
newly written index files. This can be used to initialize repositories
with index-v4.
Signed-off-by: Thomas Gummerer <redacted>
---
Documentation/git.txt | 5 +++++
read-cache.c | 18 +++++++++++++++++-
t/t1600-index.sh | 24 ++++++++++++++++++++++++
3 files changed, 46 insertions(+), 1 deletion(-)
create mode 100755 t/t1600-index.sh
@@ -712,6 +712,11 @@ Git so take care if using Cogito etc. index file. If not specified, the default of `$GIT_DIR/index` is used.+'GIT_INDEX_VERSION'::+ This environment variable allows the specification of an index+ version for new repositories. It won't affect existing index+ files. By default index file version 3 is used.+ 'GIT_OBJECT_DIRECTORY':: If the object storage directory is specified via this environment variable then the sha1 directories are created
@@ -1223,6 +1223,22 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall#define INDEX_FORMAT_DEFAULT 3+staticunsignedintget_index_format_default()+{+char*envversion=getenv("GIT_INDEX_VERSION");+if(!envversion){+returnINDEX_FORMAT_DEFAULT;+}else{+unsignedintversion=strtol(envversion,NULL,10);+if(version<INDEX_FORMAT_LB||version>INDEX_FORMAT_UB){+warning(_("GIT_INDEX_VERSION set, but the value is invalid.\n"+"Using version %i"),INDEX_FORMAT_DEFAULT);+version=INDEX_FORMAT_DEFAULT;+}+returnversion;+}+}+/**dev/ino/uid/gid/sizearealsojusttrackedtothelow32bits*Again-thisisjusta(verystronginpractice)heuristicthat
@@ -1799,7 +1815,7 @@ int write_index(struct index_state *istate, int newfd)}if(!istate->version)-istate->version=INDEX_FORMAT_DEFAULT;+istate->version=get_index_format_default();/* demote version 3 to version 2 when the latter suffices */if(istate->version==3||istate->version==2)
From: Thomas Gummerer <hidden> Date: 2016-06-15 22:59:55
Add a config variable that allows setting the default index version when
initializing a new index file. Similar to the GIT_INDEX_VERSION
environment variable this only affects new index files.
Signed-off-by: Thomas Gummerer <redacted>
---
Documentation/config.txt | 4 ++++
read-cache.c | 27 ++++++++++++++++++++++-----
t/t1600-index.sh | 27 +++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 5 deletions(-)
@@ -1591,6 +1591,10 @@ imap:: The configuration variables in the 'imap' section are described in linkgit:git-imap-send[1].+index.version::+ Specify the version with which new index files should be+ initialized. This does not affect existing repositories.+ init.templatedir:: Specify the directory from which templates will be copied. (See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].)
@@ -1223,20 +1223,37 @@ static struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int reall#define INDEX_FORMAT_DEFAULT 3+staticintindex_format_config(constchar*var,constchar*value,void*cb)+{+unsignedint*version=cb;+if(!strcmp(var,"index.version")){+*version=git_config_int(var,value);+return0;+}+return1;+}++staticunsignedintget_index_format_default(){char*envversion=getenv("GIT_INDEX_VERSION");+unsignedintversion=INDEX_FORMAT_DEFAULT;if(!envversion){-returnINDEX_FORMAT_DEFAULT;-}else{-unsignedintversion=strtol(envversion,NULL,10);+git_config(index_format_config,&version);if(version<INDEX_FORMAT_LB||version>INDEX_FORMAT_UB){-warning(_("GIT_INDEX_VERSION set, but the value is invalid.\n"+warning(_("index.version set, but the value is invalid.\n""Using version %i"),INDEX_FORMAT_DEFAULT);-version=INDEX_FORMAT_DEFAULT;+returnINDEX_FORMAT_DEFAULT;}returnversion;}+version=strtol(envversion,NULL,10);+if(version<INDEX_FORMAT_LB||version>INDEX_FORMAT_UB){+warning(_("GIT_INDEX_VERSION set, but the value is invalid.\n"+"Using version %i"),INDEX_FORMAT_DEFAULT);+version=INDEX_FORMAT_DEFAULT;+}+returnversion;}/*
On Sun, Feb 16, 2014 at 2:23 AM, Thomas Gummerer [off-list ref] wrote:
Hi,
since index-v5 didn't seem to generate enough interest to be merged, I
I thought there were some comments last time that you were going to
address and resubmit?
have a few patches that give users users easier access to index-v4.
Until now users have to go into the source code and compile git
themselves to use index-v4 by default, or use git-update-index to
change the index file to the new version.
Not objecting this, but I think something like [1] would give v4 more
exposure. Reading the patch again, I think putting that detection code
in unpack_trees() or git-merge may make more sense because people will
be advised about upgrading to v4 at the next fast-forward.
[1] http://article.gmane.org/gmane.comp.version-control.git/216307
With this patches it's possible to set the default index file format
either in gitconfig or in an environment variable. It also simplifies
testing index-v4 by adding a Makefile knob to use it for running the
test suite. For safety, existing repositories are not changed when
the environment or the config variables are set.
I'm not sure about the precedence in patch 3, right now the environment
variable has precedence, but it should be easy to give the config
option precedence over that.
Thomas Gummerer (3):
introduce GIT_INDEX_VERSION environment variable
test-lib: allow setting the index format version
read-cache: add index.version config variable
Documentation/config.txt | 4 +++
Documentation/git.txt | 5 ++++
Makefile | 7 +++++
read-cache.c | 36 +++++++++++++++++++++++-
t/t1600-index.sh | 52 +++++++++++++++++++++++++++++++++++
t/t2104-update-index-skip-worktree.sh | 2 ++
t/test-lib-functions.sh | 5 ++++
t/test-lib.sh | 3 ++
8 files changed, 113 insertions(+), 1 deletion(-)
create mode 100755 t/t1600-index.sh
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Sunshine <hidden> Date: 2016-06-15 22:59:55
On Sat, Feb 15, 2014 at 2:23 PM, Thomas Gummerer [off-list ref] wrote:
quoted hunk
Add a config variable that allows setting the default index version when
initializing a new index file. Similar to the GIT_INDEX_VERSION
environment variable this only affects new index files.
Signed-off-by: Thomas Gummerer <redacted>
---
index 37fd84d..bf34985 100755
--- a/t/t1600-index.sh+++ b/t/t1600-index.sh
@@ -21,4 +21,31 @@ test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' ')'+test_expect_success'out of bounds index.version issuses warning''
s/issuses/issues/
+ (
+ unset GIT_INDEX_VERSION &&
+ rm .git/index &&
+ git config --add index.version 1 &&
+ git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
+ sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
+ warning: index.version set, but the value is invalid.
+ Using version Z
+ EOF
+ test_i18ncmp expect.err actual.err
+ )
+'
+
+test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
+ (
+ rm .git/index &&
+ GIT_INDEX_VERSION=4 &&
+ export GIT_INDEX_VERSION &&
+ git config --add index.version 2 &&
+ git add a 2>&1 &&
+ echo 4 >expect &&
+ test-index-version <.git/index >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done
--
1.8.5.2.300.ge613be6.dirty
have a few patches that give users users easier access to index-v4.
Until now users have to go into the source code and compile git
themselves to use index-v4 by default, or use git-update-index to
change the index file to the new version.
Not objecting this, but I think something like [1] would give v4 more
exposure. Reading the patch again, I think putting that detection code
in unpack_trees() or git-merge may make more sense because people will
be advised about upgrading to v4 at the next fast-forward.
Thanks, I forgot about this patch. I still think at least the first two
patches of this series make sense in addition to your patch, allowing
developers to easily run the test suite with index-v4.
With this patches it's possible to set the default index file format
either in gitconfig or in an environment variable. It also simplifies
testing index-v4 by adding a Makefile knob to use it for running the
test suite. For safety, existing repositories are not changed when
the environment or the config variables are set.
I'm not sure about the precedence in patch 3, right now the environment
variable has precedence, but it should be easy to give the config
option precedence over that.
Thomas Gummerer (3):
introduce GIT_INDEX_VERSION environment variable
test-lib: allow setting the index format version
read-cache: add index.version config variable
Documentation/config.txt | 4 +++
Documentation/git.txt | 5 ++++
Makefile | 7 +++++
read-cache.c | 36 +++++++++++++++++++++++-
t/t1600-index.sh | 52 +++++++++++++++++++++++++++++++++++
t/t2104-update-index-skip-worktree.sh | 2 ++
t/test-lib-functions.sh | 5 ++++
t/test-lib.sh | 3 ++
8 files changed, 113 insertions(+), 1 deletion(-)
create mode 100755 t/t1600-index.sh
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
@@ -712,6 +712,11 @@ Git so take care if using Cogito etc. index file. If not specified, the default of `$GIT_DIR/index` is used.+'GIT_INDEX_VERSION'::+ This environment variable allows the specification of an index+ version for new repositories. It won't affect existing index+ files. By default index file version 3 is used.+
This is half-correct, isn't it? In-code variable may say version 3
but we demote it to version 2 unless we absolutely need to use the
version 3 ugliness.
If we are using strtol() to parse it carefully, we should make sure
it parses to the end by giving a non-NULL second argument and
checking where the parsing stopped.
@@ -342,6 +342,10 @@ all::# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"# (defaults to "man") if you want to have a different default when# "git help" is called without a parameter specifying the format.+#+# Define TEST_GIT_INDEX_FORMAT to 2, 3 or 4 to run the test suite
s/_FORMAT/_VERSION/, I would think.
Will queue on 'pu' with a fix-up on top.
Thanks.
@@ -712,6 +712,11 @@ Git so take care if using Cogito etc. index file. If not specified, the default of `$GIT_DIR/index` is used.+'GIT_INDEX_VERSION'::+ This environment variable allows the specification of an index+ version for new repositories. It won't affect existing index+ files. By default index file version 3 is used.+
This is half-correct, isn't it? In-code variable may say version 3
but we demote it to version 2 unless we absolutely need to use the
version 3 ugliness.
Yes, you're right, to be correct we should say [23] instead of 3 here
maybe?
If we are using strtol() to parse it carefully, we should make sure
it parses to the end by giving a non-NULL second argument and
checking where the parsing stopped.