From: larsxschneider@gmail.com
To: git@vger.kernel.org
Cc: sbeller@google.com, peff@peff.net, Jens.Lehmann@web.de,
Lars Schneider <larsxschneider@gmail.com>
Subject: [PATCH v3 3/3] submodule: extend die message on failed checkout with depth argument
Date: Mon, 21 Dec 2015 00:19:55 +0100 [thread overview]
Message-ID: <1450653595-22676-4-git-send-email-larsxschneider@gmail.com> (raw)
In-Reply-To: <1450653595-22676-1-git-send-email-larsxschneider@gmail.com>
From: Lars Schneider <larsxschneider@gmail.com>
A submodule checkout might fail due missing hashes caused by a shallow
fetch operation triggered with the "--depth" argument. Make the user
aware of this with an extended die message.
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
git-submodule.sh | 4 ++++
t/t7406-submodule-update.sh | 33 +++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bc5c5f..b555d87 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -764,6 +764,10 @@ Maybe you want to use 'update --init'?")"
command="git checkout $subforce -q"
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
+ if ! test -z "$depth"
+ then
+ die_msg="$die_msg $(eval_gettext "Commit is probably not on the default branch. Try to remove the '\$depth' argument!")"
+ fi
;;
rebase)
command="git rebase"
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index b5bd976..52b7120 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -31,6 +31,14 @@ test_expect_success 'setup a submodule tree' '
git clone super rebasing &&
git clone super merging &&
git clone super none &&
+ git clone super non-default-branch &&
+ (cd non-default-branch &&
+ git checkout -b non-default &&
+ echo "non-default" >file &&
+ git add file &&
+ git commit -m "Commit on non-default branch" &&
+ git checkout master
+ ) &&
(cd super &&
git submodule add ../submodule submodule &&
test_tick &&
@@ -63,6 +71,15 @@ test_expect_success 'setup a submodule tree' '
git submodule add ../none none &&
test_tick &&
git commit -m "none"
+ ) &&
+ (cd super &&
+ git submodule add ../non-default-branch non-default-branch &&
+ (cd non-default-branch &&
+ git checkout non-default
+ ) &&
+ git add non-default-branch &&
+ test_tick &&
+ git commit -m "non-default-branch"
)
'
@@ -752,17 +769,29 @@ test_expect_success SYMLINKS 'submodule update can handle symbolic links in pwd'
)
'
-test_expect_success 'submodule update clone shallow submodule' '
+test_expect_success 'submodule update clone shallow submodule on default branch' '
git clone cloned super3 &&
pwd=$(pwd) &&
(cd super3 &&
sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
mv -f .gitmodules.tmp .gitmodules &&
+ git config submodule.non-default-branch.update none &&
git submodule update --init --depth=3 &&
(cd submodule &&
test 1 = $(git log --oneline | wc -l)
)
-)
+ )
+'
+
+test_expect_success 'submodule update clone shallow submodule on non-default branch' '
+ git clone cloned super4 &&
+ pwd=$(pwd) &&
+ (cd super4 &&
+ sed -e "s#url = ../#url = file://$pwd/#" <.gitmodules >.gitmodules.tmp &&
+ mv -f .gitmodules.tmp .gitmodules &&
+ test_must_fail git submodule update --init --depth=3 2>submodule.out &&
+ test_i18ngrep --count "Commit is probably not on the default branch." submodule.out
+ )
'
test_expect_success 'submodule update --recursive drops module name before recursing' '
--
2.5.1
next prev parent reply other threads:[~2015-12-20 23:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-20 23:19 [PATCH v3 0/3] add test to demonstrate that shallow recursive clones fail larsxschneider
2015-12-20 23:19 ` [PATCH v3 1/3] submodule: " larsxschneider
2016-03-15 19:50 ` Stefan Beller
2016-03-15 20:12 ` Junio C Hamano
2016-03-20 17:05 ` Lars Schneider
2016-03-20 19:40 ` Jeff King
2016-03-20 21:27 ` Stefan Beller
2015-12-20 23:19 ` [PATCH v3 2/3] submodule: fix &&-chain breakage larsxschneider
2015-12-20 23:19 ` larsxschneider [this message]
2016-01-11 16:26 ` [PATCH v3 3/3] submodule: extend die message on failed checkout with depth argument Stefan Beller
2016-01-12 9:29 ` Lars Schneider
2016-01-12 23:32 ` Stefan Beller
2016-01-07 21:50 ` [PATCH v3 0/3] add test to demonstrate that shallow recursive clones fail Lars Schneider
2016-01-11 16:29 ` Stefan Beller
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450653595-22676-4-git-send-email-larsxschneider@gmail.com \
--to=larsxschneider@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).