Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » potentially risk during branch switch
potentially risk during branch switch [message #662779] Thu, 31 March 2011 18:00 Go to next message
Pawel is currently offline Pawel
Messages: 10
Registered: March 2011
Junior Member
I have Egit/JGit plugin 0.11.3, eclipse 3.5.2.

I create local branch (eg "masterTask1") on base of remote branch (eg "master").
Next I create second branch (eg "masterTask2") on base of the same remote branch ("master").

I checkout "masterTask1", make some changes in files, and then I checkout "masterTask2". After this I still can see changes I made in "masterTask1" !!!
Eclipse even not warn me, that there are some uncomitted changes.

This problem not happens when branches are created on different remote branches, only when they are on the same remote branch.

Best regards
Pawel

[Updated on: Thu, 14 April 2011 17:17]

Report message to a moderator

Re: critical bug in local branch [message #665507 is a reply to message #662779] Thu, 14 April 2011 16:41 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias Sohn
Messages: 556
Registered: July 2009
Senior Member
If you didn't commit the changes done on first branch they will not go away when you switch to another branch, that's how git behaves (also native git). Though it may happen that you get a checkout conflict in case the branch you try to checkout would destroy a not yet committed modification.
Re: critical bug in local branch [message #665519 is a reply to message #665507] Thu, 14 April 2011 17:16 Go to previous messageGo to next message
Pawel is currently offline Pawel
Messages: 10
Registered: March 2011
Junior Member
Thank you for response.
You right, thats the way how native git works.
So it's not a bug.

But...I think it is a place for potentially mistakes.
I think there is a very big risk, not to notice those changes and commit them accidentialy in incorrect branch.

I think taht icon or color on branch name, sygnalizing status (git status) would be great. I could then, easy check if there are any uncommited changes, and not to switch.

By the way
If you don't want your changes stays in workspace during switch, you need to use: "git stash" before switch. But there is a risk, that stash not hide unstaged changes....
And Egit not support stash...

Best regards
Paweł.

PS. I changed title of this topic and added feature request:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=341588

[Updated on: Thu, 14 April 2011 17:35]

Report message to a moderator

Re: critical bug in local branch [message #665784 is a reply to message #665519] Fri, 15 April 2011 18:17 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin Rosenberg
Messages: 319
Registered: July 2009
Senior Member
On 2011-04-14 23.16, Pawel wrote:
> Thank you for response.
> You right, thats the way how native git works.
> So it's not a bug.
>
> But...I think it is a place for potentially mistakes.
> I think there is a very big risk, not to notice those changes and commit
> them accidentialy in incorrect branch.
>
> I think taht icon or color on branch name, sygnalizing status (git
> status) would be great. I could then, easy check if there are any
> uncommited changes, and not to switch.
>
> By the way
> If you don't want your changes stays in workspace during switch, you
> need to use: "git stash" before switch. But there is a risk, that stash
> not hide unstaged changes....
> And Egit not support stash...

I think it would be a good idea for EGit to ask the user what to do when
there are uncommitted changes, even untracked ones and allow the user to
stash, commit, discard or bring along changes.

-- robin
Re: critical bug in local branch [message #665787 is a reply to message #665784] Fri, 15 April 2011 18:49 Go to previous messageGo to next message
Pawel is currently offline Pawel
Messages: 10
Registered: March 2011
Junior Member
Robin, its really good idea.

So, I try to describe solution.

1. There should be a option in EGit configuration: "Check uncommited files on branch switch/checkout"
2. If during branch switch EGit find uncomitted changes, it should ask user for decision:
--a. Abort switch (don't do anything)
--b. stash changes and continue switch
--c. commit changes and continue switch
--d. leave changes uncommited ang take them to branch XXX.

I know, that stash is not supported now, so it could be feature for far future.
By the way, I have just started friendship with git in my company. My colleagues are serious frightened about accidentialy commit files to incorrect branch after branch switch.

Best regards.
Paweł

[Updated on: Fri, 15 April 2011 18:51]

Report message to a moderator

Re: critical bug in local branch [message #665808 is a reply to message #665787] Sat, 16 April 2011 04:35 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin Rosenberg
Messages: 319
Registered: July 2009
Senior Member
On 2011-04-16 00.49, Pawel wrote:
> Robin, its really good idea.
>
> So, I try to describe solution.
>
> 1. There should be a option in EGit configuration: "Check uncommited
> files on branch switch/checkout"
> 2. If during branch switch EGit find uncomitted changes, it should ask
> user for decision:
> a. Abort switch (don't do anything)
> b. stash changes and continue switch
> c. commit changes and continue switch
> d. leave changes uncommited ang take them to branch XXX.
>
> I know, that stash is not supported now, so it could be feature for far
> future.

Can you enter this into bugzilla? Desribe it assuming stash is an
option.

> By the way, I have just started friendship with git in my company. My
> colleagues are serious frightened about accidentialy commit files to
> incorrect branch after branch switch.

Regardless of which tool you use, a sane procedure is to *always* do
a quick self-review of what you are committing. *Never* just commit.

-- robin
Re: critical bug in local branch [message #665870 is a reply to message #665808] Sun, 17 April 2011 14:06 Go to previous message
Pawel is currently offline Pawel
Messages: 10
Registered: March 2011
Junior Member
Added to bugzilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=343072

So you may vote Smile

Best regards
Paweł
Previous Topic:cloning an empty repository
Next Topic:too short labels on history view
Goto Forum:
  


Current Time: Thu Aug 21 17:59:51 EDT 2014

Powered by FUDForum. Page generated in 0.02248 seconds