timbrel / GitSavvy

Full git and GitHub integration with Sublime Text
MIT License
1.91k stars 137 forks source link

Can't diff inline, normal diff working #818

Closed AllanLRH closed 7 years ago

AllanLRH commented 7 years ago

Can't get inline diff viewing to work (git: status, l), although normal diff does (git: status, e).

Steps to reproduce

Software versions

Logs and settings

Console output

startup, version: 3154 osx x64 channel: dev
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: /Users/allan/Library/Application Support/Sublime Text 3/Packages
state path: /Users/allan/Library/Application Support/Sublime Text 3/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/allan/Library/Application Support/Sublime Text 3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.239726
using gpu buffer for window
startup time: 0.303021
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin ShellScript.ShellScript
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.50-pyyaml
reloading plugin GitSavvy.__init__
reloading plugin GitSavvy.git_savvy
reloading plugin Package Control.1_reloader
reloading plugin Package Control.2_bootstrap
reloading plugin Package Control.Package Control
plugins loaded
Package Control: Skipping automatic upgrade, last run at 2017-11-29 10:49:47, next run at 2017-11-29 11:49:47 or after
environment variables loaded using: /bin/zsh -l
Traceback (most recent call last):
  File "core.commands.inline_diff in /Users/allan/Library/Application Support/Sublime Text 3/Installed Packages/GitSavvy.sublime-package", line 38, in <lambda>
  File "core.commands.inline_diff in /Users/allan/Library/Application Support/Sublime Text 3/Installed Packages/GitSavvy.sublime-package", line 63, in run_async
  File "core.commands.inline_diff in /Users/allan/Library/Application Support/Sublime Text 3/Installed Packages/GitSavvy.sublime-package", line 98, in augment_color_scheme
  File "common.theme_generator in /Users/allan/Library/Application Support/Sublime Text 3/Installed Packages/GitSavvy.sublime-package", line 45, in __init__
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime.py", line 192, in load_resource
    raise IOError("resource not found")
OSError: resource not found

Since the console log suggests that there's a missing resource, I checked the function which raises the exception in the file /Applications/Sublime Text.app/Contents/MacOS/sublime.py:

import sys
import sublime_api

# ...  lots of other lines here

def load_resource(name):
    s = sublime_api.load_resource(name)
    if s is None:
        raise IOError("resource not found")
    return s

# ...  lots of other lines here

Gitsavvy log

