Skip to content

Commit

Permalink
gvfs: add the feature to skip writing the index' SHA-1
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kevin Willford authored and dscho committed Aug 8, 2023
1 parent 562428f commit 0d6a6e7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,15 @@ core.multiPackIndex::
information. Defaults to true.

core.gvfs::
Enable the features needed for GVFS.
Enable the features needed for GVFS. This value can be set to true
to indicate all features should be turned on or the bit values listed
below can be used to turn on specific features.
+
--
GVFS_SKIP_SHA_ON_INDEX::
Bit value 1
Disables the calculation of the sha when writing the index
--

core.sparseCheckout::
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
Expand Down
6 changes: 6 additions & 0 deletions gvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
* used for GVFS functionality
*/


/*
* The list of bits in the core_gvfs setting
*/
#define GVFS_SKIP_SHA_ON_INDEX (1 << 0)

static inline int gvfs_config_is_set(int mask) {
return (core_gvfs & mask) == mask;
}
Expand Down
8 changes: 8 additions & 0 deletions repo-settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "midx.h"
#include "fsmonitor-ipc.h"
#include "fsmonitor-settings.h"
#include "gvfs.h"

static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
int def)
Expand Down Expand Up @@ -94,6 +95,13 @@ void prepare_repo_settings(struct repository *r)
r->settings.pack_use_bitmap_boundary_traversal);
repo_cfg_bool(r, "core.usereplacerefs", &r->settings.read_replace_refs, 1);

/*
* For historical compatibility reasons, enable index.skipHash based
* on a bit in core.gvfs.
*/
if (gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
r->settings.index_skip_hash = 1;

/*
* The GIT_TEST_MULTI_PACK_INDEX variable is special in that
* either it *or* the config sets
Expand Down
22 changes: 22 additions & 0 deletions t/t1016-read-tree-skip-sha-on-read.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

test_description='check that read-tree works with core.gvfs config value'

. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

test_expect_success setup '
echo one >a &&
git add a &&
git commit -m initial
'
test_expect_success 'read-tree without core.gvsf' '
read_tree_u_must_succeed -m -u HEAD
'

test_expect_success 'read-tree with core.gvfs set to 1' '
git config core.gvfs 1 &&
read_tree_u_must_succeed -m -u HEAD
'

test_done

0 comments on commit 0d6a6e7

Please sign in to comment.