Bug 339397 - [server] git-status "unstage all" showed all of my files in the unstage list (not just the changed ones)
Summary: [server] git-status "unstage all" showed all of my files in the unstage list ...
Status: RESOLVED WORKSFORME
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: Git (show other bugs)
Version: 0.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on: 301775
Blocks: 342502
  Show dependency tree
 
Reported: 2011-03-09 12:47 EST by Susan McCourt CLA
Modified: 2012-06-11 04:15 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Susan McCourt CLA 2011-03-09 12:47:21 EST
I had three files that were changed in git.
I staged one.
Decided to unstage it.

- couldn't find a single "unstage" command.  Can you only unstage all?
- I pressed unstage all and ended up with a list of *all* the files from the repo as unstaged.  Refreshed the page and it was still there.

Panicked.  Went to Git GUI and pressed "rescan".  It showed only the three files.  Reloaded git-status.  Now it shows only the three files.

Perhaps for M6 we should consider an "unstage" command to avoid this scenario?
Comment 1 libing wang CLA 2011-03-09 12:53:06 EST
Susan , there is no support from the server yet for unstaging sigle file .
Regarding the "all file unstaged" issue , could not reproduce here but I will investigate further.
Comment 2 Susan McCourt CLA 2011-03-09 13:04:57 EST
I just pulled the server again and restarted it.
Same problem.
Rescanning the files in Git Gui corrects it, otherwise all files are listed.
I'm on Win7, using msysgit
Comment 3 Boris Bokowski CLA 2011-03-09 13:52:41 EST
Is your top-level folder (project) in Orion the same directory as the Git repository you are using? I.e. if you have a local directory "org.eclipse.orion.client" containing ".git" and "bundles", is that the directory you link to from Orion?

