Git development
 help / color / mirror / Atom feed
* Can git log <file> follow log of its origins?
@ 2008-01-29 17:48 Max Pollard
  2008-01-29 18:17 ` Sean
  2008-01-29 20:03 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Max Pollard @ 2008-01-29 17:48 UTC (permalink / raw)
  To: git

Hi all,

If I do the following:

     $ git init
     $ echo "The brown fox is getting old" > a.txt
     $ git add a.txt
     $ git commit -m "Commit a.txt"

     $ cp a.txt b.txt
     $ git add b.txt
     $ git commit -m "Copy a.txt to b.txt"

     $ git log b.txt

I only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it possible
to have the above command keep going and show the history of a.txt?  Or at
least somehow indicate that b.txt originated from a.txt?


Thanks,
MP



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 17:48 Can git log <file> follow log of its origins? Max Pollard
@ 2008-01-29 18:17 ` Sean
  2008-01-29 19:47   ` Max Pollard
  2008-01-29 20:03 ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Sean @ 2008-01-29 18:17 UTC (permalink / raw)
  To: Max Pollard; +Cc: git

On Tue, 29 Jan 2008 09:48:05 -0800 (PST)
Max Pollard <ajaxsupremo@yahoo.com> wrote:

> If I do the following:
> 
>      $ git init
>      $ echo "The brown fox is getting old" > a.txt
>      $ git add a.txt
>      $ git commit -m "Commit a.txt"
> 
>      $ cp a.txt b.txt
>      $ git add b.txt
>      $ git commit -m "Copy a.txt to b.txt"
> 
>      $ git log b.txt
> 
> I only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it possible
> to have the above command keep going and show the history of a.txt?  Or at
> least somehow indicate that b.txt originated from a.txt?

Hi Max,

Not sure it will leave you feeling totally satisfied but the
following command will at least show you the copy which
occurred in that commit:

$ git log --full-diff -C --find-copies-harder --stat -- b.txt
commit 578ecbc516e70ce7178545233192a08369a07101
Author: xyz <x@y.z>
Date:   Tue Jan 29 13:11:16 2008 -0500

    Copy a.txt to b.txt

 a.txt => b.txt |    0 
 1 files changed, 0 insertions(+), 0 deletions(-)

If you had done a rename instead of a copy, then "git log --follow b.txt" would
have done what you're looking for, but there is no corresponding option to
follow copies.

HTH,
Sean

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 18:17 ` Sean
@ 2008-01-29 19:47   ` Max Pollard
  0 siblings, 0 replies; 7+ messages in thread
From: Max Pollard @ 2008-01-29 19:47 UTC (permalink / raw)
  To: Sean; +Cc: git


--- Sean wrote:

> On Tue, 29 Jan 2008 09:48:05 -0800 (PST)
> Max Pollard wrote:
> 
> > I only see the log corresponding to the 2nd commit (v1.5.3.5).  Is it
> > possible to have the above command keep going and show the history of
> > a.txt?  Or at least somehow indicate that b.txt originated from a.txt?
> 
> Hi Max,
> 
> Not sure it will leave you feeling totally satisfied but the
> following command will at least show you the copy which
> occurred in that commit:
> 
> $ git log --full-diff -C --find-copies-harder --stat -- b.txt
> commit 578ecbc516e70ce7178545233192a08369a07101
> Author: xyz <x@y.z>
> Date:   Tue Jan 29 13:11:16 2008 -0500
> 
>     Copy a.txt to b.txt
> 
>  a.txt => b.txt |    0 
>  1 files changed, 0 insertions(+), 0 deletions(-)
> 
> If you had done a rename instead of a copy, then "git log --follow b.txt"
> would have done what you're looking for, but there is no corresponding option
> to follow copies.

Many thanks for that Sean.  I saw all the options in the manual, but couldn't
figure out how to put them together.

This is exactly the information I wanted.  It appears to identify copies in
both text & binary files even if contents of b.txt are modified before commit
(or at least modified in ways the copy-detection logic can identify copies).


MP



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 17:48 Can git log <file> follow log of its origins? Max Pollard
  2008-01-29 18:17 ` Sean
@ 2008-01-29 20:03 ` Junio C Hamano
  2008-01-29 21:07   ` Max Pollard
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-01-29 20:03 UTC (permalink / raw)
  To: Max Pollard; +Cc: git

Max Pollard <ajaxsupremo@yahoo.com> writes:

> If I do the following:
>
>      $ git init
>      $ echo "The brown fox is getting old" > a.txt
>      $ git add a.txt
>      $ git commit -m "Commit a.txt"
>
>      $ cp a.txt b.txt
>      $ git add b.txt
>      $ git commit -m "Copy a.txt to b.txt"
>
>      $ git log b.txt
>
> I only see the log corresponding to the 2nd commit (v1.5.3.5).

That is what you are asking "git log" to show.  "git log b.txt"
means "please simplify the history by throwing away commits that
do not have changes to paths that match b.txt, and then show the
resulting log with the change pertaining to that path".  The
first commit does not change a path called b.txt (in other
words, "git show --stat HEAD^" will not give diffstat for "b.txt"),
so that commit is not shown.

$ git log --pretty=oneline --name-status -C -C

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 20:03 ` Junio C Hamano
@ 2008-01-29 21:07   ` Max Pollard
  2008-01-29 21:21     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Max Pollard @ 2008-01-29 21:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


--- Junio C Hamano wrote:

> Max Pollard writes:
> 
> > I only see the log corresponding to the 2nd commit (v1.5.3.5).
> 
> That is what you are asking "git log" to show.  "git log b.txt"
> means "please simplify the history by throwing away commits that
> do not have changes to paths that match b.txt, and then show the
> resulting log with the change pertaining to that path".  The
> first commit does not change a path called b.txt (in other
> words, "git show --stat HEAD^" will not give diffstat for "b.txt"),
> so that commit is not shown.
> 
> $ git log --pretty=oneline --name-status -C -C
> 

Got it - many thanks.  So -C -C is the answer, with --name-status or --stat to
actually show the result.  From the code, a status like Cxxx appears to contain
the "similarity percentage" in xxx; so that C100 would mean an exact copy...


MP



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 21:07   ` Max Pollard
@ 2008-01-29 21:21     ` Junio C Hamano
  2008-01-29 21:40       ` Max Pollard
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2008-01-29 21:21 UTC (permalink / raw)
  To: Max Pollard; +Cc: git

Max Pollard <ajaxsupremo@yahoo.com> writes:

>> Max Pollard writes:
>> 
>> > I only see the log corresponding to the 2nd commit (v1.5.3.5).
>> 
>> That is what you are asking "git log" to show.  "git log b.txt"
>> means "please simplify the history by throwing away commits that
>> do not have changes to paths that match b.txt, and then show the
>> resulting log with the change pertaining to that path".  The
>> first commit does not change a path called b.txt (in other
>> words, "git show --stat HEAD^" will not give diffstat for "b.txt"),
>> so that commit is not shown.
>> 
>> $ git log --pretty=oneline --name-status -C -C
>> 
>
> ...  So -C -C is the answer, with --name-status or --stat to
> actually show the result.

The real "answer" part in that example is not -C -C.  Obviously,
you would need double-C aka --find-copies-harder, because you
did not change a.txt when creating b.txt, so it is still needed.

But the essential part of the answer is "not giving b.txt as the
pathspec, so that whatever _other_ file that could have been
copied into it is still visible when the command works".

If you say "git log --name-status -C -C -- b.txt", you would be
back to square one.

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

* Re: Can git log <file> follow log of its origins?
  2008-01-29 21:21     ` Junio C Hamano
@ 2008-01-29 21:40       ` Max Pollard
  0 siblings, 0 replies; 7+ messages in thread
From: Max Pollard @ 2008-01-29 21:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


--- Junio C Hamano wrote:

> Max Pollard writes:
> 
> > ...  So -C -C is the answer, with --name-status or --stat to
> > actually show the result.
> 
> The real "answer" part in that example is not -C -C.  Obviously,
> you would need double-C aka --find-copies-harder, because you
> did not change a.txt when creating b.txt, so it is still needed.
> 
> But the essential part of the answer is "not giving b.txt as the
> pathspec, so that whatever _other_ file that could have been
> copied into it is still visible when the command works".
> 
> If you say "git log --name-status -C -C -- b.txt", you would be
> back to square one.

Aha, point taken.  In this case, looks like I can do:

    $ git log -C -C --full-diff --name-status/--stat/--summary -- b.txt

as Sean has suggested to get the copy information back.  Or are you saying that
even with "--full-diff" I can lose copy information in some cases?


MP



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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

end of thread, other threads:[~2008-01-29 21:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-29 17:48 Can git log <file> follow log of its origins? Max Pollard
2008-01-29 18:17 ` Sean
2008-01-29 19:47   ` Max Pollard
2008-01-29 20:03 ` Junio C Hamano
2008-01-29 21:07   ` Max Pollard
2008-01-29 21:21     ` Junio C Hamano
2008-01-29 21:40       ` Max Pollard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox