summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f96bc79)
raw | patch | inline | side by side (parent: f96bc79)
author | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 30 May 2009 05:05:43 +0000 (01:05 -0400) | ||
committer | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 30 May 2009 05:12:32 +0000 (01:12 -0400) |
This is just a handy way to create a new branch from the newly-split subtree.
git-subtree.sh | patch | blob | history | |
todo | patch | blob | history |
diff --git a/git-subtree.sh b/git-subtree.sh
index 825dd1dcad32fd3cac7cf0c72a9a3aeb8fe44eda..f6bdef300159327977f882208ad481b52c81105f 100755 (executable)
--- a/git-subtree.sh
+++ b/git-subtree.sh
prefix= the name of the subdir to split out
options for 'split'
annotate= add a prefix to commit message of new commits
+b,branch= create a new branch from the split subtree
+ignore-joins ignore prior --rejoin commits
onto= try connecting new tree to an existing one
rejoin merge the new branch back into HEAD
-ignore-joins ignore prior --rejoin commits
"
eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
. git-sh-setup
require_work_tree
quiet=
+branch=
debug=
command=
onto=
-d) debug=1 ;;
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
+ -b) branch="$1"; shift ;;
--prefix) prefix="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
--ignore-joins) ignore_joins=1 ;;
--no-ignore-joins) ignore_joins= ;;
--) break ;;
+ *) die "Unexpected option: $opt" ;;
esac
done
echo "$newrev" >"$cachedir/$oldrev"
}
+rev_exists()
+{
+ if git rev-parse "$1" >/dev/null 2>&1; then
+ return 0
+ else
+ return 1
+ fi
+}
+
# 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
+ if rev_exists "$1^"; then
echo "^$1^"
fi
}
cmd_split()
{
+ if [ -n "$branch" ] && rev_exists "refs/heads/$branch"; then
+ die "Branch '$branch' already exists."
+ fi
+
debug "Splitting $dir..."
cache_setup || exit $?
-m "$(merge_msg $dir $latest_old $latest_new)" \
$latest_new >&2 || exit $?
fi
+ if [ -n "$branch" ]; then
+ git update-ref -m 'subtree split' "refs/heads/$branch" \
+ $latest_new "" || exit $?
+ say "Created branch '$branch'"
+ fi
echo $latest_new
exit 0
}
index 97142fa4e2cd98875bb8c31c0881401a61b4a542..f23a6d4ff2a3f256edfae486cbd083d8ef4a344a 100644 (file)
--- a/todo
+++ b/todo
delete tempdir
- --annotate-sometimes: only annotate if the patch also changes files
- outside the subdir?
-
'git subtree rejoin' option to do the same as --rejoin, eg. after a
rebase
+ --prefix doesn't force the subtree correctly in merge/pull:
"-s subtree" should be given an explicit subtree option?
-
- --prefix doesn't force the subtree correctly in merge/pull
+ There doesn't seem to be a way to do this. We'd have to
+ patch git-merge-subtree. Ugh.
add a 'push' subcommand to parallel 'pull'
+
+ add a 'log' subcommand to see what's new in a subtree?
add a --squash option so we don't merge histories but can still split