# [PATCH] checkout_entry(): remove unreachable error() call

2 messages from 2020-08-18 to 2020-08-18. Participants: Matheus Tavares, Jeff King.
Thread: https://gitlist.dev/t/54064

## Matheus Tavares, 2020-08-18 17:46

Subject: [PATCH] checkout_entry(): remove unreachable error() call
Message-ID: <a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br>
URL: https://gitlist.dev/e/a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino%40usp.br

```
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(-)

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);
-- 
2.28.0


```

## Jeff King, 2020-08-18 18:34

Subject: Re: [PATCH] checkout_entry(): remove unreachable error() call
Message-ID: <20200818183416.GA2479537@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20200818183416.GA2479537%40coredump.intra.peff.net
In-Reply-To: <a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br>

```
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

```
