scottgonzalez / pretty-diff

colorized HTML diffs
MIT License
218 stars 27 forks source link

Fails when merge conflict is on deleted file #11

Closed jzaefferer closed 10 years ago

jzaefferer commented 10 years ago

My git status looks like this:

# You are currently rebasing branch 'pr/443' on '6bfd76e'.
#   (fix conflicts and then run "git rebase --continue")
#   (use "git rebase --skip" to skip this patch)
#   (use "git rebase --abort" to check out the original branch)
#
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   deleted by us:      qunit/qunit.js
#

Running pretty-diff in that context exits with error code 8 and this stack trace:

/usr/local/share/npm/lib/node_modules/pretty-diff/diff.js:38
        files[ filename ].push( line );
                          ^
TypeError: Cannot call method 'push' of undefined
    at /usr/local/share/npm/lib/node_modules/pretty-diff/diff.js:38:21
    at Array.forEach (native)
    at splitByFile (/usr/local/share/npm/lib/node_modules/pretty-diff/diff.js:32:21)
    at ChildProcess.<anonymous> (/usr/local/share/npm/lib/node_modules/pretty-diff/diff.js:23:14)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:735:16)
    at Socket.<anonymous> (child_process.js:948:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

Might be annoying to debug, but maybe the stack trace makes the issue obvious enough.

scottgonzalez commented 10 years ago

I guess the question is whether you want this to produce something useful. git diff isn't going to show you an actual diff while your repo is in this state, so my preference would be to treat this the same as a clean working directory.

jzaefferer commented 10 years ago

Treating as clean working dir sounds fine.

scottgonzalez commented 10 years ago

Published as 0.2.1.