Hi Ray,

On 03/08/21 13:26, Ni, Ray wrote:
> 
> 
>> -----Original Message-----
>> From: Rebecca Cran <[email protected]>
>> Sent: Monday, March 8, 2021 10:43 AM
>> To: Ni, Ray <[email protected]>; [email protected]; 
>> [email protected]; [email protected]
>> Subject: Re: 回复: [edk2-devel] New Year, New PR Thread
>>
>> It was discussed in the recent Community Meeting last week.
>>
>> Now that the stable tag has been created, I believe it's moving forward
>> as the highest priority task (behind, for example, converting the line
>> endings from Windows to UNIX).
> 
> Converting the line endings will cause "git blame" useless because
> every line of code now is changed by someone who changes the line endings.

it doesn't make git-blame useless, just a bit less comfortable.

For example, with master being at 59a3ccb09e7a, assume you run:

  git blame -- BaseTools/Scripts/ConvertFceToStructurePcd.py

and you get an output snippet like

ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 528)     for i in 
range(len(info_list)-1,-1,-1):
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 529)       if 
len(info_list[i]) == 0:
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 530)         
info_list.remove(info_list[i])
d79b63c64f58a (Leif Lindholm    2019-09-18 22:41:08 +0100 531)     for i in 
(inf_list, title_all, header_list):
d79b63c64f58a (Leif Lindholm    2019-09-18 22:41:08 +0100 532)       i.sort()
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 533)     return 
keys,title_all,info_list,header_list,inf_list

Assume you are curious about the "sort" invocation, so you run

  git show d79b63c64f58a

But that only tells you:

commit d79b63c64f58ac47e570e8d2e9b090525f7e8efd
Author: Leif Lindholm <[email protected]>
Date:   Wed Sep 18 22:41:08 2019 +0100

    BaseTools: correct line endings for ConvertFce Python script
    
    Cc: Bob Feng <[email protected]>
    Cc: Liming Gao <[email protected]>
    Signed-off-by: Leif Lindholm <[email protected]>
    Reviewed-by: Bob Feng <[email protected]>
    Reviewed-by: Liming Gao <[email protected]>
    Acked-by: Ard Biesheuvel <[email protected]>
    Reviewed-by: Philippe Mathieu-Daude <[email protected]>

So what can we do in this case?

Simple: run git blame "as of the direct parent" of commit d79b63c64f58a:

  git blame d79b63c64f58a^ -- BaseTools/Scripts/ConvertFceToStructurePcd.py

Then you get:

ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 506)     for i in 
range(len(info_list)-1,-1,-1):
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 507)       if 
len(info_list[i]) == 0:
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 508)         
info_list.remove(info_list[i])
cfb29d2bda57b (Fan, ZhijuX      2019-04-15 16:55:01 +0800 509)     for i in 
(inf_list, title_all, header_list):
cfb29d2bda57b (Fan, ZhijuX      2019-04-15 16:55:01 +0800 510)       i.sort()
ef529e6ab7c31 (Liming Gao       2018-07-17 11:42:21 +0800 511)     return 
keys,title_all,info_list,header_list,inf_list

And this time you can run:

  git show cfb29d2bda57b

which gives you the commit you are after:

commit cfb29d2bda57baa344bded40cf12af81b13e8a40
Author: Fan, ZhijuX <[email protected]>
Date:   Mon Apr 15 16:55:01 2019 +0800

    BaseTools:update ConvertFceToStructurePcd.py with the char order PCD name.
    
    BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1718
    
    BaseTools\Scripts\ConvertFceToStructurePcd.py
    Update script to sort the PCD order base on PcdName,
    then base on Pcd field name.
    
    Cc: Liming Gao <[email protected]>
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Zhiju.Fan <[email protected]>
    Reviewed-by: Liming Gao <[email protected]>

This command sequence can be repeated as many times as necessary. git-blame 
gives you a commit, run git-show to check the commit. If the commit is not 
relevant (i.e., you need to run earlier), re-run git-blame on the same file, 
but at the *direct parent commit* of the previously used commit, using the 
caret (^) notation.

It also works if files are renamed (or code is moved between files). In that 
case, "git-show" will tell you the original file name, so when you run 
git-blame on the parent commit, you can use the original file name too.

Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#72536): https://edk2.groups.io/g/devel/message/72536
Mute This Topic: https://groups.io/mt/81164385/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to