git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 6/6] use setup_git_directory() in test-* programs

From
Jeff King <peff@peff.net>
Date
Mar 5, 2016, 22:16 UTC
Message-ID
<20160305221650.GF31508@sigill.intra.peff.net>
In-Reply-To
<20160305220829.GA31316@sigill.intra.peff.net>

Some of the test-* programs rely on examining refs, but did not bother to make sure we are actually in a git repository. Let's have them call setup_git_directory() to do so.

Signed-off-by: Jeff King <peff@peff.net>
---
As discussed elsewhere, test-match-trees isn't actually used in the test
suite (except for the weird use which was removed in patch 1 here). So
we could also just get rid of it, but maybe somebody uses it for
debugging or something.
 test-match-trees.c      | 2 ++
 test-revision-walking.c | 2 ++
 2 files changed, 4 insertions(+)
diff --git a/test-match-trees.c b/test-match-trees.c
index 109f03e..4dad709 100644
--- a/test-match-trees.c
+++ b/test-match-trees.c
@@ -6,6 +6,8 @@ int main(int ac, char **av)
 	unsigned char hash1[20], hash2[20], shifted[20];
 	struct tree *one, *two;
 
+	setup_git_directory();
+
 	if (get_sha1(av[1], hash1))
 		die("cannot parse %s as an object name", av[1]);
 	if (get_sha1(av[2], hash2))
diff --git a/test-revision-walking.c b/test-revision-walking.c
index 285f06b..3d03133 100644
--- a/test-revision-walking.c
+++ b/test-revision-walking.c
@@ -50,6 +50,8 @@ int main(int argc, char **argv)
 	if (argc < 2)
 		return 1;
 
+	setup_git_directory();
+
 	if (!strcmp(argv[1], "run-twice")) {
 		printf("1st\n");
 		if (!run_revision_walk())
-- 
2.8.0.rc1.318.g2193183
Previous: Jeff KingNext: Junio C Hamano
Message 9 of 10 in “avoid touching ref code in non-repositories”
  1. 0/6 avoid touching ref code in non-repositoriesJeff King, Mar 5, 2016
  2. 1/6 setup: make startup_info available everywhereJeff King, Mar 5, 2016
  3. 2/6 setup: set startup_info->have_repository more reliablyJeff King, Mar 5, 2016
  4. 3/6 remote: don't resolve HEAD in non-repositoryJeff King, Mar 5, 2016
  5. 4/6 mailmap: do not resolve blobs in a non-repositoryJeff King, Mar 5, 2016
  6. 5/6 grep: turn off gitlink detection for --no-indexJeff King, Mar 5, 2016
  7. Junio C HamanoMar 7, 2016
  8. 5/6 grep: turn off gitlink detection for --no-indexJeff King, Mar 7, 2016
  9. 6/6 use setup_git_directory() in test-* programsJeff King, Mar 5, 2016
  10. Junio C HamanoMar 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.