Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347776 - [client] Unstaging selected file causes error
Summary: [client] Unstaging selected file causes error
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Git (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 0.3   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 347856 348524 352348
Blocks:
  Show dependency tree
 
Reported: 2011-05-31 09:00 EDT by libing wang CLA
Modified: 2011-09-29 08:08 EDT (History)
1 user (show)

See Also:


Attachments
Test that used to fail. (3.27 KB, text/plain)
2011-07-13 06:56 EDT, Tomasz Zarna CLA
no flags Details
mylyn/context/zip (14.47 KB, application/octet-stream)
2011-07-13 06:56 EDT, Tomasz Zarna CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description libing wang CLA 2011-05-31 09:00:10 EDT
I have a test repo and the real dev repo , where I get different result from unstaging a single file.

In my test repo , I am doing 

POST http://localhost:8080/git/index/file/Z/  with  {"Path":["file1.js"]} 
There is no error from the post response , but after the post I am getting file1.js on both unstaged and staged.

{
  "Added": [],
  "Changed": [{
    "Git": {
      "CommitLocation": "/git/commit/HEAD/file/Z/file1.js",
      "DiffLocation": "/git/diff/Cached/file/Z/file1.js",
      "IndexLocation": "/git/index/file/Z/file1.js"
    },
    "Location": "/file/Z/file1.js",
    "Name": "file1.js",
    "Path": "file1.js"
  }],
  "CloneLocation": "/git/clone/file/Z/",
  "CommitLocation": "/git/commit/HEAD/file/Z/",
  "Conflicting": [],
  "IndexLocation": "/git/index/file/Z/",
  "Missing": [],
  "Modified": [{
    "Git": {
      "CommitLocation": "/git/commit/HEAD/file/Z/file1.js",
      "DiffLocation": "/git/diff/Default/file/Z/file1.js",
      "IndexLocation": "/git/index/file/Z/file1.js"
    },
    "Location": "/file/Z/file1.js",
    "Name": "file1.js",
    "Path": "file1.js"
  }],
  "Removed": [],
  "Untracked": []
}

In my dev repo , I am doing 

POST http://localhost:8080/git/index/file/K/  with {"Path":["bundles/org.eclipse.orion.client.git/static/js/git-status-table.js"]} 
I am getting errors like :

{"HttpCode":500,"DetailedMessage":"Invalid mode 40000 for path bundles","Message":"Failed to process an operation on index for file/K/","Severity":"Error","Code":0}
Comment 1 Tomasz Zarna CLA 2011-05-31 15:40:53 EDT
(In reply to comment #0)
> POST http://localhost:8080/git/index/file/Z/  with  {"Path":["file1.js"]} 
> There is no error from the post response , but after the post I am getting
> file1.js on both unstaged and staged.

This is strange, but it looks like a bug in JGit, I've opened bug 347856 for it.

> POST http://localhost:8080/git/index/file/K/  with
> {"Path":["bundles/org.eclipse.orion.client.git/static/js/git-status-table.js"]} 
> I am getting errors like :
> 
> {"HttpCode":500,"DetailedMessage":"Invalid mode 40000 for path
> bundles","Message":"Failed to process an operation on index for
> file/K/","Severity":"Error","Code":0}

I was able to reproduce it, but have no clue what does it mean. Will check that tomorrow.
Comment 2 Szymon Brandys CLA 2011-06-02 05:08:00 EDT
Need to wait till JGit bug is fixed.
Comment 3 Tomasz Zarna CLA 2011-06-06 12:33:38 EDT
Libing, have you reverted the change that allowed to unstage a single file? Could you at least give me a hint how can I enable it in my workspace?
Comment 4 libing wang CLA 2011-06-06 13:13:56 EDT
(In reply to comment #3)
> Libing, have you reverted the change that allowed to unstage a single file?
> Could you at least give me a hint how can I enable it in my workspace?

Yeah , please go to git-status-table.js 
The go to where unstage command is defined :	var unstageCommand = new mCommands.Command

At function visibleWhen, 
visibleWhen: function(item) {
    return false;//(item.type === "fileItem" && self._model.isStaged(item.object.type));
				}

Just uncomment the return value(Current I am always hiding it)
Comment 5 Tomasz Zarna CLA 2011-06-07 05:40:09 EDT
(In reply to comment #1)
> > I am getting errors like :
> >
> > {"HttpCode":500,"DetailedMessage":"Invalid mode 40000 for path
> > bundles","Message":"Failed to process an operation on index for
> > file/K/","Severity":"Error","Code":0}
> 
> I was able to reproduce it, but have no clue what does it mean. Will check that
> tomorrow.

See blocking bug 348524. I'm afraid we will need to keep the action hidden until JGit guys respond.
Comment 6 Tomasz Zarna CLA 2011-06-13 11:20:08 EDT
EGit gives you an option to unstage a single file: open Git Staging view and drag'n'drop files between Staged and Unstaged section. The bad news is that under the hood they not using ResetCommand[1], which we tried to leverage here, but they modify the index tree directly[2].

[1] org.eclipse.jgit.api.ResetCommand
[2] org.eclipse.egit.ui.internal.staging.StagingView.unstage(IStructuredSelection)
Comment 7 Tomasz Zarna CLA 2011-06-20 05:44:26 EDT
Since hacking it on our side doesn't sound like a good idea at this point I'm changing target milestone to 0.3. Hopefully, guys from JGit will find some time to look at the provided patch.
Comment 8 Tomasz Zarna CLA 2011-07-13 06:56:03 EDT
Created attachment 199565 [details]
Test that used to fail.

Both blocking bugs have been fixed (actually, one of them turned out to be a dupe). The attached test case used to fail without the fix in JGit. Now it's green. I'll wait til the fix finds its way to JGit nighty build and release changes in Orion then.
Comment 9 Tomasz Zarna CLA 2011-07-13 06:56:06 EDT
Created attachment 199566 [details]
mylyn/context/zip
Comment 10 Tomasz Zarna CLA 2011-09-22 09:13:37 EDT
This is still blocked by bug 352348, which in turn blocked by two bugs in JGit: bug 353867, bug 355205. If they're not fixed within a week or so I will change the target to 0.4. To match the reality.
Comment 11 Tomasz Zarna CLA 2011-09-29 08:08:03 EDT
This should be fixed now as verified in bug 352348. The UI action has been re-enabled in http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=38840c1d039ce6ca6a8a3f76be6461af22460bbf.