diff --git a/.gitignore b/.gitignore index ff1992dcf..1fa8458bc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ nbproject /*egg-info /.tox /.vscode/ +.idea/ +.cache/ diff --git a/.gitmodules b/.gitmodules index 4a3f37c25..251eeeec4 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 04a3934d6..378a9d792 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -569,6 +569,9 @@ def _preprocess_add_items(self, items): """ Split the items into two lists of path strings and BaseEntries. """ paths = [] entries = [] + # if it is a string put in list + if isinstance(items, str): + items = [items] for item in items: if isinstance(item, string_types): @@ -580,7 +583,7 @@ def _preprocess_add_items(self, items): else: raise TypeError("Invalid Type: %r" % item) # END for each item - return (paths, entries) + return paths, entries def _store_path(self, filepath, fprogress): """Store file at filepath in the database and return the base index entry @@ -801,6 +804,10 @@ def _items_to_rela_paths(self, items): """Returns a list of repo-relative paths from the given items which may be absolute or relative paths, entries or blobs""" paths = [] + # if string put in list + if isinstance(items, str): + items = [items] + for item in items: if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): paths.append(self._to_relative_path(item.path)) diff --git a/git/test/test_index.py b/git/test/test_index.py index a30d314b5..393158f7f 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -772,7 +772,16 @@ def test_compare_write_tree(self, rw_repo): orig_tree = commit.tree self.assertEqual(index.write_tree(), orig_tree) # END for each commit - + + @with_rw_repo('HEAD', bare=False) + def test_index_single_addremove(self, rw_repo): + 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): B = self.rorepo.tree("6d9b1f4f9fa8c9f030e3207e7deacc5d5f8bba4e") H = self.rorepo.tree("25dca42bac17d511b7e2ebdd9d1d679e7626db5f")