]> git.madduck.net Git - code/myrepos.git/blob - lib/git-subtree

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

changelog
[code/myrepos.git] / lib / git-subtree
1 # Add support for Avery Pennarun's git-subtree
2 #
3 # Example:
4 #
5 # [repo]
6 # checkout = git clone git.example.org:repo.git
7 #
8 # [repo/lib]
9 # git_subtree_test = true
10 # checkout = git subtree add --prefix=lib git.example.org:lib.git master
11 # update = git_subtree_update --prefix=lib git.example.org:lib.git master
12 # push = git_subtree_push --prefix=lib git.example.org:lib.git master
13
14 lib =
15         git_get_toplevel() {
16                 local toplevel
17                 toplevel="$(git rev-parse --show-toplevel)" || true
18                 if [ -z "$toplevel" ]; then
19                         error "git toplevel is not set"
20                 fi
21                 toplevel="${toplevel%%/}/"
22                 if [ ! -d "$toplevel" ]; then
23                         error "git toplevel $toplevel does not exist"
24                 fi
25                 echo "$toplevel"
26         }
27         git_subtree_update() {
28                 cd "$(git_get_toplevel)"
29                 git subtree pull "$@"
30         }
31         git_subtree_push() {
32                 cd "$(git_get_toplevel)"
33                 git subtree push "$@"
34         }
35
36 git_subtree_status = git status -s "$@" . || true
37 git_subtree_commit = git add . && git commit "$@" && git_subtree_push
38 git_subtree_record = git add . && git commit "$@"
39 git_subtree_diff = git diff .
40 git_subtree_log = git log .