Closed ethanbustad closed 9 years ago
The same happens when trying to unstage hunks too.
@ethanbustad @oswjk, I rolled out v1.1.0 which includes a feature to help debug. After upgrading, can you:
GitSavvy: start logging
GitSavvy: stop logging
GitSavvy: view recorded log
Then paste the output here.
Here's the output:
[
{
"stdin": null,
"stderr": "",
"stdout": "100644 89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d 0\tportlets/testray-portlet/docroot/WEB-INF/jsp/util/testray_run_util.jspf\n",
"type": "git",
"command": [
"ls-files",
"-s",
"D:\\Liferay\\source\\EE\\liferay-plugins-ee\\portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf"
]
},
{
"stdin": null,
"stderr": "",
"stdout": "/* sanitized */",
"type": "git",
"command": [
"show",
"89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d"
]
},
{
"stdin": "/* sanitized */",
"stderr": "",
"stdout": "de7da1855214395527a7eca5cb42547650c74e82\n",
"type": "git",
"command": [
"hash-object",
"-w",
"--stdin"
]
},
{
"stdin": null,
"stderr": "",
"stdout": "diff --git a/89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d b/de7da1855214395527a7eca5cb42547650c74e82\nindex 89f4c8f..de7da18 100644\n--- a/89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d\n+++ b/de7da1855214395527a7eca5cb42547650c74e82\n@@ -20 +20 @@ public static class TestrayRunUtil {\n-\tpublic static Criterion getTestrayRunCriterion(long testrayBuildId, List<Long> testrayRunIds, long testrayTeamId) throws Exception {\n+\tpublic static Criterion getTestrayRunCriterion(List<Long> testrayRunIds, long testrayTeamId) throws Exception {\n@@ -23,4 +22,0 @@ public static class TestrayRunUtil {\n-\t\tif (testrayRunIds.isEmpty()) {\n-\t\t\treturn testrayRunIdProperty.eq((long)0);\n-\t\t}\n-\n@@ -38 +34 @@ public static class TestrayRunUtil {\n-\t\t\ttestrayCaseIds.add((long)0);\n+\t\t\treturn testrayCaseIdProperty.eq(0L);\n@@ -43 +39 @@ public static class TestrayRunUtil {\n-\t\treturn RestrictionsFactoryUtil.and(testrayCaseIdCriterion, testrayRunIdCriterion);\n+\t\treturn RestrictionsFactoryUtil.and(testrayRunIdCriterion, testrayCaseIdCriterion);\n",
"type": "git",
"command": [
"diff",
"-U0",
"89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d",
"de7da1855214395527a7eca5cb42547650c74e82"
]
},
{
"stdin": null,
"stderr": "",
"stdout": " M portlets/testray-portlet/docroot/WEB-INF/jsp/util/testray_run_util.jspf\u0000",
"type": "git",
"command": [
"status",
"--porcelain",
"-z"
]
},
{
"stdin": "diff --git a/portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf b/portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf\n--- a/portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf\n+++ b/portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf\n@@ -23,4 +23,0 @@\n-\t\tif (testrayRunIds.isEmpty()) {\n-\t\t\treturn testrayRunIdProperty.eq((long)0);\n-\t\t}\n-\n",
"stderr": "error: portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf: does not exist in index\n",
"stdout": "",
"type": "git",
"command": [
"apply",
"--unidiff-zero",
null,
"--cached",
"-"
]
},
{
"type": "error",
"error": "'`C:\\\\Git\\\\cmd\\\\git.EXE apply --unidiff-zero --cached -` failed with following output:\\n\\nerror: portlets\\\\testray-portlet\\\\docroot\\\\WEB-INF\\\\jsp\\\\util\\\\testray_run_util.jspf: does not exist in index\\n'"
},
{
"stdin": null,
"stderr": "",
"stdout": "100644 89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d 0\tportlets/testray-portlet/docroot/WEB-INF/jsp/util/testray_run_util.jspf\n",
"type": "git",
"command": [
"ls-files",
"-s",
"D:\\Liferay\\source\\EE\\liferay-plugins-ee\\portlets\\testray-portlet\\docroot\\WEB-INF\\jsp\\util\\testray_run_util.jspf"
]
},
{
"stdin": null,
"stderr": "",
"stdout": "/* sanitized */",
"type": "git",
"command": [
"show",
"89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d"
]
},
{
"stdin": "/* santized */",
"stderr": "",
"stdout": "de7da1855214395527a7eca5cb42547650c74e82\n",
"type": "git",
"command": [
"hash-object",
"-w",
"--stdin"
]
},
{
"stdin": null,
"stderr": "",
"stdout": "diff --git a/89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d b/de7da1855214395527a7eca5cb42547650c74e82\nindex 89f4c8f..de7da18 100644\n--- a/89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d\n+++ b/de7da1855214395527a7eca5cb42547650c74e82\n@@ -20 +20 @@ public static class TestrayRunUtil {\n-\tpublic static Criterion getTestrayRunCriterion(long testrayBuildId, List<Long> testrayRunIds, long testrayTeamId) throws Exception {\n+\tpublic static Criterion getTestrayRunCriterion(List<Long> testrayRunIds, long testrayTeamId) throws Exception {\n@@ -23,4 +22,0 @@ public static class TestrayRunUtil {\n-\t\tif (testrayRunIds.isEmpty()) {\n-\t\t\treturn testrayRunIdProperty.eq((long)0);\n-\t\t}\n-\n@@ -38 +34 @@ public static class TestrayRunUtil {\n-\t\t\ttestrayCaseIds.add((long)0);\n+\t\t\treturn testrayCaseIdProperty.eq(0L);\n@@ -43 +39 @@ public static class TestrayRunUtil {\n-\t\treturn RestrictionsFactoryUtil.and(testrayCaseIdCriterion, testrayRunIdCriterion);\n+\t\treturn RestrictionsFactoryUtil.and(testrayRunIdCriterion, testrayCaseIdCriterion);\n",
"type": "git",
"command": [
"diff",
"-U0",
"89f4c8f4af82e2ac3f89062a1bbac2e9d35b708d",
"de7da1855214395527a7eca5cb42547650c74e82"
]
}
]
I sanitized the content of the file -- not sure I can share the whole thing publicly. But if you need it I can send it to you.
Np about sanitizing the file - if you don't mind checking a couple of other things, that'd be helpful. The diff appears reasonable. Can you confirm that the line numbers match up?
For example, in the above output, there should be a file portlets\testray-portlet\docroot\WEB-INF\jsp\util\testray_run_util.jspf
, and line 23 should be (\t
is a tab):
\t\tif (testrayRunIds.isEmpty()) {
If the line numbers don't match up, that should point us to where the problem lies. If they do match up, that's not the issue, and there are a couple of other things to look at. It sounds like this has happened for other Git GUIs also. In some cases, the issue was never definitively resolved. Reading through some of this, there are a few other potential causes:
diff.mnemonicprefix
is set to true
(unlikely cause here, since it would probably fail for all partial staging)Just got this again, ironically, while working on GitSavvy. The log output is at https://dl.dropboxusercontent.com/u/101485540/sublime/gitsavvy_diff_error.json, this time with no file contents sanitized. The code can also be found in https://github.com/divmain/GitSavvy/pull/77.
git config --get diff.mnemonicprefix
yields nothing, which I assume means it's not set."default_line_ending": "unix"
in Sublime, and core.autocrlf
in git is set to input
."default_encoding": "UTF-8"
.So..... I don't know what's going on! :p
@ethanbustad - can you send me the commit hash of where you are in GitSavvy, as well as a diff representing the working dir? If I have something I can consistently reproduce, this will be much easier to work out.
I'm at 1876c02
. Diff is:
diff --git a/core/git_mixins/active_branch.py b/core/git_mixins/active_branch.py
index 0cf3c8b..8f35f88 100644
--- a/core/git_mixins/active_branch.py
+++ b/core/git_mixins/active_branch.py
@@ -1,4 +1,5 @@
import re
+import string
class ActiveBranchMixin():
@@ -34,7 +35,8 @@ class ActiveBranchMixin():
if first_line.startswith("## Initial commit on "):
return "Initial commit on `{}`.".format(first_line[21:])
- short_status_pattern = r"## ([A-Za-z0-9\-_\/]+)(\.\.\.([A-Za-z0-9\-_\/]
+ branch_pattern = "[A-Za-z0-9" + re.escape(re.sub("[~\\^\\:\\?\\*\\[\"]"
+ short_status_pattern = r"## (" + branch_pattern + ")(\.\.\.(" + branch_
status_match = re.match(short_status_pattern, first_line)
if not status_match:
I open up the inline-diff view and try to stage the top hunk, and I get the error. Reproduced it a couple times now.
You should be able to get the diff by fetching my branch reproduce-issue-63
if that's easier. It's one commit ahead of 1876c02
, with the given diff applied.
Awesome, thank you!
I tried this on my Mac and could not reproduce. Specifically:
git remote add alt git@github.com:ethanbustad/GitSavvy.git
git fetch alt
git checkout reproduce-issue-63
git checkout HEAD^
Copy the following into my clipboard:
diff --git a/core/git_mixins/active_branch.py b/core/git_mixins/active_branch.py
index 0cf3c8b..8f35f88 100644
--- a/core/git_mixins/active_branch.py
+++ b/core/git_mixins/active_branch.py
@@ -1,4 +1,5 @@
import re
+import string
class ActiveBranchMixin():
@@ -34,7 +35,8 @@ class ActiveBranchMixin():
if first_line.startswith("## Initial commit on "):
return "Initial commit on `{}`.".format(first_line[21:])
- short_status_pattern = r"## ([A-Za-z0-9\-_\/]+)(\.\.\.([A-Za-z0-9\-_\/]+)( \[((ahead (\d+))(, )?)?(behind (\d+))?\])?)?"
+ branch_pattern = "[A-Za-z0-9" + re.escape(re.sub("[~\\^\\:\\?\\*\\[\"]", "", string.punctuation)) + "]+?"
+ short_status_pattern = r"## (" + branch_pattern + ")(\.\.\.(" + branch_pattern + ")( \[((ahead (\d+))(, )?)?(behind (\d+))?\])?)?$"
status_match = re.match(short_status_pattern, first_line)
if not status_match:
pbpaste | git apply -
I'll try reproducing this on a Windows VM, maybe have better luck there.
I am able to reproduce in a Windows VM. Stay tuned...
@ethanbustad, can you pull down master when you get a chance? I was able to resolve this in my VM, but not sure if it solves this issue in all cases. Would like confirmation beyond my own tests before including it in a release. Thanks again for the repro steps, that proved to be very useful!
Will do!
Fixed! I'll continue to test, as I've seen this bug elsewhere as well, but the steps I gave you yesterday that consistently revealed the bug are now working correctly. Thanks for the fix!
Tried to stage hunk (h) in inline_diff_file view. Got the following error message in sublime's console:
The file does exist in the index. However, the previous commit created the file, so maybe that confuses git or something?
I can stage sections of this file with no problems using "git add -i". Even after doing this, I still can't stage other parts of the file using the inline_diff_file view in GitSavvy, even though the file clearly exists in the index (confirmed by
git status
).