User Tools

Site Tools


git_diff

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_diff [2019/02/20 14:12]
rpjday [Popular options with git diff]
git_diff [2019/03/01 11:58] (current)
rpjday
Line 19: Line 19:
 ===== Output of "git diff" ===== ===== Output of "git diff" =====
  
-Default output format is the patch-style difference to change from the first argument to the second ​arguent:+Default output format is the patch-style difference to change from the first argument to the second ​argument:
  
 <​code>​ <​code>​
Line 81: Line 81:
 ===== Path limiting ===== ===== Path limiting =====
  
-Compare only part of the tree-ish objects:+Compare only //part// of the tree-ish objects:
  
 <​code>​ <​code>​
-$ git diff v4.19 v4.20 -- scripts +$ git diff v4.19 v4.20 -- scripts/dtc/ 
-diff --git a/scripts/Kbuild.include ​b/scripts/Kbuild.include +diff --git a/scripts/dtc/​Makefile ​b/scripts/dtc/​Makefile 
-index ce53639a864a..3d09844405c9 ​100644 +index 1c943e03eaf2..056d5da6c477 ​100644 
---- a/scripts/Kbuild.include +--- a/scripts/dtc/​Makefile 
-+++ b/scripts/Kbuild.include ++++ b/scripts/dtc/​Makefile 
-@@ -138,17 +138,@@ cc-option-yn = $(call try-run,\ +@@ -1,+1,@@ 
- cc-disable-warning = $(call try-run,\ + # SPDX-License-Identifier: GPL-2.0 
-        $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "​$$TMP",​-Wno-$(strip $(1)))+ # scripts/dtc makefile
    
--# cc-name +-hostprogs-y    := dtc 
--# Expands to either gcc or clang ++hostprogs-$(CONFIG_DTC:= dtc 
--cc-name = $(shell $(CC) -v 2>&1 | grep -q "clang version"​ && echo clang || echo gcc+ always ​        := $(hostprogs-y)
-+
- # cc-version +
- ​cc-version ​= $(shell $(CONFIG_SHELL) $(srctree)/​scripts/​gcc-version.sh $(CC))+
    
--# cc-fullversion + dtc-objs       := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
--cc-fullversion = $(shell $(CONFIG_SHELL) \ +
-      ​$(srctree)/​scripts/​gcc-version.sh -p $(CC)) +
-+
- # cc-ifversion +
- # Usage ​EXTRA_CFLAGS +$(call cc-ifversion,​ -lt, 0402, -O1) +
- ​cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))+
  
 ... lots of output snipped ... ... lots of output snipped ...
Line 116: Line 107:
  
 <​code>​ <​code>​
-$ git diff v4.19 v4.20 -- scripts | wc -l +$ git diff v4.19 v4.20 -- scripts/dtc/ | wc -l 
-3375+2097
 $ $
 </​code>​ </​code>​
- 
  
 ==== --stat ==== ==== --stat ====
 +
 +Normalized histogram:
  
 <​code>​ <​code>​
-$ git diff v4.14 v4.15 --stat -- scripts/dtc/+$ git diff v4.19 v4.20 --stat -- scripts/
  ​scripts/​dtc/​checks.c ​                | 291 +++++++++++++++++++++++-  ​scripts/​dtc/​checks.c ​                | 291 +++++++++++++++++++++++-
  ​scripts/​dtc/​dtc-lexer.lex.c_shipped ​ |  10 +-  ​scripts/​dtc/​dtc-lexer.lex.c_shipped ​ |  10 +-
Line 171: Line 163:
 </​code>​ </​code>​
  
