On Aug 11, 3:38 pm, David Aguilar <dav...@gmail.com> wrote:
> On Wed, Aug 10, 2011 at 10:01:38PM -0700, LovelyLich wrote:
> > Hi all....
> > I have git clone 
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git,
> > So, I get an repo for linux  kernel source code .
> > What I  want to do is to search for a function changes from version A
> > to version B.
> > for instance, I want to get change log for function
> > "kmem_cache_create"  in file  mm/slab.c  from kernel 2.6.18  to
> > 3.0.....
>
> > What I should issue an command?
> > I have tried
> >            git  log --grep='kmem_cache_create' mm/slab.c
> > but this will get many commits and every commit is specified with an
> > sha1,  not kernel version  which  i wanted.
>
> What if you did something like this?
>
>         $ git log \
>         --grep='kmem_cache_create --pretty=format:%H \
>         -- mm/slab.c |
>         while read sha1; do
>                 echo $sha1
>                 git describe "$sha1"
>         done
>
> Be advised that that only finds commits that mention
> 'kmem_cache_create' in the commit message (--grep).
>
> You might get farther using git blame on the file
> and see the commits that make up that function.
>
> Also, the git describe output is a "fuzzy" representation
> of the version.
>
> What are you trying to find?  There's a lot you can do once you
> have the $sha1.  For example, "git tag --contains $sha1"
> would tell you which releases contain the change.
>
> That might be closer to what you're interested in.
> If you're interested in commits that touch the function
> definition you could try the -S switch, which will show you
> everytime content changes containing that string:
>
>         $ git log -S'kmem_cache_create' ...
>
> There's no way to do a general "log for changes to a function"
> but git has all the information necessary to implement such
> a script.  That'd be a pretty useful script.  I wonder if
> anyone's ever written such a thing.
>
> git-blame is the closest to that.  It can be told to look
> at the history of a range of lines in a file:
>
> http://stackoverflow.com/questions/5098256/git-blame-prior-commitshttp://book.git-scm.com/5_finding_issues_-_git_blame.html
>
> I hope that helps,
> --
>                                         David
>
> git-cola: The highly caffeinated git GUI
>
> https://github.com/davvid/git-cola.githttp://cola.tuxfamily.org/



Very thanks for you long and detailed reply.    I think I got what i
want from your reply . thanks again.
BTW, i found i can solve this problem easily by using gitk  to browse
log...

-- 
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-users@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.

Reply via email to