From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>,
git@vger.kernel.org
Subject: Re: The most efficient way to test if repositories share the same objects
Date: Thu, 22 Mar 2018 20:53:57 +0100 [thread overview]
Message-ID: <87muyzyjhm.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqlgejlx8e.fsf@gitster-ct.c.googlers.com>
On Thu, Mar 22 2018, Junio C. Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> But of course that'll just give you the tips. You could then use `git
>> cat-file --batch-check` on both ends to see what commits from the other
>> they report knowing about, in case they have branches that are
>> ahead/behind the other.
>
> I am not sure how you are envisioning to use "cat-file
> --batch-check" here. Do you mean to take "rev-list --all" output
> from both and compare, or something?
By doing something like this:
(
cd /tmp &&
git clone http://github.com/gitster/git gitster-git;
git clone http://github.com/avar/git avar-git;
git -C gitster-git for-each-ref --format="%(object)" | git -C avar-git cat-file --batch-check|grep -E -o '(commit|missing)'|sort|uniq -c &&
git -C avar-git for-each-ref --format="%(object)" | git -C gitster-git cat-file --batch-check|grep -E -o '(commit|missing)'|sort|uniq -c
)
Which outputs:
673 commit
696 missing
374 commit
495 missing
Which of course, as noted, isn't going to be a good general solution in
all cases, but it's blindingly fast, and since the original question is
essentially that he's starting out with doing a rough equivalent of
that, but for tags only, maybe it'll work for his use-case.
> I am not sure how Konstantin defines "the most efficient", but if it
> is "with the smallest number of bits exchanged between the
> repositories", then the answer would probably be to find the root
> commit(s) in each repository and if they share any common root(s).
> If there isn't then there is no hope to share objects between them,
> of course.
Yes, that would probably be much better:
diff -ru <(git -C avar-git log --oneline --pretty=format:%H --max-parents=0) \
<(git -C gitster-git log --oneline --pretty=format:%H --max-parents=0) &&
do_stuff_because_they_have_stuff_in_common
next prev parent reply other threads:[~2018-03-22 19:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-22 16:48 The most efficient way to test if repositories share the same objects Konstantin Ryabitsev
2018-03-22 19:20 ` Ævar Arnfjörð Bjarmason
2018-03-22 19:35 ` Junio C Hamano
2018-03-22 19:53 ` Ævar Arnfjörð Bjarmason [this message]
2018-03-22 21:32 ` Konstantin Ryabitsev
2018-03-22 21:44 ` Junio C Hamano
2018-03-23 13:57 ` Konstantin Ryabitsev
2018-03-23 14:36 ` Ævar Arnfjörð Bjarmason
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87muyzyjhm.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=konstantin@linuxfoundation.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).