Skip to contentSkip to conversation

git-submodule: add support for --rebase.

PATCH/RESEND Peter Hutterer 3 participants 9 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

---

Previous thread:
http://thread.gmane.org/gmane.comp.version-control.git/115950/focus=116076

Original thread died after discussions about the wording in the man page, last reviewer comment being:
"You can really rebase only onto a commit. And the index is not a commit, so I do not like the wording (not even in the rebase man page).

But let's see what other reviewers say... :-)"

I'm still unsure about whether to change the wording (it currently uses the same terms as git-rebase and the rest of the git-submodule man page). Please let me know what to do to get this patch done.

 Documentation/git-submodule.txt |   12 +++++-
 git-submodule.sh                |   22 +++++++++--
 t/t7404-submodule-update.sh     |   79 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 6 deletions(-)
 create mode 100755 t/t7404-submodule-update.sh
Documentation/git-submodule.txt +10 -2
index 3b8df44..7e0dcb1 100644
@@ -12,7 +12,7 @@ SYNOPSIS
 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
 'git submodule' [--quiet] status [--cached] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--] [<path>...]
 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach <command>
 'git submodule' [--quiet] sync [--] [<path>...]
@@ -113,7 +113,8 @@ init::
 update::
 	Update the registered submodules, i.e. clone missing submodules and
 	checkout the commit specified in the index of the containing repository.
-	This will make the submodules HEAD be detached.
+	This will make the submodules HEAD be detached unless '--rebase' is
+	specified.
 +
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
@@ -177,6 +178,13 @@ OPTIONS
 	This option is only valid for the update command.
 	Don't fetch new objects from the remote site.
 
+--rebase::
+	This option is only valid for the update command.
+	Rebase the current branch onto the index of the containing repository
+	instead of detaching the HEAD.
+	If a a merge failure prevents this process, you will have to resolve
+	these failures with linkgit:git-rebase[1].
+
 <path>...::
 	Paths to submodule(s). When specified this will restrict the command
 	to only operate on the submodules found at the specified paths.
git-submodule.sh +18 -4
index 7c2e060..e2d40ee 100755
@@ -17,6 +17,7 @@ branch=
 quiet=
 cached=
 nofetch=
+rebase=
 
 #
 # print stuff on stdout unless -q was specified
@@ -314,6 +315,10 @@ cmd_update()
 			shift
 			nofetch=1
 			;;
+		-r|--rebase)
+			shift
+			rebase=1
+			;;
 		--)
 			shift
 			break
@@ -367,11 +372,20 @@ cmd_update()
 				die "Unable to fetch in submodule path '$path'"
 			fi
 
-			(unset GIT_DIR; cd "$path" &&
-				  git-checkout $force -q "$sha1") ||
-			die "Unable to checkout '$sha1' in submodule path '$path'"
+			if test -z "$rebase"
+			then
+				command="git-checkout $force -q"
+				action="checkout"
+				msg="checked out"
+			else
+				command="git-rebase"
+				action="rebase"
+				msg="rebased onto"
+			fi
 
-			say "Submodule path '$path': checked out '$sha1'"
+			(unset GIT_DIR; cd "$path" && $command "$sha1") ||
+			die "Unable to $action '$sha1' in submodule path '$path'"
+			say "Submodule path '$path': $msg '$sha1'"
 		fi
 	done
 }
t/t7404-submodule-update.sh new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
1.6.2.2.447.g4afa7
#1 lore raw

Hi,

Quoted 1 line · Peter Hutterer

'git submodule update --rebase' rebases your local branch on top of what would

This line is so long that it got wrapped in my mail program. But it is even worse: we would like to show this in an 80-column display with a 4-space indent, so it would be nice if you could rewrap to 76 columns (I even use 72 columns, because it looks nicer).

Quoted 7 lines

Original thread died after discussions about the wording in the man page, last reviewer comment being:

"You can really rebase only onto a commit. And the index is not a commit, so I do not like the wording (not even in the rebase man page).

But let's see what other reviewers say... :-)"

I take this as a sign that other reviewers (if any) agree with me ;-)

