fix notes on updating submodules

This commit is contained in:
Daniel Langbein 2021-06-26 18:30:33 +02:00
parent 372f94d2bb
commit 2858795bc0
2 changed files with 6 additions and 19 deletions

3
.gitmodules vendored
View File

@ -247,3 +247,6 @@
[submodule "pkg/forklift-git"]
path = pkg/forklift-git
url = https://aur.archlinux.org/forklift-git.git
[submodule "pkg/dotfiles"]
path = pkg/dotfiles
url = https://git.privacy1st.de/langfingaz/dotfiles.git

View File

@ -21,27 +21,11 @@ To initialize the submodules, run
git submodule init
```
To update all submodules and print a list of those who received an update, run
To update all submodules and add those who received an update to
[build-pkg/pkglist.tmp](build-pkg/pkglist.tmp), run
```shell
if output="$(git submodule update --remote 2>&1)"; then
# We capture only the part after "pkg" until the next "'" using sed
# Source: https://unix.stackexchange.com/a/165590/315162
sed 's|^Submodule path '\''pkg/\([^'\'']*\).*|\1|' <<< "$output"
else
echo "$output"
fi
```
It may happen that some submodules have a detached HEAD (due to local changes, etc.)
and do not get updated with the above command. One can list those submodules as follows:
```shell
git submodule status | grep --invert-match '(heads/master)$'
# One could then reset them to master with e.g.
# git reset --hard
# git checkout master
git submodule foreach 'if git pull | grep '\''^Updating'\''; then printf " %s" "$(basename $sm_path)" >> $toplevel/build-pkg/pkglist.tmp; fi'
```