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

[PATCH v2 3/4] Treat BISECT_HEAD as a pseudo ref

From
Han-Wen Nienhuys via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 10, 2020, 17:19 UTC
Message-ID
<d4007c2a5b785aac54d3ce7635cd6a50225c1361.1594401593.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.669.v2.git.1594401593.gitgitgadget@gmail.com>
From: Han-Wen Nienhuys <hanwen@google.com>
Both the git-bisect.sh as bisect--helper inspected the file system directly.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
---
 builtin/bisect--helper.c | 3 +--
 git-bisect.sh            | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index ec4996282e..73f9324ad7 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -13,7 +13,6 @@ static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
 static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV")
 static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK")
 static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
-static GIT_PATH_FUNC(git_path_bisect_head, "BISECT_HEAD")
 static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
 static GIT_PATH_FUNC(git_path_head_name, "head-name")
 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
@@ -164,7 +163,7 @@ static int bisect_reset(const char *commit)
 		strbuf_addstr(&branch, commit);
 	}
 
-	if (!file_exists(git_path_bisect_head())) {
+	if (!ref_exists("BISECT_HEAD")) {
 		struct argv_array argv = ARGV_ARRAY_INIT;
 
 		argv_array_pushl(&argv, "checkout", branch.buf, "--", NULL);
diff --git a/git-bisect.sh b/git-bisect.sh
index 08a6ed57dd..f03fbb18f0 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -41,7 +41,7 @@ TERM_GOOD=good
 
 bisect_head()
 {
-	if test -f "$GIT_DIR/BISECT_HEAD"
+	if git rev-parse --verify -q BISECT_HEAD > /dev/null
 	then
 		echo BISECT_HEAD
 	else
@@ -153,7 +153,7 @@ bisect_next() {
 	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit
 
 	# Perform all bisection computation, display and checkout
-	git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
+	git bisect--helper --next-all $(git rev-parse --verify -q BISECT_HEAD > /dev/null && echo --no-checkout)
 	res=$?
 
 	# Check if we should exit because bisection is finished
-- 
gitgitgadget
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys via GitGitGadget
Message 9 of 13 in “Preliminary fixes for reftable support”
  1. 0/4 Preliminary fixes for reftable supportHan-Wen Nienhuys via GitGitGadget, Jun 30, 2020
  2. 1/4 lib-t6000.sh: write tag using git-update-refHan-Wen Nienhuys via GitGitGadget, Jun 30, 2020
  3. 2/4 t3432: use git-reflog to inspect the reflog for HEADHan-Wen Nienhuys via GitGitGadget, Jun 30, 2020
  4. 3/4 checkout: add '\n' to reflog messageHan-Wen Nienhuys via GitGitGadget, Jun 30, 2020
  5. 4/4 Treat BISECT_HEAD as a pseudo refHan-Wen Nienhuys via GitGitGadget, Jun 30, 2020
  6. Junio C HamanoJul 7, 2020
  7. 0/4 Preliminary fixes for reftable supportHan-Wen Nienhuys via GitGitGadget, Jul 10, 2020
  8. 1/4 lib-t6000.sh: write tag using git-update-refHan-Wen Nienhuys via GitGitGadget, Jul 10, 2020
  9. 3/4 Treat BISECT_HEAD as a pseudo refHan-Wen Nienhuys via GitGitGadget, Jul 10, 2020
  10. 2/4 t3432: use git-reflog to inspect the reflog for HEADHan-Wen Nienhuys via GitGitGadget, Jul 10, 2020
  11. 4/4 Cleanse reflog messages in the refs.c layerJunio C Hamano via GitGitGadget, Jul 10, 2020
  12. Junio C HamanoJul 10, 2020
  13. Junio C HamanoJul 10, 2020

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.