Quoted 3 lines

I'm still unsure about whether to change the wording (it currently uses the same terms as git-rebase and the rest of the git-submodule man page). Please let me know what to do to get this patch done.

AFAIR I gave an alternative wording, am I wrong?

So I'd prefer a repost with rewrapped commit message and reworded man page modifications.

However, I could imagine that Junio does not want to take this patch right now, as we are deep in -rc mode for the upcoming 1.6.3. Junio?

Ciao,
Dscho

#2 lore raw
Quoted 8 lines · Johannes Schindelin
Quoted 1 line · Peter Hutterer

'git submodule update --rebase' rebases your local branch on top of what would

This line is so long that it got wrapped in my mail program. But it is even worse: we would like to show this in an 80-column display with a 4-space indent, so it would be nice if you could rewrap to 76 columns (I even use 72 columns, because it looks nicer).

amended to 72 cols, see below.

Quoted 5 lines
Quoted 3 lines

I'm still unsure about whether to change the wording (it currently uses the same terms as git-rebase and the rest of the git-submodule man page). Please let me know what to do to get this patch done.

AFAIR I gave an alternative wording, am I wrong?

yes, but tbh. I found it a bit confusing. Your suggestion was

"Instead of detaching the HEAD to the revision committed in the
superproject, rebase the current branch onto that revision."

How about this one, basically the same but split up in two sentences:

+--rebase::
+ This option is only valid for the update command.
+ Rebase the current branch onto the commit recorded in the
+ superproject. If this option is given, the submodule's HEAD will not
+ be detached. If a a merge failure prevents this process, you will have
+ to resolve these failures with linkgit:git-rebase[1].
+

Cheers,
Peter

Quoted 1 line

From f5664840db1193311054eb38c91ec762846cd00c Mon Sep 17 00:00:00 2001

From: Peter Hutterer <[email protected]>
Date: Fri, 27 Mar 2009 13:42:42 +1000
Subject: [PATCH] git-submodule: add support for --rebase.

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

---
 Documentation/git-submodule.txt |   12 +++++-
 git-submodule.sh                |   22 +++++++++--
 t/t7404-submodule-update.sh     |   79 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 6 deletions(-)
 create mode 100755 t/t7404-submodule-update.sh
Documentation/git-submodule.txt +10 -2
index 3b8df44..2935cb8 100644
@@ -12,7 +12,7 @@ SYNOPSIS
 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
 'git submodule' [--quiet] status [--cached] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--] [<path>...]
 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach <command>
 'git submodule' [--quiet] sync [--] [<path>...]
@@ -113,7 +113,8 @@ init::
 update::
 	Update the registered submodules, i.e. clone missing submodules and
 	checkout the commit specified in the index of the containing repository.
-	This will make the submodules HEAD be detached.
+	This will make the submodules HEAD be detached unless '--rebase' is
+	specified.
 +
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
@@ -177,6 +178,13 @@ OPTIONS
 	This option is only valid for the update command.
 	Don't fetch new objects from the remote site.
 
+--rebase::
+	This option is only valid for the update command.
+	Rebase the current branch onto the commit recorded in the
+	superproject. If this option is given, the submodule's HEAD will not
+	be detached. If a a merge failure prevents this process, you will have
+	to resolve these failures with linkgit:git-rebase[1].
+
 <path>...::
 	Paths to submodule(s). When specified this will restrict the command
 	to only operate on the submodules found at the specified paths.
git-submodule.sh +18 -4
index 7c2e060..e2d40ee 100755
@@ -17,6 +17,7 @@ branch=
 quiet=
 cached=
 nofetch=
+rebase=
 
 #
 # print stuff on stdout unless -q was specified
@@ -314,6 +315,10 @@ cmd_update()
 			shift
 			nofetch=1
 			;;
+		-r|--rebase)
+			shift
+			rebase=1
+			;;
 		--)
 			shift
 			break
@@ -367,11 +372,20 @@ cmd_update()
 				die "Unable to fetch in submodule path '$path'"
 			fi
 
