Re: Exec upload-pack on remote with what parameters to get direntries.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux