summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar https://launchpad.net/~arand <arand@web>2013-03-13 12:05:50 +0000
committerGravatar admin <admin@branchable.com>2013-03-13 12:05:50 +0000
commit80885fa44ad5514d9d6faebec334f49ec22a5b76 (patch)
tree34aefc7f692b5e8c56feae301066be2561f0323a
parent629db25c1bfbd0ca86ddaafa19848a900611a35c (diff)
Added a comment
-rw-r--r--doc/tips/How_to_retroactively_annex_a_file_already_in_a_git_repo/comment_2_dac1a171204f30d7c906e878eb6bd461._comment45
1 files changed, 45 insertions, 0 deletions
diff --git a/doc/tips/How_to_retroactively_annex_a_file_already_in_a_git_repo/comment_2_dac1a171204f30d7c906e878eb6bd461._comment b/doc/tips/How_to_retroactively_annex_a_file_already_in_a_git_repo/comment_2_dac1a171204f30d7c906e878eb6bd461._comment
new file mode 100644
index 000000000..a3ea62385
--- /dev/null
+++ b/doc/tips/How_to_retroactively_annex_a_file_already_in_a_git_repo/comment_2_dac1a171204f30d7c906e878eb6bd461._comment
@@ -0,0 +1,45 @@
+[[!comment format=mdwn
+ username="https://launchpad.net/~arand"
+ nickname="arand"
+ subject="comment 2"
+ date="2013-03-13T12:05:49Z"
+ content="""
+Based on the hints given here I've worked on a filter to both annex and add urls via filter-branch:
+
+[https://gitorious.org/arand-scripts/arand-scripts/blobs/master/annex-filter](https://gitorious.org/arand-scripts/arand-scripts/blobs/master/annex-filter)
+
+The script above is very specific but I think there are a few ideas that can be used in general, the general structure is
+
+ #!/bin/bash
+
+ # links that already exist
+ links=$(mktemp)
+ find . -type l >\"$links\"
+
+ # remove from staging area first to not block and then annex
+ git rm --cached --ignore-unmatch -r bin*
+ git annex add -c annex.alwayscommit=false bin*
+
+ # compare links before and after annexing, remove links that existed before
+ newlinks=$(mktemp -u)
+ mkfifo \"$newlinks\"
+ comm -13 <(sort \"$links\") <(find . -type l | sort) > \"$newlinks\" &
+
+ # rewrite links
+ while IFS= read -r file
+ do
+ # link is created below .git-rewrite/t/ during filter-branch, strip two parents for correct target
+ ln -sf \"$(readlink \"$file\" | sed -e 's%^\.\./\.\./%%')\" \"$file\"
+ done < \"$newlinks\"
+
+ git annex merge
+
+which would be run using
+
+ git filter-branch --tree-filter path/annex-filter --tag-filter cat -- --all
+
+or similar.
+
+* I'm using `find` to make sure the only rewritten symlinks are for the newly annexed files, this way it is possible to annex an unknown set of filenames
+* If doing several git annex commands using `-c annex.alwayscommit=false` and doing a `git annex merge` at the end instead might be faster.
+"""]]