-			(unset GIT_DIR; cd "$path" &&
-				  git-checkout $force -q "$sha1") ||
-			die "Unable to checkout '$sha1' in submodule path '$path'"
+			if test -z "$rebase"
+			then
+				command="git-checkout $force -q"
+				action="checkout"
+				msg="checked out"
+			else
+				command="git-rebase"
+				action="rebase"
+				msg="rebased onto"
+			fi
 
-			say "Submodule path '$path': checked out '$sha1'"
+			(unset GIT_DIR; cd "$path" && $command "$sha1") ||
+			die "Unable to $action '$sha1' in submodule path '$path'"
+			say "Submodule path '$path': $msg '$sha1'"
 		fi
 	done
 }
t/t7404-submodule-update.sh new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
1.6.2.2.447.g4afa7
#3 lore raw

Hi,

Quoted 11 lines · Peter Hutterer
Quoted 8 lines · Johannes Schindelin
Quoted 1 line · Peter Hutterer

'git submodule update --rebase' rebases your local branch on top of what would

This line is so long that it got wrapped in my mail program. But it is even worse: we would like to show this in an 80-column display with a 4-space indent, so it would be nice if you could rewrap to 76 columns (I even use 72 columns, because it looks nicer).

amended to 72 cols, see below.

Thanks.

Quoted 14 lines
Quoted 5 lines
Quoted 3 lines

I'm still unsure about whether to change the wording (it currently uses the same terms as git-rebase and the rest of the git-submodule man page). Please let me know what to do to get this patch done.

AFAIR I gave an alternative wording, am I wrong?

yes, but tbh. I found it a bit confusing. Your suggestion was

"Instead of detaching the HEAD to the revision committed in the
superproject, rebase the current branch onto that revision."

How about this one, basically the same but split up in two sentences:

+--rebase::

Documentation/git-submodule.txt OPTIONS · line 186

Quoted 5 lines
Documentation/git-submodule.txt +5 -0
+	This option is only valid for the update command.
+	Rebase the current branch onto the commit recorded in the
+	superproject. If this option is given, the submodule's HEAD will not
+	be detached. If a a merge failure prevents this process, you will have
+	to resolve these failures with linkgit:git-rebase[1].

Way better!

Thank you,
Dscho

#4 lore raw

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

git-config key: submodule.$name.rebase (bool)

---

I figured if we're waiting for 1.6.3 anyway I might as well add support for gitconfig to make this feature "complete".
Test cases are updated as well.

Cheers,
Peter

 Documentation/git-submodule.txt |   14 ++++-
 git-submodule.sh                |   28 +++++++-
 t/t7404-submodule-update.sh     |  130 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+), 6 deletions(-)
 create mode 100755 t/t7404-submodule-update.sh
Documentation/git-submodule.txt +12 -2
index 3b8df44..0286409 100644
@@ -12,7 +12,7 @@ SYNOPSIS
 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
 'git submodule' [--quiet] status [--cached] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--] [<path>...]
 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach <command>
 'git submodule' [--quiet] sync [--] [<path>...]
@@ -113,7 +113,8 @@ init::
 update::
 	Update the registered submodules, i.e. clone missing submodules and
 	checkout the commit specified in the index of the containing repository.
-	This will make the submodules HEAD be detached.
+	This will make the submodules HEAD be detached unless '--rebase' is
+	specified or the key `submodule.$name.rebase` is set to `true`.
 +
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
@@ -177,6 +178,15 @@ OPTIONS
 	This option is only valid for the update command.
 	Don't fetch new objects from the remote site.
 
+--rebase::
+	This option is only valid for the update command.
+	Rebase the current branch onto the commit recorded in the
+	superproject. If this option is given, the submodule's HEAD will not
+	be detached. If a a merge failure prevents this process, you will have
+	to resolve these failures with linkgit:git-rebase[1].
+	If the key `submodule.$name.rebase` is set to `true`, this option is
+	implicit.
+
 <path>...::
 	Paths to submodule(s). When specified this will restrict the command
 	to only operate on the submodules found at the specified paths.
git-submodule.sh +24 -4
index 7c2e060..c4ba19a 100755
@@ -17,6 +17,7 @@ branch=
 quiet=
 cached=
 nofetch=
+rebase=
 
 #
 # print stuff on stdout unless -q was specified
@@ -314,6 +315,10 @@ cmd_update()
 			shift
 			nofetch=1
 			;;
+		-r|--rebase)
+			shift
+			rebase=true
+			;;
 		--)
 			shift
 			break
@@ -332,6 +337,7 @@ cmd_update()
 	do
 		name=$(module_name "$path") || exit
 		url=$(git config submodule."$name".url)
+		rebase_module=$(git config submodule."$name".rebase)
 		if test -z "$url"
 		then
 			# Only mention uninitialized submodules when its
@@ -352,6 +358,11 @@ cmd_update()
 			die "Unable to find current revision in submodule path '$path'"
 		fi
 
+		if test true = "$rebase"
+		then
+			rebase_module=true
+		fi
+
 		if test "$subsha1" != "$sha1"
 		then
 			force=
@@ -367,11 +378,20 @@ cmd_update()
 				die "Unable to fetch in submodule path '$path'"
 			fi
 
-			(unset GIT_DIR; cd "$path" &&
-				  git-checkout $force -q "$sha1") ||
-			die "Unable to checkout '$sha1' in submodule path '$path'"
+			if test true = "$rebase_module"
+			then
+				command="git-rebase"
+				action="rebase"
+				msg="rebased onto"
+			else
+				command="git-checkout $force -q"
+				action="checkout"
+				msg="checked out"
+			fi
 
-			say "Submodule path '$path': checked out '$sha1'"
+			(unset GIT_DIR; cd "$path" && $command "$sha1") ||
+			die "Unable to $action '$sha1' in submodule path '$path'"
+			say "Submodule path '$path': $msg '$sha1'"
 		fi
 	done
 }
t/t7404-submodule-update.sh new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
1.6.3.rc1.2.gfa66a
#5 lore raw

Hi,

Quoted 9 lines · Peter Hutterer

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

Quoted 8 lines

git-config key: submodule.$name.rebase (bool)

---

I figured if we're waiting for 1.6.3 anyway I might as well add support for gitconfig to make this feature "complete".
Test cases are updated as well.

Thanks.

With this squashed in, I actually would not be too opposed to put this into 1.6.3, as it _is_ an improvement.

-- snipsnap --
[PATCH] To be squashed in

This does three things:

- add .gitmodules support for rebase,
- use --bool for the git config calls for type checking, and
- rename ambiguous t7404 to t7406.

---
 Documentation/gitmodules.txt                       |    3 +++
 git-submodule.sh                                   |    7 ++++++-
 ...bmodule-update.sh => t7406-submodule-update.sh} |   10 ++++++++++
 3 files changed, 19 insertions(+), 1 deletions(-)
 rename t/{t7404-submodule-update.sh => t7406-submodule-update.sh} (88%)
Documentation/gitmodules.txt +3 -0
index d1a17e2..7c22c40 100644
@@ -30,6 +30,9 @@ submodule.<name>.path::
 submodule.<name>.url::
 	Defines an url from where the submodule repository can be cloned.
 
+submodule.<name>.rebase::
+	Defines that the submodule should be rebased by default.
+
 
 EXAMPLES
 --------
git-submodule.sh +6 -1
index 091cb2d..3176226 100755
@@ -295,6 +295,11 @@ cmd_init()
 		git config submodule."$name".url "$url" ||
 		die "Failed to register url for submodule path '$path'"
 
+		test true != "$(git config -f .gitmodules --bool \
+			submodule."$name".rebase)" ||
+		git config submodule."$name".rebase true ||
+		die "Failed to register submodule path '$path' as rebasing"
+
 		say "Submodule '$name' ($url) registered for path '$path'"
 	done
 }
@@ -344,7 +349,7 @@ cmd_update()
 	do
 		name=$(module_name "$path") || exit
 		url=$(git config submodule."$name".url)
-		rebase_module=$(git config submodule."$name".rebase)
+		rebase_module=$(git config --bool submodule."$name".rebase)
 		if test -z "$url"
 		then
 			# Only mention uninitialized submodules when its
t/t7406-submodule-update.sh renamed from t/t7404-submodule-update.sh +10 -0
similarity index 88%
rename from t/t7404-submodule-update.sh
rename to t/t7406-submodule-update.sh
index d70bae1..3a474be 100755
@@ -127,4 +127,14 @@ test_expect_success 'submodule update - rebase false in .git/config' '
 	)
 '
 
+test_expect_success 'submodule init picks up rebase' '
+	(cd super &&
+	 git config submodule.rebasing.url git://non-existing/git &&
+	 git config submodule.rebasing.path does-not-mater &&
+	 git config submodule.rebasing.rebase true &&
+	 git submodule init rebasing &&
+	 test true = $(git config --bool submodule.rebasing.rebase)
+	)
+'
+
 test_done
Signature · 1 line
1.6.2.1.613.g25746
#6 lore raw

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

git-config key: submodule.$name.rebase (bool)

---

Quoted 6 lines

With this squashed in, I actually would not be too opposed to put this into 1.6.3, as it _is_ an improvement.

-- snipsnap --
[PATCH] To be squashed in

Quoted 7 lines

This does three things:

- add .gitmodules support for rebase,
- use --bool for the git config calls for type checking, and
- rename ambiguous t7404 to t7406.

Squashed in, thank you. One typo fixed in last testcase (does-not-mater -> does-not-matter).

 Documentation/git-submodule.txt |   14 ++++-
 Documentation/gitmodules.txt    |    3 +
 git-submodule.sh                |   33 ++++++++-
 t/t7406-submodule-update.sh     |  140 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 184 insertions(+), 6 deletions(-)
 create mode 100755 t/t7406-submodule-update.sh
Documentation/git-submodule.txt +12 -2
index 3b8df44..0286409 100644
@@ -12,7 +12,7 @@ SYNOPSIS
 'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
 'git submodule' [--quiet] status [--cached] [--] [<path>...]
 'git submodule' [--quiet] init [--] [<path>...]
-'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--] [<path>...]
+'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase] [--] [<path>...]
 'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
 'git submodule' [--quiet] foreach <command>
 'git submodule' [--quiet] sync [--] [<path>...]
@@ -113,7 +113,8 @@ init::
 update::
 	Update the registered submodules, i.e. clone missing submodules and
 	checkout the commit specified in the index of the containing repository.
-	This will make the submodules HEAD be detached.
+	This will make the submodules HEAD be detached unless '--rebase' is
+	specified or the key `submodule.$name.rebase` is set to `true`.
 +
 If the submodule is not yet initialized, and you just want to use the
 setting as stored in .gitmodules, you can automatically initialize the
@@ -177,6 +178,15 @@ OPTIONS
 	This option is only valid for the update command.
 	Don't fetch new objects from the remote site.
 
+--rebase::
+	This option is only valid for the update command.
+	Rebase the current branch onto the commit recorded in the
+	superproject. If this option is given, the submodule's HEAD will not
+	be detached. If a a merge failure prevents this process, you will have
+	to resolve these failures with linkgit:git-rebase[1].
+	If the key `submodule.$name.rebase` is set to `true`, this option is
+	implicit.
+
 <path>...::
 	Paths to submodule(s). When specified this will restrict the command
 	to only operate on the submodules found at the specified paths.
Documentation/gitmodules.txt +3 -0
index d1a17e2..7c22c40 100644
@@ -30,6 +30,9 @@ submodule.<name>.path::
 submodule.<name>.url::
 	Defines an url from where the submodule repository can be cloned.
 
+submodule.<name>.rebase::
+	Defines that the submodule should be rebased by default.
+
 
 EXAMPLES
 --------
git-submodule.sh +29 -4
index 7c2e060..b7c9bdc 100755
@@ -17,6 +17,7 @@ branch=
 quiet=
 cached=
 nofetch=
+rebase=
 
 #
 # print stuff on stdout unless -q was specified
@@ -287,6 +288,11 @@ cmd_init()
 		git config submodule."$name".url "$url" ||
 		die "Failed to register url for submodule path '$path'"
 
