Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 339107

Summary: [server] Provide REST API for git checkout
Product: [ECD] Orion Reporter: Tomasz Zarna <tomasz.zarna>
Component: ClientAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: bokowski, libingw, Szymon.Brandys
Version: 0.2   
Target Milestone: 0.2   
Hardware: PC   
OS: Windows XP   
URL: http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html
Whiteboard:
Bug Depends on:    
Bug Blocks: 336116, 341384, 344280    

Description Tomasz Zarna CLA 2011-03-07 11:02:31 EST
We're going to need REST API for git checkout (switching to a branch).
Comment 1 Boris Bokowski CLA 2011-03-07 13:27:30 EST
yes, switching to a branch, but also "get rid of my local changes for this one file".
Comment 2 Szymon Brandys CLA 2011-04-29 10:42:06 EDT
*** Bug 344281 has been marked as a duplicate of this bug. ***
Comment 3 Tomasz Zarna CLA 2011-05-18 05:47:51 EDT
Fixed with http://git.eclipse.org/c/e4/org.eclipse.orion.server.git/commit/?id=de02a01c00b7c246fd4c401e63774c919a0c9888.

"git checkout -- {paths}" implemented as PUT on /git/clone/file/{path to folder with clone} with { "Path" : [ "{path1}", "{path2}" ] } as JSON request body
"git checkout "branch"" implemented as PUT on /git/clone/file/{path to folder with clone} with { "Branch" : "{branch}" } as JSON request body

For "git checkout {tree-ish} -- {paths}" see bug 346206.

In case of a failure the API is not doing well at the moment see bug 346201.
Comment 4 libing wang CLA 2011-05-26 16:13:25 EDT
Should we have the checkout location and the branch name in the git status response ? Otherwise I have to craft it again.
Comment 5 Szymon Brandys CLA 2011-05-27 04:26:03 EDT
major loss of function = major
Comment 6 Tomasz Zarna CLA 2011-05-27 06:31:08 EDT
Added CloneLocaton to Git Status response in http://git.eclipse.org/c/e4/org.eclipse.orion.server.git/commit/?id=c8cc60cd4f142db07f36dbfccd9c9646b77f8b55.

As for checking out branches, it's done on a different page, see bug 346213, no problems there.
Comment 8 libing wang CLA 2011-05-27 12:09:51 EDT
I implemented it in UI :
PUT http://localhost:8080/git/clone/file/K/
with
{"Path":["/file/K/bundles/org.eclipse.orion.client.git/static/git-status.js"]}

got this response

{"HttpCode":500,"DetailedMessage":"One of setGitDir or setWorkTree must be called.","Message":"Failed to handle /git/clone request for file/K/","Severity":"Error","Code":0}
Comment 9 libing wang CLA 2011-05-27 12:31:09 EDT
I implemented it in UI :
PUT http://localhost:8080/git/clone/file/K/
with
{"Path":["/file/K/bundles/org.eclipse.orion.client.git/static/git-status.js"]}

got this response

{"HttpCode":500,"DetailedMessage":"One of setGitDir or setWorkTree must be called.","Message":"Failed to handle /git/clone request for file/K/","Severity":"Error","Code":0}
Comment 10 Tomasz Zarna CLA 2011-05-30 06:37:20 EDT
Equivalents for both "git checkout -- {path}" (this bug) and "git reset HEAD -- {path}" (bug 338202) accept paths in a relative form eg. "folder/file.txt". Take a look at bug 338202, comment 5 or transcription from our last chat. So it does work as expected. However, I agree the format could be changed to what you used in comment 8 ("/file/{projectId}/folder/file.txt"). Since you make those requests from Git Status page I thought the first form would suit you better. Please open a separate bug if you would like to stick to the format from your last comment, but please leave this one as FIXED ;)
Comment 11 libing wang CLA 2011-05-30 09:00:57 EDT
(In reply to comment #10)
> Equivalents for both "git checkout -- {path}" (this bug) and "git reset HEAD --
> {path}" (bug 338202) accept paths in a relative form eg. "folder/file.txt".
> Take a look at bug 338202, comment 5 or transcription from our last chat. So it
> does work as expected. However, I agree the format could be changed to what you
> used in comment 8 ("/file/{projectId}/folder/file.txt"). Since you make those
> requests from Git Status page I thought the first form would suit you better.
> Please open a separate bug if you would like to stick to the format from your
> last comment, but please leave this one as FIXED ;)

I do not have to stick tot the format , I can use the relative path.But where is it from the git status response ? I am using .Location now .
Comment 12 libing wang CLA 2011-05-30 09:03:18 EDT
Ohh , I got it : "Path": "bundles/org.eclipse.orion.client.git/static/git-status.js"