From 758019cc18e03c203b023efb3c0d76c053265362 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Jan 2011 13:34:39 -0400 Subject: update --- doc/todo/smudge.mdwn | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'doc/todo/smudge.mdwn') diff --git a/doc/todo/smudge.mdwn b/doc/todo/smudge.mdwn index 65cfb0fda..855d9c7f8 100644 --- a/doc/todo/smudge.mdwn +++ b/doc/todo/smudge.mdwn @@ -21,11 +21,19 @@ On the smudge side, I have not heard of a way to have the smudge filter point to an existing file, it probably still needs to cat it out. Luckily that is only done at checkout anyway. ----- +### dealing with partial content availability + +The smudge filter cannot be allowed to fail, that leaves the tree and +index in a weird state. So if a file's content is requested by calling +the smudge filter, the trick is to instead provide dummy content, +indicating it is not available (and perhaps saying to run "git-annex get"). + +Then, in the clean filter, it has to detect that it's cleaning a file +with that dummy content, and make sure to provide the same identifier as +it would if the file content was there. + +I've a demo implementation of this technique in the scripts below. -The other trick may be doing it with partial content availability. -When a smudge filter fails, git leaves the tree and index in a very weird -state. More investigation needed. ### test files @@ -35,7 +43,11 @@ huge-smudge: #!/bin/sh read sha1 echo "smudging $sha1" >&2 -cat ~/$sha1 +if [ -e ~/$sha1 ]; then + cat ~/$sha1 +else + echo "$sha1 not available" +fi huge-clean: @@ -43,6 +55,11 @@ huge-clean:
 #!/bin/sh
 cat >temp
+if grep -q 'not available' temp; then
+	awk '{print $1}' temp # provide what we would if the content were avail!
+	rm temp
+	exit 0
+fi
 sha1=`sha1sum temp | cut -d' ' -f1`
 echo "cleaning $sha1" >&2
 ls -l temp >&2
-- 
cgit v1.2.3