so-fancy / diff-so-fancy

Good-lookin' diffs. Actually… nah… The best-lookin' diffs. :tada:
MIT License
17.28k stars 330 forks source link

Use of uninitialized value in addition #438

Open dbeecham opened 2 years ago

dbeecham commented 2 years ago

I get this error when running diff-so-fancy:


Use of uninitialized value in addition (+) at diff-so-fancy line 947, <STDIN> line 25.
``
astorije-vmware commented 2 years ago

I'm getting something similar here:

Use of uninitialized value in addition (+) at /usr/local/bin/diff-so-fancy line 967.

Obtained while trying to run git diff.

Installed from Homebrew:

% brew info diff-so-fancy
==> diff-so-fancy: stable 1.4.3 (bottled), HEAD
Good-lookin' diffs with diff-highlight and more
https://github.com/so-fancy/diff-so-fancy
/usr/local/Cellar/diff-so-fancy/1.4.3 (8 files, 46.3KB) *
  Poured from bottle on 2022-08-25 at 10:24:20
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/diff-so-fancy.rb
License: MIT

The parts of my ~/.gitconfig that could be relevant:

[core]
  excludesfile = ~/.gitignore_global
  pager = diff-so-fancy | less --tabs=4 -RFX
[diff]
  # Enables a heuristic to make the patch output more readable by using a blank
  # line as a strong hint that the contents before and after it belong to
  # logically separate units. It is still experimental.
  compactionHeuristic = true
[diff-so-fancy]
  # Do not color the first block of an empty line.
  markEmptyLines = false
  # Do not remove the pesky + or - at line-start.
  stripLeadingSymbols = false
[color "diff"]
  meta = yellow # Default is white
  frag = magenta # Default is cyan
[color "diff-highlight"]
  oldNormal = red
  newNormal = green
  oldHighlight = "#dd0000 #550000" # Default is red reverse
  newHighlight = "green #004400" # Default is green reverse
scottchiefbaker commented 2 years ago

Line 967 does not contain addition. I'm confused trying to track down the bug.

Can you try it again with the official release? That should at least give us consistent line numbers.

rxgx commented 2 years ago

For the diff-so-fancy error I am receiving at:

Use of uninitialized value in addition (+) at /Users/rgasparini/.volta/tools/image/packages/diff-so-fancy/bin/diff-so-fancy line 1282, <STDIN> line 28.

is some color setting in ~/.gitconfig that is not expected?

Screen Shot 2022-08-30 at 11 55 39 AM
rxgx commented 2 years ago

If I remove this line from my ~/.gitconfig file, I no longer get the addition error.

[color "diff"]
    ...
-   meta = normal
    ...
scottchiefbaker commented 2 years ago

@rxgx I just posted a potential fix on the next branch. Can you see if that fixes your problem?

We don't support "normal" in a gitconfig, but it should fail silently. I put "normal" in my gitconfig like you posted and I don't get an error. This one is a little confusing.

zaufi commented 1 year ago

Commenting meta didn't help much... the same error, but another lineno :(

Use of uninitialized value in addition (+) at /usr/host/bin/diff-so-fancy line 1282, <STDIN> line 25.

Same error I have even for diff -u file1 file2 | diff-so-fancy from the README.

My Git colors:

[color "diff"]
    #meta = "#328cad" "" italic
    frag = "#b060ff" "" italic
    func = "#6b41a7" "" italic
    old = "#c05040"
    new = "#20ff70"
    commit = "#30b0c0"
    whitespace = "" "#c05040"
    oldMoved = "#c03060"
    newMoved = "#50b060"
    oldMovedDimmed = "#802030"
    oldMovedAlternative = "#d05030"
    oldMovedAlternativeDimmed = "#a03020"
    newMovedDimmed = "#307040"
    newMovedAlternative = "#70e0a0"
    newMovedAlternativeDimmed = "#407050"

Upd: I have to comment everything up to comment to make it work

webstech commented 1 year ago

The git-ansi-color routine does not appear to support:

sergeylukin commented 1 year ago

Same here. emptying [color "diff"] in ~/.gitconfig solves it but it would be great if diff-so-fancy would support custom [color "diff"] settings.

scottchiefbaker commented 1 year ago

This appears to be related to d-s-f not supporting hex colors, and not understanding "normal" and "default".