Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Tao Klerks <tao@klerks.biz>
To: Robert Coup <robert@coup.net.nz>
Cc: git <git@vger.kernel.org>
Subject: Re: "git fetch --refetch" and multiple (separate/orphan) branches
Date: Thu, 10 Aug 2023 09:14:55 +0200	[thread overview]
Message-ID: <CAPMMpoh9xP8PomAUTHGZfYAMAgHb_BF74EVgmo1C-DQh22-cUA@mail.gmail.com> (raw)
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:
>
> 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

      reply	other threads:[~2023-08-10  7:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 21:22 "git fetch --refetch" and multiple (separate/orphan) branches Tao Klerks
2023-06-03  8:18 ` Robert Coup
2023-08-10  7:14   ` Tao Klerks [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=CAPMMpoh9xP8PomAUTHGZfYAMAgHb_BF74EVgmo1C-DQh22-cUA@mail.gmail.com \
    --to=tao@klerks.biz \
    --cc=git@vger.kernel.org \
    --cc=robert@coup.net.nz \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).