q quiet
prefix= the name of the subdir to split out
options for 'split'
+annotate= add a prefix to commit message of new commits
onto= try connecting new tree to an existing one
rejoin merge the new branch back into HEAD
ignore-joins ignore prior --rejoin commits
onto=
rejoin=
ignore_joins=
+annotate=
debug()
{
shift
case "$opt" in
-q) quiet=1 ;;
+ --annotate) annotate="$1"; shift ;;
+ --no-annotate) annotate= ;;
--prefix) prefix="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
echo "$newrev" >"$cachedir/$oldrev"
}
+# 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()
+{
+ if git rev-parse "$1^" >/dev/null 2>&1; then
+ echo "^$1^"
+ fi
+}
+
find_existing_splits()
{
debug "Looking for prior splits..."
dir="$1"
revs="$2"
git log --grep="^git-subtree-dir: $dir\$" \
- --pretty=format:'%s%n%n%b%nEND' "$revs" |
+ --pretty=format:'%s%n%n%b%nEND' $revs |
while read a b junk; do
case "$a" in
git-subtree-mainline:) main="$b" ;;
if [ -n "$main" -a -n "$sub" ]; then
debug " Prior: $main -> $sub"
cache_set $main $sub
- echo "^$main^ ^$sub^"
+ try_remove_previous "$main"
+ try_remove_previous "$sub"
main=
sub=
fi
GIT_COMMITTER_NAME \
GIT_COMMITTER_EMAIL \
GIT_COMMITTER_DATE
- (echo -n '*'; cat ) | # FIXME
+ (echo -n "$annotate"; cat ) |
git commit-tree "$2" $3 # reads the rest of stdin
) || die "Can't copy commit $1"
}