Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!

Bug 248332

Summary: Offer sync of the current with tracked branch after Fetch
Product: versioncontrol Reporter: hifi
Component: GitAssignee: Ondrej Vrabec <ovrabec>
Status: RESOLVED FIXED QA Contact: issues <issues.netbeans.org>
Priority: P3 CC: git
Version: 8.1   
Target Milestone: 8.1   
Hardware: All   
OS: All   
Whiteboard:
Issue Type: ENHANCEMENT Exception Report:
Attachments: Full test case visually

Description hifi 2014-11-01 11:56:29 UTC
I've noticed that the "Automatically sync with tracked branch" feature of NetBeans git integration doesn't seem to work when doing "Fetch from Upstream". Instead the local branches go from "in-sync" to "behind" and I need to manually fast-forward each one of them.

It should sync all local branches when fetching if tracking is enabled and there is no merge involved.
Comment 1 Ondrej Vrabec 2014-11-03 10:08:55 UTC
Strange. It works for me correctly. I mark the branch i want to sync (Automatically sync with origin/BRANCH). Then i do Git -:> Fetch from Upstream and it's updated.
Are you sure the branch has its tracked branch and the Autosyc flag really enabled?
Comment 2 Ondrej Vrabec 2014-11-03 10:09:26 UTC
Also please check the IDE log for any related errors (attach it here after the fetch action).
Comment 3 hifi 2014-11-04 19:08:15 UTC
Created attachment 150274 [details]
Full test case visually

To reproduce this in a clean room environment, I did this on my Linux machine with the 201411010002 nightly:

1) git init on a remote system, make the initial commit
2) clone the repo over ssh using NetBeans
3) enable sync for origin/master
3) add more commits remotely
4) fetch from upstream
5) master is behind origin

I couldn't attach the log here for reasons, but I hope this can be reproduced on your end like this. In the screenshot I first fetched the second commit, then tried to fetch again and it's a no-op as it should, then made more commits and fetched again. The master branch kept being on the initial commit.

I'm certain this happens on my Windows 7 machine too but again when I got the time to reply I was on a different system.
Comment 4 Ondrej Vrabec 2014-11-05 07:08:41 UTC
> 4) fetch from upstream
> 5) master is behind origin
That is correct of course, it works as expected. We cannot sync the current branch automatically because it requires a merge/rebase or a checkout at least (in which case your files will change right under our nose with a danger of you making changes to them in the meantime). That sync option works *only* for other (not checked-out) branches. What you want to do in this case is a git pull.

So it works as designed, but probably not as you expected. It merely works for all other branches than the currently checked-out (you can see on the screenshot that even the manual "Sync with origin/master" is disabled, that's the reason). Sorry if you expected something else.
Comment 5 hifi 2014-11-05 07:12:47 UTC
Couldn't it do that if your working directory is clean? That's the case when I expected it to fast-forward the checked out branch when there are no changes to be committed or no commits that would need to be merged so updating the working copy wouldn't have any negative effects.
Comment 6 Ondrej Vrabec 2014-11-05 07:16:07 UTC
(In reply to hifi from comment #5)
> Couldn't it do that if your working directory is clean? That's the case when
> I expected it to fast-forward the checked out branch when there are no
> changes to be committed or no commits that would need to be merged so
> updating the working copy wouldn't have any negative effects.
I guess it could ask you (after a fetch) if you want to sync and make the checkout. In that case the responsibility would be up to you (as a user). Because i am not very comfortable with actually messing with user source files without user noticing or approving it. Would that be ok?
Comment 7 hifi 2014-11-05 07:22:40 UTC
That would be much better in my opinion than leaving you "hanging" without any idea why the sync "isn't working".

So offering to fast-forward the current branch if it is by all means possible (no unsaved modifications in any editor tab for the files or saved modifications in the working copy or commits that would prevent ff) would be nice. Also the manual sync button should be enabled if these conditions are met as it would effectively work as a shortcut if you don't have syncing enabled.
Comment 8 Ondrej Vrabec 2014-11-05 07:30:08 UTC
(In reply to hifi from comment #7)
> That would be much better in my opinion than leaving you "hanging" without
> any idea why the sync "isn't working".
ok.
> So offering to fast-forward the current branch if it is by all means
> possible (no unsaved modifications in any editor tab for the files or saved
> modifications in the working copy or commits that would prevent ff) would be
> nice.
Not sure if we can ensure that for 100%, but in case you have local modifications preventing the checkout the checkout will probably just fail - with the same result.
> Also the manual sync button should be enabled if these conditions are
> met as it would effectively work as a shortcut if you don't have syncing
> enabled.
That's what i offered as a solution for bug 248334, but you were kind of against it :-). That button would offer you the same as during pull (if a merge is needed, then offering merge or rebase)
Comment 9 Ondrej Vrabec 2014-11-07 17:23:58 UTC
fixed: core-main #37e39335d381
Comment 10 Quality Engineering 2014-11-08 10:59:31 UTC
Integrated into 'main-silver', will be available in build *201411080653* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/37e39335d381
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: Issue #248332 - Offer sync of the current with tracked branch after Fetch
Comment 11 hifi 2014-11-10 06:01:26 UTC
Just got around testing the sync suggestion on fetch for current branch, works nice and is a welcome change. Thank you.
Comment 12 hifi 2015-04-15 04:30:08 UTC
I must comment after using this for almost 6 months now that it's a beautiful thing.

I do stuff, co-worker does stuff. He pushes, I fetch, NetBeans asks me if I want to synchronize the checked out tracked branch, I agree, NetBeans tells me it's not a fast-forward, I select Rebase usually, cue magic if no conflicts, I'm now ahead of origin, I push my changes and we're done. I didn't need to go through anything else than two useful dialogs.

Even when there's nothing to merge it's very handy that it will automatically sync the checked out branch so continuing a project is as fast as one click on "Fetch from Upstream" toolbar button and agreeing on the dialog.

In addition getting the rebase/merge stuff flowing with dialogs as suggested in bug 250823 and 250826 will definitely be a big improvement as well. I might not need to hold everyone's hand all the time after that.

This is how you support workflow! It's just brilliant to be working with the nightly version. Now the only thing we're missing is a release. My co-workers are struggling without these and they generally only use the stable releases.
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo