ahrefs/atd

atddiff: Print the git file path instead of temporary paths when using `git difftool`

Opened this issue · 0 comments

git difftool -x atddiff takes two versions of the same file and passes them to atddiff as temporary paths. This results in error messages pointing to nonexistent files.

Problems

  1. This produces spurious diffs although #377 offers a way to solve this.
  2. The actual location of the file isn't provided so it's hard for a human to go and check the error.

Here's a diff between two successive runs of git difftool -x atddiff that should produce the same result:

 Incompatibility in both directions:
-File "/var/folders/gt/kglng66x0wb5l42m3tp4806c0000gp/T//git-blob-tak22U/semgrep_output_v1.atd", line 489, characters 27-34
-File "/var/folders/gt/kglng66x0wb5l42m3tp4806c0000gp/T//git-blob-rDRrHB/semgrep_output_v1.atd", line 390, character 62 to line 438, character 24:
+File "/var/folders/gt/kglng66x0wb5l42m3tp4806c0000gp/T//git-blob-pcSZSS/semgrep_output_v1.atd", line 489, characters 27-34
+File "/var/folders/gt/kglng66x0wb5l42m3tp4806c0000gp/T//git-blob-wIEPak/semgrep_output_v1.atd", line 390, character 62 to line 438, character 24:

Proposed solution

Add a --git option that cause the output to be git-friendly. This could mean:

  • Consult the MERGED environment variable to obtain the path to the checked-out version of the file.
  • Don't print the path to the input files since they're temporary.
  • Print a git commit ID for each version of the file if possible (?)