On Tue, Jul 18, 2017 at 10:49 PM, Prathamesh Chavan <pc44800@xxxxxxxxx> wrote: > +static void deinit_submodule(const struct cache_entry *list_item, > + void *cb_data) > +{ > + struct deinit_cb *info = cb_data; > + const struct submodule *sub; > + char *displaypath = NULL; > + struct child_process cp_config = CHILD_PROCESS_INIT; > + struct strbuf sb_config = STRBUF_INIT; > + char *sm_path = xstrdup(list_item->name); If I understood the previous rounds correctly, list_item->name is duplicated because it is changed below... > + char *sub_git_dir = xstrfmt("%s/.git", sm_path); > + struct stat st; > + > + sub = submodule_from_path(null_sha1, sm_path); > + > + if (!sub || !sub->name) > + goto cleanup; > + > + displaypath = get_submodule_displaypath(sm_path, info->prefix); > + > + /* remove the submodule work tree (unless the user already did it) */ > + if (is_directory(sm_path)) { > + /* protect submodules containing a .git directory */ > + if (is_git_directory(sub_git_dir)) > + die(_("Submodule work tree '%s' contains a .git " > + "directory use 'rm -rf' if you really want " > + "to remove it including all of its history"), > + displaypath); > + > + if (!info->force) { > + struct child_process cp_rm = CHILD_PROCESS_INIT; > + cp_rm.git_cmd = 1; > + argv_array_pushl(&cp_rm.args, "rm", "-qn", sm_path, > + NULL); > + > + /* list_item->name is changed by cmd_rm() below */ ... but it looks like cmd_rm() is not used anymore below, so this comment is outdated and I wonder if duplicated list_item->name is still needed. > + if (run_command(&cp_rm)) > + die(_("Submodule work tree '%s' contains local " > + "modifications; use '-f' to discard them"), > + displaypath); > + } > + > + if (!lstat(sm_path, &st)) { > + struct strbuf sb_rm = STRBUF_INIT; > + strbuf_addstr(&sb_rm, sm_path); > + > + if (!remove_dir_recursively(&sb_rm, 0)) { > + if (!info->quiet) > + printf(_("Cleared directory '%s'\n"), > + displaypath); > + } else { > + if (!info->quiet) > + printf(_("Could not remove submodule work tree '%s'\n"), > + displaypath); > + } Nit: maybe this could be: struct strbuf sb_rm = STRBUF_INIT; const char *format; strbuf_addstr(&sb_rm, sm_path); if (!remove_dir_recursively(&sb_rm, 0)) format = _("Cleared directory '%s'\n"); else format = _("Could not remove submodule work tree '%s'\n"); if (!info->quiet) printf(format, displaypath); > + strbuf_release(&sb_rm); > + } > + }