[git-users] Looking up SHA1s

2010-11-16 Thread Martin Fick
Hello,

This might be a silly question, but I can't figure it out: is 
there a way to get all the tags and branches whose tip 
includes a certain blob (by SHA1) in its tree object?

Thanks,

-Martin

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Re: Looking up SHA1s

2010-11-16 Thread Konstantin Khomoutov
Martin Fick wrote:

> This might be a silly question, but I can't figure it out: is
> there a way to get all the tags and branches whose tip
> includes a certain blob (by SHA1) in its tree object?

I doubt there is any ready-made solution for this corner case, but you
could roll your own using git-ls-tree low-level command -- given a
commit name, it outputs a list of objects the tree linked to that
commit references, and that output includes type, sha1 and name of
each of those objects. So you could write a script which starts with a
given commit name, calls git-ls-tree on it, tries to find a matching
sha1 in its output, and that fails, descends to each listed tree
objects doing the same thing on them until either the hierarchy is
exhausted or the matching sha1 is found.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Re: Looking up SHA1s

2010-11-16 Thread Martin Fick
On Tuesday 16 November 2010 06:02:27 pm Konstantin Khomoutov 
wrote:
> Martin Fick wrote:
> > This might be a silly question, but I can't figure it
> > out: is there a way to get all the tags and branches
> > whose tip includes a certain blob (by SHA1) in its tree
> > object?
> 
> I doubt there is any ready-made solution for this corner
>  case, but you could roll your own using git-ls-tree
>  low-level command -- given a commit name, it outputs a
>  list of objects the tree linked to that commit
>  references, and that output includes type, sha1 and name
>  of each of those objects. So you could write a script
>  which starts with a given commit name, calls git-ls-tree
>  on it, tries to find a matching sha1 in its output, and
>  that fails, descends to each listed tree objects doing
>  the same thing on them until either the hierarchy is
>  exhausted or the matching sha1 is found.

Thanks, I actually just did something similar.  Although 
the -r option to git-ls-tree seems to recurse for me
automatically.  A few simple switches to automatically
iterate over the list of branches and tags and... a simple
working generic solution.  I am still kinda curious if there
isn't a much better way since this may not scale well on 
large repos?  It takes about ~1s on a cached gerrit repo.

-Martin

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Re: Looking up SHA1s

2010-11-16 Thread Konstantin Khomoutov
On Nov 17, 4:12 am, Martin Fick  wrote:

> > > This might be a silly question, but I can't figure it
> > > out: is there a way to get all the tags and branches
> > > whose tip includes a certain blob (by SHA1) in its tree
> > > object?
> > I doubt there is any ready-made solution for this corner
> >  case, but you could roll your own using git-ls-tree
[...]
> Thanks, I actually just did something similar.  Although
> the -r option to git-ls-tree seems to recurse for me
> automatically.  A few simple switches to automatically
> iterate over the list of branches and tags and... a simple
> working generic solution.  I am still kinda curious if there
> isn't a much better way since this may not scale well on
> large repos?  It takes about ~1s on a cached gerrit repo.

I think it would be then fine to ask this question on the main Git
list (git at vger.kernel.org). Maybe you'll get additional hints on
the implementation.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Re: How do you download only the necessary part of a repository?

2010-11-16 Thread Konstantin Khomoutov
On Nov 16, 2:20 am, vfclists  wrote:

> If you want to work with only a few of the branches of a remote
> repository, how to you clone it in a way which does not bring down
> everything?
I think it's impossible.
But you should maybe rethink your approach to this.
First, what you requested could only spare you bandwidth and disk
space if the branches contain really divergent histories; for a
typical project it is not true -- the branches tend to share vast
amounts of history (hence bringing only few of them in would anyway
bring most of the history), and if they don't, then you should
probably look at submodules [1].
The next thing to consider is "shallow cloning" -- see this FAQ entry
[2].

1. http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html
2.
https://git.wiki.kernel.org/index.php/GitFaq#How_do_I_use_git_for_large_projects.2C_where_the_repository_is_large.2C_say_approaching_1_TB.2C_but_a_checkout_is_only_a_few_hundred_MB.3F_Will_every_developer_need_1_TB_of_local_disk_space.3F

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.