threads / rfc / 43958

RFC patchsubtree: support subtree -P /path/to/file split

Subject: [PATCH RFC] subtree: support subtree -P /path/to/file split

## tl;dr

One message between Aug 30, 2016 and Aug 30, 2016. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Ivan Shapovalov· Aug 30, 2016, 09:55 UTC · lore
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(-)
Show changes to contrib/subtree/git-subtree.sh +5 −1
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

← back to recent threads