]> git.madduck.net Git - code/myrepos.git/commitdiff

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:

Add support for for git-subtree
authorSvend Sorensen <svend@ciffer.net>
Mon, 28 Mar 2011 17:52:43 +0000 (10:52 -0700)
committerJoey Hess <joey@kitenet.net>
Mon, 28 Mar 2011 21:04:41 +0000 (17:04 -0400)
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 [new file with mode: 0644]

diff --git a/lib/git-subtree b/lib/git-subtree
new file mode 100644 (file)
index 0000000..45b048e
--- /dev/null
@@ -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 .