All of lore.kernel.org
 help / color / mirror / Atom feed
* Feature request: implement '--follow' option for `git blame`
@ 2015-04-06 12:12 KES
  2015-04-07 17:26 ` Fwd: " KES
  2015-04-08  2:48 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: KES @ 2015-04-06 12:12 UTC (permalink / raw)
  To: git

    $ pwd
    /data/mdi2/classes

    $ git blame -L22,+1 -- utils.js
    99b7a802 mdi2/utils.js (user 2015-03-26 21:54:57 +0200 22)  #comment

    $ git blame -L22,+1 99b7a802^ -- utils.js
    fatal: no such path mdi2/classes/utils.js in 99b7a802^

As you have noticed, the file were in different directory in that commit

    $ git blame -L22,+1 99b7a802^ -- ../utils.js
    c5105267 (user 2007-04-10 08:00:20 +0000 22)    #comment 2

Despite on doc

    The origin of lines is automatically followed across whole-file renames (currently there is no option to turn
           the rename-following off)

blame does not follow renames. Why?

**UPDATE:** Short answer

`git blame` follow renames but not for `git blame COMMIT^ -- <filename>`

But this is too hard to track file renames manually through bulk of renames and ton of history.
I think, this behaviour must be fixed to silently follow renames for `git blame COMMIT^ -- <filename>`. Or, at least, `--follow` must be implemented, so I can: `git blame --follow COMMIT^ -- <filename>`

The good answer is here:
http://stackoverflow.com/questions/29468273/why-git-blame-does-not-follow-renames

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

* Fwd: Feature request: implement '--follow' option for `git blame`
  2015-04-06 12:12 Feature request: implement '--follow' option for `git blame` KES
@ 2015-04-07 17:26 ` KES
  2015-04-08  2:48 ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: KES @ 2015-04-07 17:26 UTC (permalink / raw)
  To: git



-------- Пересылаемое сообщение  --------
06.04.2015, 15:12, "KES" <kes-kes@yandex.ua>:

    $ pwd
    /data/mdi2/classes

    $ git blame -L22,+1 -- utils.js
    99b7a802 mdi2/utils.js (user 2015-03-26 21:54:57 +0200 22)  #comment

    $ git blame -L22,+1 99b7a802^ -- utils.js
    fatal: no such path mdi2/classes/utils.js in 99b7a802^

As you have noticed, the file were in different directory in that commit

    $ git blame -L22,+1 99b7a802^ -- ../utils.js
    c5105267 (user 2007-04-10 08:00:20 +0000 22)    #comment 2

Despite on doc

    The origin of lines is automatically followed across whole-file renames (currently there is no option to turn
           the rename-following off)

blame does not follow renames. Why?

**UPDATE:** Short answer

`git blame` follow renames but not for `git blame COMMIT^ -- <filename>`

But this is too hard to track file renames manually through bulk of renames and ton of history.
I think, this behaviour must be fixed to silently follow renames for `git blame COMMIT^ -- <filename>`. Or, at least, `--follow` must be implemented, so I can: `git blame --follow COMMIT^ -- <filename>`

The good suggestion is here:
http://stackoverflow.com/questions/29468273/why-git-blame-does-not-follow-renames
-------- Завершение пересылаемого сообщения --------

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

* Re: Feature request: implement '--follow' option for `git blame`
  2015-04-06 12:12 Feature request: implement '--follow' option for `git blame` KES
  2015-04-07 17:26 ` Fwd: " KES
@ 2015-04-08  2:48 ` Junio C Hamano
  2015-04-10  6:40   ` Re[2]: " Eugen Konkov
  1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-04-08  2:48 UTC (permalink / raw)
  To: KES; +Cc: git

KES <kes-kes@yandex.ua> writes:

> **UPDATE:** Short answer
>
> `git blame` follow renames but not for `git blame COMMIT^ -- <filename>`

Suppose you have file A and file B in your version v1.0.

Six month down the road, the code was much refactored, and you do
not need the contents of these two files separately.  You have
removed A and B and much of what they had is now in file C.  That is
the current state.

    git blame -C HEAD -- C

may follow the contents from both just fine, but if you _were_
allowed to say

    git blame v1.0 -- C

what does it even mean?  C did not exist v1.0 at all.  Are you
asking to follow the contents of A back then, or B?  How did you
tell you meant A and not B when you told it C in this command?

"git blame" follows content movements, and never treats "renames" in
any special way, as it is a stupid thing to do to think a rename is
somehow special ;-)

The way you tell what content to start digging from to the command
from its command line is to give starting point commit (defaults to
HEAD but you may give COMMIT^ as your example) and the path in that
starting point.  As it does not make any sense to tell C to Git and
then magically make it guess you meant A in some cases and B in some
other.  If v1.0 did not have C, the only sensible thing to do is to
exit instead of making a guess (and without telling the user how it
guessed).

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

* Re[2]: Feature request: implement '--follow' option for `git blame`
  2015-04-08  2:48 ` Junio C Hamano
