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 <inte...@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

Reply via email to