[PATCH RFC] subtree: support subtree -P /path/to/file split
- From
Ivan Shapovalov <intelfx@intelfx.name>
- Date
- Aug 30, 2016, 09:55 UTC
- Message-ID
- <20160830095526.15286-1-intelfx@intelfx.name>
Hello,
I'm missing `git subtree split` functionality for the case when prefix is a single file. Looking at git-subtree, pretty few changes are needed to handle this. The attached patch works for me in the common case (no rejoins). As such, I'm looking for comments :)
Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
--- contrib/subtree/git-subtree.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh index dec085a..464dcf7 100755 --- a/contrib/subtree/git-subtree.sh +++ b/contrib/subtree/git-subtree.sh @@ -485,8 +485,12 @@ subtree_for_commit () { while read mode type tree name do assert test "$name" = "$dir" - assert test "$type" = "tree" -o "$type" = "commit" + assert test "$type" = "tree" -o "$type" = "commit" -o "$type" = "blob" test "$type" = "commit" && continue # ignore submodules + test "$type" = "blob" && { # handle if $dir is a file + printf "%s %s %s\t%s\0" "$mode" "$type" "$tree" "${file##*/}" | git mktree + break + } echo $tree break done
-- 2.9.3