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

[PATCH 1/2] bisect: parse revs before passing them to check_expected_revs()

From
Christian Couder <chriscool@tuxfamily.org>
Date
Dec 25, 2014, 18:25 UTC
Message-ID
<20141225182534.32540.83491.chriscool@tuxfamily.org>

When running for example "git bisect bad HEAD" or "git bisect good master", the parameter passed to "git bisect (bad|good)" has to be parsed into a commit hash before checking if it is the expected commit or not.

We could do that in is_expected_rev() or in check_expected_revs(), but it is already done in bisect_state(). Let's just store the hash values that result from this parsing, and then reuse them after all the parsing is done.

This way we can also use a for loop over these values to call bisect_write() on them, instead of using eval.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
I think that it is a better patch than the one I sent
previously to the list as with this one we parse revs
only once. 
Merry Christmas!
 git-bisect.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index 6cda2b5..2fc07ac 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -237,15 +237,18 @@ bisect_state() {
 		check_expected_revs "$rev" ;;
 	2,bad|*,good|*,skip)
 		shift
-		eval=''
+		hash_list=''
 		for rev in "$@"
 		do
 			sha=$(git rev-parse --verify "$rev^{commit}") ||
 				die "$(eval_gettext "Bad rev input: \$rev")"
-			eval="$eval bisect_write '$state' '$sha'; "
+			hash_list="$hash_list $sha"
 		done
-		eval "$eval"
-		check_expected_revs "$@" ;;
+		for rev in $hash_list
+		do
+			bisect_write "$state" "$rev"
+		done
+		check_expected_revs $hash_list ;;
 	*,bad)
 		die "$(gettext "'git bisect bad' can take only one argument.")" ;;
 	*)
-- 
2.1.2.555.gfbecd99
Next: Junio C Hamano
Message 1 of 3 in “bisect: parse revs before passing them to check_expected_revs()”
  1. 1/2 bisect: parse revs before passing them to check_expected_revs()Christian Couder, Dec 25, 2014
  2. Junio C HamanoDec 29, 2014
  3. Christian CouderDec 29, 2014

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.