All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Git Mailing List" <git@vger.kernel.org>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Alan Blotz" <work@blotz.org>,
	"Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Jeff King" <peff@peff.net>
Subject: Re: [PATCH v5 2/3] difftool: create a tmpdir path without repeated slashes
Date: Thu, 30 Sep 2021 10:05:12 -0700	[thread overview]
Message-ID: <CAJDDKr6MqDhGXcPzCW8f96C3XEAp8w+imc9Jzrw+sUEasqXeng@mail.gmail.com> (raw)
In-Reply-To: <871r5e45jw.fsf@evledraar.gmail.com>

On Fri, Sep 24, 2021 at 3:43 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
>
> On Wed, Sep 22 2021, David Aguilar wrote:
>
> > @@ -580,7 +574,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
> >               flags = 0;
> >       } else
> >               setenv("GIT_DIFFTOOL_DIRDIFF", "true", 1);
> > -     rc = run_command_v_opt(helper_argv, flags);
> > +     ret = run_command_v_opt(helper_argv, flags);
> >
> >       /* TODO: audit for interaction with sparse-index. */
> >       ensure_full_index(&wtindex);
>
> Just on this part: There was already a logic error in the pre-image
> where we'd return error() return values up to cmd_main() et al. This
> means that (on POSIX) we return 255, not 1, per the C standard doing
> this is "implementation defined".
>
> I think you want the "rc" variable back, and either in another commit or
> in some other cleanup this on top or ahead of this patch:

Good catch. I submitted an incremental follow-up patch that addresses
this issue.


> diff --git a/builtin/difftool.c b/builtin/difftool.c
> index a867c49067c..6605d17e6bc 100644
> --- a/builtin/difftool.c
> +++ b/builtin/difftool.c
> @@ -345,6 +345,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
>         const char *helper_argv[] = { "difftool--helper", NULL, NULL, NULL };
>         struct hashmap wt_modified, tmp_modified;
>         int indices_loaded = 0;
> +       int rc;
>
>         workdir = get_git_work_tree();
>
> @@ -574,7 +575,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
>                 flags = 0;
>         } else
>                 setenv("GIT_DIFFTOOL_DIRDIFF", "true", 1);
> -       ret = run_command_v_opt(helper_argv, flags);
> +       rc = run_command_v_opt(helper_argv, flags);
>
>         /* TODO: audit for interaction with sparse-index. */
>         ensure_full_index(&wtindex);
> @@ -660,7 +661,7 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
>         strbuf_release(&tmpdir);
>         UNLEAK(working_tree_dups);
>
> -       return ret;
> +       return ret < 0 ? 1 : rc;
>  }


"return ret < 0 ? 1 : rc;" seems rather subtle.

In the submitted patch we're able to keep this as "return ret;" by
never assigning -1 in the first place.

My rationale is that it's better to not have to apply this fixup after the fact.

Thanks for reviewing.
--
David

  reply	other threads:[~2021-09-30 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  4:12 [PATCH v5 0/3] difftool dir-diff symlink bug fix and cleanup patches David Aguilar
2021-09-23  4:12 ` [PATCH v5 1/3] difftool: fix symlink-file writing in dir-diff mode David Aguilar
2021-09-23 21:46   ` Junio C Hamano
2021-09-30 17:03     ` David Aguilar
2021-09-23  4:12 ` [PATCH v5 2/3] difftool: create a tmpdir path without repeated slashes David Aguilar
2021-09-24 10:35   ` Ævar Arnfjörð Bjarmason
2021-09-30 17:05     ` David Aguilar [this message]
2021-09-23  4:12 ` [PATCH v5 3/3] difftool: add a missing space to the run_dir_diff() comments David Aguilar
2021-09-23 18:24 ` [PATCH v5 0/3] difftool dir-diff symlink bug fix and cleanup patches 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=CAJDDKr6MqDhGXcPzCW8f96C3XEAp8w+imc9Jzrw+sUEasqXeng@mail.gmail.com \
    --to=davvid@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=congdanhqx@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=sunshine@sunshineco.com \
    --cc=work@blotz.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.