All of lore.kernel.org
 help / color / mirror / Atom feed
* Does Git now have any C struct version history tracking mechanism?
@ 2013-08-18 10:33 Zhan Jianyu
  2013-08-19  5:54 ` Nazri Ramliy
  0 siblings, 1 reply; 4+ messages in thread
From: Zhan Jianyu @ 2013-08-18 10:33 UTC (permalink / raw)
  To: git

Hi, all.

* Background

  Such a requirement came into my mind when I am tracking a gloomy C
struct , with lengthy list of elements which are either elaborated or
opaque. So I use git blame to track it down and found that its
original version is quite simple and intuitive. So I think I could
just slice out every snapshot of this struct, reading every changelog
, to get a better knowledge of what it is and why it should be like
this.

It seems quite helpful but the process is quite cumbersome. So I
wonder if there is already some mechanism fulfilling my requirement in
Git.  If it doesn't,  would it be worthy adding one ?

Thanks




--

Regards,
Zhan Jianyu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Does Git now have any C struct version history tracking mechanism?
  2013-08-18 10:33 Does Git now have any C struct version history tracking mechanism? Zhan Jianyu
@ 2013-08-19  5:54 ` Nazri Ramliy
  2013-08-19  8:37   ` Thomas Rast
  0 siblings, 1 reply; 4+ messages in thread
From: Nazri Ramliy @ 2013-08-19  5:54 UTC (permalink / raw)
  To: Zhan Jianyu; +Cc: Git Mailing List

On Sun, Aug 18, 2013 at 6:33 PM, Zhan Jianyu <nasa4836@gmail.com> wrote:
>   Such a requirement came into my mind when I am tracking a gloomy C
> struct , with lengthy list of elements which are either elaborated or
> opaque. So I use git blame to track it down and found that its
> original version is quite simple and intuitive. So I think I could
> just slice out every snapshot of this struct, reading every changelog
> , to get a better knowledge of what it is and why it should be like
> this.
>
> It seems quite helpful but the process is quite cumbersome. So I
> wonder if there is already some mechanism fulfilling my requirement in
> Git.  If it doesn't,  would it be worthy adding one ?

It's already merged to git.git's master quite recently in
ed73fe56428eecd2b635473f6a517a183c4713a3 (back in June).

You'd invoke git log like this:

    $ git log -L :struct_or_function_name:filename.c

and it will show you the commits and the specific hunks that affect
the struct or function name.

It's still a bit rough on the edges, for example, doing the following
in git.git:

    $ git log -L :rev_cmdline_info:revision.h

Shows three commits (a765499, ca92e59 and 281eee4) where the second
one does not touch the struct at all (if you do "git show ca92e59" you
might gain an insight as to how -L works).

But that is not to say that it's not good. The gain really shadows the
roughness.

nazri

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Does Git now have any C struct version history tracking mechanism?
  2013-08-19  5:54 ` Nazri Ramliy
@ 2013-08-19  8:37   ` Thomas Rast
  2013-08-20  3:55     ` Nazri Ramliy
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Rast @ 2013-08-19  8:37 UTC (permalink / raw)
  To: Nazri Ramliy; +Cc: Zhan Jianyu, Git Mailing List

Nazri Ramliy <ayiehere@gmail.com> writes:

> On Sun, Aug 18, 2013 at 6:33 PM, Zhan Jianyu <nasa4836@gmail.com> wrote:
>>   Such a requirement came into my mind when I am tracking a gloomy C
>> struct , with lengthy list of elements which are either elaborated or
>> opaque. So I use git blame to track it down and found that its
>> original version is quite simple and intuitive. So I think I could
>> just slice out every snapshot of this struct, reading every changelog
>> , to get a better knowledge of what it is and why it should be like
>> this.
>>
>> It seems quite helpful but the process is quite cumbersome. So I
>> wonder if there is already some mechanism fulfilling my requirement in
>> Git.  If it doesn't,  would it be worthy adding one ?
>
> It's already merged to git.git's master quite recently in
> ed73fe56428eecd2b635473f6a517a183c4713a3 (back in June).
>
> You'd invoke git log like this:
>
>     $ git log -L :struct_or_function_name:filename.c
>
> and it will show you the commits and the specific hunks that affect
> the struct or function name.
>
> It's still a bit rough on the edges, for example, doing the following
> in git.git:
>
>     $ git log -L :rev_cmdline_info:revision.h
>
> Shows three commits (a765499, ca92e59 and 281eee4) where the second
> one does not touch the struct at all (if you do "git show ca92e59" you
> might gain an insight as to how -L works).

Hmm, IIUC that's actually not a bug or even a roughness; it's an
artifact of how the :pattern:file syntax is defined.  It takes the first
_funcname line_ matching 'pattern', up to (but excluding) the next
funcname line.

The default funcname rule (in the absence of any patterns) does not
match '#define...' on account of the '#'.  The default funcname pattern
for 'cpp' (if you manually configured your git.git repo to set this
attribute; it doesn't by default) never matches a leading '#´ either.
So it's no surprise that the tracked range extends a few more lines
after the struct.

Or is there an issue that I'm missing?

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Does Git now have any C struct version history tracking mechanism?
  2013-08-19  8:37   ` Thomas Rast
@ 2013-08-20  3:55     ` Nazri Ramliy
  0 siblings, 0 replies; 4+ messages in thread
From: Nazri Ramliy @ 2013-08-20  3:55 UTC (permalink / raw)
  To: Thomas Rast; +Cc: Zhan Jianyu, Git Mailing List

On Mon, Aug 19, 2013 at 4:37 PM, Thomas Rast <trast@inf.ethz.ch> wrote:
> Hmm, IIUC that's actually not a bug or even a roughness; it's an
> artifact of how the :pattern:file syntax is defined.  It takes the first
> _funcname line_ matching 'pattern', up to (but excluding) the next
> funcname line.
>
...
> Or is there an issue that I'm missing?

No you're correct. I should have used the following instead for the demo:

    $ git log -L /struct\ rev_cmdline_info/,/^}/:revision.h

Moral: You'd hit your target better if you work on your aim.

nazri

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-20  3:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-18 10:33 Does Git now have any C struct version history tracking mechanism? Zhan Jianyu
2013-08-19  5:54 ` Nazri Ramliy
2013-08-19  8:37   ` Thomas Rast
2013-08-20  3:55     ` Nazri Ramliy

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.