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

[PATCH 1/6] bisect: add git_path_bisect_terms helper

From
Jeff King <peff@peff.net>
Date
Apr 20, 2017, 21:08 UTC
Message-ID
<20170420210825.lr55sl7se4uloncf@sigill.intra.peff.net>
In-Reply-To
<20170420210754.bzrnc74dpjs7fgpf@sigill.intra.peff.net>

This avoids using the dangerous git_path(). Right now there's only one call site (because the writing half is still part of the shell script), but it may come in handy in the future as more of bisect is written in C. It also matches how we access the other BISECT_* files.

Signed-off-by: Jeff King <peff@peff.net>
---
 bisect.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/bisect.c b/bisect.c
index 03af06c66..08c9fb726 100644
--- a/bisect.c
+++ b/bisect.c
@@ -432,6 +432,7 @@ static int read_bisect_refs(void)
 
 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
 static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
+static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
 
 static void read_bisect_paths(struct argv_array *array)
 {
@@ -906,7 +907,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
 void read_bisect_terms(const char **read_bad, const char **read_good)
 {
 	struct strbuf str = STRBUF_INIT;
-	const char *filename = git_path("BISECT_TERMS");
+	const char *filename = git_path_bisect_terms();
 	FILE *fp = fopen(filename, "r");
 
 	if (!fp) {
-- 
2.13.0.rc0.363.g8726c260e
Previous: Jeff KingNext: Jeff King
Message 2 of 8 in “removing more calls to git_path()”
  1. 0/6 removing more calls to git_path()Jeff King, Apr 20, 2017
  2. 1/6 bisect: add git_path_bisect_terms helperJeff King, Apr 20, 2017
  3. 2/6 branch: add edit_description() helperJeff King, Apr 20, 2017
  4. 3/6 use git_path_* helper functionsJeff King, Apr 20, 2017
  5. 4/6 replace xstrdup(git_path(...)) with git_pathdup(...)Jeff King, Apr 20, 2017
  6. 5/6 replace strbuf_addstr(git_path()) with git_path_buf()Jeff King, Apr 20, 2017
  7. 6/6 am: drop "dir" parameter from am_state_initJeff King, Apr 20, 2017
  8. Junio C HamanoApr 21, 2017

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.