File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -380,9 +380,17 @@ def raise_exc(e):
380380
381381 # resolve globs if possible
382382 if '?' in path or '*' in path or '[' in path :
383- for f in self ._iter_expand_paths (glob .glob (abs_path )):
384- yield f .replace (rs , '' )
385- continue
383+ resolved_paths = glob .glob (abs_path )
384+ # not abs_path in resolved_paths:
385+ # a glob() resolving to the same path we are feeding it with
386+ # is a glob() that failed to resolve. If we continued calling
387+ # ourselves we'd endlessly recurse. If the condition below
388+ # evaluates to true then we are likely dealing with a file
389+ # whose name contains wildcard characters.
390+ if abs_path not in resolved_paths :
391+ for f in self ._iter_expand_paths (glob .glob (abs_path )):
392+ yield f .replace (rs , '' )
393+ continue
386394 # END glob handling
387395 try :
388396 for root , dirs , files in os .walk (abs_path , onerror = raise_exc ):
Original file line number Diff line number Diff line change @@ -796,3 +796,14 @@ def test_add_utf8P_path(self, rw_dir):
796796 r = Repo .init (rw_dir )
797797 r .index .add ([fp ])
798798 r .index .commit ('Added orig and prestable' )
799+
800+ @with_rw_directory
801+ def test_add_a_file_with_wildcard_chars (self , rw_dir ):
802+ # see issue #407
803+ fp = os .path .join (rw_dir , '[.exe' )
804+ with open (fp , "wb" ) as f :
805+ f .write (b'something' )
806+
807+ r = Repo .init (rw_dir )
808+ r .index .add ([fp ])
809+ r .index .commit ('Added [.exe' )
You can’t perform that action at this time.
0 commit comments