* [PATCH] checkout_entry(): remove unreachable error() call
@ 2020-08-18 17:46 Matheus Tavares
2020-08-18 18:34 ` Jeff King
0 siblings, 1 reply; 2+ messages in thread
From: Matheus Tavares @ 2020-08-18 17:46 UTC (permalink / raw)
To: git
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] checkout_entry(): remove unreachable error() call
2020-08-18 17:46 [PATCH] checkout_entry(): remove unreachable error() call Matheus Tavares
@ 2020-08-18 18:34 ` Jeff King
0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2020-08-18 18:34 UTC (permalink / raw)
To: Matheus Tavares; +Cc: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-18 18:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 17:46 [PATCH] checkout_entry(): remove unreachable error() call Matheus Tavares
2020-08-18 18:34 ` Jeff King
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).