Re: [PATCH v2] fetch: no FETCH_HEAD display if --no-write-fetch-head
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 3, 2020, 02:03 UTC
- Message-ID
- <xmqqo8mnaa6k.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200902235628.GB4035286@google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 24 quoted lines
>> builtin/fetch.c | 8 +++++++-
>> t/t0410-partial-clone.sh | 7 +++++--
>> t/t5510-fetch.sh | 18 ++++++++++--------
>> 3 files changed, 22 insertions(+), 11 deletions(-)
>
> Thanks for fixing it, and sorry I didn't catch it during initial
> review.
> ...
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 320ba9471d..c6c4689250 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -1023,11 +1023,17 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
>> rc |= update_local_ref(ref, what, rm, ¬e,
>> summary_width);
>> free(ref);
>> - } else
>> + } else if (write_fetch_head || dry_run) {
>> + /*
>> + * Display fetches written to FETCH_HEAD (or
>> + * would be written to FETCH_HEAD, if --dry-run
>
> nit: to fix the parallel construction, s/would/that would/ or
> s/written/that were written/True.
Show 7 quoted lines
>> + * is set). >> + */ >> format_display(¬e, '*', >> *kind ? kind : "branch", NULL, >> *what ? what : "HEAD", >> "FETCH_HEAD", summary_width); >> + }
Strictly speaking, I suspect that this is still broken when the user says "fetch --no-write-fetch-head --dry-run" in which case we should skip this block.
And to fix it properly, we would probably need to keep track of three things semi-independently.
- were we told this is a "dry-run"? (current 'dry_run' variable)
- were we told not to store fetch-head? (missing)
- after all, are we going to write or not write fetch-head (current 'write_fetch_head' variable)
And the conditional to protect this block would be fixed to use only the second and new "have we seen --no-fetch-head on the command line?" variable, and ignore the settings of the dry_run variable, I think.
Thanks.