Skip to content

Commit 22583f7

Browse files
Kevin Willforddscho
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: Kevin Willford <kewillf@microsoft.com> Signed-off-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e781a50 commit 22583f7

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

Documentation/config/core.txt

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

746746
core.gvfs::
747-
Enable the features needed for GVFS.
747+
Enable the features needed for GVFS. This value can be set to true
748+
to indicate all features should be turned on or the bit values listed
749+
below can be used to turn on specific features.
750+
+
751+
--
752+
GVFS_SKIP_SHA_ON_INDEX::
753+
Bit value 1
754+
Disables the calculation of the sha when writing the index
755+
--
748756

749757
core.sparseCheckout::
750758
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
@@ -4,6 +4,7 @@
44
#include "repository.h"
55
#include "midx.h"
66
#include "pack-objects.h"
7+
#include "gvfs.h"
78

89
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
910
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',
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)