message=
prefix=
-debug()
-{
+debug () {
if test -n "$debug"
then
printf "%s\n" "$*" >&2
fi
}
-say()
-{
+say () {
if test -z "$quiet"
then
printf "%s\n" "$*" >&2
fi
}
-progress()
-{
+progress () {
if test -z "$quiet"
then
printf "%s\r" "$*" >&2
fi
}
-assert()
-{
+assert () {
if ! "$@"
then
die "assertion failed: " "$@"
debug "opts: {$*}"
debug
-cache_setup()
-{
+cache_setup () {
cachedir="$GIT_DIR/subtree-cache/$$"
rm -rf "$cachedir" ||
die "Can't delete old cachedir: $cachedir"
debug "Using cachedir: $cachedir" >&2
}
-cache_get()
-{
+cache_get () {
for oldrev in "$@"
do
if test -r "$cachedir/$oldrev"
done
}
-cache_miss()
-{
+cache_miss () {
for oldrev in "$@"
do
if ! test -r "$cachedir/$oldrev"
done
}
-check_parents()
-{
+check_parents () {
missed=$(cache_miss "$@")
for miss in $missed
do
done
}
-set_notree()
-{
+set_notree () {
echo "1" > "$cachedir/notree/$1"
}
-cache_set()
-{
+cache_set () {
oldrev="$1"
newrev="$2"
if test "$oldrev" != "latest_old" &&
echo "$newrev" >"$cachedir/$oldrev"
}
-rev_exists()
-{
+rev_exists () {
if git rev-parse "$1" >/dev/null 2>&1
then
return 0
fi
}
-rev_is_descendant_of_branch()
-{
+rev_is_descendant_of_branch () {
newrev="$1"
branch="$2"
branch_hash=$(git rev-parse "$branch")
# if a commit doesn't have a parent, this might not work. But we only want
# to remove the parent from the rev-list, and since it doesn't exist, it won't
# be there anyway, so do nothing in that case.
-try_remove_previous()
-{
+try_remove_previous () {
if rev_exists "$1^"
then
echo "^$1^"
fi
}
-find_latest_squash()
-{
+find_latest_squash () {
debug "Looking for latest squash ($dir)..."
dir="$1"
sq=
done
}
-find_existing_splits()
-{
+find_existing_splits () {
debug "Looking for prior splits..."
dir="$1"
revs="$2"
done
}
-copy_commit()
-{
+copy_commit () {
# We're going to set some environment vars here, so
# do it in a subshell to get rid of them safely later
debug copy_commit "{$1}" "{$2}" "{$3}"
) || die "Can't copy commit $1"
}
-add_msg()
-{
+add_msg () {
dir="$1"
latest_old="$2"
latest_new="$3"
EOF
}
-add_squashed_msg()
-{
+add_squashed_msg () {
if test -n "$message"
then
echo "$message"
fi
}
-rejoin_msg()
-{
+rejoin_msg () {
dir="$1"
latest_old="$2"
latest_new="$3"
EOF
}
-squash_msg()
-{
+squash_msg () {
dir="$1"
oldsub="$2"
newsub="$3"
echo "git-subtree-split: $newsub"
}
-toptree_for_commit()
-{
+toptree_for_commit () {
commit="$1"
git log -1 --pretty=format:'%T' "$commit" -- || exit $?
}
-subtree_for_commit()
-{
+subtree_for_commit () {
commit="$1"
dir="$2"
git ls-tree "$commit" -- "$dir" |
done
}
-tree_changed()
-{
+tree_changed () {
tree=$1
shift
if test $# -ne 1
fi
}
-new_squash_commit()
-{
+new_squash_commit () {
old="$1"
oldsub="$2"
newsub="$3"
fi
}
-copy_or_skip()
-{
+copy_or_skip () {
rev="$1"
tree="$2"
newparents="$3"
fi
}
-ensure_clean()
-{
+ensure_clean () {
if ! git diff-index HEAD --exit-code --quiet 2>&1
then
die "Working tree has modifications. Cannot add."
fi
}
-ensure_valid_ref_format()
-{
+ensure_valid_ref_format () {
git check-ref-format "refs/heads/$1" ||
die "'$1' does not look like a ref"
}
-cmd_add()
-{
+cmd_add () {
if test -e "$dir"
then
die "'$dir' already exists. Cannot add."
fi
}
-cmd_add_repository()
-{
+cmd_add_repository () {
echo "git fetch" "$@"
repository=$1
refspec=$2
cmd_add_commit "$@"
}
-cmd_add_commit()
-{
+cmd_add_commit () {
revs=$(git rev-parse $default --revs-only "$@") || exit $?
set -- $revs
rev="$1"
say "Added dir '$dir'"
}
-cmd_split()
-{
+cmd_split () {
debug "Splitting $dir..."
cache_setup || exit $?
exit 0
}
-cmd_merge()
-{
+cmd_merge () {
revs=$(git rev-parse $default --revs-only "$@") || exit $?
ensure_clean
fi
}
-cmd_pull()
-{
+cmd_pull () {
if test $# -ne 2
then
die "You must provide <repository> <ref>"
cmd_merge "$@"
}
-cmd_push()
-{
+cmd_push () {
if test $# -ne 2
then
die "You must provide <repository> <ref>"