Browse Source
If we change an upstream URL, all submodules break. Users would need to run 'git submodule sync'. Note that the libbacktrace fix was merged upstream so this is no longer necessary, but it's good for future changes. Also, stress-testing reveals that git submodule fails locking '.git/config' when run in paralell. It also segfaults and other problems. This is my final attempt to fix submodules; I've wasted far too many days on obscure problems it creates: I've already lost one copy of my repo to apparently unfixable submodule preoblems. The next "fix" will be to simply import the source code so it works properly. Reported-by: @jsarenik Fixes: #1543 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>ppa-0.6.1
Rusty Russell
7 years ago
committed by
Christian Decker
2 changed files with 44 additions and 8 deletions
@ -0,0 +1,30 @@ |
|||||
|
#! /bin/sh |
||||
|
|
||||
|
if [ $# = 0 ]; then |
||||
|
echo "Usage: $0 <submoduledir1>..." >&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# git submodule can't run in parallel. Really. |
||||
|
echo $$ > .refresh-submodules.$$ |
||||
|
if ! mv -n .refresh-submodules.$$ .refresh-submodules; then |
||||
|
rm -f .refresh-submodules.$$ |
||||
|
exit 0 |
||||
|
fi |
||||
|
trap "rm -f .refresh-submodules" EXIT |
||||
|
|
||||
|
# Be a little careful here, since we do rm -rf! |
||||
|
for m in "$@"; do |
||||
|
if ! grep -q "path = $m\$" .gitmodules; then |
||||
|
echo "$m is not a submodule!" >&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
# git submodule can segfault. Really. |
||||
|
if [ "$(git submodule status "$@" | grep -c '^ ')" != $# ]; then |
||||
|
echo Reinitializing submodules "$@" ... |
||||
|
git submodule sync "$@" |
||||
|
rm -rf "$@" |
||||
|
git submodule update --init "$@" |
||||
|
fi |
Loading…
Reference in new issue