summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel <marcel.beining@gmail.com>2019-10-13 10:25:02 +0200
committerSebastian Thiel <sebastian.thiel@icloud.com>2019-10-15 13:27:48 +0200
commitd759e17181c21379d7274db76d4168cdbb403ccf (patch)
treea36a651dd63799ab94f4869564e75d3ac0f70810
parent1fa1ce2b7dcf7f1643bb494b71b9857cbfb60090 (diff)
downloadgitpython-d759e17181c21379d7274db76d4168cdbb403ccf.tar.gz
As string is iterable, changed to isinstance check
test now works
-rw-r--r--.gitignore2
-rw-r--r--.gitmodules6
-rw-r--r--git/index/base.py12
-rw-r--r--git/test/test_index.py8
4 files changed, 14 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index ff1992dc..1fa8458b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,5 @@ nbproject
/*egg-info
/.tox
/.vscode/
+.idea/
+.cache/
diff --git a/.gitmodules b/.gitmodules
index 4a3f37c2..251eeeec 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "gitdb"]
- url = https://github.com/gitpython-developers/gitdb.git
- path = git/ext/gitdb
+[submodule "gitdb"]
+ url = https://github.com/gitpython-developers/gitdb.git
+ path = git/ext/gitdb
diff --git a/git/index/base.py b/git/index/base.py
index 9ca663f4..378a9d79 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -569,10 +569,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
""" Split the items into two lists of path strings and BaseEntries. """
paths = []
entries = []
- # check if is iterable, else put in list
- try:
- test_item = iter(items)
- except TypeError:
+ # if it is a string put in list
+ if isinstance(items, str):
items = [items]
for item in items:
@@ -806,10 +804,8 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
"""Returns a list of repo-relative paths from the given items which
may be absolute or relative paths, entries or blobs"""
paths = []
- # check if is iterable, else put in list
- try:
- test_item = iter(items)
- except TypeError:
+ # if string put in list
+ if isinstance(items, str):
items = [items]
for item in items:
diff --git a/git/test/test_index.py b/git/test/test_index.py
index ee48bae6..065de887 100644
--- a/git/test/test_index.py
+++ b/git/test/test_index.py
@@ -775,9 +775,11 @@ class TestIndex(TestBase):
@with_rw_repo('HEAD', bare=False)
def test_index_single_addremove(self, rw_repo):
- path = osp.join('git', 'test', 'test_index.py')
- self._assert_entries(rw_repo.index.add(path))
- deleted_files = rw_repo.index.remove(path)
+ fp = osp.join(rw_repo.working_dir, 'testfile.txt')
+ with open(fp, 'w') as fs:
+ fs.write(u'content of testfile')
+ self._assert_entries(rw_repo.index.add(fp))
+ deleted_files = rw_repo.index.remove(fp)
assert deleted_files
def test_index_new(self):