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

Re: "git fetch --refetch" and multiple (separate/orphan) branches

From
Tao Klerks <tao@klerks.biz>
Date
Aug 10, 2023, 07:14 UTC
Message-ID
<CAPMMpoh9xP8PomAUTHGZfYAMAgHb_BF74EVgmo1C-DQh22-cUA@mail.gmail.com>
In-Reply-To
<CACf-nVfUotaTYeCC9XMvnYYNhjX+EW89z7fhUX0Ok9TpsVTRTw@mail.gmail.com>
Hi Robert,

Sorry about the extended delay, I haven't had a chance to do "git hacking" in a while.

On Sat, Jun 3, 2023 at 10:18 AM Robert Coup <robert@coup.net.nz> wrote:
Show 15 quoted lines
>
> On Fri, 2 Jun 2023 at 22:23, Tao Klerks <tao@klerks.biz> wrote:
>
> > What I believe is happening is that *if* there are refs to be updated
> > (or new refs, presumably), *then* the objects returned to the client
> > are only those required for those refs. If, on the other hand, there
> > are no updated refs, then you get what is advertised in the doc: "all
> > objects as a fresh clone would [...]".
> >
> > I've tested a couple of different scenarios and the behavior seems
> > consistent with this explanation.
>
> Do you have a repo & steps that could reproduce this easily? Otherwise
> I can try and work up something.
>

Does the following work? It shows that with a change to the orphan branch from another client, a refetch in the original client gets about half the objects (the ones for the orphan branch that was updated), and in another fetch right after, with no new changes, the refetch gets all 600-or-so objects.

create_n_commits() {
  for i in $(seq $2); do
    echo "another new line $RANDOM" >> "$1/datafile"
    git -C "$1" add datafile
    git -C "$1" commit -m anothercommit -q
  done
}

mkdir refetch-testing SERVERFOLDER=refetch-testing/server git init "$SERVERFOLDER" --bare

CLIENTFOLDER=refetch-testing/client git init "$CLIENTFOLDER" git -C "$CLIENTFOLDER" remote add origin "../server"

git -C "$CLIENTFOLDER" checkout -b main create_n_commits "$CLIENTFOLDER" 100 git -C "$CLIENTFOLDER" push origin HEAD

git -C "$CLIENTFOLDER" checkout --orphan orphan create_n_commits "$CLIENTFOLDER" 100 git -C "$CLIENTFOLDER" push origin HEAD

echo "---HERE IS A NORMAL FULL REFETCH---" git -C "$CLIENTFOLDER" fetch --refetch echo "---NORMAL FULL REFETCH ENDS---"

OTHERCLIENTFOLDER=refetch-testing/otherclient git clone "$SERVERFOLDER" "$OTHERCLIENTFOLDER" git -C "$OTHERCLIENTFOLDER" checkout orphan create_n_commits "$OTHERCLIENTFOLDER" 5 git -C "$OTHERCLIENTFOLDER" push origin HEAD

echo "---HERE IS A WEIRD PARTIAL REFETCH OF ONE BRANCH ONLY---" git -C "$CLIENTFOLDER" fetch --refetch echo "---WEIRD PARTIAL REFETCH ENDS---"

echo "---HERE IS NORMAL REFETCH AGAIN---" git -C "$CLIENTFOLDER" fetch --refetch echo "---NORMAL REFETCH ENDS---"

rm -rf refetch-testing
Previous: Robert Coup
Message 3 of 3 in “"git fetch --refetch" and multiple (separate/orphan) branches”
  1. Tao KlerksJun 2, 2023
  2. Robert CoupJun 3, 2023
  3. Tao KlerksAug 10, 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.