Tomek, would this be a possible cause for the behaviour Susan is seeing?
Comment 4 Boris Bokowski CLA 2011-03-09 13:53:55 EST
And yes, it's a known limitation that you can only unstage all (but it shouldn't show every single file as modified).
Comment 5 libing wang CLA 2011-03-09 14:13:39 EST
I am routing this to Tomasz.
Susan and I spent some time tackling it down.
She created a freshh link to her git repo and I tried on her server as well.
Not sure why server responded all the files.
I even tried to view the diff and there was no real diff.
Comment 6 libing wang CLA 2011-03-09 14:15:54 EST
additional info : I tried same steps on my server (pulled the latest code ) and couldn't reproduce.
Comment 7 Tomasz Zarna CLA 2011-03-10 04:44:01 EST
(In reply to comment #3)
> Tomek, would this be a possible cause for the behaviour Susan is seeing?
(In reply to comment #5)
> Not sure why server responded all the files.
> I even tried to view the diff and there was no real diff.

The first thing that came to my mind was that line endings must have changed from CRLF to LF or vice versa.
Comment 8 Tomasz Zarna CLA 2011-03-10 04:58:10 EST
I'm trying to reproduce it on my side... 

In the meantime, Susan, I assume you used msysgit to create the clone, right? Do you have core.autocrlf option on or off? Did "git diff" and "git diff -w" give same results?
Comment 9 Tomasz Zarna CLA 2011-03-10 07:47:58 EST
I'm able to reproduce, even better, I've got a failing test for that case. Mixing different line endings (CRLF and LF) across files and having the core.autocrlf option set to "true" gave me a similar result - after unstaging (all) I got an extra file marked as modified, a file which I didn't touch at all. 

What is werid, if I do "git status" in bash just before I ask for the same thing using REST API the test passes. Trying to figure out what's going on...
Comment 10 Tomasz Zarna CLA 2011-03-10 08:40:55 EST
I think I've got it: A clone created with CloneCommand will have auto.crlf set to "false" on the repository level. On the other hand, If you clone the same repo with msysgit it will not set that option and use the global setting, which I guess is set to "true". The bad news is that JGit doesn't support the core.autocrlf option[1], so we cannot make it return the same result as msysgit/native git.

Workaround: "git config --global core.autocrlf false"

[1] bug 301775
Comment 11 libing wang CLA 2011-03-10 09:37:36 EST
(In reply to comment #10)
> I think I've got it: A clone created with CloneCommand will have auto.crlf set
> to "false" on the repository level. On the other hand, If you clone the same
> repo with msysgit it will not set that option and use the global setting, which
> I guess is set to "true". The bad news is that JGit doesn't support the
> core.autocrlf option[1], so we cannot make it return the same result as
> msysgit/native git.
> 
> Workaround: "git config --global core.autocrlf false"
> 
> [1] bug 301775

Tomasz , it would be nice if we can add this to the git-clone section in wiki.
People starting to use  our git features may hit the same issue by chance.
Comment 12 Tomasz Zarna CLA 2011-03-10 10:20:23 EST
Until JGit guys fix bug 301775 I will turn autocrlf off (set it to false) for the time of creating a Git Status response and when done set it back to the original value -- b6c6e3e2d8d89ba8416508330a7d251084eef367.
Comment 13 John Arthorne CLA 2011-03-10 15:42:05 EST
(In reply to comment #12)
> Until JGit guys fix bug 301775 I will turn autocrlf off (set it to false) for
> the time of creating a Git Status response and when done set it back to the
> original value -- b6c6e3e2d8d89ba8416508330a7d251084eef367.

This workaround isn't quite right. When getting the preference it does:

autocrlf = config.getString(...);

But then in the finally block it does:

boolean p = Boolean.parseBoolean(autocrlf);
config.setBoolean(...);

The problem is that "autocrlf" is not a boolean. It supports values of "true", "false", or "input". A value of "input" will be converted to "false" in this case.

More deeply, we are bashing this value for the "status" command, but not for other commands. It seems like this means the extra files will be hidden from our status view, but stage/unstage/commit will operate on them anyway. Overall this feels very unsafe. We are going to revert this workaround, and instead document the other workaround... People using a mixture of JGit and non-JGit clients for git should disable autocrlf until the JGit bug is fixed:

"git config --global core.autocrlf false"
Comment 14 Susan McCourt CLA 2011-03-10 16:20:50 EST
I agree the fix sounds risky and I think the right fix is at the JGit level.

I tried the workaround.  Of course the first time you change the setting, the git client will show all files as changed (as did git-status).  I had to revert all the changes and after that, the git client and Orion git-status operate as I expect.

> We are going to revert this workaround, and instead
> document the other workaround... People using a mixture of JGit and non-JGit
> clients for git should disable autocrlf until the JGit bug is fixed:

"People using a mixture of JGit and non-JGit clients" really means "anyone who downloads Orion to run locally and runs a typical git client."  So we need to make sure the warning is prominent in the "Getting the code" wiki or anywhere else where we talk about localhost usage.

If I don't know/care that Orion uses JGit, I won't understand the explanation.  So I suggest wording like:

------------

Orion git support is implemented using JGit.  A bug in JGit (bug 301775) prevents the Orion client from showing the correct git status when core.autocrlf is set to true.  If you are using a git client other than JGit, you must set core.autocrlf to false in order for the Orion git status to operate properly.

 "git config --global core.autocrlf false"
Comment 15 Susan McCourt CLA 2011-03-10 16:31:08 EST
We should also say:

"If you need to run with core.autocrlf set to true, you can still use the Orion git status GUI, but you should always run your git client's status command before using the Orion git status GUI."  

(someone with more git knowledge can explain why this works, but this is what I've been doing.)
Comment 16 Tomasz Zarna CLA 2011-03-11 06:09:09 EST
I've marked the GitResetTest.testResetAutocrlfTrue() test to be ignored, so all tests pass again -- 144f8cce6201f5117dd4416511d704ba53477960.
Comment 17 libing wang CLA 2011-05-18 10:23:25 EDT
Simon showed me the similar issue today :unchanged files are listed as unstaged. It prevented him from self-hosting.
If JGit can not fix our depending issue we may want to figure out a way on our side. Otherwise I think it is a show stopper for June release.
Comment 18 Tomasz Zarna CLA 2011-05-18 10:43:31 EDT
I'll try to find some time and look at it this week.
Comment 19 Simon Kaegi CLA 2011-05-18 10:45:26 EDT
(In reply to comment #17)
> Simon showed me the similar issue today :unchanged files are listed as
> unstaged. It prevented him from self-hosting.


A bit more info...

I have core.autocrlf=false set but I am still hosed.

What I did was link my org.eclipse.orion.client folder. My git repo was created by using the regular bash shell git commands with cygwin.

If I use the command-line my git status looks fine. I've tried a new checkout, switching branches, running git gc, a hard git reset but am still broken in the webui.
Comment 20 Susan McCourt CLA 2011-05-18 14:00:17 EDT
while you are looking into this, please read bug 344038.  I know nothing at all about the git implementation but my gut tells me that this is a related symptom because it is also of the variety of "my command line created git repo was okay and then it was hosed from an Orion point of view."
Comment 21 Tomasz Zarna CLA 2011-05-20 06:38:25 EDT
(In reply to comment #17)
> If JGit can not fix our depending issue we may want to figure out a way on our
> side. Otherwise I think it is a show stopper for June release.

AFAIK linking to a clone in local file system was supposed to be a short term solution. If so, the only way to work with a git repository is to clone one in Orion. From what I can see on both bugs (this one and bug 344038) this would prevent Simon and Susan from seeing all those nasty things. I'm not saying it's not a issue, but I don't think it's 'critical'.

I'm still trying to understand what's going on.
Comment 22 Tomasz Zarna CLA 2011-05-20 09:34:21 EDT
(In reply to comment #19)
> I have core.autocrlf=false set but I am still hosed.

I will need exact steps for this. I've followed your description and it worked fine for me:
1. set global core.autocrlf to false
2. cloned a repo with msysgit
3. linked it to a project in Orion
4. modified a file
5. went to Git Status page
6. staged it, unstaged all
=> single file in the Unstaged section, good

If I go through the same steps but having autocrlf set to true (default) I'm seeing the same thing as in comment 0 (already confirmed in comment 9).
Comment 23 Tomasz Zarna CLA 2011-05-30 06:50:47 EDT
It's been over a week so I'm marking this one as "worksforme". If it's reproducable for you guys, please reopen and provide the exact steps you used to produce the problem.
Comment 24 Tomasz Zarna CLA 2011-06-06 04:02:07 EDT
Please ignore my last comment, the issue for which Susan has filed this bug is still valid. I read couple of last comments and closed the bug, sorry. The "worksforme" solution applies only to Simon's comment 19. I'm reopening the bug, clearing Target Milestone at the same time, as it doesn't seem to be as urgent as it used to be. Sorry for the noise.
Comment 25 libing wang CLA 2011-07-14 13:30:22 EDT
Mark hit the same issue today :
He cloned git://github.com/mamacdon/mamacdon.github.com.git by git bash.
He changed a file and used stage all to stage it. He saw dozens of files in the
staged area. 
I verified that he had  core.autocrlf as true.
So I set "git config --global core.autocrlf false" and cloned the repo.
Everything was fine then.
Hopefully this can be another test case when either Jgit fixes bug 301775 or we
provide a patch.
Comment 26 Robin Rosenberg CLA 2012-06-07 18:06:04 EDT
Is this still an issue?
Comment 27 Szymon Brandys CLA 2012-06-11 04:15:13 EDT
I haven't seen this for long time.