From: Ivan Shapovalov <intelfx@intelfx.name>
To: git@vger.kernel.org
Cc: Ivan Shapovalov <intelfx@intelfx.name>
Subject: [PATCH RFC] subtree: support subtree -P /path/to/file split
Date: Tue, 30 Aug 2016 12:55:26 +0300 [thread overview]
Message-ID: <20160830095526.15286-1-intelfx@intelfx.name> (raw)
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
reply other threads:[~2016-08-30 9:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160830095526.15286-1-intelfx@intelfx.name \
--to=intelfx@intelfx.name \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).