Merge branch 'rs/janitorial' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Jun 2015 21:33:47 +0000 (14:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Jun 2015 21:33:47 +0000 (14:33 -0700)
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

1  2 
builtin/blame.c
builtin/clean.c
dir.c
diff --combined builtin/blame.c
index 8d70623cb8714a87650f2425daf4ee7aaf6307a8,91d4221f5949a94077cad5e528e547d988fd6135..ff978253f1fb3d72ff3add9d2718aa3611697b4a
@@@ -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 [<options>] [<rev-opts>] [<rev>] [--] 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 ada0196c9e7be080847641973ddd5201534f6094,a9eb7723e95931fc79da4d0652a5ca7fd832f8da..6dcb72e64484fa5082bd2b77b370107984373340
@@@ -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;
        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 4183acc082671f135fe64cbcaa66ed3b17bc6364,480ad05c74aa6a5dea52907ff23583e145767999..56106c9ae8a954104d2f79aa2a352e7790eb21af
--- 1/dir.c
--- 2/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;
                      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)