From: Junio C Hamano <gitster@pobox.com>
To: "Chris Torek via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Chris Torek <chris.torek@gmail.com>
Subject: Re: [PATCH] git-mv: improve error message for conflicted file
Date: Fri, 17 Jul 2020 17:07:17 -0700 [thread overview]
Message-ID: <xmqqeep9d6tm.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <pull.678.git.1595028293855.gitgitgadget@gmail.com> (Chris Torek via GitGitGadget's message of "Fri, 17 Jul 2020 23:24:53 +0000")
"Chris Torek via GitGitGadget" <gitgitgadget@gmail.com> writes:
> - } else if (cache_name_pos(src, length) < 0)
> - bad = _("not under version control");
> - else if (lstat(dst, &st) == 0 &&
> + } else if (cache_name_pos(src, length) < 0) {
> + /*
> + * This occurs for both untracked files *and*
> + * files that are in merge-conflict state, so
> + * let's distinguish between those two.
> + */
> + struct cache_entry *ce = cache_file_exists(src, length, ignore_case);
> + if (ce == NULL)
> + bad = _("not under version control");
> + else
> + bad = _("must resolve merge conflict first");
The original did not care about the cache entry itself, and that is
why cache_name_pos() was used. Now you care what cache entry is at
that position, running both calls is quite wasteful.
Would it work better to declare "struct cache_entry *ce" in the
scope that surrounds this if/elseif cascade and then rewrite this
part more like so:
} else if (!(ce = cache_file_exists(...)) {
bad = _("not tracked");
} else if (ce_stage(ce)) {
bad = _("conflicted");
} else if (lstat(...)) { ...
next prev parent reply other threads:[~2020-07-18 0:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 23:24 [PATCH] git-mv: improve error message for conflicted file Chris Torek via GitGitGadget
2020-07-17 23:47 ` Eric Sunshine
2020-07-18 1:35 ` Chris Torek
2020-07-18 6:55 ` Eric Sunshine
2020-07-18 0:07 ` Junio C Hamano [this message]
2020-07-18 2:00 ` Elijah Newren
2020-07-18 17:46 ` Junio C Hamano
2020-07-19 1:48 ` Elijah Newren
2020-07-19 6:16 ` Junio C Hamano
2020-07-20 6:17 ` [PATCH v2] " Chris Torek via GitGitGadget
2020-07-20 18:28 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqeep9d6tm.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
/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.
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 NNTP newsgroup(s).