Ⅰ 如何查看文件修改歷史
有時候在比對代碼時,看到某些改動,但不清楚這個改動的作者和原因,也不知道對應的BUG號,也就是說無從查到這些改動的具體原因了~
【注】:某個文件的改動是有限次的,而且每次代碼修改的提交都會有commit描述,我們可以從這里進行入手;
一、切換到目錄
首先切換到要查看的文件所在的目錄:
cd packages/apps/Mms/src/com/android/mms/ui/
二、git log --pretty
然後使用下面的命令可列出文件的所有改動歷史,注意,這里著眼於具體的一個文件,而不是git庫,如果是庫,那改動可多了去了~
git log --pretty=oneline 文件名
如:
root@ubuntu:android_src/packages/apps/Mms/src/com/android/mms/ui# git log --pretty=oneline MessageItem.java
fix to process force close when empty address contained in card
display for 1970-1-1
HREF#13954 receive, store, and display wap push
HREF#16265_uim_show_time_error
fix xxxx
Fix ANR from calling Contact.get()
Fix missing From field
fix bug 2112925: don't display zip file garbage content in MMS.
Don't always show sent timestamp
Don't show Anonymous as the MMS sender
add search capability
Remove all references to ContactInfoCache except those in Contact.
Begin moving all conversation data behind a data model with a cache.
Begin adding UI unit tests to the Mms app.
Stop requiring a Context to be passed in to ContactInfoCache.
auto import from //branches/cupcake_rel/...@138607
auto import from //depot/cupcake/@135843
auto import from //depot/cupcake/@135843
auto import from //depot/cupcake/@132589
auto import from //depot/cupcake/@137055
auto import from //branches/cupcake/...@132276
auto import from //branches/cupcake/...@131421
Code drop from //branches/cupcake/...@124589
Initial Contribution
三、git show
如上所示,列印出來的就是針對文件MessageItem.java的所有的改動歷史,每一行最前面的那一長串數字就是每次提交形成的哈希值,接下來使用git show即可顯示具體的某次的改動的修改~
git show
結果如下:
root@ubuntu:/android_src/packages/apps/Mms/src/com/android/mms/ui# git show
commit
Author: 某某某 <某某某的郵箱>
Date: Thu Jan 6 01:50:31 2011 +0800
修改的描述(是該代碼commit時所填)
Signed-off-by: 某某某 <某某某的郵箱>
diff --git a/src/com/android/mms/ui/MessageItem.java b/src/com/android/mms/ui/MessageItem.java
index 0a0c4b7..55c3b27 100644
--- a/src/com/android/mms/ui/MessageItem.java
+++ b/src/com/android/mms/ui/MessageItem.java
+
+ 列出具體的改動
-
-
這樣就可以知道是誰做了修改,以及具體的修改代碼~
那接下來不管是直接去找他交流還是研究代碼,都有依據了~