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

[WIP/PATCH 6/9] Teach bisect the --[no-]recurse-submodules option

From
Jens Lehmann <jens.lehmann@web.de>
Date
Feb 3, 2014, 19:51 UTC
Message-ID
<52EFF35D.7070908@web.de>
In-Reply-To
<52EFF25E.6080306@web.de>

When using this option 'git bisect' will automatically update the work tree of all initialized submodules (so they match the SHA-1 recorded in the superproject) in each bisection step. This makes calling 'git submodule update' eacht time obsolete, which was tedious and error prone. If the option is given it is stored in the BISECT_RECURSE_SUBMODULES file in the git directory so that later bisection steps can reuse it. But this commit only adds the option without any functionality, that will be added to unpack_trees() in subsequent commits.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 Documentation/git-bisect.txt |  5 +++++
 git-bisect.sh                | 29 ++++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index f986c5c..c0aaba8 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -276,6 +276,11 @@ does not require a checked out tree.
 +
 If the repository is bare, `--no-checkout` is assumed.

+include::recurse-submodules-update.txt[]
++
+This option is passed to linkgit:git-checkout[1] when checking out the next
+to be tested commit and is ignored when used together with `--no-checkout`.
+
 EXAMPLES
 --------

diff --git a/git-bisect.sh b/git-bisect.sh
index 73b4c14..ba64a21 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -3,7 +3,7 @@
 USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
 LONG_USAGE='git bisect help
 	print this long help message.
-git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
+git bisect start [--no-checkout] [--[no-]recurse-submodules[=<mode>]] [<bad> [<good>...]] [--] [<pathspec>...]
 	reset bisect state and start bisection.
 git bisect bad [<rev>]
 	mark <rev> a known-bad revision.
@@ -91,6 +91,12 @@ bisect_start() {
 		--no-checkout)
 			mode=--no-checkout
 			shift ;;
+		--no-recurse-submodules)
+			recurse_submodules="$1"
+			shift ;;
+		--recurse-submodules*)
+			recurse_submodules="$1"
+			shift ;;
 		--*)
 			die "$(eval_gettext "unrecognised option: '\$arg'")" ;;
 		*)
@@ -124,9 +130,13 @@ bisect_start() {
 	then
 		# Reset to the rev from where we started.
 		start_head=$(cat "$GIT_DIR/BISECT_START")
+		if test -s "$GIT_DIR/BISECT_RECURSE_SUBMODULES"
+		then
+			recurse_submodules=$(cat "$GIT_DIR/BISECT_RECURSE_SUBMODULES")
+		fi
 		if test "z$mode" != "z--no-checkout"
 		then
-			git checkout "$start_head" -- ||
+			git checkout ${recurse_submodules:+"$recurse_submodules"} "$start_head" -- ||
 			die "$(eval_gettext "Checking out '\$start_head' failed. Try 'git bisect reset <validbranch>'.")"
 		fi
 	else
@@ -168,7 +178,10 @@ bisect_start() {
 		test "z$mode" != "z--no-checkout" ||
 		git update-ref --no-deref BISECT_HEAD "$start_head"
 	} &&
-	git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
+	git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" && {
+		test -z "$recurse_submodules" ||
+		echo "$recurse_submodules" >"$GIT_DIR/BISECT_RECURSE_SUBMODULES"
+	} &&
 	eval "$eval true" &&
 	echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
 	#
@@ -306,8 +319,13 @@ bisect_next() {
 	bisect_autostart
 	bisect_next_check good

+	if test -f "$GIT_DIR/BISECT_RECURSE_SUBMODULES"
+	then
+		recurse_submodules=$(cat "$GIT_DIR/BISECT_RECURSE_SUBMODULES")
+	fi
+
 	# 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 $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout) ${recurse_submodules:+"$recurse_submodules"}
 	res=$?

 	# Check if we should exit because bisection is finished
@@ -374,7 +392,7 @@ bisect_reset() {
 		usage ;;
 	esac

-	if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" --
+	if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout ${recurse_submodules:+"$recurse_submodules"} "$branch" --
 	then
 		die "$(eval_gettext "Could not check out original HEAD '\$branch'.
 Try 'git bisect reset <commit>'.")"
@@ -397,6 +415,7 @@ bisect_clean_state() {
 	# Cleanup head-name if it got left by an old version of git-bisect
 	rm -f "$GIT_DIR/head-name" &&
 	git update-ref -d --no-deref BISECT_HEAD &&
+	rm -f "$GIT_DIR/BISECT_RECURSE_SUBMODULES" &&
 	# clean up BISECT_START last
 	rm -f "$GIT_DIR/BISECT_START"
 }
-- 
1.9.rc0.28.ge3363ff
Previous: Jens LehmannNext: W. Trevor King
Message 24 of 35 in “What's cooking in git.git (Jan 2014, #01; Mon, 6)”
  1. Junio C HamanoJan 6, 2014
  2. Francesco PrettoJan 6, 2014
  3. Junio C HamanoJan 6, 2014
  4. Francesco PrettoJan 6, 2014
  5. Jens LehmannJan 7, 2014
  6. 0/9 v2 submodule recursive checkout]Jens Lehmann, Feb 3, 2014
  7. 1/9 submodule: prepare for recursive checkout of submodulesJens Lehmann, Feb 3, 2014
  8. Junio C HamanoFeb 3, 2014
  9. Jens LehmannFeb 7, 2014
  10. Jonathan NiederFeb 4, 2014
  11. Jens LehmannFeb 7, 2014
  12. 2/9 Teach reset the --[no-]recurse-submodules optionJens Lehmann, Feb 3, 2014
  13. Junio C HamanoFeb 3, 2014
  14. Jens LehmannFeb 7, 2014
  15. 3/9 Teach checkout the --[no-]recurse-submodules optionJens Lehmann, Feb 3, 2014
  16. Junio C HamanoFeb 3, 2014
  17. Jens LehmannFeb 7, 2014
  18. 4/9 Teach merge the --[no-]recurse-submodules optionJens Lehmann, Feb 3, 2014
  19. Junio C HamanoFeb 3, 2014
  20. Jens LehmannFeb 7, 2014
  21. Junio C HamanoFeb 7, 2014
  22. W. Trevor KingFeb 7, 2014
  23. 5/9 Teach bisect--helper the --[no-]recurse-submodules optionJens Lehmann, Feb 3, 2014
  24. 6/9 Teach bisect the --[no-]recurse-submodules optionJens Lehmann, Feb 3, 2014
  25. W. Trevor KingFeb 3, 2014
  26. Jens LehmannFeb 3, 2014
  27. 7/9 submodule: teach unpack_trees() to remove submodule contentsJens Lehmann, Feb 3, 2014
  28. W. Trevor KingFeb 3, 2014
  29. Jens LehmannFeb 7, 2014
  30. 8/9 submodule: teach unpack_trees() to repopulate submodulesJens Lehmann, Feb 3, 2014
  31. 9/9 submodule: teach unpack_trees() to update submodulesJens Lehmann, Feb 3, 2014
  32. W. Trevor KingFeb 3, 2014
  33. Jens LehmannFeb 7, 2014
  34. Duy NguyenFeb 4, 2014
  35. Jens LehmannFeb 7, 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.