mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
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>
This commit is contained in:
parent
2a79d2f662
commit
b9b378a001
|
@ -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'"
|
||||
|
|
Loading…
Reference in a new issue