summarylogtreecommitdiffstats
path: root/subgit
blob: 55b1fdb8f3f91bb9b2fff473f500e15871f02554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env sh

# subgit
#
# A tiny wrapper around git to help you manage
# Git sub-projects easily, safely, and simply.
#
# Created by Rusty Klophaus (@rklophaus)
#
# See http://blog.rusty.io/2010/01/24/submodules-and-subrepos-done-right/ for usage.

if [ "$1" == "setup" ]; then
	if [ -d ".git" ]; then
		mv .git .subgit
		echo "Converted to a subgit repository."
		exit 0
	else
		echo "Could not find .git directory."
		exit -1
	fi
fi

DIR=`pwd`
while [ ! -d "$DIR/.subgit" ] && [ ! "$DIR" == "/" ]; do
	DIR=`dirname $DIR`
done

if [ $DIR == "/" ]; then
	echo "Not in a subgit repository!"
	exit -1
fi

git --git-dir=$DIR/.subgit "$@"