threads / patch / 45626

patchtest-read-cache: setup git dir

Subject: [PATCH] test-read-cache: setup git dir

## tl;dr

2 messages between Apr 6, 2017 and Apr 7, 2017. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

René Scharfe· Apr 6, 2017, 20:41 UTC · lore

b1ef400e (setup_git_env: avoid blind fall-back to ".git") made programs that tried to access a repository without initializing properly die with a diagnostic message. One offender is test-read-cache, which is used in p0002. Fix it by calling setup_git_directory() before accessing the index.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 t/helper/test-read-cache.c | 1 +
 1 file changed, 1 insertion(+)
Show changes to t/helper/test-read-cache.c +1 −0
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 2a7990efc3..48255eef31 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -5,6 +5,7 @@ int cmd_main(int argc, const char **argv)
 	int i, cnt = 1;
 	if (argc == 2)
 		cnt = strtol(argv[1], NULL, 0);
+	setup_git_directory();
 	for (i = 0; i < cnt; i++) {
 		read_cache();
 		discard_cache();
-- 
2.12.2
Jeff King· Apr 7, 2017, 05:22 UTC · re: René Scharfe · lore

Re: [PATCH] test-read-cache: setup git dir

On Thu, Apr 06, 2017 at 10:41:41PM +0200, René Scharfe wrote:
Show 5 quoted lines
> b1ef400e (setup_git_env: avoid blind fall-back to ".git") made programs
> that tried to access a repository without initializing properly die with
> a diagnostic message.  One offender is test-read-cache, which is used in
> p0002.  Fix it by calling setup_git_directory() before accessing the
> index.

Right, makes sense. I wondered why we didn't notice this before, but it's because it's _only_ called from the perf suite.

-Peff

← back to recent threads