-==== Whitespace issues ====+===== Comparing two arbitrary files ===== 
 + 
 +General form: 
 + 
 +<​code>​ 
 +$ git diff <​commit1>:<​file2>​ <​commit2>:<​file2>​ 
 +</​code>​ 
 + 
 +For example, after a rename: 
 + 
 +<​code>​ 
 +$ git diff v4.18:​Makefile v4.19:​makefile 
 +</​code>​ 
 + 
 +===== Using "​.."​ and "​..."​ ===== 
 + 
 +==== DESCRIPTION ==== 
 + 
 +<​code>​ 
 +git diff [<​options>​] <​commit>​ <​commit>​ [--] [<​path>​...] 
 +    This is to view the changes between two arbitrary <​commit>​. 
 + 
 +git diff [<​options>​] <​commit>​..<​commit>​ [--] [<​path>​...] 
 +    This is synonymous to the previous form. If <​commit>​ on one 
 +    side is omitted, it will have the same effect as using HEAD 
 +    instead. 
 + 
 +git diff [<​options>​] <​commit>​...<​commit>​ [--] [<​path>​...] 
 +    This form is to view the changes on the branch containing 
 +    and up to the second <​commit>,​ starting at a common 
 +    ancestor of both <​commit>​. "git diff A...B" is equivalent 
 +    to "git diff $(git merge-base A B) B". You can omit any one 
 +    of <​commit>,​ which has the same effect as using HEAD 
 +    instead. 
 +</​code>​ 
 + 
 +==== The initial branches to compare ==== 
 + 
 +<​code>​ 
 +$ git show fix_readme 
 +commit 5f1992a4245c301ed5e556f4ef47153981a67820 (fix_readme) 
 +Author: Robert P. J. Day <​rpjday@crashcourse.ca>​ 
 +Date:   Fri Mar 1 05:27:13 2019 -0500 
 + 
 +    fix readme 
 + 
 +diff --git a/​README.asc b/​README.asc 
 +index fa40bad..b7f3816 100644 
 +--- a/​README.asc 
 ++++ b/​README.asc 
 +@@ -1,3 +1,4 @@ 
 ++stuff in README.asc 
 + = Pro Git, Second Edition 
 +  
 + ​Welcome to the second edition of the Pro Git book. 
 +</​code>​ 
 + 
 +<​code>​ 
 +$ git show fix_license  
 +commit 65633ac0f606e70db50460502989a7a74dca8e20 (fix_license) 
 +Author: Robert P. J. Day <​rpjday@crashcourse.ca>​ 
 +Date:   Fri Mar 1 05:26:23 2019 -0500 
 + 
 +    fix license 
 + 
 +diff --git a/​LICENSE.asc b/​LICENSE.asc 
 +index 81f2824..19f935b 100644 
 +--- a/​LICENSE.asc 
 ++++ b/​LICENSE.asc 
 +@@ -1 +1,2 @@ 
 ++stuff in LICENSE.asc 
 + This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://​creativecommons.org/​licenses/​by-nc-sa/​3.0/​ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 
 +</​code>​ 
 + 
 +==== The basic comparison ==== 
 + 
 +<​code>​ 
 +$ git diff fix_readme fix_license 
 +diff --git a/​LICENSE.asc b/​LICENSE.asc 
 +index 81f2824..19f935b 100644 
 +--- a/​LICENSE.asc 
 ++++ b/​LICENSE.asc 
 +@@ -1 +1,2 @@ 
 ++stuff in LICENSE.asc 
 + This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://​creativecommons.org/​licenses/​by-nc-sa/​3.0/​ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 
 +diff --git a/​README.asc b/​README.asc 
 +index b7f3816..fa40bad 100644 
 +--- a/​README.asc 
 ++++ b/​README.asc 
 +@@ -1,4 +1,3 @@ 
 +-stuff in README.asc 
 + = Pro Git, Second Edition 
 +  
 + ​Welcome to the second edition of the Pro Git book. 
 +</​code>​ 
 + 
 +Using ''​..''​ means exactly the same thing: 
 + 
 +<​code>​ 
 +$ git diff fix_readme..fix_license 
 +diff --git a/​LICENSE.asc b/​LICENSE.asc 
 +index 81f2824..19f935b 100644 
 +--- a/​LICENSE.asc 
 ++++ b/​LICENSE.asc 
 +@@ -1 +1,2 @@ 
 ++stuff in LICENSE.asc 
 + This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://​creativecommons.org/​licenses/​by-nc-sa/​3.0/​ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 
 +diff --git a/​README.asc b/​README.asc 
 +index b7f3816..fa40bad 100644 
 +--- a/​README.asc 
 ++++ b/​README.asc 
 +@@ -1,4 +1,3 @@ 
 +-stuff in README.asc 
 + = Pro Git, Second Edition 
 +  
 + ​Welcome to the second edition of the Pro Git book. 
 +</​code>​ 
 + 
 +However, using ''​%%...%%''​ means something different:​ 
 + 
 +<​code>​ 
 +$ git diff fix_license...fix_readme 
 +diff --git a/​README.asc b/​README.asc 
 +index fa40bad..b7f3816 100644 
 +--- a/​README.asc 
 ++++ b/​README.asc 
 +@@ -1,3 +1,4 @@ 
 ++stuff in README.asc 
 + = Pro Git, Second Edition 
 +  
 + ​Welcome to the second edition of the Pro Git book. 
 +</​code>​ 
 +===== Whitespace issues ====
 + 
 +Just scratching the surface:
  
 <​code>​ <​code>​
git_diff.1550671929.txt.gz · Last modified: 2019/02/20 14:12 by rpjday