From: Junio C Hamano Date: Tue, 16 Jun 2015 21:33:47 +0000 (-0700) Subject: Merge branch 'rs/janitorial' into maint X-Git-Tag: v2.4.4~6 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/dfb67594e964e63f20546361597c06432c73779d?ds=inline;hp=-c Merge branch 'rs/janitorial' into maint Code clean-up. * rs/janitorial: dir: remove unused variable sb clean: remove unused variable buf use file_exists() to check if a file exists in the worktree --- dfb67594e964e63f20546361597c06432c73779d diff --combined builtin/blame.c index 8d70623cb8,91d4221f59..ff978253f1 --- a/builtin/blame.c +++ b/builtin/blame.c @@@ -26,6 -26,7 +26,7 @@@ #include "userdiff.h" #include "line-range.h" #include "line-log.h" + #include "dir.h" static char blame_usage[] = N_("git blame [] [] [] [--] file"); @@@ -2151,16 -2152,6 +2152,6 @@@ static void sanity_check_refcnt(struct } } - /* - * Used for the command line parsing; check if the path exists - * in the working tree. - */ - static int has_string_in_work_tree(const char *path) - { - struct stat st; - return !lstat(path, &st); - } - static unsigned parse_score(const char *arg) { char *end; @@@ -2348,7 -2339,6 +2339,7 @@@ static struct commit *fake_working_tree if (strbuf_read(&buf, 0, 0) < 0) die_errno("failed to read from stdin"); } + convert_to_git(path, buf.buf, buf.len, &buf, 0); origin->file.ptr = buf.buf; origin->file.size = buf.len; pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1); @@@ -2656,14 -2646,14 +2647,14 @@@ parse_done if (argc < 2) usage_with_options(blame_opt_usage, options); path = add_prefix(prefix, argv[argc - 1]); - if (argc == 3 && !has_string_in_work_tree(path)) { /* (2b) */ + if (argc == 3 && !file_exists(path)) { /* (2b) */ path = add_prefix(prefix, argv[1]); argv[1] = argv[2]; } argv[argc - 1] = "--"; setup_work_tree(); - if (!has_string_in_work_tree(path)) + if (!file_exists(path)) die_errno("cannot stat path '%s'", path); } diff --combined builtin/clean.c index ada0196c9e,a9eb7723e9..6dcb72e644 --- a/builtin/clean.c +++ b/builtin/clean.c @@@ -314,7 -314,6 +314,6 @@@ static void print_highlight_menu_stuff( { struct string_list menu_list = STRING_LIST_INIT_DUP; struct strbuf menu = STRBUF_INIT; - struct strbuf buf = STRBUF_INIT; struct menu_item *menu_item; struct string_list_item *string_list_item; int i; @@@ -363,7 -362,6 +362,6 @@@ pretty_print_menus(&menu_list); strbuf_release(&menu); - strbuf_release(&buf); string_list_clear(&menu_list, 0); } @@@ -941,15 -939,15 +939,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; diff --combined dir.c index 4183acc082,480ad05c74..56106c9ae8 --- a/dir.c +++ b/dir.c @@@ -385,7 -385,6 +385,6 @@@ int report_path_error(const char *ps_ma /* * Make sure all pathspec matched; otherwise it is an error. */ - struct strbuf sb = STRBUF_INIT; int num, errors = 0; for (num = 0; num < pathspec->nr; num++) { int other, found_dup; @@@ -417,7 -416,6 +416,6 @@@ pathspec->items[num].original); errors++; } - strbuf_release(&sb); return errors; } @@@ -1671,19 -1669,18 +1669,19 @@@ int remove_dir_recursively(struct strbu void setup_standard_excludes(struct dir_struct *dir) { const char *path; - char *xdg_path; dir->exclude_per_dir = ".gitignore"; + + /* core.excludefile defaulting to $XDG_HOME/git/ignore */ + if (!excludes_file) + excludes_file = xdg_config_home("ignore"); + if (excludes_file && !access_or_warn(excludes_file, R_OK, 0)) + add_excludes_from_file(dir, excludes_file); + + /* per repository user preference */ path = git_path("info/exclude"); - if (!excludes_file) { - home_config_paths(NULL, &xdg_path, "ignore"); - excludes_file = xdg_path; - } if (!access_or_warn(path, R_OK, 0)) add_excludes_from_file(dir, path); - if (excludes_file && !access_or_warn(excludes_file, R_OK, 0)) - add_excludes_from_file(dir, excludes_file); } int remove_path(const char *name)