Comments (12)
Same issue.
Cannot read property 'push' of undefined
from atom-git-control.
Same issue, when I installed git:control, it worked, now, I get this issue. Atom Windows 0.194.0, git-control 0.2.0
from atom-git-control.
Can you post a screenshot like the one above? I have a feeling that this issue is related to Atom not properly recognizing your project as a git repository. ( See the icon in the top image is a normal folder, not a repository icon the way it normally is)
from atom-git-control.
@MarcelMue the icon isn't a good indicator of this. I have a project some levels deep inside a git repository and Atom has no problem displaying the changes in the left margin. Oh and it also does not display it as a book.
from atom-git-control.
I have the same problem. running the command "git --no-pager diff" from both git bash and the Command Promp seems to work fine.
from atom-git-control.
any updates on that issue? it's still occuring...
from atom-git-control.
same occurs on my project. It is not 100% reproducible though.
from atom-git-control.
Hello, I debugged this issue and think that I know what's going on.
When Compare button is clicked git-control will run git diff
command and parse its output. The following is an excerpt of that output.
warning: LF will be replaced by CRLF in src/elm/Main.elm.
The file will have its original line endings in your working directory.
diff --git a/README.md b/README.md
index a72397a..9867dcd 100644
--- a/README.md
+++ b/README.md
@@ -159,3 +159,51 @@ according to the model.
div.ball
And the relevant parsing code can located at git.coffee#42, in a function that is quoted below for reference.
parseDiff = (data) -> q.fcall ->
diffs = []
diff = {}
for line in data.split('\n') when line.length
switch
when /^diff --git /.test(line)
diff =
lines: []
added: 0
removed: 0
diff['diff'] = line.replace(/^diff --git /, '')
diffs.push diff
when /^index /.test(line)
diff['index'] = line.replace(/^index /, '')
when /^--- /.test(line)
diff['---'] = line.replace(/^--- [a|b]\//, '')
when /^\+\+\+ /.test(line)
diff['+++'] = line.replace(/^\+\+\+ [a|b]\//, '')
else
diff['lines'].push line
diff['added']++ if /^\+/.test(line)
diff['removed']++ if /^-/.test(line)
return diffs
The first two lines git
prints are just warnings regarding line ending handling in Windows, however they are not being filtered. Thus, the first iteration of the for loop will enter the switch in the else branch while diff
is still uninitialized (it will not be assigned valid data until handling line 3 of the output) which leads to trying to call push of undefined.
What I think it would help is to do as in the following "pseudo-patch":
diff['+++'] = line.replace(/^\+\+\+ [a|b]\//, '')
- else
+ when /^[ +-]/.test(line)
diff['lines'].push line
diff['added']++ if /^\+/.test(line)
diff['removed']++ if /^-/.test(line)
+ else
+ # Do whatever you want with non-diff lines
+ continue # such as ignoring them
from atom-git-control.
another option would be to "initialize" the object before the switch statement - or am I wrong?
parseDiff = (data) -> q.fcall ->
diffs = []
- diff = {}
+ diff = {
+ lines: [],
+ added: 0,
+ removed: 0
+ }
for line in data.split('\n') when line.length
switch
when /^diff --git /.test(line)
- diff =
- lines: []
- added: 0
- removed: 0
diff['diff'] = line.replace(/^diff --git /, '')
diffs.push diff
from atom-git-control.
That will break when there are many diff lines in the same output. Each of them start a new diff
object that needs to be pushed into diffs
array.
from atom-git-control.
+1 bump same issue even with a similar package
from atom-git-control.
I've tested your patch and it solves the issue. Thanks
from atom-git-control.
Related Issues (20)
- Uncaught Error: Command failed: ls `git rev-parse --git-dir` | grep rebase || echo norebase"ls" ...
- copy text from the git control logger or diff views / panes. Feature request / enhancement.
- Unable to set correct project folder
- No credential popup for non github git servers
- Unable to write commit message started with #
- Uncaught TypeError: Cannot read property 'local' of undefined
- Uncaught TypeError: Cannot read property 'split' of undefined HOT 6
- cannot resize information pane HOT 1
- Uncaught TypeError: Path must be a string. Received undefined HOT 4
- Uncaught TypeError: Cannot read property 'split' of undefined HOT 10
- Uncaught TypeError: this.setworkspacetitle is not a function HOT 2
- Uncaught TypeError: Cannot read property 'workingDirectory' of null
- Uncaught TypeError: Cannot read property 'split' of undefined HOT 36
- Cannot read property 'split' of undefined HOT 1
- Unexplained disappearance
- Cannot spawn /usr/bin/ssh.exe HOT 1
- Deprecated? HOT 7
- Uncaught TypeError: Cannot read property 'split' of undefined HOT 36
- Git-control GUI from Atom GUI HOT 1
- Error with a bitbucket repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atom-git-control.