summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96db2c0)
raw | patch | inline | side by side (parent: 96db2c0)
author | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 25 Apr 2009 02:57:14 +0000 (22:57 -0400) | ||
committer | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 25 Apr 2009 02:57:14 +0000 (22:57 -0400) |
I like this better. It's more like git-read-tree and some other commands.
git-subtree.sh | patch | blob | history | |
test.sh | patch | blob | history |
diff --git a/git-subtree.sh b/git-subtree.sh
index d42cc1a1643cfd03b797ddc101fdca52a4023026..0c7b755cf1b779a040dde44c1ec850531ba813f4 100755 (executable)
--- a/git-subtree.sh
+++ b/git-subtree.sh
set -- -h
fi
OPTS_SPEC="\
-git subtree split [options...] <commit...> -- <path>
+git subtree split [options...] <--prefix=prefix> <commit...> -- <path>
git subtree merge
-
-git subtree does foo and bar!
--
h,help show the help
q quiet
-v verbose
+prefix= the name of the subdir to split out
onto= try connecting new tree to an existing one
rejoin merge the new branch back into HEAD
ignore-joins ignore prior --rejoin commits
shift
case "$opt" in
-q) quiet=1 ;;
+ --prefix) prefix="$1"; shift ;;
+ --no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
--no-onto) onto= ;;
--rejoin) rejoin=1 ;;
esac
revs=$(git rev-parse --default HEAD --revs-only "$@") || exit $?
-dirs="$(git rev-parse --sq --no-revs --no-flags "$@")" || exit $?
-#echo "dirs is {$dirs}"
-eval $(echo set -- $dirs)
-if [ "$#" -ne 1 ]; then
- die "Must provide exactly one subtree dir (got $#)"
+if [ -z "$prefix" ]; then
+ die "You must provide the --prefix option."
+fi
+dir="$prefix"
+
+dirs="$(git rev-parse --no-revs --no-flags "$@")" || exit $?
+if [ -n "$dirs" ]; then
+ die "Error: Use --prefix instead of bare filenames."
fi
-dir="$1"
debug "command: {$command}"
debug "quiet: {$quiet}"
unrevs="$(find_existing_splits "$dir" "$revs")"
fi
- debug "git rev-list --reverse $revs $unrevs"
- git rev-list --reverse --parents $revs $unrevsx |
+ # We can't restrict rev-list to only "$dir" here, because that leaves out
+ # critical information about commit parents.
+ debug "git rev-list --reverse --parents $revs $unrevs"
+ git rev-list --reverse --parents $revs $unrevs |
while read rev parents; do
debug
debug "Processing commit: $rev"
index 39c4382f0df292b1969e73f6dd52007baf18e536..dac9b3559af93c633a2c752cbf2efb2bdbfb7c5e 100755 (executable)
--- a/test.sh
+++ b/test.sh
git merge -s subtree FETCH_HEAD
git branch pre-split
-split1=$(git subtree split --onto FETCH_HEAD subdir --rejoin)
+split1=$(git subtree split --prefix subdir --onto FETCH_HEAD --rejoin)
echo "split1={$split1}"
git branch split1 "$split1"
git commit -m 'sub6'
cd ../mainline
-split2=$(git subtree split subdir --rejoin)
+split2=$(git subtree split --prefix subdir --rejoin)
git branch split2 "$split2"
touch subdir/main-sub7
git add subdir/main-sub7
git commit -m 'main-sub7'
-split3=$(git subtree split subdir --rejoin)
+split3=$(git subtree split --prefix subdir --rejoin)
git branch split3 "$split3"
cd ../subproj