afnanenayet / diffsitter

A tree-sitter based AST difftool to get meaningful semantic diffs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] crash when comparing c++ files between git tags

scarf005 opened this issue · comments

commented

Describe the bug

diffsitter crashes when comparing c++ files between git tags like git difftool tagname^ tagname.

To Reproduce

  1. set .git/config like in https://github.com/afnanenayet/diffsitter#git-integration
[diff]
        tool = diffsitter
[difftool]
        prompt = false
[difftool "diffsitter"]
        cmd = diffsitter "$LOCAL" "$REMOTE" --debug
  1. create a tag to commit.
  2. run git difftool tagname^ tagname

Expected behavior
it does not crash.

Log output/screenshots

Details
 !  ~/r/c/Monoclysm   Mono  git difftool filter^ filter -- --debug                                                                                                                                              2023년 04월 28일 (금) 오전 12시 50분 37초 ~/r/c/Monoclysm   Mono  diffsitter filter^ filter                                                                                                                                                               2023년 04월 28일 (금) 오전 12시 50분 39초Error: Unsupported file type with no fallback command specified.
 !  ~/r/c/Monoclysm   Mono  diffsitter filter^ filter^C                                                                                                                                                         2023년 04월 28일 (금) 오전 12시 50분 46초 !  ~/r/c/Monoclysm   Mono  code .git/config                                                                                                                                                                    2023년 04월 28일 (금) 오전 12시 50분 46초 ~/r/c/Monoclysm   Mono  git difftool filter^ filter                                                                                                                                                     116ms  2023년 04월 28일 (금) 오전 12시 51분 13초 2023-04-27T15:51:22.492Z DEBUG diffsitter > Checking if /tmp/git-blob-6VqWI8/Cataclysm.sln can be parsed
 2023-04-27T15:51:22.492Z ERROR diffsitter::parse > Was not able to find a language string for extension sln
 2023-04-27T15:51:22.492Z ERROR diffsitter        > Extension sln not supported
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.502Z DEBUG diffsitter > Checking if /dev/null can be parsed
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.514Z DEBUG diffsitter > Checking if /tmp/git-blob-hnWfJ3/distribute.bat can be parsed
 2023-04-27T15:51:22.514Z ERROR diffsitter::parse > Was not able to find a language string for extension bat
 2023-04-27T15:51:22.514Z ERROR diffsitter        > Extension bat not supported
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.524Z DEBUG diffsitter > Checking if /tmp/git-blob-mG4MTa/calendar.cpp can be parsed
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.524Z DEBUG diffsitter        > Checking if /tmp/git-blob-L5Iuoo/calendar.cpp can be parsed
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.524Z DEBUG diffsitter        > Extensions for both input files are supported
 2023-04-27T15:51:22.524Z DEBUG diffsitter        > Reading /tmp/git-blob-mG4MTa/calendar.cpp to string
 2023-04-27T15:51:22.524Z INFO  diffsitter        > Will deduce filetype from file extension
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.524Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.524Z DEBUG diffsitter::parse > Constructed parser
 2023-04-27T15:51:22.527Z DEBUG diffsitter::parse > Parsed AST
 2023-04-27T15:51:22.527Z INFO  TimerFinished     > parse::parse_file(), Elapsed=3.199784ms
 2023-04-27T15:51:22.528Z DEBUG diffsitter        > Reading /tmp/git-blob-L5Iuoo/calendar.cpp to string
 2023-04-27T15:51:22.528Z INFO  diffsitter        > Will deduce filetype from file extension
 2023-04-27T15:51:22.528Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.528Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.528Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.528Z DEBUG diffsitter::parse > Constructed parser
 2023-04-27T15:51:22.530Z DEBUG diffsitter::parse > Parsed AST
 2023-04-27T15:51:22.530Z INFO  TimerFinished     > parse::parse_file(), Elapsed=2.764685ms
 2023-04-27T15:51:22.531Z INFO  TimerFinished     > ast::from_ts_tree(), Elapsed=972.108µs
 2023-04-27T15:51:22.533Z INFO  TimerFinished     > ast::process(), Elapsed=2.665082ms
 2023-04-27T15:51:22.534Z INFO  TimerFinished     > ast::from_ts_tree(), Elapsed=891.149µs
 2023-04-27T15:51:22.536Z INFO  TimerFinished     > ast::process(), Elapsed=2.527398ms
 2023-04-27T15:51:22.536Z INFO  TimerFinished     > diff::compute_edit_script(), Elapsed=105.815µs
 2023-04-27T15:51:22.536Z INFO  diffsitter::formatting > Detected terminal width: 253 columns
 2023-04-27T15:51:22.536Z INFO  diffsitter::formatting > Using stack style horizontal for title
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing hunk (lines 234 - 238)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Title string has length of 11
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 234
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 234
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 235
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 235
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 236
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 236
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 237
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 237
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 238
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 238
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End hunk (lines 234 - 238)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing hunk (lines 240 - 241)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Title string has length of 11
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 240
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 240
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 241
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 241
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End hunk (lines 240 - 241)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing hunk (lines 243 - 247)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Title string has length of 11
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 243
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 243
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 244
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 244
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 245
/tmp/git-blob-mG4MTa/calendar.cpp -> /tmp/git-blob-L5Iuoo/calendar.cpp
======================================================================

234 - 238:
----------
+ bool calendar::is_dusk() const
+ {
+     const time_duration now = time_past_midnight(*this);
+     const time_duration sunrise = time_past_midnight(this->sunrise());
+     const time_duration sunset = time_past_midnight(this->sunset());

240 - 241:
----------
+     return  (sunset < now && now < sunset + twilight_duration) || (sunrise - twilight_duration < now && now < sunrise);
+ }

243 - 247:
----------
+ bool calendar::is_noon() const
+ {
+     const time_ 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 245
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 246
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 246
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 247
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 247
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End hunk (lines 243 - 247)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing hunk (lines 249 - 250)
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Title string has length of 11
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 249
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 249
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > Printing line 250
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End line 250
 2023-04-27T15:51:22.536Z DEBUG diffsitter::formatting > End hunk (lines 249 - 250)
 2023-04-27T15:51:22.536Z INFO  TimerFinished          > formatting::print(), Elapsed=354.232µs
duration now = time_past_midnight(*this);
+     const time_duration sunrise = time_past_midnight(this->sunrise());
+     const time_duration sunset = time_past_midnight(this->sunset());

249 - 250:
----------
+     return sunrise < now && now < sunset;
+ }
 2023-04-27T15:51:22.577Z DEBUG diffsitter > Checking if /tmp/git-blob-l8uwZi/calendar.h can be parsed
 2023-04-27T15:51:22.577Z INFO  diffsitter::parse > Deduced language "c" from extension "h" from default mappings
 2023-04-27T15:51:22.577Z INFO  diffsitter::parse > Using tree-sitter parser for language c
 2023-04-27T15:51:22.577Z DEBUG diffsitter::parse > Failed to load candidate grammar for c: The program was not compiled with support for c
 2023-04-27T15:51:22.577Z ERROR diffsitter::parse > Failed to load all candidate grammars for c
 2023-04-27T15:51:22.577Z ERROR diffsitter        > Extension h not supported
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.587Z DEBUG diffsitter > Checking if /tmp/git-blob-FCCi4D/cata_tiles.cpp can be parsed
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.587Z DEBUG diffsitter        > Checking if /tmp/git-blob-UxNGZU/cata_tiles.cpp can be parsed
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.587Z DEBUG diffsitter        > Extensions for both input files are supported
 2023-04-27T15:51:22.587Z DEBUG diffsitter        > Reading /tmp/git-blob-FCCi4D/cata_tiles.cpp to string
 2023-04-27T15:51:22.587Z INFO  diffsitter        > Will deduce filetype from file extension
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.587Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.587Z DEBUG diffsitter::parse > Constructed parser
 2023-04-27T15:51:22.598Z DEBUG diffsitter::parse > Parsed AST
 2023-04-27T15:51:22.598Z INFO  TimerFinished     > parse::parse_file(), Elapsed=11.02616ms
Error: stream did not contain valid UTF-8
 2023-04-27T15:51:22.610Z DEBUG diffsitter > Checking if /tmp/git-blob-1mzHdQ/cata_tiles.h can be parsed
 2023-04-27T15:51:22.610Z INFO  diffsitter::parse > Deduced language "c" from extension "h" from default mappings
 2023-04-27T15:51:22.610Z INFO  diffsitter::parse > Using tree-sitter parser for language c
 2023-04-27T15:51:22.610Z DEBUG diffsitter::parse > Failed to load candidate grammar for c: The program was not compiled with support for c
 2023-04-27T15:51:22.610Z ERROR diffsitter::parse > Failed to load all candidate grammars for c
 2023-04-27T15:51:22.610Z ERROR diffsitter        > Extension h not supported
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.619Z DEBUG diffsitter > Checking if /tmp/git-blob-0IwUlB/lightmap.h can be parsed
 2023-04-27T15:51:22.619Z INFO  diffsitter::parse > Deduced language "c" from extension "h" from default mappings
 2023-04-27T15:51:22.619Z INFO  diffsitter::parse > Using tree-sitter parser for language c
 2023-04-27T15:51:22.619Z DEBUG diffsitter::parse > Failed to load candidate grammar for c: The program was not compiled with support for c
 2023-04-27T15:51:22.619Z ERROR diffsitter::parse > Failed to load all candidate grammars for c
 2023-04-27T15:51:22.619Z ERROR diffsitter        > Extension h not supported
