From: Jonathan Nieder <jrnieder@gmail.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Klaus Ethgen <Klaus@Ethgen.de>,
Sven Verdoolaege <skimo@kotnet.org>,
mlevedahl@gmail.com
Subject: Re: [PATCH] git submodule -b ... of current HEAD fails
Date: Wed, 8 Dec 2010 17:45:08 -0600 [thread overview]
Message-ID: <20101208234508.GB8865@burratino> (raw)
In-Reply-To: <4D001292.3020503@web.de>
Jens Lehmann wrote:
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -241,7 +241,9 @@ cmd_add()
> # ash fails to wordsplit ${branch:+-b "$branch"...}
> case "$branch" in
> '') git checkout -f -q ;;
> - ?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
> + ?*) if [ "$(git branch)" != "* $branch" ]; then
Agh. The command to use is "git symbolic-ref -q HEAD", I suppose.
Maybe we can simplify by relying on "git clone".
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
git-submodule.sh | 16 ++++++----------
t/t7400-submodule-basic.sh | 8 +++++++-
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index d937f0b..6fd09e7 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -219,17 +219,13 @@ cmd_add()
esac
git config submodule."$path".url "$url"
else
-
- module_clone "$path" "$realrepo" "$reference" || exit
+ brancharg=${branch:+"-b $(git rev-parse --sq-quote "$branch")"}
+ refarg=${reference:+"$(git rev-parse --sq-quote "$reference")"}
(
- clear_local_git_env
- cd "$path" &&
- # ash fails to wordsplit ${branch:+-b "$branch"...}
- case "$branch" in
- '') git checkout -f -q ;;
- ?*) git checkout -f -q -b "$branch" "origin/$branch" ;;
- esac
- ) || die "Unable to checkout submodule '$path'"
+ export realrepo path &&
+ eval "git clone $brancharg $refarg" '"$realrepo" "$path"'
+ ) ||
+ die "Clone of '$realrepo' into submodule path '$path' failed"
fi
git add $force "$path" ||
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 2c49db9..77088cc 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -114,7 +114,6 @@ test_expect_success 'submodule add --branch' '
echo "refs/heads/initial" >expect-head &&
cat <<-\EOF >expect-heads &&
refs/heads/initial
- refs/heads/master
EOF
>empty &&
@@ -131,6 +130,13 @@ test_expect_success 'submodule add --branch' '
test_cmp empty untracked
'
+test_expect_success 'submodule add --branch succeeds even when branch is at HEAD' '
+ (
+ cd addtest &&
+ git submodule add -b master "$submodurl" submod-existing-branch
+ )
+'
+
test_expect_success 'submodule add with ./ in path' '
echo "refs/heads/master" >expect &&
>empty &&
next prev parent reply other threads:[~2010-12-08 23:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20101201171814.GC6439@ikki.ethgen.de>
2010-12-01 18:50 ` [RFC/PATCH] Re: git submodule -b ... of current HEAD fails Jonathan Nieder
2010-12-02 21:11 ` Jens Lehmann
2010-12-03 1:16 ` Mark Levedahl
2010-12-03 1:21 ` Ben Jackson
2010-12-03 7:10 ` Jonathan Nieder
2010-12-04 23:27 ` [PATCH] git submodule: Remove now obsolete tests before cloning a repo Jens Lehmann
2010-12-07 22:57 ` [RFC/PATCH] Re: git submodule -b ... of current HEAD fails Junio C Hamano
2010-12-08 21:35 ` Jens Lehmann
2010-12-08 23:19 ` [PATCH] " Jens Lehmann
2010-12-08 23:45 ` Jonathan Nieder [this message]
2010-12-28 21:42 ` [RFC/PATCH] " Junio C Hamano
2010-12-29 0:05 ` Jens Lehmann
2010-12-29 0:34 ` Junio C Hamano
2010-12-29 9:04 ` Jens Lehmann
2010-12-29 20:53 ` Re* " Junio C Hamano
[not found] ` <4D1BB26D.1010502@web.de>
2010-12-29 22:23 ` Jens Lehmann
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=20101208234508.GB8865@burratino \
--to=jrnieder@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=Klaus@Ethgen.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mlevedahl@gmail.com \
--cc=skimo@kotnet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox