Ake Koomsin

TIL There Is a Tool Named Diffstat

Right now I am working on my thesis which is “Specializing Operating System Kernels using a Scripting Language”. A part of my work is porting the LuaJIT compiler into the FreeBSD x86 kernel.

When I was writing my thesis, I was asked to show modification information in the thesis. They are number of lines added, numbers of lines removed, number of lines changed. I know that diff exists. However, I need a summary of information produced by it.

My Google kung fu led me to diffstat. It is very simple to use:

diff -u /path/to/luajit_kernel/src /path/to/luajit/src | diffstat -f0

The result is shown below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
 ./lib_syscall.c                                       |only
 ./lib_util.c                                          |only
 /Users/peace/sources/LuaJIT-2.0.3/src/lauxlib.h       |   13     2 + 11 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_aux.c       |   23     6 + 17 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_base.c      |   59     20 +    39 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_debug.c     |   36     17 +    19 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_init.c      |   11     0 + 11 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_package.c   |   43     0 + 43 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lib_string.c    |   40     0 + 40 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_alloc.c      |   18     2 + 16 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_asm.c        |   18     0 + 18 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_asm_x86.h    |   46     0 + 46 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_bc.h         |  127     1 + 126 -   0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_ccallback.c  |    4     0 + 4 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_def.h        |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_dispatch.c   |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_dispatch.h   |   19     1 + 18 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_err.c        |   12     0 + 12 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_errmsg.h     |    6     0 + 6 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_ffrecord.c   |  154     0 + 154 -   0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_ir.c         |   25     0 + 25 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_ir.h         |  143     1 + 142 -   0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_ircall.h     |   37     0 + 37 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_lex.c        |    5     0 + 5 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_lib.c        |    7     0 + 7 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_lib.h        |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_load.c       |    6     0 + 6 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_mcode.c      |   59     1 + 58 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_meta.c       |    4     0 + 4 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_obj.h        |   38     3 + 35 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_opt_fold.c   | 1195     551 +   644 -   0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_opt_loop.c   |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_opt_narrow.c |   70     0 + 70 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_parse.c      |   99     3 + 96 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_record.c     |   42     0 + 42 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_snap.c       |    7     0 + 7 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_state.c      |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_str.c        |    2     0 + 2 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_strscan.c    |   91     1 + 90 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_tab.c        |   33     0 + 33 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_trace.c      |    2     1 + 1 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_vm.h         |   33     0 + 33 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_vmevent.c    |    6     0 + 6 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lj_vmmath.c     |   67     0 + 67 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lua.h           |    6     1 + 5 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/luaconf.h       |   30     0 + 30 -    0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/lualib.h        |    6     0 + 6 - 0 !
 /Users/peace/sources/LuaJIT-2.0.3/src/vm_x86.dasc     |  452     34 +    418 -   0 !
 51 files changed, 645 insertions(+), 2459 deletions(-)