Skip to content

Commit 8e016a5

Browse files
Kevin Willfordmjcheetham
authored andcommitted
gvfs: add the feature to skip writing the index' SHA-1
This takes a substantial amount of time, and if the user is reasonably sure that the files' integrity is not compromised, that time can be saved. Git no longer verifies the SHA-1 by default, anyway. Signed-off-by: Kevin Willford <[email protected]> Update for 2023-02-27: This feature was upstreamed as the index.skipHash config option. This resulted in some changes to the struct and some of the setup code. In particular, the config reading was moved to prepare_repo_settings(), so the core.gvfs bit check was moved there, too. Signed-off-by: Kevin Willford <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3081376 commit 8e016a5

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

Documentation/config/core.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,15 @@ core.multiPackIndex::
738738
information. Defaults to true.
739739

740740
core.gvfs::
741-
Enable the features needed for GVFS.
741+
Enable the features needed for GVFS. This value can be set to true
742+
to indicate all features should be turned on or the bit values listed
743+
below can be used to turn on specific features.
744+
+
745+
--
746+
GVFS_SKIP_SHA_ON_INDEX::
747+
Bit value 1
748+
Disables the calculation of the sha when writing the index
749+
--
742750

743751
core.sparseCheckout::
744752
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]

gvfs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
* used for GVFS functionality
88
*/
99

10+
11+
/*
12+
* The list of bits in the core_gvfs setting
13+
*/
14+
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
15+
1016
void gvfs_load_config_value(const char *value);
1117
int gvfs_config_is_set(int mask);
1218

repo-settings.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "midx.h"
66
#include "pack-objects.h"
77
#include "setup.h"
8+
#include "gvfs.h"
89

910
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
1011
int def)
@@ -78,6 +79,13 @@ void prepare_repo_settings(struct repository *r)
7879
r->settings.pack_use_bitmap_boundary_traversal);
7980
repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);
8081

82+
/*
83+
* For historical compatibility reasons, enable index.skipHash based
84+
* on a bit in core.gvfs.
85+
*/
86+
if (gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
87+
r->settings.index_skip_hash = 1;
88+
8189
/*
8290
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
8391
* either it *or* the config sets

t/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ integration_tests = [
178178
't1014-read-tree-confusing.sh',
179179
't1015-read-index-unmerged.sh',
180180
't1016-compatObjectFormat.sh',
181+
't1017-read-tree-skip-sha-on-read.sh',
181182
't1020-subdirectory.sh',
182183
't1021-rerere-in-workdir.sh',
183184
't1022-read-tree-partial-clone.sh',

t/t1017-read-tree-skip-sha-on-read.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
test_description='check that read-tree works with core.gvfs config value'
4+
5+
. ./test-lib.sh
6+
. "$TEST_DIRECTORY"/lib-read-tree.sh
7+
8+
test_expect_success setup '
9+
echo one >a &&
10+
git add a &&
11+
git commit -m initial
12+
'
13+
test_expect_success 'read-tree without core.gvsf' '
14+
read_tree_u_must_succeed -m -u HEAD
15+
'
16+
17+
test_expect_success 'read-tree with core.gvfs set to 1' '
18+
git config core.gvfs 1 &&
19+
read_tree_u_must_succeed -m -u HEAD
20+
'
21+
22+
test_done

0 commit comments

Comments
 (0)