summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorPing Yin <pkufranky@gmail.com>2008-09-26 15:33:23 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2008-09-29 15:24:19 (GMT)
commitb9b378a001d35a64a30a652a45f8084ee2be6cdf (patch)
tree339ecad79fa3f4dfbbb8b9a073fca52ce82f3e2a /git-submodule.sh
parent2a79d2f662a5a82a6cfcfd2a0d980e7b1875f320 (diff)
downloadgit-b9b378a001d35a64a30a652a45f8084ee2be6cdf.zip
git-b9b378a001d35a64a30a652a45f8084ee2be6cdf.tar.gz
git-b9b378a001d35a64a30a652a45f8084ee2be6cdf.tar.bz2
git-submodule: Fix "Unable to checkout" for the initial 'update'
Since commit 55218("checkout: do not lose staged removal"), in cmd_add/cmd_update, "git checkout <commit>" following "git clone -n" may fail if <commit> is different from HEAD. So Use "git checkout -f <commit>" to fix this. Signed-off-by: Ping Yin <pkufranky@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index b40f876..5888735 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -185,7 +185,7 @@ cmd_add()
else
module_clone "$path" "$realrepo" || exit
- (unset GIT_DIR; cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
+ (unset GIT_DIR; cd "$path" && git checkout -f -q ${branch:+-b "$branch" "origin/$branch"}) ||
die "Unable to checkout submodule '$path'"
fi
@@ -311,8 +311,13 @@ cmd_update()
if test "$subsha1" != "$sha1"
then
+ force=
+ if test -z "$subsha1"
+ then
+ force="-f"
+ fi
(unset GIT_DIR; cd "$path" && git-fetch &&
- git-checkout -q "$sha1") ||
+ git-checkout $force -q "$sha1") ||
die "Unable to checkout '$sha1' in submodule path '$path'"
say "Submodule path '$path': checked out '$sha1'"