From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Add --reference option to git submodule
Date: Tue, 28 Apr 2009 09:52:37 +0300 [thread overview]
Message-ID: <20090428065237.GA5972@redhat.com> (raw)
This adds --reference option to 'git submodule add' and
'git submodule update' commands, which is passed on to git clone.
This option is useful when the submodule is large, such as linux kernel.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
I noticed that there's no easy way to specify a reference
for submodule repositories. Here's a patch to add this option.
Documentation/git-submodule.txt | 14 ++++++++++++--
git-submodule.sh | 31 ++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 3b8df44..0584cb7 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -9,10 +9,12 @@ git-submodule - Initialize, update or inspect submodules
SYNOPSIS
--------
[verse]
-'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
+'git submodule' [--quiet] add [-b branch]
+ [--reference <repository>] [--] <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]
+ [--reference <repository>] [--] [<path>...]
'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
'git submodule' [--quiet] foreach <command>
'git submodule' [--quiet] sync [--] [<path>...]
@@ -177,6 +179,14 @@ OPTIONS
This option is only valid for the update command.
Don't fetch new objects from the remote site.
+--reference <repository>::
+ This option is only valid for add and update commands. These
+ commands sometimes need to clone a remote repository. In this case,
+ this option will be passed to linkgit:git-clone[1] command.
++
+*NOTE*: Do *not* use this option unless you have read the note
+for linkgit:git-clone[1] --reference and --shared options carefully.
+
<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 8e234a4..32be246 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -15,6 +15,7 @@ require_work_tree
command=
branch=
quiet=
+reference=
cached=
nofetch=
@@ -91,6 +92,7 @@ module_clone()
{
path=$1
url=$2
+ reference="$3"
# If there already is a directory at the submodule path,
# expect it to be empty (since that is the default checkout
@@ -106,7 +108,12 @@ module_clone()
test -e "$path" &&
die "A file already exist at path '$path'"
- git-clone -n "$url" "$path" ||
+ if test "reference"
+ then
+ git-clone "$reference" -n "$url" "$path"
+ else
+ git-clone -n "$url" "$path"
+ fi ||
die "Clone of '$url' into submodule path '$path' failed"
}
@@ -131,6 +138,15 @@ cmd_add()
-q|--quiet)
quiet=1
;;
+ --reference)
+ case "$2" in '') usage ;; esac
+ reference="--reference=$2"
+ shift
+ ;;
+ --reference=*)
+ reference="$1"
+ shift
+ ;;
--)
shift
break
@@ -203,7 +219,7 @@ cmd_add()
git config submodule."$path".url "$url"
else
- module_clone "$path" "$realrepo" || exit
+ module_clone "$path" "$realrepo" "$reference" || exit
(
unset GIT_DIR
cd "$path" &&
@@ -321,6 +337,15 @@ cmd_update()
shift
nofetch=1
;;
+ --reference)
+ case "$2" in '') usage ;; esac
+ reference="$2"
+ shift 2
+ ;;
+ --reference=*)
+ reference="$1"
+ shift
+ ;;
--)
shift
break
@@ -351,7 +376,7 @@ cmd_update()
if ! test -d "$path"/.git -o -f "$path"/.git
then
- module_clone "$path" "$url" || exit
+ module_clone "$path" "$url" "$reference"|| exit
subsha1=
else
subsha1=$(unset GIT_DIR; cd "$path" &&
--
1.6.3.rc3.dirty
next reply other threads:[~2009-04-28 6:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-28 6:52 Michael S. Tsirkin [this message]
2009-04-28 11:10 ` [PATCH] Add --reference option to git submodule Michael J Gruber
2009-04-28 11:25 ` Michael S. Tsirkin
2009-04-28 13:12 ` Michael J Gruber
2009-04-28 11:27 ` Michael S. Tsirkin
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=20090428065237.GA5972@redhat.com \
--to=mst@redhat.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).