diff mbox series

checkout_entry(): remove unreachable error() call

Message ID a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br (mailing list archive)
State New, archived
Headers show
Series checkout_entry(): remove unreachable error() call | expand

Commit Message

Matheus Tavares Aug. 18, 2020, 5:46 p.m. UTC
This if statement never evaluates to true since we already check
state->force a few lines above, and immediately return when it is
false.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
 entry.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Jeff King Aug. 18, 2020, 6:34 p.m. UTC | #1
On Tue, Aug 18, 2020 at 02:46:55PM -0300, Matheus Tavares wrote:

> This if statement never evaluates to true since we already check
> state->force a few lines above, and immediately return when it is
> false.

Yep. Looks like this was unreachable even when it was added back in
d48a72f337 (Fix replacing of a directory with a file/symlink in
git-checkout-cache, 2005-07-14).

-Peff
diff mbox series

Patch

diff --git a/entry.c b/entry.c
index 449bd32dee..a0532f1f00 100644
--- a/entry.c
+++ b/entry.c
@@ -492,26 +492,24 @@  int checkout_entry(struct cache_entry *ce, const struct checkout *state,
 		if (!state->force) {
 			if (!state->quiet)
 				fprintf(stderr,
 					"%s already exists, no checkout\n",
 					path.buf);
 			return -1;
 		}

 		if (state->clone)
 			mark_colliding_entries(state, ce, &st);

 		/*
 		 * We unlink the old file, to get the new one with the
 		 * right permissions (including umask, which is nasty
 		 * to emulate by hand - much easier to let the system
 		 * just do the right thing)
 		 */
 		if (S_ISDIR(st.st_mode)) {
 			/* If it is a gitlink, leave it alone! */
 			if (S_ISGITLINK(ce->ce_mode))
 				return 0;
-			if (!state->force)
-				return error("%s is a directory", path.buf);
 			remove_subtree(&path);
 		} else if (unlink(path.buf))
 			return error_errno("unable to unlink old '%s'", path.buf);