From: Peter Hutterer <peter.hutterer@who-t.net>
To: git@vger.kernel.org
Subject: [RFC/PATCH] git-submodule: add support for --rebase.
Date: Tue, 7 Apr 2009 21:14:55 +1000 [thread overview]
Message-ID: <20090407111445.GA11344@dingo> (raw)
'git submodule update --rebase' rebases onto the current branch rather than
detaching the HEAD.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
I use git-submodule to keep track of repositories that I only infrequently
commit to. I keep them to have a set that is known to work.
git submodule update is annoying, as it (in my case needlessly) detaches the
HEAD, making the workflow more complicated when I do have to commit (checkout
master, rebase onto master, then commit).
This patch adds a "--rebase" flag to git submodule update that calls
git-rebase instead of git-checkout.
Any comments? Is there a better solution for this problem?
Cheers,
Peter
Documentation/git-submodule.txt | 11 +++++++++--
git-submodule.sh | 21 +++++++++++++++++----
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 3b8df44..117ad3d 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -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,12 @@ 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.
+ Forward-port local commits to the index of the containing repository.
+ 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.
diff --git a/git-submodule.sh b/git-submodule.sh
index 7c2e060..6180bf4 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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,19 @@ 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
+ (unset GIT_DIR; cd "$path" &&
+ git-checkout $force -q "$sha1") ||
+ die "Unable to checkout '$sha1' in submodule path '$path'"
+ say "Submodule path '$path': checked out '$sha1'"
+ else
+ (unset GIT_DIR; cd "$path" &&
+ git-rebase "$sha1") ||
+ die "Unable to rebase onto '$sha1' in submodule path '$path'"
+ say "Submodule path '$path': rebased onto '$sha1'"
+ fi
- say "Submodule path '$path': checked out '$sha1'"
fi
done
}
--
1.6.2.2.447.ge953ab
next reply other threads:[~2009-04-07 12:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 11:14 Peter Hutterer [this message]
2009-04-07 12:38 ` [RFC/PATCH] git-submodule: add support for --rebase Johannes Schindelin
2009-04-08 4:22 ` Peter Hutterer
2009-04-08 10:44 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090407111445.GA11344@dingo \
--to=peter.hutterer@who-t.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.