cache: convert struct cache_entry to use struct object_id
[gitweb.git] / builtin / rm.c
index 8abb0207fa8e4da05ea447ae4e58c8e54c97c35b..109969d5146410d5651ad88ef633c1e796ad4a91 100644 (file)
@@ -199,7 +199,7 @@ static int check_local_mod(unsigned char *head, int index_only)
                if (no_head
                     || get_tree_entry(head, name, sha1, &mode)
                     || ce->ce_mode != create_ce_mode(mode)
-                    || hashcmp(ce->sha1, sha1))
+                    || hashcmp(ce->oid.hash, sha1))
                        staged_changes = 1;
 
                /*
@@ -387,6 +387,7 @@ 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) {
@@ -398,7 +399,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                                                continue;
                                        }
                                } else {
-                                       struct strbuf buf = STRBUF_INIT;
+                                       strbuf_reset(&buf);
                                        strbuf_addstr(&buf, path);
                                        if (!remove_dir_recursively(&buf, 0)) {
                                                removed = 1;
@@ -410,7 +411,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
                                                /* Submodule was removed by user */
                                                if (!remove_path_from_gitmodules(path))
                                                        gitmodules_modified = 1;
-                                       strbuf_release(&buf);
                                        /* Fallthrough and let remove_path() fail. */
                                }
                        }
@@ -421,6 +421,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();
        }