[
  {
    "stdout": " M dot_zshrc\u0000 M symlinkerscript.py\u0000", 
    "seconds": 0.007544040679931641, 
    "command": [
      "status", 
      "--porcelain", 
      "-z"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "## master\n M dot_zshrc\n M symlinkerscript.py\n", 
    "seconds": 0.00664210319519043, 
    "command": [
      "status", 
      "-b", 
      "--porcelain"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "0e7c693 Add plotly credentials", 
    "seconds": 0.006794929504394531, 
    "command": [
      "log", 
      "-n 1", 
      "--pretty=format:%h %s", 
      "--abbrev-commit"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "", 
    "seconds": 0.07788586616516113, 
    "command": [
      "stash", 
      "list"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": " dot_zshrc | 53 ++++++++++++++++++++++++++++-------------------------\n 1 file changed, 28 insertions(+), 25 deletions(-)\n\ndiff --git a/dot_zshrc b/dot_zshrc\nindex 7e3d893..9b5a0f1 100644\n--- a/dot_zshrc\n+++ b/dot_zshrc\n@@ -131,6 +131,7 @@ if [[ \"$unamestr\" == 'Linux' ]]; then\n   alias -g pbpaste='xsel --clipboard --output'\n elif [[ \"$unamestr\" == 'Darwin' ]]; then\n   alias matlabPrompt=\"open -a XQuartz; /Applications/$(ls -F /Applications | grep MATLAB)/bin/matlab -nosplash -nodesktop\"\n+  source ~/.iterm2_shell_integration.zsh\n fi\n \n alias ag=\"ag --color-path \\\"1;36\\\"\"  # Cyan\n@@ -374,7 +375,7 @@ uplio ()  # Upload file to upl.io pastebin service, print URL to terminal\n   curl -F file=@$1 https://upl.io\n }\n \n-source activate py36up\n+source activate py36\n # while [ $(which python) = \"$HOME/homeInstalled/miniconda3/envs/py35/bin/python\" ]\n # do\n #   # http://www.linuxquestions.org/questions/programming-9/random-float-numbers-in-bash-871336/#post4305559\n@@ -431,30 +432,30 @@ alias dbanotify=\"$HOME/src/dbaNotifier/dbaNotifier.py $HOME/src/dbaNotifier/conf\n \n # Don't run kinit until there's established a WiFi connection... make sure that\n # the shell environment in which kinit is run isn't destroyed upon Python exit.\n-python << END\n-import os\n-if os.uname().sysname == 'Linux':\n-    exit()\n-import subprocess\n-import time\n-import sys\n-\n-p = subprocess.Popen(\"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --getinfo\".split(),\n-                     stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n-p.wait()\n-stdout, stderr = p.communicate()\n-stdout = stdout.decode(\"utf-8\")\n-p.kill()\n-for i in range(10):\n-    for line in stdout.splitlines():\n-        if line.strip().startswith(\"SSID: \"):\n-            ssid = line.replace(\"SSID:\", \"\").strip()\n-            if len(ssid):\n-                subprocess.call(\"/usr/bin/kinit --keychain bzg778@NBI.KU.DK\", shell=True)\n-                sys.exit()\n-            else:\n-                time.sleep(0.3)\n-END\n+# python << END\n+# import os\n+# if os.uname().sysname == 'Linux':\n+#     exit()\n+# import subprocess\n+# import time\n+# import sys\n+\n+# p = subprocess.Popen(\"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --getinfo\".split(),\n+#                      stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n+# p.wait()\n+# stdout, stderr = p.communicate()\n+# stdout = stdout.decode(\"utf-8\")\n+# p.kill()\n+# for i in range(10):\n+#     for line in stdout.splitlines():\n+#         if line.strip().startswith(\"SSID: \"):\n+#             ssid = line.replace(\"SSID:\", \"\").strip()\n+#             if len(ssid):\n+#                 subprocess.call(\"/usr/bin/kinit --keychain bzg778@NBI.KU.DK\", shell=True)\n+#                 sys.exit()\n+#             else:\n+#                 time.sleep(0.3)\n+# END\n \n export PATH=$HOME/local/bin:$PATH\n \n@@ -465,3 +466,5 @@ fi\n \n export MOZ_USE_XINPUT2=1\n export HOMEBREW_MAKE_JOBS=1\n+\n+eval $(thefuck --alias)\n", 
    "seconds": 0.007215023040771484, 
    "command": [
      "diff", 
      null, 
      null, 
      "--stat", 
      "--patch", 
      "--no-color", 
      null, 
      null, 
      null, 
      "--", 
      "/Users/allan/Dropbox/Crap/dotfiles/dot_zshrc"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": " M dot_zshrc\u0000 M symlinkerscript.py\u0000", 
    "seconds": 0.010293006896972656, 
    "command": [
      "status", 
      "--porcelain", 
      "-z"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "## master\n M dot_zshrc\n M symlinkerscript.py\n", 
    "seconds": 0.009741067886352539, 
    "command": [
      "status", 
      "-b", 
      "--porcelain"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "0e7c693 Add plotly credentials", 
    "seconds": 0.008771896362304688, 
    "command": [
      "log", 
      "-n 1", 
      "--pretty=format:%h %s", 
      "--abbrev-commit"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "", 
    "seconds": 0.1047811508178711, 
    "command": [
      "stash", 
      "list"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": " M dot_zshrc\u0000 M symlinkerscript.py\u0000", 
    "seconds": 0.009149789810180664, 
    "command": [
      "status", 
      "--porcelain", 
      "-z"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "## master\n M dot_zshrc\n M symlinkerscript.py\n", 
    "seconds": 0.008958101272583008, 
    "command": [
      "status", 
      "-b", 
      "--porcelain"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "0e7c693 Add plotly credentials", 
    "seconds": 0.009160041809082031, 
    "command": [
      "log", 
      "-n 1", 
      "--pretty=format:%h %s", 
      "--abbrev-commit"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }, 
  {
    "stdout": "", 
    "seconds": 0.10177111625671387, 
    "command": [
      "stash", 
      "list"
    ], 
    "stdin": null, 
    "type": "git", 
    "stderr": ""
  }
]

GitSavvy settings

// Settings in here override those in "GitSavvy/GitSavvy.sublime-settings",

{
    "git_path": "/usr/local/bin/git",

}

git-settings

Contents of ~/.gitconfig

[user]
    name = ***REDACTED BEFORE PUT ON GITHUB***
    email = ***REDACTED BEFORE PUT ON GITHUB***
[push]
    default = matching
[branch]
    autosetuprebase = always
[color]
    status = auto
    branch = auto
    ui = auto
    diff = auto
[core]
    excludesfile = /Users/allan/.gitignore_global
    editor = "subl -n -w"
    pager = less --tabs=4 -RFX
[credential]
    helper = osxkeychain
[alias]
    wdiff = diff
    ci = commit
    gp = grep --break --heading --line-number
    ribbon = tag --force _ribbon origin/master
    catchup = log --patch --reverse --topo-order _ribbon..origin/master
    diffmerge = difftool --tool=diffmerge -y
[grep]
    extendRegexp = true
    lineNumber = true
[filter "media"]
    required = true
    clean = git media clean %f
    smudge = git media smudge %f
[filter "lfs"]
    clean = git lfs clean %f
    smudge = git lfs smudge %f
    required = true
[github]
    user = AllanLRH
    token = ***REDACTED BEFORE PUT ON GITHUB***
[color "diff-highlight"]
    oldNormal = red bold
    oldHighlight = red bold 52
    newNormal = green bold
    newHighlight = green bold 22
[gitrepo "gitlab"]
    token = ***REDACTED ***
[gitrepo "github"]
    token = ***REDACTED ***
[difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
[mergetool "sourcetree"]
    cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
[diff]
  tool = meld
[difftool]
  prompt = false
[difftool "meld"]
  trustExitCode = true
  cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\"
[merge]
  tool = meld
[mergetool]
  prompt = false
[mergetool "meld"]
  trustExitCode = true
  cmd = open -W -a Meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"

EDITS:

stoivo commented 7 years ago

I think it trying to load a scheme which you don't have on disk.

Check which scheme is set and try to load it. Open any view and the console

scheme = view.settings().get("color_scheme")
sublime.load_resource(scheme)

It smells like a conflict with another package. Did you install some new packages lately? Great issue report.

AllanLRH commented 7 years ago

I just got a new macbook, so I got an entirely new system, where I kept my old User-folder, which caused all the previously installed packages to be automatically installed by Package Control (once Package Control was installed). That's of course a bad foundation for providing a bug-report, which is why I reverted to a freshly installed state before submitting the bug report — the issue persisted in the "fresh state". But downgrading the the previous DEV-build (3153 instead of 3154) seems to have solved the issue.

Indeed, when I ran the commands like you asked me to I got this running 3154:

>>> scheme = view.settings().get("color_scheme")
>>> sublime.load_resource(scheme)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime.py", line 192, in load_resource
    raise IOError("resource not found")
OSError: resource not found
>>> scheme
'Monokai.sublime-color-scheme'

I tried reinstalling ST 3154, but it didn't help. Downgrading to 3153 made print(sublime.load_resource(scheme)) print the content of the XML-file which contains the Monokai color-scheme.


If this is really a bug in ST 3154, should I change the title of the issue and keep it open, or should I close it as resolved, since the issue can be circumvented... it could be a bug in the DEV-version of ST?

P. S.: Thanks for the help :)

EDIT: I've asked whether other people have encountered similar problems in the Build 3154 thread on the Sublime Text Forums.

AllanLRH commented 7 years ago

Closing since it seems to work in ST Build 3155.

But the response from the ST forum might be of interest to the maintainers (@stoivo ?):

Pretty sure it's not a bug - color schemes IIRC used to have to be referenced by their full path (.tmTheme files), but now with .sublime-color-scheme files, it doesn't make sense to do so, nor is there generally any need for a plugin to try to directly open a .sublime-color-scheme. If it is absolutely necessary, GitSavvy should probably use sublime.find_resources first to get a full path to the file

randy3k commented 7 years ago

I reckon that a workaround would be adding Packages/Color Scheme - Default before the name of your default color scheme.

    "color_scheme": "Packages/Color Scheme - Default/Mariana.sublime-color-scheme",
randy3k commented 6 years ago

@AllanLRH

indeed, it is an issue of GitSavvy #829 and a fix #830 has been proposed.

fhchl commented 5 years ago

Same problem can occur if an old style color scheme is set in the user preferences. Removing that line solves problem.