All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Stef Bon <stefbon@gmail.com>
Cc: Git Users <git@vger.kernel.org>
Subject: Re: Exec upload-pack on remote with what parameters to get direntries.
Date: Tue, 31 Aug 2021 03:07:26 -0400	[thread overview]
Message-ID: <YS3VLh8SFvpDZy84@coredump.intra.peff.net> (raw)
In-Reply-To: <CANXojczR1hMrzz7t0P6AkqL3kjdk+NzBKyCQnm-9cWFbULifow@mail.gmail.com>

On Tue, Aug 31, 2021 at 08:38:39AM +0200, Stef Bon wrote:

> So in my program I do not have to do something like:
> 
> ssh -x git@server "git-upload-pack 'simplegit-progit.git'"
> 
> It is only the sending of an exec message with the right command.
> Via the SSH_MSG_CHANNEL_DATA message the server will return the
> output. In my program I have to write a parser to get the
> tree/direntries.
> 
> Now you suggest the git clone --depth 1 --filter=blob:none
> --single-branch -b $branch
> command. How does that look when writing it in lowlevel git messages
> as described in
> 
> https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols
> 
> ?
> I'm programming at this low level, so I have to write the messages to
> send to the server myself.

You'll have to read the documentation I pointed to earlier:

  https://github.com/git/git/blob/master/Documentation/technical/pack-protocol.txt

In short: the server tells you which refs it has and what they point to,
then the client says which objects it wants and which objects it has,
and then the server sends a packfile. The flow of the protocol and the
format of the messages is laid out there.

You might also set GIT_TRACE_PACKET=1 in your environment and try
running some Git commands. They will show you what's being said on the
wire, up until the packfile is sent (decoding the packfile itself is a
whole other story).

> And you mention the api github has for a git tree object. But git2 has
> already the git_tree object?

If you mean libgit2, then yes, it has a git_tree struct. Just like we
have internally within regular Git. But those are for accessing _local_
objects, that have already been fetched.

You could build a fuse filesystem around a local Git repository pretty
easily, either by using libgit2 or around tools like "git ls-tree" and
"git cat-file". But if your purpose is to access a remote one without
downloading all of the objects first, then no, Git does not expose any
of the endpoints you'd need remotely (but provider-specific APIs like
GitHub's do).

-Peff

  reply	other threads:[~2021-08-31  7:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 12:56 Exec upload-pack on remote with what parameters to get direntries Stef Bon
2021-08-30 19:10 ` Jeff King
2021-08-30 19:43   ` Junio C Hamano
2021-08-30 20:46     ` Jeff King
2021-08-30 21:21       ` Junio C Hamano
2021-08-31 14:23         ` Ævar Arnfjörð Bjarmason
2021-08-31 15:35           ` Bruno Albuquerque
2021-08-31 16:23             ` Junio C Hamano
2021-08-31  6:38   ` Stef Bon
2021-08-31  7:07     ` Jeff King [this message]
2021-08-31  9:44       ` Stef Bon
2021-08-31 14:01         ` Æ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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YS3VLh8SFvpDZy84@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=stefbon@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.