git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git fetch --dry-run changes the local repo and transfers data

From
THTim Hockin <thockin@google.com>
Date
Dec 27, 2022, 18:42 UTC
Message-ID
<CAO_RewbVicTznpDeCDG0Uqng-MdQ_GKtp-Vgz8kmtaXoczQGOg@mail.gmail.com>
In-Reply-To
<xmqqcz85t3dr.fsf@gitster.g>

Thanks. What threw me is that I expected it to be "very fast" and "very cheap" . If I commit a multi-gig file on the server, I see the dry-run fetch takes several seconds (clearly indicating some work proportional to the server repo size). I don't want to transfer that file on a dry-run, I hoped the server and client were both dry-running, andb the server could simply say "here's metadata for what I _would have_ returned if this was real". Not possible?

Tim
On Tue, Dec 27, 2022 at 4:52 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 38 quoted lines
>
> Tim Hockin <thockin@google.com> writes:
>
> > I'm trying to test if a remote repo has a given SHA. `ls-remote` does
> > not work for this unless it is a tag or a HEAD (which is not
> > guaranteed for this case).
> >
> > `git fetch --dry-run $remote $rev` SEEMS to fit the bill, except it
> > changes local state. For example:
>
> Well, without changing the "local state", you cannot see if that
> report repository has or does not have the commit.
>
> > FETCH_HEAD was not updated (good)
>
> None of your refs are updated, either.
>
> There are things that are not reachable from your refs (or other
> anchoring points like the index and the reflog).  As far as Git is
> concerned, they don't exist [*], and that is why Git will happily
> remove them with "git gc", for example.  They are crufts and it is
> easier to think of them as not a part of "local data".
>
> So I suspect that ...
>
> > but the rev in question is now
> > present locally (bad),
>
> ... this complaint is a bit misguided.  After all, the procdure you
> gave above is exactly how you would ask the "I'm trying to test if a
> remote repo has a given SHA" question about commit f80f1b23b4ca.  If
> the operation did not transfer data, you would not be able to get
> the answer to that question.
>
> > Am I using --dry-run wrong (or misunderstanding its purpose)?
>
> Maybe (mis)understanding on Git's data model (see above [*]) is the
> root cause of this confusion.
Previous: Junio C HamanoNext: Jeff King
Message 3 of 4 in “git fetch --dry-run changes the local repo and transfers data”
  1. Tim HockinDec 26, 2022
  2. Junio C HamanoDec 27, 2022
  3. Tim HockinDec 27, 2022
  4. Jeff KingJan 3, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.