Error: Unsupported file type with no fallback command specified.
 2023-04-27T15:51:22.631Z DEBUG diffsitter > Checking if /tmp/git-blob-zutKhu/map.cpp can be parsed
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.631Z DEBUG diffsitter        > Checking if /tmp/git-blob-bLry7g/map.cpp can be parsed
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.631Z DEBUG diffsitter        > Extensions for both input files are supported
 2023-04-27T15:51:22.631Z DEBUG diffsitter        > Reading /tmp/git-blob-zutKhu/map.cpp to string
 2023-04-27T15:51:22.631Z INFO  diffsitter        > Will deduce filetype from file extension
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.631Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.631Z DEBUG diffsitter::parse > Constructed parser
 2023-04-27T15:51:22.659Z DEBUG diffsitter::parse > Parsed AST
 2023-04-27T15:51:22.659Z INFO  TimerFinished     > parse::parse_file(), Elapsed=28.538961ms
 2023-04-27T15:51:22.660Z DEBUG diffsitter        > Reading /tmp/git-blob-bLry7g/map.cpp to string
 2023-04-27T15:51:22.660Z INFO  diffsitter        > Will deduce filetype from file extension
 2023-04-27T15:51:22.660Z INFO  diffsitter::parse > Deduced language "cpp" from extension "cpp" from default mappings
 2023-04-27T15:51:22.660Z INFO  diffsitter::parse > Using tree-sitter parser for language cpp
 2023-04-27T15:51:22.660Z INFO  diffsitter::parse > Succeeded loading grammar for cpp
 2023-04-27T15:51:22.660Z DEBUG diffsitter::parse > Constructed parser
 2023-04-27T15:51:22.688Z DEBUG diffsitter::parse > Parsed AST
 2023-04-27T15:51:22.688Z INFO  TimerFinished     > parse::parse_file(), Elapsed=28.291725ms
 2023-04-27T15:51:22.698Z INFO  TimerFinished     > ast::from_ts_tree(), Elapsed=10.144177ms
 2023-04-27T15:51:22.713Z INFO  TimerFinished     > ast::process(), Elapsed=25.464658ms
 2023-04-27T15:51:22.723Z INFO  TimerFinished     > ast::from_ts_tree(), Elapsed=9.756224ms
 2023-04-27T15:51:22.739Z INFO  TimerFinished     > ast::process(), Elapsed=25.519236ms
 2023-04-27T15:51:22.742Z INFO  TimerFinished     > diff::compute_edit_script(), Elapsed=2.833481ms
 2023-04-27T15:51:22.742Z INFO  diffsitter::formatting > Detected terminal width: 253 columns
 2023-04-27T15:51:22.742Z INFO  diffsitter::formatting > Using stack style horizontal for title
 2023-04-27T15:51:22.742Z DEBUG diffsitter::formatting > Printing hunk (lines 5748 - 5751)
 2023-04-27T15:51:22.742Z DEBUG diffsitter::formatting > Title string has length of 13
 2023-04-27T15:51:22.742Z DEBUG diffsitter::formatting > Printing line 5748
 2023-04-27T15:51:22.742Z TRACE os_info::imp           > linux::current_platform is called
 2023-04-27T15:51:22.788Z TRACE os_info::imp::lsb_release > lsb_release command returned Output { status: ExitStatus(unix_wait_status(0)), stdout: "LSB Version:\tcore-11.2ubuntu1-noarch:security-11.2ubuntu1-noarch\nDistributor ID:\tUbuntu\nDescription:\tUbuntu 22.10\nRelease:\t22.10\nCodename:\tkinetic\n", stderr: "" }
 2023-04-27T15:51:22.788Z TRACE os_info::imp::lsb_release > Trying to parse "LSB Version:\tcore-11.2ubuntu1-noarch:security-11.2ubuntu1-noarch\nDistributor ID:\tUbuntu\nDescription:\tUbuntu 22.10\nRelease:\t22.10\nCodename:\tkinetic\n"
 2023-04-27T15:51:22.788Z TRACE os_info::imp::lsb_release > Parsed as 'Some("Ubuntu")' distribution and 'Some("22.10")' version
 2023-04-27T15:51:22.789Z TRACE os_info::imp              > Returning Info { os_type: Ubuntu, version: Version { version: Custom("22.10"), edition: None }, bitness: X64 }
Well, this is embarrassing.

diffsitter had a problem and crashed. To help us diagnose the problem you can send us a crash report.

We have generated a report file at "/tmp/report-811f0bf2-8ba8-4502-9b89-9a2300fadad6.toml". Submit an issue or email with the subject of "diffsitter Crash Report" and include the report as an attachment.

- Homepage: https://github.com/afnanenayet/diffsitter
- Authors: Afnan Enayet <afnan@afnan.io>

We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.

Thank you kindly!
 2023-04-27T15:51:22.832Z INFO  TimerFinished             > formatting::print(), Elapsed=90.625644ms
/tmp/git-blob-zutKhu/map.cpp -> /tmp/git-blob-bLry7g/map.cpp
============================================================

5748 - 5751:
------------
+     /*if (apparent_light > 1) {⏎  

Platform:
Operating System: Kubuntu 22.10
Kernel Version: 6.3.0-060300-generic (64-bit)

Additional context
generated code report
report.toml.tar.gz

Hey I'm unable to find that commit (it doesn't seem to be a valid commit in your fork), I tried setting a tag on another arbitrary commit and was unable to replicate the issue. Do you have another example?

@scarf005 Just following up, could you check if the latest release fixes this issue?

commented

yes, upgrading to v0.8.0 solved the issue. thank you!

Awesome, thanks for confirming!