Git development
 help / color / mirror / Atom feed
From: "Andrei Șova" <andreisva2023@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin/clone: fix --revision with SHA-256 commits
Date: Fri, 20 Nov 2026 13:36:35 -0700	[thread overview]
Message-ID: <87eccfutnw.fsf@gmail.com> (raw)
In-Reply-To: <xmqqv75rqubf.fsf@gitster.g>

Hi! Thanks for the review.

> Having said all that, if the problem is "the refspec item is created
> before we know what algorithm to use", wouldn't that suggest that
> the right conclusion from the observation should be more like "so,
> swap the sequence of initialization, keep the command line argument
> as an array of strings, do the handshake with the other side first
> and *then* finally create the refspec"?

Yea that was what I tried doing initially. Unfortunately it does not
work because the ref prefixes have to be initialized before we can fetch
the remote refs (and thus find out the remote hash algo), and we need
the refspec item to exist before that, so there is a kind of circular
dependency.

> Undoing what was done in an earlier step and recomputing may have
> been possible without losing information in this particular case,
> but that does not look like a good design, just sheer chance.

I agree. I originally did not quite understand the purpose of
refspec_ref_prefixes but I looked into it some more and I think it is OK
to not initialize the ref prefixes when using --revision (IIUC the
prefixes are used just as an optimization?). This also allows to get rid
of the extra case in the if (refs) as it should be non-NULL now
(previously it could be NULL since transport_get_remote_refs would
falsely return nothing because of the incorrectly parsed refspec item).

-- 
Andrei Șova

      reply	other threads:[~2026-11-20 20:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  4:00 [PATCH] builtin/clone: fix --revision with SHA-256 commits =?UTF-8?q?Andrei=20=C8=98ova?=
2026-11-20 17:36 ` Junio C Hamano
2026-11-20 20:36   ` Andrei Șova [this message]

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=87eccfutnw.fsf@gmail.com \
    --to=andreisva2023@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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