File: git-subtree

package info (click to toggle)
myrepos 1.20141024
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 260 kB
  • ctags: 41
  • sloc: perl: 1,620; makefile: 26
file content (44 lines) | stat: -rw-r--r-- 1,210 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
# Add support for Avery Pennarun's git-subtree
#
# To make mr use this file, add a line like this inside the [DEFAULT]
# section of your ~/.mrconfig
#include = cat /usr/share/mr/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 -s "$@" . || true
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 .