Skip to content

Commit 854652c

Browse files
Kevin Willfordvdye
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 <kewillf@microsoft.com> 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: Derrick Stolee <derrickstolee@github.com>
1 parent 6420fd9 commit 854652c

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

Documentation/config/core.txt

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

731731
core.gvfs::
732-
Enable the features needed for GVFS.
732+
Enable the features needed for GVFS. This value can be set to true
733+
to indicate all features should be turned on or the bit values listed
734+
below can be used to turn on specific features.
735+
+
736+
--
737+
GVFS_SKIP_SHA_ON_INDEX::
738+
Bit value 1
739+
Disables the calculation of the sha when writing the index
740+
--
733741

734742
core.sparseCheckout::
735743
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
@@ -9,6 +9,12 @@
99
* used for GVFS functionality
1010
*/
1111

12+
13+
/*
14+
* The list of bits in the core_gvfs setting
15+
*/
16+
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
17+
1218
static inline int gvfs_config_is_set(int mask) {
1319
return (core_gvfs & mask) == mask;
1420
}

repo-settings.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "midx.h"
55
#include "fsmonitor-ipc.h"
66
#include "fsmonitor-settings.h"
7+
#include "gvfs.h"
78

89
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
910
int def)
@@ -89,6 +90,13 @@ void prepare_repo_settings(struct repository *r)
8990
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);
9091
repo_cfg_bool(r, "pack.readreverseindex", &r->settings.pack_read_reverse_index, 1);
9192

93+
/*
94+
* For historical compatibility reasons, enable index.skipHash based
95+
* on a bit in core.gvfs.
96+
*/
97+
if (gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
98+
r->settings.index_skip_hash = 1;
99+
92100
/*
93101
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
94102
* either it *or* the config sets
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)