FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.44k stars 637 forks source link

Git-parser crashes on parseGitDiff: "Cannot read property '1' of null" #149

Closed FredrikNoren closed 11 years ago

FredrikNoren commented 11 years ago

@sorin-ionescu reported this in #125 :

I can report something similar.

error: TypeError: Cannot read property '1' of null
    at Object.exports.parseGitDiff [as parser] (/Users/sorin/.homebrew/lib/node_modules/ungit/source/git-parser.js:34:20)
    at /Users/sorin/.homebrew/lib/node_modules/ungit/source/git.js:28:42
    at ChildProcess.exithandler (child_process.js:635:7)
    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)
FredrikNoren commented 11 years ago

@sorin-ionescu I've been looking at this an I'm not sure why it occurs. Which version of git are you running?

sorin-ionescu commented 11 years ago

I am using v1.8.4.

FredrikNoren commented 11 years ago

@sorin-ionescu can you run git diff HEAD -- name_of_the_file_youre_trying_to_diff and paste the output here? It looks like it some kind of irregular diff output that the parser isn't anticipating

sorin-ionescu commented 11 years ago
diff --git i/zlogin w/zlogin
index e48ab66..32f28cf 100644
--- i/zlogin
+++ w/zlogin
@@ -9,21 +9,14 @@
 {
   # Compile the completion dump to increase startup speed.
   zcompdump="${ZDOTDIR:-$HOME}/.zcompdump"
-  if [[ "$zcompdump" -nt "${zcompdump}.zwc" || ! -s "${zcompdump}.zwc" ]]; then
+  if [[ -s "$zcompdump" && (! -s "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc") ]]; then
     zcompile "$zcompdump"
   fi
-
-  # Set environment variables for launchd processes.
-  if [[ "$OSTYPE" == darwin* ]]; then
-    for env_var in PATH MANPATH; do
-      launchctl setenv "$env_var" "${(P)env_var}"
-    done
-  fi
 } &!

 # Print a random, hopefully interesting, adage.
-# if (( $+commands[fortune] )); then
-#   fortune -a
-#   print
-# fi
+if (( $+commands[fortune] )); then
+  fortune -a
+  print
+fi
FredrikNoren commented 11 years ago

Thanks! I've made a fix, hope that resolves your problems