git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Matheus Tavares <matheus.bernardino@usp.br>
To: git@vger.kernel.org
Subject: [PATCH] checkout_entry(): remove unreachable error() call
Date: Tue, 18 Aug 2020 14:46:55 -0300	[thread overview]
Message-ID: <a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br> (raw)

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


             reply	other threads:[~2020-08-18 17:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 17:46 Matheus Tavares [this message]
2020-08-18 18:34 ` [PATCH] checkout_entry(): remove unreachable error() call Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a170ee42e6d642d380e6b761e8889b05e452414a.1597772501.git.matheus.bernardino@usp.br \
    --to=matheus.bernardino@usp.br \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).