{"thread":{"id":"43958","subject":"[PATCH RFC] subtree: support subtree -P /path/to/file split","startedAt":"2016-08-30T09:56:28Z","lastAt":"2016-08-30T09:56:28Z","messageCount":1,"participants":["Ivan Shapovalov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"300545","messageId":"20160830095526.15286-1-intelfx@intelfx.name","threadId":"43958","inReplyTo":null,"subject":"[PATCH RFC] subtree: support subtree -P /path/to/file split","fromName":"Ivan Shapovalov","fromEmail":"intelfx@intelfx.name","sentAt":"2016-08-30T09:55:26Z","receivedAt":"2016-08-30T09:56:28Z","isPatch":true,"sender":{"key":"intelfx@intelfx.name","avatar":"https://gravatar.com/avatar/fb0d6e45051c5d8cda450fd6d02ecba0216f5f3aae1ebcf5de522939ff18eef3?d=mp&s=160"},"body":"Hello,\n\nI'm missing `git subtree split` functionality for the case when prefix\nis a single file. Looking at git-subtree, pretty few changes are needed\nto handle this. The attached patch works for me in the common case\n(no rejoins). As such, I'm looking for comments :)\n\nSigned-off-by: Ivan Shapovalov <intelfx@intelfx.name>\n\n---\n contrib/subtree/git-subtree.sh | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex dec085a..464dcf7 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -485,8 +485,12 @@ subtree_for_commit () {\n \twhile read mode type tree name\n \tdo\n \t\tassert test \"$name\" = \"$dir\"\n-\t\tassert test \"$type\" = \"tree\" -o \"$type\" = \"commit\"\n+\t\tassert test \"$type\" = \"tree\" -o \"$type\" = \"commit\" -o \"$type\" = \"blob\"\n \t\ttest \"$type\" = \"commit\" && continue  # ignore submodules\n+\t\ttest \"$type\" = \"blob\" && { # handle if $dir is a file\n+\t\t\tprintf \"%s %s %s\\t%s\\0\" \"$mode\" \"$type\" \"$tree\" \"${file##*/}\" | git mktree\n+\t\t\tbreak\n+\t\t}\n \t\techo $tree\n \t\tbreak\n \tdone\n-- \n2.9.3\n\n"}]}