summaryrefslogtreecommitdiffstats
path: root/articles/some_quick_git_diff_tips.org
blob: 0bf78a1dc5d84f8ccc14b6ce2b0142fee8cc50bd (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#+TITLE:
#+STARTUP: showall

* Some quick git diff tips                           :org:lisp:config:
  :PROPERTIES:
  :PUBDATE:  <2013-08-11 Sun 0:54>
  :END:

A couple of quick tips.  As you possibly know you can specify some
options to be used for diffs (and other things) per file type.  The
one I'm interested in is the function name.

** For org-mode

   The primary way of identifying which part of an org-mode document
   a change occurs in seems to me to be the heading.  So, in your
   ~$HOME/.gitconfig~ put:

   #+BEGIN_SRC conf
     [diff "org"]
           xfuncname = "^\\*+.*"
   #+END_SRC

   Which should show any lines starting with one or more ~*~
   characters.  And then in ~$XDG_CONFIG_HOME/git/attributes~ or
   ~$HOME/.config/git/attributes~ put:

   #+BEGIN_EXAMPLE
     ,*.org   diff=org
   #+END_EXAMPLE

** For lisp and lisp-like langauges

   For anything that resembles lisp (so Common Lisp, Emacs Lisp, Hy,
   scheme, etc.) I would think that the easiest thing to do is just
   see the closes top-level form.  So, in your ~$HOME/.gitconfig~ put:

   #+BEGIN_SRC conf
     [diff "lisp"]
           xfuncname = "^\\([^ ]+ [^ ]+"
   #+END_SRC

   Which should show the opening parenthesis and the first two words.
   For example:

   #+BEGIN_EXAMPLE
     (defun some-function-name
     (defclass my-awesome-class
     (define-route this-strange-route
   #+END_EXAMPLE

   And then put in your ~$XDG_CONFIG_HOME/git/attributes~ or
   ~$HOME/.config/git/attributes~:

   #+BEGIN_EXAMPLE
     ,*.lisp  diff=lisp
     ,*.el    diff=lisp
     ,*.hy    diff=lisp
     ,*.scm   diff=lisp
   #+END_EXAMPLE

   And possibly any other lisp-like language files you can think of.