Skip to content

Commit 66e92a0

Browse files
committed
PR 128399: Don't compute the SHA when updating the index if GVFS_SKIP_SHA_ON_INDEX is set.
Don't compute the SHA when updating the index if GVFS_SKIP_SHA_ON_INDEX is set.
1 parent 7d9c821 commit 66e92a0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

gvfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* The list of bits in the core_gvfs setting
1515
*/
16-
#define GVFS_SKIP_SHA_ON_INDEX_READ 1
16+
#define GVFS_SKIP_SHA_ON_INDEX 1
1717
#define GVFS_SPARSE_HASHMAP 2
1818
#define GVFS_MISSING_OK 4
1919
#define GVFS_NO_DELETE_OUTSIDE_SPARSECHECKOUT 8

read-cache.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
13661366
and is called before git_config(git_default_config, ...)
13671367
the config values are not loaded and has to be retrieved directly here.
13681368
*/
1369-
if (gvfs_config_load_and_is_set(GVFS_SKIP_SHA_ON_INDEX_READ))
1369+
if (gvfs_config_load_and_is_set(GVFS_SKIP_SHA_ON_INDEX))
13701370
return 0;
13711371

13721372
git_SHA1_Init(&c);
@@ -1735,7 +1735,8 @@ static int ce_write_flush(git_SHA_CTX *context, int fd)
17351735
{
17361736
unsigned int buffered = write_buffer_len;
17371737
if (buffered) {
1738-
git_SHA1_Update(context, write_buffer, buffered);
1738+
if (!gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
1739+
git_SHA1_Update(context, write_buffer, buffered);
17391740
if (write_in_full(fd, write_buffer, buffered) != buffered)
17401741
return -1;
17411742
write_buffer_len = 0;
@@ -1780,7 +1781,8 @@ static int ce_flush(git_SHA_CTX *context, int fd, unsigned char *sha1)
17801781

17811782
if (left) {
17821783
write_buffer_len = 0;
1783-
git_SHA1_Update(context, write_buffer, left);
1784+
if (!gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
1785+
git_SHA1_Update(context, write_buffer, left);
17841786
}
17851787

17861788
/* Flush first if not enough space for SHA1 signature */
@@ -1791,7 +1793,10 @@ static int ce_flush(git_SHA_CTX *context, int fd, unsigned char *sha1)
17911793
}
17921794

17931795
/* Append the SHA1 signature at the end */
1794-
git_SHA1_Final(write_buffer + left, context);
1796+
if (!gvfs_config_is_set(GVFS_SKIP_SHA_ON_INDEX))
1797+
git_SHA1_Final(write_buffer + left, context);
1798+
else
1799+
hashclr(write_buffer + left);
17951800
hashcpy(sha1, write_buffer + left);
17961801
left += 20;
17971802
return (write_in_full(fd, write_buffer, left) != left) ? -1 : 0;

0 commit comments

Comments
 (0)