From 6253eb3cb923a1bbeae76829c98cbcb06e68988f Mon Sep 17 00:00:00 2001 From: Svend Sorensen Date: Mon, 28 Mar 2011 10:52:43 -0700 Subject: [PATCH] Add support for for git-subtree This lib allows you to merge separate git repos into a single repo, and push changes back to the separate repos. See https://github.com/apenwarr/git-subtree for the git-subtree command. --- lib/git-subtree | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lib/git-subtree diff --git a/lib/git-subtree b/lib/git-subtree new file mode 100644 index 0000000..45b048e --- /dev/null +++ b/lib/git-subtree @@ -0,0 +1,40 @@ +# Add support for Avery Pennarun's git-subtree +# +# Example: +# +# [repo] +# checkout = git clone git.example.org:repo.git +# +# [repo/lib] +# git_subtree_test = true +# checkout = git subtree add --prefix=lib git.example.org:lib.git master +# update = git_subtree_update --prefix=lib git.example.org:lib.git master +# push = git_subtree_push --prefix=lib git.example.org:lib.git master + +lib = + git_get_toplevel() { + local toplevel + toplevel="$(git rev-parse --show-toplevel)" || true + if [ -z "$toplevel" ]; then + error "git toplevel is not set" + fi + toplevel="${toplevel%%/}/" + if [ ! -d "$toplevel" ]; then + error "git toplevel $toplevel does not exist" + fi + echo "$toplevel" + } + git_subtree_update() { + cd "$(git_get_toplevel)" + git subtree pull "$@" + } + git_subtree_push() { + cd "$(git_get_toplevel)" + git subtree push "$@" + } + +git_subtree_status = git status . +git_subtree_commit = git add . && git commit "$@" && git_subtree_push +git_subtree_record = git add . && git commit "$@" +git_subtree_diff = git diff . +git_subtree_log = git log . -- 2.39.5