blob: 4ba15c7c6db6f6649419fc557152a773a551a210 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/bash
[ $# -eq 0 ] && die $(cat <<-EOF
Usage: subgit run CMD [ARG..]
Executes a command in the current subrepository context,
temporarily symlinking .git to the bare repository before
running the command.
EOF
)
root="$(subgit-sub root)"
relpath=$(subgit-sub relpath "$root" .)
path="$root/$relpath"
if [ ! -e "$path" ]; then
echo "Subgit for $path not initialized?"
exit 1
fi
trap 'unlink "$path/.git"' EXIT
ln -sf "$repo/.subgit/$relpath" "$path/.git"
"$@"
|