jakesankey / git-history

View previous versions of any file known to git.
https://atom.io/packages/git-history
MIT License
28 stars 10 forks source link

Uncaught TypeError: Cannot read property 'repo' of null #24

Closed alvinsen closed 9 years ago

alvinsen commented 9 years ago

[Enter steps to reproduce below:]

  1. ...
  2. ...

Atom Version: 1.0.0 System: Mac OS X 10.10.4 Thrown From: git-history package, v3.0.0

Stack Trace

Uncaught TypeError: Cannot read property 'repo' of null

At /Users/shenyongquan/.atom/packages/git-history/lib/git-history-view.coffee:115

TypeError: Cannot read property 'repo' of null
  at GitHistoryView._loadRevision (/Users/shenyongquan/.atom/packages/git-history/lib/git-history-view.coffee:115:78)
  at GitHistoryView.confirmed (/Users/shenyongquan/.atom/packages/git-history/lib/git-history-view.coffee:112:10)
  at GitHistoryView.module.exports.SelectListView.confirmSelection (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21)
  at space-pen-li.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:139:19)
  at HTMLOListElement.jQuery.event.dispatch (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4435:9)
  at HTMLOListElement.elemData.handle (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/jquery/dist/jquery.js:4121:28)

Commands

     -5:26.5.0 application:add-project-folder (atom-text-editor.editor.is-focused)
     -0:05.1.0 application:hide-other-applications (atom-text-editor.editor.is-focused)
     -0:03.4.0 git-history:show-file-history (atom-text-editor.editor.is-focused)

Config

{
  "core": {},
  "git-history": {}
}

Installed Packages

# User
autocomplete-python, v0.5.1
git-history, v3.0.0
git-log, v0.4.1

# Dev
No dev packages
danShumway commented 9 years ago

I consistently have this behavior as well on private, local repos (only one's I've tested). Does git-history support getting history in those cases?

Steps to reproduce:

danShumway commented 9 years ago

Did a little bit of digging. Problem seems to spring from a couple of sources.

Firstly, there's no null check when checking the repos that atom returns, so atom can return [repo, null, null] if you have folders open that aren't tracked, and that will throw an exception.

Secondly, "/" and "\" aren't converted for file paths, so the repo filepath and the filepath atom returns for the current file aren't compatible.

Didn't check any deeper.

jakesankey commented 9 years ago

Can anyone confirm whether or not they are still having this issue in the latest version of atom and git-history? I am still unable to reproduce the issue.

danielabar commented 9 years ago

I'm having this issue, it's been broken for last few weeks.

[Enter steps to reproduce below:]

1. ...
2. ...

**Atom Version**: 1.0.7
**System**: Mac OS X 10.9.5
**Thrown From**: [git-history](https://github.com/jakesankey/git-history) package, v3.0.1

### Stack Trace

Uncaught TypeError: Cannot read property 'repo' of null

At /Users/dbaron/.atom/packages/git-history/lib/git-history-view.coffee:115

TypeError: Cannot read property 'repo' of null at GitHistoryView._loadRevision (/Users/dbaron/.atom/packages/git-history/lib/git-history-view.coffee:186:52) at GitHistoryView.confirmed (/Users/dbaron/.atom/packages/git-history/lib/git-history-view.coffee:178:19) at GitHistoryView.module.exports.SelectListView.confirmSelection (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21) at space-pen-div.atom.commands.add.core:confirm (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:109:19) at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:241:29) at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61 at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:524:16) at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:347:22) at HTMLDocument.module.exports.WindowEventHandler.onKeydown (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:177:20)


### Commands
 -3:01.2.0 core:move-right (atom-text-editor.editor.mini.is-focused)
 -2:19.1.0 core:move-left (atom-text-editor.editor.is-focused)
 -2:14.5.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
 -2:14.5.0 core:cancel (atom-text-editor.editor.is-focused)
 -2:12.5.0 core:save (atom-text-editor.editor.is-focused)
 -1:28 symbols-view:toggle-file-symbols (atom-text-editor.editor.is-focused)

3x -1:25.8.0 core:move-down (atom-text-editor.editor.mini.is-focused) -1:24.7.0 core:confirm (atom-text-editor.editor.mini.is-focused) 3x -0:56.8.0 pane:show-next-item (atom-text-editor.editor.is-focused) 3x -0:33.2.0 pane:show-previous-item (atom-text-editor.editor.is-focused) -0:14.7.0 command-palette:toggle (atom-text-editor.editor.is-focused) -0:11.5.0 core:move-down (atom-text-editor.editor.mini.is-focused) -0:07.0 core:confirm (atom-text-editor.editor.mini.is-focused) -0:07.0 git-history:show-file-history (atom-text-editor.editor) 3x -0:04.1.0 core:move-down (atom-text-editor.editor.mini.is-focused) -0:01.0 core:confirm (atom-text-editor.editor.mini.is-focused)


### Config

```json
{
  "core": {
    "themes": [
      "atom-dark-ui",
      "base16-tomorrow-dark-theme"
    ],
    "ignoredNames": [
      ".git",
      ".svn",
      ".DS_Store"
    ]
  }
}

Installed Packages

# User
atom-beautify, v0.28.11
autocomplete-paths, v1.0.2
color-picker, v2.0.11
editorconfig, v1.0.1
emmet, v2.3.12
git-history, v3.0.1
jshint, v1.3.10
local-history, v3.2.3
pigments, v0.11.0

# Dev
No dev packages
jakesankey commented 9 years ago

@danielabar - Is it broken for every file? certain files? Do you have multiple projects open in the same workspace?

danielabar commented 9 years ago

I just tried it again on Windows 8.1, a few variations:

A single git project in the workspace, then it works.

Multiple git projects in the workspace, it works

Combination of git and non git root folders, then get the error.

jakesankey commented 9 years ago

If @ChowSinWon 's pull request did not resolve this issue for you all, please reopen the issue.