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

Bug 349480

Summary: [client][server][git]All files (unstaged and staged) get committed
Product: [ECD] Orion Reporter: Silenio Quarti <Silenio_Quarti>
Component: ClientAssignee: Tomasz Zarna <tomasz.zarna>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P2 CC: eclipse.felipe, libingw, malgorzata.tomczyk, simon_kaegi, Szymon.Brandys
Version: 0.2Flags: libingw: review+
simon_kaegi: review+
Szymon.Brandys: review+
Target Milestone: 0.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
mylyn/context/zip none

Description Silenio Quarti CLA 2011-06-15 13:37:46 EDT
I am trying to reproduce the problems I mentioned in the status meeting. So I could not find steps. I believe is related to Unstage ALL. But I found this problem that could be related.

Steps:

1) Modify three files
2) Open Git status page
3) Stage on file, type message ("test") and commit
4) Refresh page (everything seems fine, other two files are unstaged and committed file is not showing)
5) Stage another file
6) Unstage ALL files

	The page shows the initial THREE files unstaged even though one has been committed already. Refreshing the page does not fix it. Opening side by side compare on file that was committed in step 3) does not show any diff.
Comment 1 John Arthorne CLA 2011-06-15 14:03:24 EDT
Is this a clone that was created with orion or command line?
Comment 2 Silenio Quarti CLA 2011-06-15 14:15:38 EDT
For this problem the clone was create with command line.
Comment 3 Silenio Quarti CLA 2011-06-15 14:22:00 EDT
I can reproduce this problem with core.aurocrlf set to true. It seems to work fine when set to false. It could be a dup of bug#339397.
Comment 4 Silenio Quarti CLA 2011-06-15 16:26:53 EDT
I was able to reproduce my original problem again: stage one file and commit it, but get all files (unstaged and staged) committed. I do not have exact steps. This is my work flow:

- Login in to orion.eclipse.org:8080
- Clone ssh://silenio@git.eclipse.org/gitroot/e4/org.eclipse.orion.client.git into a new folder
- modify several files
- stage a file
- unstage all
- stage another and commit
- modify another file
- stage another file
- unstage all
- stage a file and commit

At this point all files get committed instead of just the one I staged.  I will see if I can find more precise steps.
Comment 5 Tomasz Zarna CLA 2011-06-16 06:45:34 EDT
I'm not able to reproduce cases from neither comment 0 nor comment 4. I followed the steps on localhost[1] with sources pulled this morning (server+client). Tried with core.autocrlf on and off.

A set of precise, reproducible steps would be great.

PS. The case from comment 0 does sound like a dupe of bug 339397 indeed, so I'm updating the summary to match comment 4.

[1] I think I've lost my creds to orion.eclipse.org :/
Comment 6 Tomasz Zarna CLA 2011-06-16 07:31:31 EDT
(In reply to comment #4)
> - Login in to orion.eclipse.org:8080
> - Clone ssh://silenio@git.eclipse.org/gitroot/e4/org.eclipse.orion.client.git
> into a new folder
> - modify several files
> - stage a file
> - unstage all
> - stage another and commit
> - modify another file
> - stage another file
> - unstage all
> - stage a file and commit

These steps work fine to me on and Gosia orion.eclipse.org:8080.
Comment 7 Silenio Quarti CLA 2011-06-17 10:44:54 EDT
I am not able to come up with steps. So far I only had the problem three times.
Comment 8 Szymon Brandys CLA 2011-06-17 13:46:00 EDT
(In reply to comment #7)
> I am not able to come up with steps. So far I only had the problem three times.

We can't reproduce the issue locally. But let's look closer at it next week. We need to understand what is/was going on there.
Comment 9 Tomasz Zarna CLA 2011-06-20 06:33:52 EDT
Silenio, maybe if you described your dev profile like Felipe did in bug 349096, comment 10, this could shed some light on the issue. But I remember you told us you're working 100% in Orion and this is what I kept in mind when trying to reproduce the problem on my side in comment 5.
Comment 10 Silenio Quarti CLA 2011-06-20 11:20:48 EDT
I was only able to reproduce the problem from comment#4 when using 100% Orion (Dev1 from bug#349096).
Comment 11 Tomasz Zarna CLA 2011-06-21 10:59:28 EDT
I've found the steps (while playing with Orion), wrote a unit test for them... but it didn't fail. Switched back to Orion to double check if I didn't miss anything and found bug 349953. Still on it.
Comment 12 Tomasz Zarna CLA 2011-06-22 08:07:13 EDT
Found the culprit: "Commit all" on Git Status page uses HeadLocation for the current folder to commit files. When in a folder, the location looks like this /gitapi/commit/HEAD/file/{id}/folder. On the server side this is going to be interpreted as "commit all files in 'folder'", which when combined with using --only option for "git commit" will commit all changed/modified files in folder regardless of the index state.

The client should always use HeadLocation of the clone to "Commit All".

The fix has two parts:
[1] In the client (Git Statues page), I've changed the 'commit' function so it uses now HeadLocation from a clone. This will result in committing only staged files. Libing, please review the fix.
[2] On the server, I've added HeadLocation to JSON representation of a clone. I've also added a server-side test case verifying the fix[3].

[1] http://git.eclipse.org/c/e4/org.eclipse.orion.client.git/log/?h=bug349480
[2] http://git.eclipse.org/c/e4/org.eclipse.orion.server.git/log/?h=bug349480
[3] org.eclipse.orion.server.tests.servlets.git.GitCommitTest.testCommitAllInFolder()
Comment 13 Tomasz Zarna CLA 2011-06-22 08:08:40 EDT
Created attachment 198392 [details]
mylyn/context/zip
Comment 14 libing wang CLA 2011-06-22 10:40:50 EDT
+1. I've looked at the client code. Looks good.
Comment 15 Szymon Brandys CLA 2011-06-22 10:48:13 EDT
Both client and server changes look fine.