@@ -38,10 +38,14 @@ def __init__(self, *args, **kwargs):
3838
3939 @write_operation
4040 @not_in ("ignore" , check = ["old" , "new" ])
41- def rename (self , old , new ):
41+ def rename (self , old , new , gitignore ):
4242 new = re .sub (self .regex , '' , new )
4343 result = super (CurrentView , self ).rename (old , new )
4444
45+ if gitignore == True :
46+ log .debug ("[ignore] rename:%s" , name )
47+ return result
48+
4549 message = "Rename {} to {}" .format (old , new )
4650 self ._stage (** {
4751 'remove' : os .path .split (old )[1 ],
@@ -54,9 +58,13 @@ def rename(self, old, new):
5458
5559 @write_operation
5660 @not_in ("ignore" , check = ["target" ])
57- def symlink (self , name , target ):
61+ def symlink (self , name , target , gitignore ):
5862 result = os .symlink (target , self .repo ._full_path (name ))
59-
63+
64+ if gitignore == True :
65+ log .debug ("[ignore] symlink:%s" , name )
66+ return result
67+
6068 message = "Create symlink to {} for {}" .format (target , name )
6169 self ._stage (add = name , message = message )
6270
@@ -65,12 +73,16 @@ def symlink(self, name, target):
6573
6674 @write_operation
6775 @not_in ("ignore" , check = ["target" ])
68- def link (self , name , target ):
76+ def link (self , name , target , gitignore ):
6977 if target .startswith ('/%s/' % self .current_path ):
7078 target = target .replace ('/%s/' % self .current_path , '/' )
7179
7280 result = super (CurrentView , self ).link (target , name )
73-
81+
82+ if gitignore == True :
83+ log .debug ("[ignore] link:%s" , name )
84+ return result
85+
7486 message = "Create link to {} for {}" .format (target , name )
7587 self ._stage (add = name , message = message )
7688
@@ -96,17 +108,22 @@ def getattr(self, path, fh=None):
96108
97109 @write_operation
98110 @not_in ("ignore" , check = ["path" ])
99- def write (self , path , buf , offset , fh ):
111+ def write (self , path , buf , offset , fh , gitignore ):
100112 """
101113 We don't like big big files, so we need to be really carefull
102114 with them. First we check for offset, then for size. If any of this
103115 is off limit, raise EFBIG error and delete the file.
104116 """
105117
106- if offset + len (buf ) > self .max_size :
118+ if ( self . max_size > 0 ) and ( offset + len (buf ) > self .max_size ) :
107119 raise FuseOSError (errno .EFBIG )
108120
109121 result = super (CurrentView , self ).write (path , buf , offset , fh )
122+
123+ if gitignore == True :
124+ log .debug ("[ignore] write:%s. Wrote %s bytes to %s" , path , len (buf ), path )
125+ return result
126+
110127 self .dirty [fh ] = {
111128 'message' : 'Update {}' .format (path ),
112129 'stage' : True
@@ -117,9 +134,13 @@ def write(self, path, buf, offset, fh):
117134
118135 @write_operation
119136 @not_in ("ignore" , check = ["path" ])
120- def mkdir (self , path , mode ):
137+ def mkdir (self , path , mode , gitignore ):
121138 result = super (CurrentView , self ).mkdir (path , mode )
122-
139+
140+ if gitignore == True :
141+ log .debug ("[ignore] mkdir:%s" , path )
142+ return result
143+
123144 keep_path = "{}/.keep" .format (path )
124145 full_path = self .repo ._full_path (keep_path )
125146 if not os .path .exists (keep_path ):
@@ -141,10 +162,15 @@ def mkdir(self, path, mode):
141162
142163 return result
143164
144- def create (self , path , mode , fi = None ):
165+ @not_in ("ignore" , check = ["path" ])
166+ def create (self , path , mode , fi = None , gitignore = False ):
145167 fh = self .open_for_write (path , os .O_WRONLY | os .O_CREAT )
146168 super (CurrentView , self ).chmod (path , mode )
147169
170+ if gitignore == True :
171+ log .debug ("[ignore] create:%s" , path )
172+ return fh
173+
148174 self .dirty [fh ] = {
149175 'message' : "Created {}" .format (path ),
150176 'stage' : True
@@ -155,10 +181,11 @@ def create(self, path, mode, fi=None):
155181
156182 @write_operation
157183 @not_in ("ignore" , check = ["path" ])
158- def chmod (self , path , mode ):
184+ def chmod (self , path , mode , gitignore ):
159185 """
160186 Executes chmod on the file at os level and then it commits the change.
161187 """
188+
162189 str_mode = ('%o' % mode )[- 4 :]
163190 if str_mode not in ['0755' , '0644' ]:
164191 raise FuseOSError (errno .EINVAL )
@@ -168,6 +195,10 @@ def chmod(self, path, mode):
168195 if os .path .isdir (self .repo ._full_path (path )):
169196 return result
170197
198+ if gitignore == True :
199+ log .debug ("[ignore] chmod:%s" , path )
200+ return result
201+
171202 message = 'Chmod to {} on {}' .format (str_mode , path )
172203 self ._stage (add = path , message = message )
173204
@@ -177,13 +208,17 @@ def chmod(self, path, mode):
177208
178209 @write_operation
179210 @not_in ("ignore" , check = ["path" ])
180- def fsync (self , path , fdatasync , fh ):
211+ def fsync (self , path , fdatasync , fh , gitignore ):
181212 """
182213 Each time you fsync, a new commit and push are made
183214 """
184215
185216 result = super (CurrentView , self ).fsync (path , fdatasync , fh )
186-
217+
218+ if gitignore == True :
219+ log .debug ("[ignore] fsync:%s" , path )
220+ return result
221+
187222 message = 'Fsync {}' .format (path )
188223 self ._stage (add = path , message = message )
189224
@@ -192,10 +227,16 @@ def fsync(self, path, fdatasync, fh):
192227
193228 @write_operation
194229 @not_in ("ignore" , check = ["path" ])
195- def open_for_write (self , path , flags ):
196- global writers
230+ def open_for_write (self , path , flags , gitignore ):
197231 fh = self .open_for_read (path , flags )
198- writers += 1
232+
233+ if gitignore == True :
234+ log .debug ("[ignore] open_for_write:%s" , path )
235+ return fh
236+
237+ global writers
238+ writers += 1
239+
199240 self .dirty [fh ] = {
200241 'message' : "Opened {} for write" .format (path ),
201242 'stage' : False
@@ -207,21 +248,30 @@ def open_for_write(self, path, flags):
207248 def open_for_read (self , path , flags ):
208249 full_path = self .repo ._full_path (path )
209250 log .info ("CurrentView: Open %s for read" , path )
251+
210252 return os .open (full_path , flags )
211253
212254 def open (self , path , flags ):
213255 write_mode = flags & (os .O_WRONLY | os .O_RDWR |
214256 os .O_APPEND | os .O_CREAT )
215257 if write_mode :
258+ log .debug ("[ignore] open.write_mode: %s" , path )
216259 return self .open_for_write (path , flags )
260+
261+ log .debug ("[ignore] open.read_mode: %s" , path )
217262 return self .open_for_read (path , flags )
218263
219- def release (self , path , fh ):
264+ @not_in ("ignore" , check = ["path" ])
265+ def release (self , path , fh , gitignore ):
220266 """
221267 Check for path if something was written to. If so, commit and push
222268 the changed to upstream.
223269 """
224270
271+ if gitignore == True :
272+ log .debug ("[ignore] release:%s" , path )
273+ return os .close (fh )
274+
225275 if fh in self .dirty :
226276 message = self .dirty [fh ]['message' ]
227277 should_stage = self .dirty [fh ].get ('stage' , False )
@@ -238,7 +288,7 @@ def release(self, path, fh):
238288
239289 @write_operation
240290 @not_in ("ignore" , check = ["path" ])
241- def rmdir (self , path ):
291+ def rmdir (self , path , gitignore ):
242292 message = 'Delete the {} directory' .format (path )
243293
244294 # Unlink all the files
@@ -248,7 +298,8 @@ def rmdir(self, path):
248298 deleting_file = os .path .join (root , _file )
249299 if os .path .exists (deleting_file ):
250300 result = super (CurrentView , self ).unlink (os .path .join (path , _file ))
251- self ._stage (remove = os .path .join (path , _file ), message = message )
301+ if gitignore == False :
302+ self ._stage (remove = os .path .join (path , _file ), message = message )
252303
253304 # Delete the actual directory
254305 result = super (CurrentView , self ).rmdir ("{}/" .format (path ))
@@ -258,9 +309,13 @@ def rmdir(self, path):
258309
259310 @write_operation
260311 @not_in ("ignore" , check = ["path" ])
261- def unlink (self , path ):
312+ def unlink (self , path , gitignore ):
262313 result = super (CurrentView , self ).unlink (path )
263-
314+
315+ if gitignore == True :
316+ log .debug ("[ignore] unlink:%s" , path )
317+ return result
318+
264319 message = 'Deleted {}' .format (path )
265320 self ._stage (remove = path , message = message )
266321
0 commit comments