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

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

From
THTim Hockin <thockin@google.com>
Date
Dec 26, 2022, 17:21 UTC
Message-ID
<CAO_RewZeUBVvqT+UgXL5V5EeTOt14zZ-5vJYA4YvNr-jNyupXg@mail.gmail.com>

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:

``` $ git cat-file -t f80f1b23b4cab2a295a091c623bb4746d188bd4a fatal: git cat-file: could not get object info

$ git rev-parse FETCH_HEAD 42d21cf12aab73ac8bc6245cc74ac9850bdf6989

$ git fetch --dry-run file:///tmp/e2e.2527526915/repo
f80f1b23b4cab2a295a091c623bb4746d188bd4a
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 18 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (18/18), 415.91 KiB | 84.00 KiB/s, done.
From file:///tmp/e2e.2527526915/repo
 * branch            f80f1b23b4cab2a295a091c623bb4746d188bd4a -> FETCH_HEAD

$ git cat-file -t f80f1b23b4cab2a295a091c623bb4746d188bd4a commit

$ git rev-parse FETCH_HEAD 42d21cf12aab73ac8bc6245cc74ac9850bdf6989 ```

FETCH_HEAD was not updated (good) but the rev in question is now present locally (bad), further tested by making a very large commit and watching the fetch be very slow. Also the same on non file:// repo (I tried https)

Am I using --dry-run wrong (or misunderstanding its purpose)?
Tim
Next: Junio C Hamano
Message 1 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.