Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
21.14k stars 346 forks source link

Difftastic panics when diffing two YAML files #782

Closed singiamtel closed 1 week ago

singiamtel commented 1 week ago

Small repro with 2 YAML files, no git involved. I have the current Homebrew build.

https://github.com/Wilfred/difftastic/issues/702 seems similar but I'm not using --display inline nor git diff

#!/usr/bin/env bash

cat >og.yml <<EOF
name: Break it all
jobs:
    steps:
        run: |
          set -x
          git clone  https://github.com/torvalds/linux
EOF

cat >changed.yml <<EOF
name: Break it all
jobs:
    steps:
        run: |
          git clone  https://github.com/torvalds/linux
EOF

RUST_BACKTRACE=full difft og.yml changed.yml
difft --version

My output

changed.yml --- YAML
1 name: Break it all                                       1 name: Break it all
2 jobs:                                                    2 jobs:
3     steps:                                               3     steps:
4         run: |                                           4         run: |
5           set -x                                         5           git clone  https://github.com/torvalds/linux
thread 'main' panicked at src/display/side_by_side.rs:568:34:
index out of bounds: the len is 5 but the index is 5
stack backtrace:
   0:        0x100484870 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h192489893ab3de20
   1:        0x1002fe32c - core::fmt::write::h2573968dce8b4c8e
   2:        0x100484664 - std::io::Write::write_fmt::hd688b4e0e14280fb
   3:        0x100478060 - std::panicking::default_hook::{{closure}}::h132ab4fd80cbd688
   4:        0x100477bb4 - std::panicking::default_hook::h25db1205ededf4a8
   5:        0x100478510 - std::panicking::rust_panic_with_hook::h1a5e700ba9552453
   6:        0x100484d7c - std::panicking::begin_panic_handler::{{closure}}::h4b087c40eb4a42d9
   7:        0x100484aac - std::sys::backtrace::__rust_end_short_backtrace::heff777664c13f8e2
   8:        0x1004781b8 - _rust_begin_unwind
   9:        0x100c3e434 - core::panicking::panic_fmt::h681f622c7f427738
  10:        0x100c3e568 - core::panicking::panic_bounds_check::h645582215ea94a7f
  11:        0x100335a78 - difft::display::side_by_side::print::hca4cc10cb8fed25b
  12:        0x10032ffe0 - difft::print_diff_result::h42fd031d58288330
  13:        0x10032cbe4 - difft::main::hba3586830b7b13e9
  14:        0x10035547c - std::sys::backtrace::__rust_begin_short_backtrace::h55ecb54612b6fca9
  15:        0x10035b950 - std::rt::lang_start::{{closure}}::h4db5ab7853ddeece
  16:        0x100487064 - std::rt::lang_start_internal::h9c7d71c5826f1ac3
  17:        0x10033025c - _main
Difftastic 0.61.0

Toolchain: 1.82.0
System:    macos aarch64