如何使用 "P4 diff" 命令在代码差异中获取 C 函数名称?

How to get C function name in code diff using "P4 diff" command?

在 perforce (P4) 命令行中是否有任何等效选项来获取代码差异中的函数名称? 我需要在生成的差异文件中有对应于每个代码差异段的函数名称。 这将帮助我使用 CTAGS 从代码差异导航到函数调用。

请注意 p4 help diff 中的这段摘录:

If the environment variable $P4DIFF is set, the specified diff program is launched in place of the default Perforce client diff.

碰巧如果 P4DIFF 包含空格,p4 会将其视为带参数的可执行文件名称,因此您可以这样做:

export P4DIFF="diff --show-c-function"

(或您使用的任何控制台 shell 的等效项)然后当您 运行 p4 diff 时,您应该看到基于 C 的代码的函数名称。