stgit/git.py: Handle a reset that changes files to directories

If reset() takes us from a tree where some path is a file to one
where it is a directory, then checkout() will replace the file
with the directory, and we don't want to try to os.remove() the
path (which would throw an exception because we're trying to
remove a directory.) This fixes bug https://gna.org/bugs/?15682.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
diff --git a/stgit/git.py b/stgit/git.py
index 0316342..b94b445 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -745,7 +745,7 @@
 
         checkout(files, tree_id, True)
         # checkout doesn't remove files
-        map(os.remove, rm_files)
+        map(os.remove, [f for f in rm_files if not os.path.isdir(f)])
 
     # if the reset refers to the whole tree, switch the HEAD as well
     if not files: