notes: don't access hash of NULL object_id pointer
[gitweb.git] / builtin / rm.c
index 452170a3ab45d24e03ab11965448572a411c349f..7c323d01235bf8bbb341004c843761dad99590d2 100644 (file)
@@ -271,8 +271,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                die(_("index file corrupt"));
 
        parse_pathspec(&pathspec, 0,
-                      PATHSPEC_PREFER_CWD |
-                      PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
+                      PATHSPEC_PREFER_CWD,
                       prefix, argv);
        refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
 
@@ -360,15 +359,14 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
         */
        if (!index_only) {
                int removed = 0, gitmodules_modified = 0;
+               struct strbuf buf = STRBUF_INIT;
                for (i = 0; i < list.nr; i++) {
                        const char *path = list.entry[i].name;
                        if (list.entry[i].is_submodule) {
-                               struct strbuf buf = STRBUF_INIT;
-
+                               strbuf_reset(&buf);
                                strbuf_addstr(&buf, path);
                                if (remove_dir_recursively(&buf, 0))
                                        die(_("could not remove '%s'"), path);
-                               strbuf_release(&buf);
 
                                removed = 1;
                                if (!remove_path_from_gitmodules(path))
@@ -382,6 +380,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                        if (!removed)
                                die_errno("git rm: '%s'", path);
                }
+               strbuf_release(&buf);
                if (gitmodules_modified)
                        stage_updated_gitmodules();
        }