git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: git@jeffhostetler.com
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
	Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH v5] read-cache: force_verify_index_checksum
Date: Wed, 5 Apr 2017 10:03:36 -0700	[thread overview]
Message-ID: <20170405170336.GE8741@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <20170405145510.2324-2-git@jeffhostetler.com>

Hi,

git@jeffhostetler.com wrote:

> Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
> ---
>  builtin/fsck.c  |  1 +
>  cache.h         |  2 ++
>  read-cache.c    |  7 +++++++
>  t/t1450-fsck.sh | 11 +++++++++++
>  4 files changed, 21 insertions(+)

Yay!  I love this version.

> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -771,6 +771,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	if (keep_cache_objects) {
> +		force_verify_index_checksum = 1;

nit: now that there isn't a config this is overriding, this isn't
"force_verify" so much as "verify".

[...]
> +++ b/t/t1450-fsck.sh
> @@ -689,4 +689,15 @@ test_expect_success 'bogus head does not fallback to all heads' '
>  	! grep $blob out
>  '
>  
> +test_expect_success PERL 'detect corrupt index file in fsck' '
> +	cp .git/index .git/index.backup &&
> +	echo zzzzzzzz >zzzzzzzz &&
> +	git add zzzzzzzz &&
> +	perl -pi -e "s/zzzzzzzz/yyyyyyyy/" .git/index &&
> +	test_must_fail git fsck --cache &&
> +	rm .git/index &&
> +	mv .git/index.backup .git/index &&
> +	rm zzzzzzzz
> +'

This is great.

optional: you can do the cleanup commands in test_when_finished to
make sure they happen even if the test fails.

Tests don't seem to use "perl -pi" anywhere else.  This instance could
be simplified by using sed.

With whatever subset of the changes below look good,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

diff --git i/builtin/fsck.c w/builtin/fsck.c
index 92324e130c..b5e13a4556 100644
--- i/builtin/fsck.c
+++ w/builtin/fsck.c
@@ -771,7 +771,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	}
 
 	if (keep_cache_objects) {
-		force_verify_index_checksum = 1;
+		verify_index_checksum = 1;
 		read_cache();
 		for (i = 0; i < active_nr; i++) {
 			unsigned int mode;
diff --git i/cache.h w/cache.h
index 48b47083d3..9834d71f28 100644
--- i/cache.h
+++ w/cache.h
@@ -706,7 +706,7 @@ extern void update_index_if_able(struct index_state *, struct lock_file *);
 extern int hold_locked_index(struct lock_file *, int);
 extern void set_alternate_index_output(const char *);
 
-extern int force_verify_index_checksum;
+extern int verify_index_checksum;
 
 /* Environment bits from configuration mechanism */
 extern int trust_executable_bit;
diff --git i/read-cache.c w/read-cache.c
index 13326464d4..008b335844 100644
--- i/read-cache.c
+++ w/read-cache.c
@@ -1372,7 +1372,7 @@ struct ondisk_cache_entry_extended {
 			    ondisk_cache_entry_size(ce_namelen(ce)))
 
 /* Allow fsck to force verification of the index checksum. */
-int force_verify_index_checksum;
+int verify_index_checksum;
 
 static int verify_hdr(struct cache_header *hdr, unsigned long size)
 {
@@ -1386,7 +1386,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
 	if (hdr_version < INDEX_FORMAT_LB || INDEX_FORMAT_UB < hdr_version)
 		return error("bad index version %d", hdr_version);
 
-	if (!force_verify_index_checksum)
+	if (!verify_index_checksum)
 		return 0;
 
 	git_SHA1_Init(&c);
diff --git i/t/t1450-fsck.sh w/t/t1450-fsck.sh
index 86757ffa52..e69b32f219 100755
--- i/t/t1450-fsck.sh
+++ w/t/t1450-fsck.sh
@@ -689,15 +689,15 @@ test_expect_success 'bogus head does not fallback to all heads' '
 	! grep $blob out
 '
 
-test_expect_success PERL 'detect corrupt index file in fsck' '
+test_expect_success 'detect corrupt index file in fsck' '
 	cp .git/index .git/index.backup &&
+	test_when_finished "mv .git/index.backup .git/index" &&
 	echo zzzzzzzz >zzzzzzzz &&
+	test_when_finished "rm zzzzzzzz" &&
 	git add zzzzzzzz &&
-	perl -pi -e "s/zzzzzzzz/yyyyyyyy/" .git/index &&
-	test_must_fail git fsck --cache &&
-	rm .git/index &&
-	mv .git/index.backup .git/index &&
-	rm zzzzzzzz
+	sed -e "s/zzzzzzzz/yyyyyyyy/" .git/index >.git/index+ &&
+	mv .git/index+ .git/index &&
+	test_must_fail git fsck --cache
 '
 
 test_done

  reply	other threads:[~2017-04-05 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 14:55 [PATCH v5] read-cache: call verify_hdr() in a background thread git
2017-04-05 14:55 ` [PATCH v5] read-cache: force_verify_index_checksum git
2017-04-05 17:03   ` Jonathan Nieder [this message]
2017-04-05 18:08     ` Jeff Hostetler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170405170336.GE8741@aiede.mtv.corp.google.com \
    --to=jrnieder@gmail.com \
    --cc=git@jeffhostetler.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).