threads / discuss / 4314

Remote git-cat-file?

Subject: Remote git-cat-file?

## tl;dr

7 messages between May 27, 2006 and May 28, 2006.

replies: 6people: 4as markdown or json

Linus Torvalds· May 28, 2006, 00:29 UTC · re: Elrond · lore

Re: Remote git-cat-file?

On Sat, 27 May 2006, Elrond wrote:
> 
> Is it possible via the git: protocol to do a git-cat-file?
> 
> To download just one object by its ID?
Nope. 

Well, depending on just how much you know about the object, you can fake it. For example, if you already know it's a commit, and you know the parents, then yes, you can download it by basically saying that you want that particular object and you already have the parents.

But in the general case, the answer is no. Set up a gitweb thing, and look up the objects that way. Or just pull the repo, and look at it locally.

Just out of interest, why would you ever want to just look at a single object?

		Linus
Linus Torvalds· May 28, 2006, 00:32 UTC · re: Linus Torvalds · lore

Re: Remote git-cat-file?

On Sat, 27 May 2006, Linus Torvalds wrote:
Show 5 quoted lines
> 
> Well, depending on just how much you know about the object, you can fake 
> it. For example, if you already know it's a commit, and you know the 
> parents, then yes, you can download it by basically saying that you want 
> that particular object and you already have the parents.

The other (similar) case is for tag objects. When you do "git ls-remote" on the remote repo, it will tell you both the tag object SHA and the object SHA of the thing it points to, so you can then do a git protocol exchange where you do a

	for_each_tag
		"want <tagsha1>"
	for_each_tag
		"have <objectitpointstosha1>"
and you'll get just the tag object back.
		Linus
Elrond· May 28, 2006, 10:57 UTC · re: Linus Torvalds · lore

Re: Remote git-cat-file?

Linus Torvalds <torvalds <at> osdl.org> writes: [...]

> But in the general case, the answer is no. Set up a gitweb thing, and look 
> up the objects that way. Or just pull the repo, and look at it locally.
I ended up doing that (clone whole remote repo).
> Just out of interest, why would you ever want to just look at a single 
> object?

Well... I screwed up my local clone of a repo. git-fsck told me what objects I needed. So I finally ended up downloading the whole repo again to extract 16 objects. ;)

The other possible use for remote git-cat-file: It might be useful in shallow repos to selectively load objects "on demand". (In fact, I screwed my repo by trying to make it shallow.)

    Elrond
Jakub Narebski· May 28, 2006, 12:00 UTC · re: Elrond · lore

Re: Remote git-cat-file?

Elrond wrote:
> Linus Torvalds <torvalds <at> osdl.org> writes:
>> 
>> Just out of interest, why would you ever want to just look at a single 
>> object?
[...]
>
> The other possible use for remote git-cat-file:
> It might be useful in shallow repos to selectively load objects "on demand".
> (In fact, I screwed my repo by trying to make it shallow.)

It would be nice I think to be able to have remote alternatives, loading (downloading and saving) objects "on demand" ("lazy alternatives"). Not necessary only with "shallow repo"/"shallow clone".

-- 
Jakub Narebski
Warsaw, Poland
Junio C Hamano· May 28, 2006, 17:38 UTC · re: Jakub Narebski · lore

Re: Remote git-cat-file?

Jakub Narebski <jnareb@gmail.com> writes:
> It would be nice I think to be able to have remote alternatives,...

Yup, I think I've mentioned that one as one of "the mostly unimplementable but would be very nice to have crazy wishlist items" some time ago. What people would want is not a "shallow" clone, but a "lazy" clone, and in the ideal world that would obviously be a nice thing to have.

Jakub Narebski· May 28, 2006, 18:34 UTC · re: Junio C Hamano · lore

Re: Remote git-cat-file?

Junio C Hamano wrote:
Show 9 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> It would be nice I think to be able to have remote alternatives,...
> 
> Yup, I think I've mentioned that one as one of "the mostly
> unimplementable but would be very nice to have crazy wishlist
> items" some time ago.  What people would want is not a "shallow"
> clone, but a "lazy" clone, and in the ideal world that would
> obviously be a nice thing to have.

I think that it should be only "commit-lazy", i.e. downloading whole trees, subtrees, and objects pointed by tags, only not following the parent links of commits; perhaps also other links to commits (branches, tags, tag objects).

-- 
Jakub Narebski
Warsaw, Poland

← back to recent threads