@matheusbsbs / matheus-bagliano / commits / d91d4c2c50
Fork 0

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>

Junio C Hamano committed May 17, 2006 at 16:56 UTC d91d4c2c500b17d50359693a406a2c68b65330fe
1 file changed +6 -4
apply.c
+6 -4
@@ -1711,10 +1711,12 @@ static int check_patch(struct patch *patch)
1711 if (new_name && (patch->is_new | patch->is_rename | patch->is_copy)) {
1712 if (check_index && cache_name_pos(new_name, strlen(new_name)) >= 0)
1713 return error("%s: already exists in index", new_name);
1714 - if (!cached && !lstat(new_name, &st))
1715 - return error("%s: already exists in working directory", new_name);
1716 - if (errno != ENOENT)
1717 - return error("%s: %s", new_name, strerror(errno));
1714 + if (!cached) {
1715 + if (!lstat(new_name, &st))
1716 + return error("%s: already exists in working directory", new_name);
1717 + if (errno != ENOENT)
1718 + return error("%s: %s", new_name, strerror(errno));
1719 + }
1720 if (!patch->new_mode) {
1721 if (patch->is_new)
1722 patch->new_mode = S_IFREG | 0644;