From: Duy Nguyen <pclouds@gmail.com>
To: Sebastian Staudt <koraktor@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] Setup working tree in describe
Date: Sat, 26 Jan 2019 18:01:29 +0700 [thread overview]
Message-ID: <CACsJy8Df6XM55ExRfCjpUQsv2Vm0cOwrSAyNf6net__uztMOGQ@mail.gmail.com> (raw)
In-Reply-To: <CA+xP2Sax+thitfKv4hTtKTYPhfVXJxD_qoJxgkCyZFTzskP-Tw@mail.gmail.com>
On Sat, Jan 26, 2019 at 5:44 PM Sebastian Staudt <koraktor@gmail.com> wrote:
>
> This ensures the given working tree is used for --dirty and --broken.
>
> Signed-off-by: Sebastian Staudt <koraktor@gmail.com>
> ---
> builtin/describe.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/builtin/describe.c b/builtin/describe.c
> index cc118448ee..ba1a0b199b 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -601,6 +601,8 @@ int cmd_describe(int argc, const char **argv,
> const char *prefix)
> if (!hashmap_get_size(&names) && !always)
> die(_("No names found, cannot describe anything."));
>
> + setup_work_tree();
This forces worktree's presence in all cases and will die() if
worktree is not available. You need to check if broken or dirty is set
and only call this function in that case.
Though in my opinion it's better to call before we need it in the "if
(broke)" and "else if (dirty)" code blocks. That way you don't even
need to check if it's "dirty" or "broken". Does "broken" really need
this though? If it runs "git diff-index" separately, that command
should handle this setup_work_tree() already, or we may need to fix it
there, not here.
> +
> if (argc == 0) {
> if (broken) {
> struct child_process cp = CHILD_PROCESS_INIT;
> --
> 2.20.1
--
Duy
next prev parent reply other threads:[~2019-01-26 11:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-26 10:40 [PATCH 2/2] Setup working tree in describe Sebastian Staudt
2019-01-26 11:01 ` Duy Nguyen [this message]
2019-01-26 14:07 ` Sebastian Staudt
2019-01-26 14:28 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACsJy8Df6XM55ExRfCjpUQsv2Vm0cOwrSAyNf6net__uztMOGQ@mail.gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=koraktor@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).