Here is a magic chant to list functions within a git diff
*
git diff | \
grep -E '^(@@)' | \
grep "(" | \
sed 's/@@.*@@//' | \
sed 's/(.*//' | \
awk -F " " '{print $NF}' | \
uniq
…and what it does is…
- Picks the current diff,
- next picks only lines with “hunk-headers” ,
- next picks only lines with opening parenthesis (as potentially containing function names),
- next ignores the hunk headers,
- next ignores the text after the opening parenthesis,
- next picks only the word immediately before the opening parenthesis,
- and lastly ignores multiple occurrences of the same word in the list.
Voila! you have a list of functions being modified by the current git diff
.
* Verified using git version 2.7.4
on Ubuntu 16.04 running bash.