+		test true != "$(git config -f .gitmodules --bool \
+			submodule."$name".rebase)" ||
+		git config submodule."$name".rebase true ||
+		die "Failed to register submodule path '$path' as rebasing"
+
 		say "Submodule '$name' ($url) registered for path '$path'"
 	done
 }
@@ -314,6 +320,10 @@ cmd_update()
 			shift
 			nofetch=1
 			;;
+		-r|--rebase)
+			shift
+			rebase=true
+			;;
 		--)
 			shift
 			break
@@ -332,6 +342,7 @@ cmd_update()
 	do
 		name=$(module_name "$path") || exit
 		url=$(git config submodule."$name".url)
+		rebase_module=$(git config --bool submodule."$name".rebase)
 		if test -z "$url"
 		then
 			# Only mention uninitialized submodules when its
@@ -352,6 +363,11 @@ cmd_update()
 			die "Unable to find current revision in submodule path '$path'"
 		fi
 
+		if test true = "$rebase"
+		then
+			rebase_module=true
+		fi
+
 		if test "$subsha1" != "$sha1"
 		then
 			force=
@@ -367,11 +383,20 @@ cmd_update()
 				die "Unable to fetch in submodule path '$path'"
 			fi
 
-			(unset GIT_DIR; cd "$path" &&
-				  git-checkout $force -q "$sha1") ||
-			die "Unable to checkout '$sha1' in submodule path '$path'"
+			if test true = "$rebase_module"
+			then
+				command="git-rebase"
+				action="rebase"
+				msg="rebased onto"
+			else
+				command="git-checkout $force -q"
+				action="checkout"
+				msg="checked out"
+			fi
 
-			say "Submodule path '$path': checked out '$sha1'"
+			(unset GIT_DIR; cd "$path" && $command "$sha1") ||
+			die "Unable to $action '$sha1' in submodule path '$path'"
+			say "Submodule path '$path': $msg '$sha1'"
 		fi
 	done
 }
t/t7406-submodule-update.sh new file +140 -0

140 lines not on this page · raw message

Signature · 1 line
1.6.3.rc1.2.gfa66a
#7 lore raw

Hi,

Quoted 9 lines · Peter Hutterer

'git submodule update --rebase' rebases your local branch on top of what would have been checked out to a detached HEAD otherwise.

In some cases, detaching the HEAD when updating a submodule complicates the workflow to commit to this submodule (checkout master, rebase, then commit). For submodules that require frequent updates but infrequent (if any) commits, a rebase can be executed directly by the git-submodule command, ensuring that the submodules stay on their respective branches.

Quoted 4 lines

git-config key: submodule.$name.rebase (bool)

Yes, I hereby give my sign-off ;-)

Quoted 10 lines

---

Quoted 8 lines

With this squashed in, I actually would not be too opposed to put this into 1.6.3, as it _is_ an improvement.

-- snipsnap --
[PATCH] To be squashed in

This does three things:

Quoted 8 lines
Quoted 5 lines

- add .gitmodules support for rebase,
- use --bool for the git config calls for type checking, and
- rename ambiguous t7404 to t7406.

Squashed in, thank you. One typo fixed in last testcase (does-not-mater -> does-not-matter).

I just blame it on the lousy Acer keyboard which cannot follow the speed of my fingers.

Thanks!

Junio, how about it? post 1.6.3 or not? It is a well contained change, with little chance of breaking something, but offers a more sensible workflow here.

Ciao,
Dscho

#8 lore raw
Quoted 6 lines · Johannes Schindelin

Yes, I hereby give my sign-off ;-)

Quoted 4 lines

---

Quoted 2 lines

With this squashed in, I actually would not be too opposed to put this into 1.6.3, as it _is_ an improvement.

I am afraid it is a bit too late for "improvements" after -rc1. People survived without the new feature until now, and they can wait a bit longer for the next one. I would welcome "fixes" til -rc2 but after that I'd like people to focus only on regressions and fixes to new features. Again, people lived with known breakages that weren't fixed before -rc2, and fixes to them can wait.