[Insight-developers] GPU code ready for Gerrit

Kris Zygmunt krismz at sci.utah.edu
Wed Feb 8 13:21:32 EST 2012


>>
>> Ok,  I see what I did.  Everything was looking good after the git  
>> mv and modifying my files, but part of the changes included adding  
>> some files to the new directory that weren't there in Modules/GPU/ 
>> Common ie Modules/Core/GPUCommon/include/itkGPUFunctorBase.h .   
>> When I added these files to git, I got lazy and did
>>
>>    >>> git add Modules/Core/GPUCommon/include Modules/Core/ 
>> GPUCommon/src
>>
>> instead of just adding the specific files.  I did a git status  
>> afterwards, but did not notice then (though it's clear now) that  
>> this messed up the rest of the changes.  I can redo all of this, is  
>> it possible to overwrite my GPUCommon branch in gerrit?  Or supply  
>> a new patch that is what this patch should have been?
>>
>> -Kris
>>


Ok, so I created a brand new branch off of master, and carefully  
reapplied my changes, git mv, edit, only git add the specific files.   
And still it was looking like the old files were deleted and new ones  
created instead of being renamed and edited.  After much digging on  
stackoverflow.com and git man pages, I learned about the git  
similarity index which git diff uses to decide whether a change was a  
rename or a delete and create.  To observe this effect, try checking  
out my branch from gerrit using the command there:

      git fetch http://review.source.kitware.com/p/ITK refs/changes/ 
90/4190/1 && git checkout FETCH_HEAD -b GPUCommon

to see the changes as deletes and creates (as displayed on gerrit for  
instance), just do

      git log -p --stat

scroll down and notice that it says files like Modules/Core/GPUCommon/ 
include/itkGPUContextManager.h are new files.

Then run

     git log -M20 -p --stat

Now you will see a diff of the changes for Modules/Core/GPUCommon/ 
include/itkGPUContextManager.h and you will see that git lists the  
similarity index at 62%.  Setting -M20 in the git log command sets the  
similarity index threshold to 20%, allowing this change and others  
like it to appear as renames and edits.

So reviewers looking at the code after checking out from gerrit can  
control seeing the diffs.  Would it be worth changing this threshold  
for Gerrit as a whole?  I have found if I set the threshold to 0.001,  
git gets very confused and starts matching random files together.  So  
I'm not entirely sure what a good reasonable threshold is in the  
general case.

Basically, I have come to the conclusion that my initial gerrit patch  
is fine, the similarity index controls how git decides to display the  
change information.

HTH,
-Kris


More information about the Insight-developers mailing list