2

Assuming a development history written in C (e.g. Linux kernel), how can I get all function names modified (not created/deleted, since this increases the complexity) by a commit? IMHO this question is pretty much from the same category as getting the files touched by a commit, with the only difference that the latter can be easily accomplished with git builtin functionality, while the former AFAIK not.

The solution I came up to so far is (assuming commit 300df508c8):

git show -U0 300df508c | grep -E -o '@@.*[^\ ]+\(' | grep -E -o '[^\ ]+\(' | sed 's/(//' | sort -u              
sdhci_omap_init_74_clocks
sdhci_omap_probe
sdhci_omap_set_ios
sdhci_omap_start_signal_voltage_switch

Did I miss anything and there is much simpler way to deal with this?

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
Eugeniu Rosca
  • 5,177
  • 16
  • 45
  • Actually, this seems almost too simple to me -- figuring out which function a line of code belongs to isn't really trivial, and essentially requires parsing C syntax. I'm not familiar enough with `grep`/`sed` to comment on how robust this solution is or isn't, but I'm reasonably sure that there are a lot of edge -- any maybe not so edgy -- cases it fails to cover. Very interesting question though, +1. – Linuxios Jun 05 '18 at 19:03
  • @Linuxios Correct, the proposed solution is an ugly workaround. However, since git always exposes the modified functions/structs/etc via `@@` markers, this means there is some git builtin functionality to identify those. Maybe it is exposed to the users somehow... I hope. – Eugeniu Rosca Jun 05 '18 at 19:17
  • Apparently, this was asked [a while ago](https://stackoverflow.com/questions/5721447/using-git-to-identify-all-modified-functions-in-a-revision), and the best answer given was also some `grep`/`awk` hacking. I've been doing some research and found nothing myself either, which makes me think that git doesn't actually expose this information... – Linuxios Jun 05 '18 at 19:31
  • @Linuxios https://stackoverflow.com/questions/5721447/using-git-to-identify-all-modified-functions-in-a-revision is very helpful. Thanks! – Eugeniu Rosca Jun 05 '18 at 19:36

0 Answers0