summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2015-05-19 23:44:23 +0200
committerJunio C Hamano <gitster@pobox.com>2015-05-20 13:49:10 -0700
commitdbe44faadb87f88e092f3dac387f96070268137a (patch)
treec110408d6bae73334427aaec8010bdb2e754e69d /sha1_name.c
parentaaa7e0d7f8f003c0c8ab34f959083f6d191d44ca (diff)
downloadgit-dbe44faadb87f88e092f3dac387f96070268137a.tar.gz
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 'sha1_name.c')
-rw-r--r--sha1_name.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 6d10f052b5..6de8c87c8a 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -6,6 +6,7 @@
#include "tree-walk.h"
#include "refs.h"
#include "remote.h"
+#include "dir.h"
static int get_sha1_oneline(const char *, unsigned char *, struct commit_list *);
@@ -1237,14 +1238,13 @@ static void diagnose_invalid_sha1_path(const char *prefix,
const char *object_name,
int object_name_len)
{
- struct stat st;
unsigned char sha1[20];
unsigned mode;
if (!prefix)
prefix = "";
- if (!lstat(filename, &st))
+ if (file_exists(filename))
die("Path '%s' exists on disk, but not in '%.*s'.",
filename, object_name_len, object_name);
if (errno == ENOENT || errno == ENOTDIR) {
@@ -1271,7 +1271,6 @@ static void diagnose_invalid_index_path(int stage,
const char *prefix,
const char *filename)
{
- struct stat st;
const struct cache_entry *ce;
int pos;
unsigned namelen = strlen(filename);
@@ -1314,7 +1313,7 @@ static void diagnose_invalid_index_path(int stage,
ce_stage(ce), filename);
}
- if (!lstat(filename, &st))
+ if (file_exists(filename))
die("Path '%s' exists on disk, but not in the index.", filename);
if (errno == ENOENT || errno == ENOTDIR)
die("Path '%s' does not exist (neither on disk nor in the index).",