Skip to content

Commit

Permalink
borg.sh: Support using a submodule as user-emacs-directory
Browse files Browse the repository at this point in the history
Note that the `bootstrap-borg' target in ".config/emacs/Makefile"
also has to be changed accordingly.

Closes #154.
Closes emacscollective/emacs.g#30.
  • Loading branch information
tarsius committed Aug 27, 2024
1 parent 7b88080 commit 6606092
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions borg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ module_hash () {

clone () {
path="$1"
shift
modsdir="$2/modules"
shift 2
echo "--- [$path] ---"

cd "$super"
Expand Down Expand Up @@ -73,8 +74,9 @@ clone () {
;;
esac

mkdir -p "$modsdir"
git clone "$url" "$path" $args \
--separate-git-dir ".git/modules/$name" ||
--separate-git-dir "$modsdir/$name" ||
echo "Cloning failed"

if [ -n "$rename" ]
Expand All @@ -94,8 +96,9 @@ clone () {
then
echo "Cloning $path from $remote ($url)"

mkdir -p "$modsdir"
if git clone "$remote_url" "$path" \
--separate-git-dir ".git/modules/$name"
--separate-git-dir "$modsdir/$name"
then
git remote rename origin "$remote"
else
Expand Down Expand Up @@ -209,12 +212,14 @@ cmd_clone () {
shift
done

gitdir="$(realpath --relative-to=. "$(git rev-parse --git-dir)")"

if [ $# -ne 0 ]
then
for path in "$@"; do clone $path; done
for path in "$@"; do clone $path $gitdir; done
else
git ls-files -s | grep ^160000 | cut -f2 |
while read path; do clone $path; done
while read path; do clone $path $gitdir; done
fi
}

Expand Down

0 comments on commit 6606092

Please sign in to comment.