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_blame [2018/05/21 09:48] – [Basic usage] rpjdaygit_blame [2019/03/07 14:04] (current) – [Some useful config options] rpjday
Line 2: Line 2:
  
 Most useful variations of ''git blame'', using examples from Linux kernel source. Most useful variations of ''git blame'', using examples from Linux kernel source.
 +
 +From ''man git-annotate'':
 +
 +<code>
 +The only difference between this command and git-blame(1) is
 +that they use slightly different output formats, and this
 +command exists only for backward compatibility to support
 +existing scripts, and provide a more familiar command name for
 +people coming from other SCM systems.
 +</code>
  
 ===== Basic usage ===== ===== Basic usage =====
Line 10: Line 20:
 $ git blame Makefile $ git blame Makefile
 b24413180f560 (Greg Kroah-Hartman       2017-11-01 15:07:57 +0100    1) # SPDX-License-Identifier: GPL-2.0 b24413180f560 (Greg Kroah-Hartman       2017-11-01 15:07:57 +0100    1) # SPDX-License-Identifier: GPL-2.0
-c517d838eb7d0 (Linus Torvalds           2015-02-22 18:21:14 -0800    2) VERSION = 4 +bfeffd1552837 (Linus Torvalds           2019-01-06 17:08:20 -0800    2) VERSION = 5 
-60cc43fc88842 (Linus Torvalds           2018-04-15 18:24:20 -0700    3) PATCHLEVEL = 17+bfeffd1552837 (Linus Torvalds           2019-01-06 17:08:20 -0800    3) PATCHLEVEL = 0
 55922c9d1b84b (Linus Torvalds           2011-05-29 17:43:36 -0700    4) SUBLEVEL = 0 55922c9d1b84b (Linus Torvalds           2011-05-29 17:43:36 -0700    4) SUBLEVEL = 0
-67b8d5c708122 (Linus Torvalds           2018-05-13 16:15:17 -0700    5) EXTRAVERSION = -rc5 +d13937116f1e8 (Linus Torvalds           2019-02-10 14:42:20 -0800    5) EXTRAVERSION = -rc6 
-75bc37fefc447 (Linus Torvalds           2018-05-06 16:57:38 -1000    6) NAME = Merciless Moray+2e6e902d18502 (Linus Torvalds           2018-11-25 14:19:31 -0800    6) NAME = Shy Crocodile
 ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700    7)  ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700    7) 
 ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700    8) # *DOCUMENTATION* ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700    8) # *DOCUMENTATION*
Line 21: Line 31:
 ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   11) # Comments in this file are targeted only to the developer, do not ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   11) # Comments in this file are targeted only to the developer, do not
 ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   12) # expect to learn how to build the kernel reading this file. ^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   12) # expect to learn how to build the kernel reading this file.
-^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   13) +^1da177e4c3f4 (Linus Torvalds           2005-04-16 15:20:36 -0700   13)
 ... snip ... ... snip ...
 </code> </code>
  
-and once you determine the offending line, you can examine its encompassing commit:+You can also use ''-L'' for //line limiting//:
  
 <code> <code>
-$ git show b24413180f560 +$ git blame -L 1420,1430 Makefile 
-commit b24413180f5600bcb3bb70fbed5cf186b60864bd +433db3e260bc8 (Vinícius Tinti   2017-04-24 13:04:58 -0700 1420)         @echo                    (requires compiler support for LLVM assembly generation)' 
-AuthorGreg Kroah-Hartman <gregkh@linuxfoundation.org> +6271897978072 (Joe Perches      2010-01-13 09:31:44 -0800 1421)         @echo  '  dir/file.lst    - Build specified mixed source/assembly target only' 
-Date  Wed Nov 1 15:07:57 2017 +0100+6271897978072 (Joe Perches      2010-01-13 09:31:44 -0800 1422)         @echo                    (requires a recent binutils and recent build (System.map))' 
 +155ad605b3c9c (Sam Ravnborg     2005-07-07 17:56:08 -0700 1423)         @echo  dir/file.ko     - Build module including final link'
  
