Show 45 quoted lines
> Jonathan Tan <jonathantanmy@google.com> writes:
>
> > OK - updated the code, added a test for the "--dry-run
> > --no-write-fetch-head" case, and updated commit message and code
> > comment.
>
> Unfortunately our actions crossed X-< and the previous one that was
> good enough is already in 'master', together with the lazy fetch
> topic.
>
> Let's turn this into an incremental fix only for "Ouch, we still say
> FETCH_HEAD when both --dry-run and --no-write-fetch-head are given"
> bug.
>
> Thanks.
>
> -- >8 --
> Subject: [PATCH] fetch: fix --dry-run --no-write-fetch-head interaction
> From: Jonathan Tan <jonathantanmy@google.com>
>
> Recently we introduced "--[no-]-write-fetch-head" option to tell
> "git fetch" not to write FETCH_HEAD file. The command reported that
> FETCH_HEAD file is written, even with the "--no-write-fetch-head"
> option.
>
> db3c293e (fetch: no FETCH_HEAD display if --no-write-fetch-head,
> 2020-09-02) tried to squelch this, but the fix was not sufficient.
> Because we never write the FETCH_HEAD file when "--dry-run" is
> given, the addition of "--[no-]write-fetch-head" option was made by
> directly fliping the internal variable 'write_fetch_head' (which
> defaults to 'on') to 'off' upon seeing "--dry-run", which allowed
> the condition to decide if we write FETCH_HEAD to be a simple
> reference to the variable. But now, we need to tell if the user
> explicitly asked "--no-write-fetch-head" with "--dry-run" to
> decide when to show the report about FETCH_HEAD correctly.
>
> Introduce an extra 'user_specified_write_fetch_head' variable, which
> is 'on' by default and is turned 'off' with '--no-write-fetch-head'.
> The 'write_fetch_head' variable that decides if we actually write
> FETCH_HEAD remains there, retaining its meaning, but use this new
> variable and 'dry_run' to decide if we report about FETCH_HEAD.
>
> Suggested-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---