subgit

Git-submodule alternative with vendoring and multiple remotes
git clone https://git.sinitax.com/sinitax/subgit
Log | Files | Refs | sfeed.txt

subgit-run (448B)


      1#!/bin/bash
      2
      3[ $# -eq 0 ] && die "Usage: subgit run CMD [ARG..]"
      4
      5repo=$(realpath "$(git rev-parse --show-toplevel)")
      6[ "${PWD#$repo/}" != "$PWD" ] || die "Bad path $repo > $PWD"
      7
      8path=$PWD
      9while [ 1 ]; do
     10	relpath=${path#$repo/}
     11	[ -d "$repo/.subgit/$relpath" ] && break
     12	path=$(dirname "$path")
     13	echo "$path"
     14	[ "$path" = "$repo" ] && die "No subgit found"
     15done
     16
     17trap 'unlink "$path/.git"' EXIT
     18ln -sf "$repo/.subgit/$relpath" "$path/.git"
     19
     20"$@"