From: Junio C Hamano Date: Tue, 16 Jun 2015 21:33:46 +0000 (-0700) Subject: Merge branch 'dt/clean-pathspec-filter-then-lstat' into maint X-Git-Tag: v2.4.4~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6b2c0ead061b1bb9ce8e4b539da495ea0ef057b5?hp=-c Merge branch 'dt/clean-pathspec-filter-then-lstat' into maint "git clean pathspec..." tried to lstat(2) and complain even for paths outside the given pathspec. * dt/clean-pathspec-filter-then-lstat: clean: only lstat files in pathspec --- 6b2c0ead061b1bb9ce8e4b539da495ea0ef057b5 diff --combined builtin/clean.c index 98c103fa8b,3c1f4b0908..ada0196c9e --- a/builtin/clean.c +++ b/builtin/clean.c @@@ -67,7 -67,7 +67,7 @@@ struct menu_item char hotkey; const char *title; int selected; - int (*fn)(); + int (*fn)(void); }; enum menu_stuff_type { @@@ -100,8 -100,6 +100,8 @@@ static int parse_clean_color_slot(cons static int git_clean_config(const char *var, const char *value, void *cb) { + const char *slot_name; + if (starts_with(var, "column.")) return git_column_config(var, value, "clean", &colopts); @@@ -111,13 -109,15 +111,13 @@@ clean_use_color = git_config_colorbool(var, value); return 0; } - if (starts_with(var, "color.interactive.")) { - int slot = parse_clean_color_slot(var + - strlen("color.interactive.")); + if (skip_prefix(var, "color.interactive.", &slot_name)) { + int slot = parse_clean_color_slot(slot_name); if (slot < 0) return 0; if (!value) return config_error_nonbool(var); - color_parse(value, var, clean_colors[slot]); - return 0; + return color_parse(value, clean_colors[slot]); } if (!strcmp(var, "clean.requireforce")) { @@@ -321,7 -321,7 +321,7 @@@ static void print_highlight_menu_stuff( switch (stuff->type) { default: - die("Bad type of menu_staff when print menu"); + die("Bad type of menu_stuff when print menu"); case MENU_STUFF_TYPE_MENU_ITEM: menu_item = (struct menu_item *)stuff->stuff; for (i = 0; i < stuff->nr; i++, menu_item++) { @@@ -754,8 -754,7 +754,8 @@@ static int ask_each_cmd(void /* Ctrl-D should stop removing files */ if (!eof) { qname = quote_path_relative(item->string, NULL, &buf); - printf(_("remove %s? "), qname); + /* TRANSLATORS: Make sure to keep [y/N] as is */ + printf(_("Remove %s [y/N]? "), qname); if (strbuf_getline(&confirm, stdin, '\n') != EOF) { strbuf_trim(&confirm); } else { @@@ -941,15 -940,15 +941,15 @@@ int cmd_clean(int argc, const char **ar if (!cache_name_is_other(ent->name, ent->len)) continue; - if (lstat(ent->name, &st)) - die_errno("Cannot lstat '%s'", ent->name); - if (pathspec.nr) matches = dir_path_match(ent, &pathspec, 0, NULL); if (pathspec.nr && !matches) continue; + if (lstat(ent->name, &st)) + die_errno("Cannot lstat '%s'", ent->name); + if (S_ISDIR(st.st_mode) && !remove_directories && matches != MATCHED_EXACTLY) continue;