#!/bin/sh # Return either the subrepo path for each path or all # subrepo paths in the current subgit container. usage() { die $(cat <<-EOF Usage: subgit subrepo [PATH..] Resolves and returns absolute paths to subrepositories. With no arguments, lists all subrepos in current container. With arguments, normalizes each path to its tracked subrepo root. EOF ) } while [ "$1" ]; do case $1 in -h) usage;; --) shift; break;; -*) die "Invalid option $1";; *) break;; esac done subrepos=() if [ $# -eq 0 ]; then root=$(subgit-sub root) source "$root/.subgitrc" for relpath in "${!subgit[@]}"; do subrepos+=("$root/$relpath") done else for arg in "$@"; do root=$(subgit-sub parent "$arg") relpath=$(subgit-sub relpath "$root" "$arg") subrepos+=("$root/$relpath") done fi for subrepo in ${subrepos[@]}; do echo "$subrepo" done