git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Matheus Tavares <matheus.bernardino@usp.br>
Date
Aug 18, 2020, 17:46 UTC
Message-ID
<a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.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
Next: Jeff King
Message 1 of 2 in “checkout_entry(): remove unreachable error() call”
  1. checkout_entry(): remove unreachable error() callMatheus Tavares, Aug 18, 2020
  2. Jeff KingAug 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.