Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351429 - Add git rebase
Summary: Add git rebase
Status: RESOLVED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Git (show other bugs)
Version: 0.2   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 0.3 M1   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard: gsoc2011
Keywords:
Depends on:
Blocks: 351458
  Show dependency tree
 
Reported: 2011-07-07 07:58 EDT by Szymon Brandys CLA
Modified: 2012-01-19 11:46 EST (History)
2 users (show)

See Also:
Szymon.Brandys: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Szymon Brandys CLA 2011-07-07 07:58:14 EDT
It is one of our self-hosting gaps.
Comment 1 Piotr Janik CLA 2011-07-14 06:27:43 EDT
Proposal:
https://github.com/pjanik/orion.client/tree/bug351429
https://github.com/pjanik/orion.server/tree/bug351429

I wrote all this code and have the rights to contribute it to Eclipse under the
eclipse.org web site terms of use.

I will write more server tests in the nearest future. I publish it now to gain some opinions in the meantime. :)
Comment 2 Piotr Janik CLA 2011-07-14 11:35:58 EDT
Ok, tests updated.
Comment 3 Szymon Brandys CLA 2011-07-19 08:04:50 EDT
1. When I try to rebase changes and there are unstaged or uncommitted changes I get js errors. I need to stage and commit first then I can continue.
2. Abort Skip patch and continue on the status page end up with

POST http://localhost:8080/gitapi/commit/HEAD/file/a0/
	
500 Internal Server Error
		40ms	
xhr.js (line 880)
Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
xhr.js (line 774)
HTTP status code: 500
gitClient.js (line 674)
GET http://localhost:8080/gitapi/status/file/a0/
	
200 OK
		263ms	