@ 2015-04-10  6:40   ` Eugen Konkov
  2015-04-13  5:32     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Eugen Konkov @ 2015-04-10  6:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: KES, git

Здравствуйте, Junio.

Вы писали 8 апреля 2015 г., 5:48:36:

JCH> KES <kes-kes@yandex.ua> writes:

>> **UPDATE:** Short answer

>> `git blame` follow renames but not for `git blame COMMIT^ -- <filename>`

JCH> Suppose you have file A and file B in your version v1.0.
....
As it does not make any sense to tell C to Git and
JCH> then magically make it guess you meant A in some cases and B in some
JCH> other.  If v1.0 did not have C, the only sensible thing to do is to
JCH> exit instead of making a guess (and without telling the user how it
JCH> guessed).

I agree with your complex example. But it will be great to guess in simple case, when in version v1.0 only one file A which were renamed into C half year later.

`git blame COMMIT^ -- C`

For complex example the clue will be if user supply line number he want to blame. So if user supply line 10 we follow A, if user supply 30 we follow B.
Simple and great =) (I mean usefull for people)

`git blame --line 10 COMMIT^ -- C`   
`git blame --line 30 COMMIT^ -- C`







-- 
С уважением,
 Eugen                          mailto:kes-kes@yandex.ru

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

* Re: Feature request: implement '--follow' option for `git blame`
  2015-04-10  6:40   ` Re[2]: " Eugen Konkov
@ 2015-04-13  5:32     ` Junio C Hamano
  2015-04-13 19:07       ` Re[2]: " Eugen Konkov
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-04-13  5:32 UTC (permalink / raw)
  To: Eugen Konkov; +Cc: KES, git

Eugen Konkov <kes-kes@yandex.ru> writes:

> I agree with your complex example.

Note that it is a norm, not anything complex, that we do not rename
a file wholesale.

> But it will be great to guess in simple case, when in version v1.0
> only one file A which were renamed into C half year later.

So you used to have A and somebody renamed that into C in the past.
The content of C in the current version is what you used to have in
A.

What should happen if you also have A, whose contents do not have
any relation to that old A, in today's code?

What should happen if you also used to have C, whose contents do not
have any relation to that old A or current C?

What happens if you added such random guessing and you were not so
familiar with the project history to know these unrelated A's and
C's that used to exist in the past?

Current Git _consistently_ behaves, even in the presense of anything
that can lead to confusing behaviour.  When you ask

    git blame OLD -- A

it does not matter if you have an unrelated A in the revision that
you happen to have checked out in your working tree (i.e. HEAD).
The above command line talks about the old revision OLD and A talks
about the path A in that old revision.

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

* Re[2]: Feature request: implement '--follow' option for `git blame`
  2015-04-13  5:32     ` Junio C Hamano
@ 2015-04-13 19:07       ` Eugen Konkov
  0 siblings, 0 replies; 6+ messages in thread
From: Eugen Konkov @ 2015-04-13 19:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: KES, git

Здравствуйте, Junio.

Вы писали 13 апреля 2015 г., 8:32:33:

JCH> Eugen Konkov <kes-kes@yandex.ru> writes:

>> I agree with your complex example.

JCH> Note that it is a norm, not anything complex, that we do not rename
JCH> a file wholesale.

>> But it will be great to guess in simple case, when in version v1.0
>> only one file A which were renamed into C half year later.

JCH> So you used to have A and somebody renamed that into C in the past.
JCH> The content of C in the current version is what you used to have in
JCH> A.

JCH> What should happen if you also have A, whose contents do not have
JCH> any relation to that old A, in today's code?

JCH> What should happen if you also used to have C, whose contents do not
JCH> have any relation to that old A or current C?

JCH> What happens if you added such random guessing and you were not so
JCH> familiar with the project history to know these unrelated A's and
JCH> C's that used to exist in the past?

JCH> Current Git _consistently_ behaves, even in the presense of anything
JCH> that can lead to confusing behaviour.  When you ask

JCH>     git blame OLD -- A

JCH> it does not matter if you have an unrelated A in the revision that
JCH> you happen to have checked out in your working tree (i.e. HEAD).
JCH> The above command line talks about the old revision OLD and A talks
JCH> about the path A in that old revision.


Yes. you are right. I do not think about these examples.


-- 
С уважением,
 Eugen                          mailto:kes-kes@yandex.ru

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

end of thread, other threads:[~2015-04-13 19:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 12:12 Feature request: implement '--follow' option for `git blame` KES
2015-04-07 17:26 ` Fwd: " KES
2015-04-08  2:48 ` Junio C Hamano
2015-04-10  6:40   ` Re[2]: " Eugen Konkov
2015-04-13  5:32     ` Junio C Hamano
2015-04-13 19:07       ` Re[2]: " Eugen Konkov

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.