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
Junio C Hamano <gitster@pobox.com>
Date
Dec 27, 2022, 12:52 UTC
Message-ID
<xmqqcz85t3dr.fsf@gitster.g>
In-Reply-To
<CAO_RewZeUBVvqT+UgXL5V5EeTOt14zZ-5vJYA4YvNr-jNyupXg@mail.gmail.com>
Tim Hockin <thockin@google.com> writes:
Show 6 quoted lines
> 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: Tim HockinNext: Tim Hockin
Message 2 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.