xhr.js (line 880)
Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
xhr.js (line 774)
Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
var err = new Error("Unable to load...Args.url + " status:" + xhr.status); 

or something similar

3. I saw "(warning) OK. Go to Git Status page." in the status bar, even if the rebase succeeded.
4. Use commands with icons for Continue, Abort etc.
Comment 4 Piotr Janik CLA 2011-07-19 16:28:30 EDT
(In reply to comment #3)
> 1. When I try to rebase changes and there are unstaged or uncommitted changes I
> get js errors. I need to stage and commit first then I can continue.
Yes, it is how Git works. ;) To rebase, repository has to be in proper state. When I've tried to repeat your steps, I've got error message: Checkout conflict with file: [file_name]. It's expected, and it's probably JGit equivalent of: 
- "Cannot rebase: You have unsateged changes. Please commit or stash them."
- "Cannor rebase: Your index contains uncommited changes. Please commit or stash them."
what we can see in Git console version.

JS errors - there was an error, so it's logged. Ofc I can disable it, but i.e. when cloning fails (i.e. random URL), there are JS errors logged too. 

> 2. Abort Skip patch and continue on the status page end up with
> 
> POST http://localhost:8080/gitapi/commit/HEAD/file/a0/
> 
> 500 Internal Server Error
>         40ms    
> xhr.js (line 880)
> Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
> xhr.js (line 774)
> HTTP status code: 500
> gitClient.js (line 674)
> GET http://localhost:8080/gitapi/status/file/a0/
> 
> 200 OK
>         263ms    
> xhr.js (line 880)
> Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
> xhr.js (line 774)
> Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> var err = new Error("Unable to load...Args.url + " status:" + xhr.status); 
> 
> or something similar
I think that's the same case as above. Wrong repository state for "continue" operations. I guess that your probably skipped one patch, but there were still some conflicts after that operation (I'm almost sure, as "rebase panel" is shown in the rebase repository state, which is active only when there are some conflicts which are waiting to be resolved).
So, you clicked "continue" without resolving conflicts, what is an error. I think that it's expected. 
To avoid this error you should:
- abort,
- skip patch again,
- resolve conflict and only then continue.

JS errors - they are logged as always.

By the way, I think that HTTP 500 isn't best HTTP response code in such cases, so I will change it. ;) 

> 3. I saw "(warning) OK. Go to Git Status page." in the status bar, even if the
> rebase succeeded.
Right, it's a bug. Fixed.

> 4. Use commands with icons for Continue, Abort etc.
Instead of buttons with text? Or just add icons next to the text?
Comment 5 Szymon Brandys CLA 2011-07-19 17:24:22 EDT
(In reply to comment #4)
> (In reply to comment #3)
> > 1. When I try to rebase changes and there are unstaged or uncommitted changes
> I
> > get js errors. I need to stage and commit first then I can continue.
> Yes, it is how Git works. ;) To rebase, repository has to be in proper state.
> When I've tried to repeat your steps, I've got error message: Checkout conflict
> with file: [file_name]. It's expected, and it's probably JGit equivalent of:
> - "Cannot rebase: You have unsateged changes. Please commit or stash them."
> - "Cannor rebase: Your index contains uncommited changes. Please commit or stash
> them."
> what we can see in Git console version.

I should have been more precise. I got JS error that has nothing in common with your "Checkout conflict with file: [file_name"] warning. I will try to reproduce and paste the exact message.

> JS errors - there was an error, so it's logged. Ofc I can disable it, but i.e.
> when cloning fails (i.e. random URL), there are JS errors logged too.

Of course you should log errors. But the warning about incorrect repo state is something expected, so it should be shown in the status bar and the user should be asked to go to the status page to handle the problem. So far we may also log it. My issue was, that there was no link to the status page.

> > 2. Abort Skip patch and continue on the status page end up with
> >
> > POST http://localhost:8080/gitapi/commit/HEAD/file/a0/
> >
> > 500 Internal Server Error
> >         40ms
> > xhr.js (line 880)
> > Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> > var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
> > xhr.js (line 774)
> > HTTP status code: 500
> > gitClient.js (line 674)
> > GET http://localhost:8080/gitapi/status/file/a0/
> >
> > 200 OK
> >         263ms
> > xhr.js (line 880)
> > Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> > var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
> > xhr.js (line 774)
> > Error: Unable to load /gitapi/commit/HEAD/file/a0/ status:500
> > var err = new Error("Unable to load...Args.url + " status:" + xhr.status);
> >
> > or something similar
> I think that's the same case as above. Wrong repository state for "continue"
> operations. I guess that your probably skipped one patch, but there were still
> some conflicts after that operation (I'm almost sure, as "rebase panel" is shown
> in the rebase repository state, which is active only when there are some
> conflicts which are waiting to be resolved).

I was just clicking around. Nothing was shown in the status bar, just the console. And as you see errors say nothing.

> > 4. Use commands with icons for Continue, Abort etc.
> Instead of buttons with text? Or just add icons next to the text?

Commands. If they are commands we can easily change it into text or icon later.
Comment 6 Szymon Brandys CLA 2011-07-19 17:46:59 EDT
(In reply to comment #5) 
> I should have been more precise. I got JS error that has nothing in common with
> your "Checkout conflict with file: [file_name"] warning. I will try to reproduce
> and paste the exact message.

Sorry, I can't reproduce it now. The remaining issue though is to show the git status page link, if there are checkout conflicts related to unstaged or uncommitted changes.
Comment 7 Piotr Janik CLA 2011-07-20 12:02:26 EDT
https://github.com/pjanik/orion.client/tree/bug351429
https://github.com/pjanik/orion.server/tree/bug351429

The most obvious errors are handled. 
I've changed Continue, Abort and Skip to commands.
Comment 8 Szymon Brandys CLA 2011-07-22 04:41:51 EDT
We were chatting online yesterday about the problem with rebase --continue in some cases. 
Steps:

1) I have a repo cloned from ssh://sbrandys@git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git 
2) Add a remote using url git://github.com/pjanik/orion.client.git
3) Check out the bug351440 branch from pjanik remote
4) Try to rebase using master, you'll be asked to go to Git Status to resolve conflicts
5) Fix the conflicts using the git status page and compare views
6) Try to Continue and nothing happens

Two calls are made after 'Continue' is clicked

POST http://localhost:8080/gitapi/commit/HEAD/file/a5/ with {"RebaseOperation":"CONTINUE"} and the result is {"Result": "FAST_FORWARD"}

then

GET http://localhost:8080/gitapi/status/file/a5/ and the result is
{
  "Added": [],
  "Changed": [],
  "CloneLocation": "/gitapi/clone/file/a5/",
  "CommitLocation": "/gitapi/commit/HEAD/file/a5/",
  "Conflicting": [],
  "IndexLocation": "/gitapi/index/file/a5/",
  "Missing": [],
  "Modified": [],
  "Removed": [],
  "RepositoryState": "REBASING_INTERACTIVE",
  "Untracked": []
}

Pressing Continue calls RebaseCommand in GitCommithandletV1#rebase, so it may be a bug in JGit. When I try to rebase --continue in the console it ends the rebase and leaves the interactive mode.

I can reproduce it all the time.
Comment 9 Szymon Brandys CLA 2011-07-25 06:44:16 EDT
Piotrek,3 of 5 rebase tests fail. I checked that on another machine so it is not just me. For me it looks like the tests are not adjusted to the recent code changes.
Comment 10 Szymon Brandys CLA 2011-07-25 11:51:18 EDT
Fixed. We will raise new bugs for further work in this area.