{"thread":{"id":"32893","subject":"[PATCH 2/4] contrib/subtree: Allow stale .gitsubtree entries to be replaced","startedAt":"2013-02-12T23:23:14Z","lastAt":"2013-02-12T23:23:14Z","messageCount":1,"participants":["Paul Campbell"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"209438","messageId":"CALeLG_=t1E9uemehqPD48r+2JrRSToJJcSBuOQn=Qz7730=4-w@mail.gmail.com","threadId":"32893","inReplyTo":null,"subject":"[PATCH 2/4] contrib/subtree: Allow stale .gitsubtree entries to be replaced","fromName":"Paul Campbell","fromEmail":"pcampbell@kemitix.net","sentAt":"2013-02-12T23:23:14Z","receivedAt":"2013-02-12T23:23:14Z","isPatch":true,"sender":{"key":"pcampbell@kemitix.net","avatar":"https://gravatar.com/avatar/57584e05501b694929004e43fcd7308f4ad64df2eb0474cd8c7e5f93662bb0f1?d=mp&s=160"},"body":"Should .gitsubtree have a <prefix> listed that doesn't exist on disk, allow\nit to be replaced/updated by a git subtree add.\n\nIdeally I would have aborted the operation if there was an existing entry\nand required the user to edit the .gitsubtree file by hand, but that\nbehaviour broke a lot of the tests.\n\nSigned-off-by: Paul Campbell <pcampbell@kemitix.net>\n---\n contrib/subtree/git-subtree.sh | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh\nindex 02aae30..4f21902 100755\n--- a/contrib/subtree/git-subtree.sh\n+++ b/contrib/subtree/git-subtree.sh\n@@ -490,7 +490,13 @@ ensure_clean()\n\n subtree_memorize()\n {\n-\tif [ $# -eq 1 ] ; then\n+\tif ( grep \"^$dir \" .gitsubtree ); then\n+\t\t# remove $dir from .gitsubtree - there's probably a clever way to\ndo this with sed\n+\t\tgrep -v \"^$dir \" .gitsubtree > .gitsubtree.temp\n+\t\trm .gitsubtree\n+\t\tmv .gitsubtree.temp .gitsubtree\n+\tfi\n+\tif [ $# -eq 1 ]; then\n \t\techo \"$dir . $@\" >> .gitsubtree\n \telif [ $# -eq 2 ]; then\n \t\techo \"$dir $@\" >> .gitsubtree\n-- \n1.8.1.3.566.gaa39828\n"}]}