-    License cleanupadd SPDX GPL-2.0 license identifier to files with no license+   (oh, look ...) 
 + 
 +c4d5ee67ce265 (Robert P. J. Day 2009-04-24 12:35:23 -0400 1424)         @echo  modules_prepare - Set up for building external modules' 
 +^1da177e4c3f4 (Linus Torvalds   2005-04-16 15:20:36 -0700 1425)         @echo  tags/TAGS       - Generate tags file for editors' 
 +^1da177e4c3f4 (Linus Torvalds   2005-04-16 15:20:36 -0700 1426)         @echo  cscope          - Generate cscope index' 
 +f4ed1009fcea8 (Jianbin Kang     2011-01-14 20:07:05 +0800 1427)         @echo  gtags           Generate GNU GLOBAL index' 
 +3f1d9a6cec011 (Michal Marek     2014-07-11 15:57:24 +0200 1428)         @echo  kernelrelease   - Output the release version string (use with make -s)' 
 +3f1d9a6cec011 (Michal Marek     2014-07-11 15:57:24 +0200 1429)         @echo  kernelversion   - Output the version stored in Makefile (use with make -s)' 
 +3f1d9a6cec011 (Michal Marek     2014-07-11 15:57:24 +0200 1430)         @echo  image_name      - Output the image name (use with make -s)' 
 +
 +</code> 
 + 
 +Once you determine the offending line, you can examine its encompassing commit with ''git show'': 
 + 
 +<code> 
 +$ git show c4d5ee67ce265 
 +commit c4d5ee67ce26503d7eaf2aca5bb13c58e89d1be8 
 +Author: Robert P. J. Day <rpjday@crashcourse.ca> 
 +Date:   Fri Apr 24 12:35:23 2009 -0400 
 + 
 +    kbuild: "make prepare" should be "make modules_prepare"
          
-    Many source files in the tree are missing licensing information, which +    Correct the Makefile help text to read "make modules_prepare".
-    makes it harder for compliance tools to determine the correct license.+
          
-    ... snip ...+    Signed-off-by: Robert PJDay <rpjday@crashcourse.ca> 
 +    Signed-off-by: Sam Ravnborg <sam@ravnborg.org> 
 + 
 +diff --git a/Makefile b/Makefile 
 +index b309fca4b944..b18afad2e100 100644 
 +--- a/Makefile 
 ++++ b/Makefile 
 +@@ -1293,7 +1293,7 @@ help: 
 +        @echo  '  dir/            - Build all files in dir and below' 
 +        @echo  '  dir/file.[ois]  - Build specified target only' 
 +        @echo  '  dir/file.ko     - Build module including final link' 
 +-       @echo  prepare         - Set up for building external modules' 
 ++       @echo  modules_prepare - Set up for building external modules' 
 +        @echo  '  tags/TAGS       - Generate tags file for editors' 
 +        @echo  '  cscope          - Generate cscope index' 
 +        @echo  '  kernelrelease   - Output the release version string' 
 +</code> 
 +===== Some useful command-line options ===== 
 + 
 +A //very// small subset of options for ''git blame'' (there are far more): 
 + 
 +<code> 
 +-L <start>,<end>, -L :<funcname> 
 +    Annotate only the given line range. May be specified multiple times. 
 +    Overlapping ranges are allowed. 
 + 
 +-s 
 +    Suppress the author name and timestamp from the output. 
 + 
 +-e, --show-email 
 +    Show the author email instead of author name (Default: off). 
 +    This can also be controlled via the ''blame.showEmail'' config option. 
 +</code> 
 + 
 +===== Some useful config options ===== 
 + 
 +From ''man git-config'': 
 + 
 +<code> 
 +blame.blankBoundary 
 +    Show blank commit object name for boundary commits in git- 
 +    blame(1). This option defaults to false. 
 + 
 +blame.coloring 
 +    This determines the coloring scheme to be applied to blame 
 +    output. It can be repeatedLines, highlightRecent, or none 
 +    which is the default. 
 + 
 +blame.date 
 +    Specifies the format used to output dates in git-blame(1). 
 +    If unset the iso format is used. For supported values, see 
 +    the discussion of the --date option at git-log(1). 
 + 
 +blame.showEmail 
 +    Show the author email instead of author name in git- 
 +    blame(1). This option defaults to false. 
 +    blame.showRoot 
 +    Do not treat root commits as boundaries in git-blame(1). 
 +    This option defaults to false.
 </code> </code>
  • git_blame.1526896101.txt.gz
  • Last modified: 2018/05/21 09:48
  • by rpjday