From 86ceb965b22d85db681118ef0d5ce76328c0d0f0 Mon Sep 17 00:00:00 2001 From: sdementen Date: Tue, 18 Sep 2018 05:10:53 +0200 Subject: [PATCH 1/5] do not glob a path if it exists 'unglobbed' fix #680 --- git/index/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/git/index/base.py b/git/index/base.py index 04a3934d6..d9e9e6d85 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -377,8 +377,13 @@ def raise_exc(e): continue # end check symlink - # resolve globs if possible - if '?' in path or '*' in path or '[' in path: + # if abs_path exists, yield it, otherwise resolve globs if possible + if os.path.exists(abs_path): + # even if the path contains special characters like ?*[ (glob) + # if it exists, we take it as such and do not try to resolve globs + yield abs_path + # otherwise resolve globs if possible + elif '?' in path or '*' in path or '[' in path: resolved_paths = glob.glob(abs_path) # not abs_path in resolved_paths: # a glob() resolving to the same path we are feeding it with From f1ec752c3a63bd8eca6145300b94f37987d78975 Mon Sep 17 00:00:00 2001 From: sdementen Date: Tue, 18 Sep 2018 05:21:26 +0200 Subject: [PATCH 2/5] glob also path even when it exists as tests fails, bring back glob even if path exists --- git/index/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git/index/base.py b/git/index/base.py index d9e9e6d85..0787d01eb 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -377,13 +377,13 @@ def raise_exc(e): continue # end check symlink - # if abs_path exists, yield it, otherwise resolve globs if possible + # if abs_path exists, yield it if os.path.exists(abs_path): # even if the path contains special characters like ?*[ (glob) - # if it exists, we take it as such and do not try to resolve globs + # if it exists, we take it yield abs_path - # otherwise resolve globs if possible - elif '?' in path or '*' in path or '[' in path: + # resolve globs if possible + if '?' in path or '*' in path or '[' in path: resolved_paths = glob.glob(abs_path) # not abs_path in resolved_paths: # a glob() resolving to the same path we are feeding it with From bc8b187b2ee73c6d3eae12ac986239c29bb5004f Mon Sep 17 00:00:00 2001 From: sdementen Date: Sun, 13 Jan 2019 12:05:16 +0100 Subject: [PATCH 3/5] yield only if file --- git/index/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git/index/base.py b/git/index/base.py index 0787d01eb..c266a7e26 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -377,8 +377,8 @@ def raise_exc(e): continue # end check symlink - # if abs_path exists, yield it - if os.path.exists(abs_path): + # if abs_path exists and is a file, yield it + if os.path.exists(abs_path) and os.path.isfile(abs_path): # even if the path contains special characters like ?*[ (glob) # if it exists, we take it yield abs_path From f31600aff5b77645697cb99064fbc0f547085155 Mon Sep 17 00:00:00 2001 From: sdementen Date: Sun, 13 Jan 2019 12:10:34 +0100 Subject: [PATCH 4/5] cancel change to see if tests pass --- git/index/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git/index/base.py b/git/index/base.py index c266a7e26..2afabff13 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -378,7 +378,7 @@ def raise_exc(e): # end check symlink # if abs_path exists and is a file, yield it - if os.path.exists(abs_path) and os.path.isfile(abs_path): + if os.path.exists(abs_path) and os.path.isfile(abs_path) and False: # even if the path contains special characters like ?*[ (glob) # if it exists, we take it yield abs_path From ea766c5e01694eee818552fe52ab42481e85ae4f Mon Sep 17 00:00:00 2001 From: sdementen Date: Mon, 14 Jan 2019 14:18:31 +0100 Subject: [PATCH 5/5] use abs_path.replace(rs, '') --- git/index/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git/index/base.py b/git/index/base.py index 2afabff13..cec2e08cb 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -378,10 +378,11 @@ def raise_exc(e): # end check symlink # if abs_path exists and is a file, yield it - if os.path.exists(abs_path) and os.path.isfile(abs_path) and False: + if os.path.exists(abs_path) and os.path.isfile(abs_path): # even if the path contains special characters like ?*[ (glob) # if it exists, we take it - yield abs_path + yield abs_path.replace(rs, '') + # resolve globs if possible if '?' in path or '*' in path or '[' in path: resolved_paths = glob.glob(abs_path)