Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit978eb5b

Browse files
committed
Merge pull request#410 from ppietrasa/master
fix(index): avoid recursing endlessly in add()
2 parents9debf6b +6f67136 commit978eb5b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎git/index/base.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,17 @@ def raise_exc(e):
380380

381381
# resolve globs if possible
382382
if'?'inpathor'*'inpathor'['inpath:
383-
forfinself._iter_expand_paths(glob.glob(abs_path)):
384-
yieldf.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+
ifabs_pathnotinresolved_paths:
391+
forfinself._iter_expand_paths(glob.glob(abs_path)):
392+
yieldf.replace(rs,'')
393+
continue
386394
# END glob handling
387395
try:
388396
forroot,dirs,filesinos.walk(abs_path,onerror=raise_exc):

‎git/test/test_index.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
deftest_add_a_file_with_wildcard_chars(self,rw_dir):
802+
# see issue #407
803+
fp=os.path.join(rw_dir,'[.exe')
804+
withopen(fp,"wb")asf:
805+
f.write(b'something')
806+
807+
r=Repo.init(rw_dir)
808+
r.index.add([fp])
809+
r.index.commit('Added [.exe')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp