Skip to content

Commit c011756

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 1f59c8f commit c011756

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎Documentation/config/core.adoc‎

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

765765
core.gvfs::
766-
Enable the features needed for GVFS.
766+
Enable the features needed for GVFS. This value can be set to true
767+
to indicate all features should be turned on or the bit values listed
768+
below can be used to turn on specific features.
769+
+
770+
--
771+
GVFS_SKIP_SHA_ON_INDEX::
772+
Bit value 1
773+
Disables the calculation of the sha when writing the index
774+
--
767775

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

‎gvfs.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ struct repository;
88
* used for GVFS functionality
99
*/
1010

11+
/*
12+
* The list of bits in the core_gvfs setting
13+
*/
14+
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)
15+
1116
int gvfs_config_is_set(struct repository *r, int mask);
1217

1318
#endif /* GVFS_H */

‎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)
@@ -85,6 +86,13 @@ void prepare_repo_settings(struct repository *r)
8586
r->settings.pack_use_bitmap_boundary_traversal);
8687
repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);
8788

89+
/*
90+
* For historical compatibility reasons, enable index.skipHash based
91+
* on a bit in core.gvfs.
92+
*/
93+
if (gvfs_config_is_set(r, GVFS_SKIP_SHA_ON_INDEX))
94+
r->settings.index_skip_hash = 1;
95+
8896
/*
8997
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
9098
* either it *or* the config sets

‎t/meson.build‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ integration_tests = [
166166
't1014-read-tree-confusing.sh',
167167
't1015-read-index-unmerged.sh',
168168
't1016-compatObjectFormat.sh',
169+
't1017-read-tree-skip-sha-on-read.sh',
169170
't1020-subdirectory.sh',
170171
't1022-read-tree-partial-clone.sh',
171172
't1050-large.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)