summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2006-05-17 16:56:20 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-05-17 16:56:20 -0700
commitb312cc82b4995414ece4c52119be38040d9626d7 (patch)
treea0d9e4b7ce8a726e0eb94a28fec6d8eb0b9b6967 /apply.c
parentMerge branch 'jc/read-tree-safety' into next (diff)
parentapply --cached: do not check newly added file in the working tree (diff)
downloadtgif-b312cc82b4995414ece4c52119be38040d9626d7.tar.xz
Merge branch 'jc/apply' into next
* jc/apply: apply --cached: do not check newly added file in the working tree
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 5bd5073365..5341e30922 100644
--- a/apply.c
+++ b/apply.c
@@ -1712,10 +1712,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;