{"thread":{"id":"54064","subject":"[PATCH] checkout_entry(): remove unreachable error() call","startedAt":"2020-08-18T17:47:06Z","lastAt":"2020-08-18T18:34:20Z","messageCount":2,"participants":["Matheus Tavares","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"403959","messageId":"a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br","threadId":"54064","inReplyTo":null,"subject":"[PATCH] checkout_entry(): remove unreachable error() call","fromName":"Matheus Tavares","fromEmail":"matheus.bernardino@usp.br","sentAt":"2020-08-18T17:46:55Z","receivedAt":"2020-08-18T17:47:06Z","isPatch":true,"sender":{"key":"matheus.tavb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701583?v=4"},"body":"This if statement never evaluates to true since we already check\nstate->force a few lines above, and immediately return when it is\nfalse.\n\nSigned-off-by: Matheus Tavares <matheus.bernardino@usp.br>\n---\n entry.c | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/entry.c b/entry.c\nindex 449bd32dee..a0532f1f00 100644\n--- a/entry.c\n+++ b/entry.c\n@@ -492,26 +492,24 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state,\n \t\tif (!state->force) {\n \t\t\tif (!state->quiet)\n \t\t\t\tfprintf(stderr,\n \t\t\t\t\t\"%s already exists, no checkout\\n\",\n \t\t\t\t\tpath.buf);\n \t\t\treturn -1;\n \t\t}\n\n \t\tif (state->clone)\n \t\t\tmark_colliding_entries(state, ce, &st);\n\n \t\t/*\n \t\t * We unlink the old file, to get the new one with the\n \t\t * right permissions (including umask, which is nasty\n \t\t * to emulate by hand - much easier to let the system\n \t\t * just do the right thing)\n \t\t */\n \t\tif (S_ISDIR(st.st_mode)) {\n \t\t\t/* If it is a gitlink, leave it alone! */\n \t\t\tif (S_ISGITLINK(ce->ce_mode))\n \t\t\t\treturn 0;\n-\t\t\tif (!state->force)\n-\t\t\t\treturn error(\"%s is a directory\", path.buf);\n \t\t\tremove_subtree(&path);\n \t\t} else if (unlink(path.buf))\n \t\t\treturn error_errno(\"unable to unlink old '%s'\", path.buf);\n-- \n2.28.0\n\n"},{"id":"403960","messageId":"20200818183416.GA2479537@coredump.intra.peff.net","threadId":"54064","inReplyTo":"a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br","subject":"Re: [PATCH] checkout_entry(): remove unreachable error() call","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2020-08-18T18:34:16Z","receivedAt":"2020-08-18T18:34:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 18, 2020 at 02:46:55PM -0300, Matheus Tavares wrote:\n\n> This if statement never evaluates to true since we already check\n> state->force a few lines above, and immediately return when it is\n> false.\n\nYep. Looks like this was unreachable even when it was added back in\nd48a72f337 (Fix replacing of a directory with a file/symlink in\ngit-checkout-cache, 2005-07-14).\n\n-Peff\n"}]}