summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-05-17 16:56:13 -0700
committerJunio C Hamano <junkio@cox.net>2006-05-17 16:56:13 -0700
commitd91d4c2c500b17d50359693a406a2c68b65330fe (patch)
treeaecd6264519055a37978e546b1bddc39e9130190 /apply.c
parentb7627278e200d8a80df6ee437b1a01d88f2b4883 (diff)
downloadgit-d91d4c2c500b17d50359693a406a2c68b65330fe.tar.gz
apply --cached: do not check newly added file in the working tree
The --cached mode does not deal with the working tree, so we should not check it with lstat. An earlier code omitted the call to lstat but forgot to omit the check for the errno. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/apply.c b/apply.c
index b3b9b40596..0ed9d132e8 100644
--- a/apply.c
+++ b/apply.c
@@ -1711,10 +1711,12 @@ static int check_patch(struct patch *patch)
if (new_name && (patch->is_new | patch->is_rename | patch->is_copy)) {
if (check_index && cache_name_pos(new_name, strlen(new_name)) >= 0)
return error("%s: already exists in index", new_name);
- if (!cached && !lstat(new_name, &st))
- return error("%s: already exists in working directory", new_name);
- if (errno != ENOENT)
- return error("%s: %s", new_name, strerror(errno));
+ if (!cached) {
+ if (!lstat(new_name, &st))
+ return error("%s: already exists in working directory", new_name);
+ if (errno != ENOENT)
+ return error("%s: %s", new_name, strerror(errno));
+ }
if (!patch->new_mode) {
if (patch->is_new)
patch->new_mode = S_IFREG | 0644;