@@ -129,12 +129,7 @@ class GitFat(object):
129
129
'''
130
130
digest , bytes = self .decode (body , noraise = True )
131
131
return digest
132
- def cmd_clean (self ):
133
- '''
134
- The clean filter runs when a file is added to the index. It gets the "smudged" (tree)
135
- version of the file on stdin and produces the "clean" (repository) version on stdout.
136
- '''
137
- self .setup ()
132
+ def filter_clean (self , instream , outstreamclean ):
138
133
h = hashlib .new ('sha1' )
139
134
bytes = 0
140
135
fd , tmpname = tempfile .mkstemp (dir = self .objdir )
@@ -143,13 +138,13 @@ class GitFat(object):
143
138
cached = False # changes to True when file is cached
144
139
with os .fdopen (fd , 'w' ) as cache :
145
140
outstream = cache
146
- blockiter = readblocks (sys . stdin )
141
+ blockiter = readblocks (instream )
147
142
firstblock = True
148
- for block in readblocks (sys . stdin ):
143
+ for block in readblocks (instream ):
149
144
if firstblock :
150
145
if len (block ) == self .magiclen and self .decode_clean (block [0 :self .magiclen ]):
151
146
ishanging = True # Working tree version is verbatim from repository (not smudged)
152
- outstream = sys . stdout
147
+ outstream = outstreamclean
153
148
firstblock = False
154
149
h .update (block )
155
150
bytes += len (block )
@@ -165,12 +160,20 @@ class GitFat(object):
165
160
os .rename (tmpname , objfile )
166
161
self .verbose ('git-fat filter-clean: caching to %s' % objfile )
167
162
cached = True
168
- sys . stdout .write (self .encode (digest , bytes ))
163
+ outstreamclean .write (self .encode (digest , bytes ))
169
164
finally :
170
165
if not cached :
171
166
os .remove (tmpname )
172
167
173
- def cmd_smudge (self ):
168
+ def cmd_filter_clean (self ):
169
+ '''
170
+ The clean filter runs when a file is added to the index. It gets the "smudged" (tree)
171
+ version of the file on stdin and produces the "clean" (repository) version on stdout.
172
+ '''
173
+ self .setup ()
174
+ self .filter_clean (sys .stdin , sys .stdout )
175
+
176
+ def cmd_filter_smudge (self ):
174
177
self .setup ()
175
178
result , bytes = self .decode_stream (sys .stdin )
176
179
if isinstance (result , str ): # We got a digest
@@ -309,9 +312,9 @@ if __name__ == '__main__':
309
312
fat = GitFat ()
310
313
cmd = sys .argv [1 ] if len (sys .argv ) > 1 else ''
311
314
if cmd == 'filter-clean' :
312
- fat .cmd_clean ()
315
+ fat .cmd_filter_clean ()
313
316
elif cmd == 'filter-smudge' :
314
- fat .cmd_smudge ()
317
+ fat .cmd_filter_smudge ()
315
318
elif cmd == 'init' :
316
319
fat .cmd_init ()
317
320
elif cmd == 'status' :
0 commit comments