diff options
author | René Scharfe <l.s.r@web.de> | 2015-05-20 00:44:23 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-20 23:49:10 +0300 |
commit | dbe44faadb87f88e092f3dac387f96070268137a (patch) | |
tree | c110408d6bae73334427aaec8010bdb2e754e69d /builtin/blame.c | |
parent | aaa7e0d7f8f003c0c8ab34f959083f6d191d44ca (diff) |
use file_exists() to check if a file exists in the worktree
Call file_exists() instead of open-coding it. That's shorter, simpler
and the intent becomes clearer.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r-- | builtin/blame.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 06484c2e0e..91d4221f59 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -26,6 +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 @@ static void sanity_check_refcnt(struct scoreboard *sb) } } -/* - * 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; @@ -2655,14 +2646,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); } |