You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "Chris2011 (via GitHub)" <gi...@apache.org> on 2025/10/15 19:12:42 UTC

[PR] Choose between multiple remotes instead of showing an error [netbeans]

Chris2011 opened a new pull request, #8922:
URL: https://github.com/apache/netbeans/pull/8922

   If you have add more than one remote and you want to push an untracked branch, NetBeans just shows an error that it can't choose the correct remote due to many remotes.
   
   I added this for push to upstream and pull from upstream. If we have multiple remotes, it just opens the same UI for pull/push and preselect the current branch.
   
   For push it will also ask for setting this branch tracked to the remote branch. I have a problem for doing the same for pull. I guess it is a thread thing.
   
   Inside of PullAction in the method perform, it never hits the finally block, due to removing the threadlocal variable inside the runWithoutInding method. I dunno whether this is a bug but for me it feels like that. So I couldn't test it.
   
   The PR is not finished yet, but you already can have a look and left comments please.
   
   
   ### PR approval and merge checklist:
   
   1. [ ] Was this PR [correctly labeled](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=240884239#PRsandYouAreviewerGuide-PRtriggeredCIJobs(conditionalCIpipeline)), did the right tests run? When did they run?
   2. [ ] Is this PR [squashed](https://cwiki.apache.org/confluence/display/NETBEANS/git%3A+squash+and+merge)?
   3. [ ] Are author name / email address correct? Are [co-authors](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line) correctly listed? Do the commit messages need updates?
   3. [ ] Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?
   
   If this PR targets the delivery branch: [don't merge](https://cwiki.apache.org/confluence/display/NETBEANS/Pull+requests+for+delivery). ([full wiki article](https://cwiki.apache.org/confluence/display/NETBEANS/PRs+and+You+-+A+reviewer+Guide))
   
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#issuecomment-3645645422

   Seemed that there are no failing tests, pipeline had a hickup probably.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#issuecomment-3700171109

   @matthiasblaesing I really appreciate your help, so no worries :). Thx.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2651743298


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullAction.java:
##########
@@ -182,55 +189,71 @@ protected void perform () {
                         return;
                     }
                 }
-                GitUtils.runWithoutIndexing(new Callable<Void>() {
-                    @Override
-                    public Void call () throws Exception {
-                        for (String branch : toDelete) {
-                            client.deleteBranch(branch, true, getProgressMonitor());
-                            getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
-                        }
-                        setDisplayName(Bundle.MSG_PullAction_fetching());
-                        Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
-                                client, getProgressMonitor(), target, fetchRefSpecs);
-                        if (isCanceled()) {
-                            return null;
+                GitUtils.runWithoutIndexing(() -> {
+                    for (String branch : toDelete) {
+                        client.deleteBranch(branch, true, getProgressMonitor());
+                        getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
+                    }
+                    setDisplayName(Bundle.MSG_PullAction_fetching());
+                    Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
+                        client, getProgressMonitor(), target, fetchRefSpecs);
+                    if (isCanceled()) {
+                        return null;
+                    }
+                    FetchUtils.log(repository, fetchResult, getLogger());
+                    if (!isCanceled()) {
+                        setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
+                        FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                    }
+                    if (isCanceled() || branchToMerge == null) {
+                        return null;
+                    }
+                    new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
+                        
+                        @Override
+                        public GitClient getClient () throws GitException {
+                            return client;
                         }
-                        FetchUtils.log(repository, fetchResult, getLogger());
-                        if (!isCanceled()) {
-                            setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
-                            FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                        
+                        @Override
+                        public OutputLogger getLogger () {
+                            return GitProgressSupportImpl.this.getLogger();
                         }
-                        if (isCanceled() || branchToMerge == null) {
-                            return null;
+                        
+                        @Override
+                        public ProgressDelegate getProgress () {
+                            return GitProgressSupportImpl.this.getProgress();
                         }
-                        new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
-
-                            @Override
-                            public GitClient getClient () throws GitException {
-                                return client;
-                            }
-
-                            @Override
-                            public OutputLogger getLogger () {
-                                return GitProgressSupportImpl.this.getLogger();
-                            }
-                            
-                            @Override
-                            public ProgressDelegate getProgress () {
-                                return GitProgressSupportImpl.this.getProgress();
-                            }
-                            
-                        }).execute();
-                        return null;
+                        
+                    }).execute();
+                    
+                    if (!isCanceled()) {
+                        pullSuccessful = true;
                     }
-                }, repository);
+                    
+                    return null;
+                }, repository);                
             } catch (GitException ex) {
                 setError(true);
                 GitClientExceptionHandler.notifyException(ex, true);
             } finally {
                 setDisplayName(NbBundle.getMessage(GitAction.class, "LBL_Progress.RefreshingStatuses")); //NOI18N
                 Git.getInstance().getFileStatusCache().refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Git.getInstance().getSeenRoots(repository)));
                 GitUtils.headChanged(repository);
+
+                // Check if tracking should be set up after successful pull
+                if (pullSuccessful && branchToMerge != null) {
+                    RepositoryInfo info = RepositoryInfo.getInstance(repository);
+                    info.refresh();
+                    GitBranch activeBranch = info.getActiveBranch();
+                    if (activeBranch != null && activeBranch.getTrackedBranch() == null) {
+                        // branchToMerge is the remote branch name (e.g., "origin/master")
+                        if (shallSetupTracking(activeBranch, branchToMerge)) {
+                            SystemAction.get(SetTrackingAction.class).setupTrackedBranchImmediately(
+                                    repository, activeBranch.getName(), branchToMerge);
+                        }
+                    }

Review Comment:
   If this is the hint then thx for this. It never gets into the finally block, beause of another thread is cancelling this. The magic happens in GitUtils.java:886.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#issuecomment-3419979833

   I also added a null check, due to a NPE throwing. I see failing tests, I will fix them soon.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2641261471


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullBranchesStep.java:
##########
@@ -129,7 +129,11 @@ public void setRemote (GitRemoteConfig remote) {
     }
 
     public void fillRemoteBranches (final Map<String, GitBranch> branches) {
-        fillRemoteBranches(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap());
+        fillRemoteBranches(branches, null);
+    }
+
+    public void fillRemoteBranches (final Map<String, GitBranch> branches, final GitBranch branchToSelect) {
+        fillRemoteBranchesInternal(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap(), null);

Review Comment:
   Is the intention here to start with an empty list in any case and then update when loading is done? That might be worth a comment.
   
   I was wondering why `null` is passed here as `branchToSelect`. That makes only sense to me, if we just want to initialize.



##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullAction.java:
##########
@@ -182,55 +189,71 @@ protected void perform () {
                         return;
                     }
                 }
-                GitUtils.runWithoutIndexing(new Callable<Void>() {
-                    @Override
-                    public Void call () throws Exception {
-                        for (String branch : toDelete) {
-                            client.deleteBranch(branch, true, getProgressMonitor());
-                            getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
-                        }
-                        setDisplayName(Bundle.MSG_PullAction_fetching());
-                        Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
-                                client, getProgressMonitor(), target, fetchRefSpecs);
-                        if (isCanceled()) {
-                            return null;
+                GitUtils.runWithoutIndexing(() -> {
+                    for (String branch : toDelete) {
+                        client.deleteBranch(branch, true, getProgressMonitor());
+                        getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
+                    }
+                    setDisplayName(Bundle.MSG_PullAction_fetching());
+                    Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
+                        client, getProgressMonitor(), target, fetchRefSpecs);
+                    if (isCanceled()) {
+                        return null;
+                    }
+                    FetchUtils.log(repository, fetchResult, getLogger());
+                    if (!isCanceled()) {
+                        setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
+                        FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                    }
+                    if (isCanceled() || branchToMerge == null) {
+                        return null;
+                    }
+                    new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
+                        
+                        @Override
+                        public GitClient getClient () throws GitException {
+                            return client;
                         }
-                        FetchUtils.log(repository, fetchResult, getLogger());
-                        if (!isCanceled()) {
-                            setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
-                            FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                        
+                        @Override
+                        public OutputLogger getLogger () {
+                            return GitProgressSupportImpl.this.getLogger();
                         }
-                        if (isCanceled() || branchToMerge == null) {
-                            return null;
+                        
+                        @Override
+                        public ProgressDelegate getProgress () {
+                            return GitProgressSupportImpl.this.getProgress();
                         }
-                        new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
-
-                            @Override
-                            public GitClient getClient () throws GitException {
-                                return client;
-                            }
-
-                            @Override
-                            public OutputLogger getLogger () {
-                                return GitProgressSupportImpl.this.getLogger();
-                            }
-                            
-                            @Override
-                            public ProgressDelegate getProgress () {
-                                return GitProgressSupportImpl.this.getProgress();
-                            }
-                            
-                        }).execute();
-                        return null;
+                        
+                    }).execute();
+                    
+                    if (!isCanceled()) {
+                        pullSuccessful = true;
                     }
-                }, repository);
+                    
+                    return null;
+                }, repository);                
             } catch (GitException ex) {
                 setError(true);
                 GitClientExceptionHandler.notifyException(ex, true);
             } finally {
                 setDisplayName(NbBundle.getMessage(GitAction.class, "LBL_Progress.RefreshingStatuses")); //NOI18N
                 Git.getInstance().getFileStatusCache().refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Git.getInstance().getSeenRoots(repository)));
                 GitUtils.headChanged(repository);
+
+                // Check if tracking should be set up after successful pull
+                if (pullSuccessful && branchToMerge != null) {
+                    RepositoryInfo info = RepositoryInfo.getInstance(repository);
+                    info.refresh();
+                    GitBranch activeBranch = info.getActiveBranch();
+                    if (activeBranch != null && activeBranch.getTrackedBranch() == null) {
+                        // branchToMerge is the remote branch name (e.g., "origin/master")
+                        if (shallSetupTracking(activeBranch, branchToMerge)) {
+                            SystemAction.get(SetTrackingAction.class).setupTrackedBranchImmediately(
+                                    repository, activeBranch.getName(), branchToMerge);
+                        }
+                    }

Review Comment:
   Am I correct in assuming, that this not called on the EDT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#issuecomment-3699047146

   Just to clarify: my comments were not meant to block. When rebased, I think this is fine to merge.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2653642298


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullAction.java:
##########
@@ -182,55 +189,71 @@ protected void perform () {
                         return;
                     }
                 }
-                GitUtils.runWithoutIndexing(new Callable<Void>() {
-                    @Override
-                    public Void call () throws Exception {
-                        for (String branch : toDelete) {
-                            client.deleteBranch(branch, true, getProgressMonitor());
-                            getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
-                        }
-                        setDisplayName(Bundle.MSG_PullAction_fetching());
-                        Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
-                                client, getProgressMonitor(), target, fetchRefSpecs);
-                        if (isCanceled()) {
-                            return null;
+                GitUtils.runWithoutIndexing(() -> {
+                    for (String branch : toDelete) {
+                        client.deleteBranch(branch, true, getProgressMonitor());
+                        getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
+                    }
+                    setDisplayName(Bundle.MSG_PullAction_fetching());
+                    Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
+                        client, getProgressMonitor(), target, fetchRefSpecs);
+                    if (isCanceled()) {
+                        return null;
+                    }
+                    FetchUtils.log(repository, fetchResult, getLogger());
+                    if (!isCanceled()) {
+                        setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
+                        FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                    }
+                    if (isCanceled() || branchToMerge == null) {
+                        return null;
+                    }
+                    new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
+                        
+                        @Override
+                        public GitClient getClient () throws GitException {
+                            return client;
                         }
-                        FetchUtils.log(repository, fetchResult, getLogger());
-                        if (!isCanceled()) {
-                            setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
-                            FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                        
+                        @Override
+                        public OutputLogger getLogger () {
+                            return GitProgressSupportImpl.this.getLogger();
                         }
-                        if (isCanceled() || branchToMerge == null) {
-                            return null;
+                        
+                        @Override
+                        public ProgressDelegate getProgress () {
+                            return GitProgressSupportImpl.this.getProgress();
                         }
-                        new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
-
-                            @Override
-                            public GitClient getClient () throws GitException {
-                                return client;
-                            }
-
-                            @Override
-                            public OutputLogger getLogger () {
-                                return GitProgressSupportImpl.this.getLogger();
-                            }
-                            
-                            @Override
-                            public ProgressDelegate getProgress () {
-                                return GitProgressSupportImpl.this.getProgress();
-                            }
-                            
-                        }).execute();
-                        return null;
+                        
+                    }).execute();
+                    
+                    if (!isCanceled()) {
+                        pullSuccessful = true;
                     }
-                }, repository);
+                    
+                    return null;
+                }, repository);                
             } catch (GitException ex) {
                 setError(true);
                 GitClientExceptionHandler.notifyException(ex, true);
             } finally {
                 setDisplayName(NbBundle.getMessage(GitAction.class, "LBL_Progress.RefreshingStatuses")); //NOI18N
                 Git.getInstance().getFileStatusCache().refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Git.getInstance().getSeenRoots(repository)));
                 GitUtils.headChanged(repository);
+
+                // Check if tracking should be set up after successful pull
+                if (pullSuccessful && branchToMerge != null) {
+                    RepositoryInfo info = RepositoryInfo.getInstance(repository);
+                    info.refresh();
+                    GitBranch activeBranch = info.getActiveBranch();
+                    if (activeBranch != null && activeBranch.getTrackedBranch() == null) {
+                        // branchToMerge is the remote branch name (e.g., "origin/master")
+                        if (shallSetupTracking(activeBranch, branchToMerge)) {
+                            SystemAction.get(SetTrackingAction.class).setupTrackedBranchImmediately(
+                                    repository, activeBranch.getName(), branchToMerge);
+                        }
+                    }

Review Comment:
   It could be, that runWithoutindexing is not part here, but I set breakpoints and see, that only the finally block inside of the runWithoutIndexing is executed, after this , no other finally block is reached. So the inner finally block is reached, the outer not. This is why I'm confused.  As said, my assumption is something with different threads?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2653646973


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullBranchesStep.java:
##########
@@ -129,7 +129,11 @@ public void setRemote (GitRemoteConfig remote) {
     }
 
     public void fillRemoteBranches (final Map<String, GitBranch> branches) {
-        fillRemoteBranches(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap());
+        fillRemoteBranches(branches, null);
+    }
+
+    public void fillRemoteBranches (final Map<String, GitBranch> branches, final GitBranch branchToSelect) {
+        fillRemoteBranchesInternal(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap(), null);

Review Comment:
   Yes, at the end, it is just to make everything set to the default. The null value. If the branchToSelect is set, line 175 is reached. Everything else, is for the default behaviour.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#issuecomment-3407918890

   I will do a correct squash and merge at the end. Unfortunately I merged master after my commit. Sry for that.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2652702518


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullBranchesStep.java:
##########
@@ -129,7 +129,11 @@ public void setRemote (GitRemoteConfig remote) {
     }
 
     public void fillRemoteBranches (final Map<String, GitBranch> branches) {
-        fillRemoteBranches(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap());
+        fillRemoteBranches(branches, null);
+    }
+
+    public void fillRemoteBranches (final Map<String, GitBranch> branches, final GitBranch branchToSelect) {
+        fillRemoteBranchesInternal(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap(), null);

Review Comment:
   Sorry, I don't get it. line 169-173 can't be reached for the marked case. I mean this call:
   
   ```java
           fillRemoteBranchesInternal(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap(), null);
   ```
   
   This will basicly execute (the maps are empty, so all loops in `fillRemoteBranchesInternal` will not execute):
   
   ```java
           List<BranchMapping> l = new ArrayList<BranchMapping>(0);
           Set<String> displayedBranches = new HashSet<String>(0);
           this.branches.setBranches(l);
           stateChanged(new ChangeEvent(this));
   ```
   
   I read this as "reset the item selector into a clean state".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "matthiasblaesing (via GitHub)" <gi...@apache.org>.
matthiasblaesing commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2652777246


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullAction.java:
##########
@@ -182,55 +189,71 @@ protected void perform () {
                         return;
                     }
                 }
-                GitUtils.runWithoutIndexing(new Callable<Void>() {
-                    @Override
-                    public Void call () throws Exception {
-                        for (String branch : toDelete) {
-                            client.deleteBranch(branch, true, getProgressMonitor());
-                            getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
-                        }
-                        setDisplayName(Bundle.MSG_PullAction_fetching());
-                        Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
-                                client, getProgressMonitor(), target, fetchRefSpecs);
-                        if (isCanceled()) {
-                            return null;
+                GitUtils.runWithoutIndexing(() -> {
+                    for (String branch : toDelete) {
+                        client.deleteBranch(branch, true, getProgressMonitor());
+                        getLogger().outputLine(Bundle.MSG_PullAction_branchDeleted(branch));
+                    }
+                    setDisplayName(Bundle.MSG_PullAction_fetching());
+                    Map<String, GitTransportUpdate> fetchResult = FetchAction.fetchRepeatedly(
+                        client, getProgressMonitor(), target, fetchRefSpecs);
+                    if (isCanceled()) {
+                        return null;
+                    }
+                    FetchUtils.log(repository, fetchResult, getLogger());
+                    if (!isCanceled()) {
+                        setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
+                        FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                    }
+                    if (isCanceled() || branchToMerge == null) {
+                        return null;
+                    }
+                    new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
+                        
+                        @Override
+                        public GitClient getClient () throws GitException {
+                            return client;
                         }
-                        FetchUtils.log(repository, fetchResult, getLogger());
-                        if (!isCanceled()) {
-                            setDisplayName(Bundle.MSG_PullAction_progress_syncBranches());
-                            FetchUtils.syncTrackingBranches(repository, fetchResult, GitProgressSupportImpl.this, GitProgressSupportImpl.this.getProgress(), false);
+                        
+                        @Override
+                        public OutputLogger getLogger () {
+                            return GitProgressSupportImpl.this.getLogger();
                         }
-                        if (isCanceled() || branchToMerge == null) {
-                            return null;
+                        
+                        @Override
+                        public ProgressDelegate getProgress () {
+                            return GitProgressSupportImpl.this.getProgress();
                         }
-                        new BranchSynchronizer(branchToMerge, repository, new BranchSynchronizer.GitProgressSupportDelegate() {
-
-                            @Override
-                            public GitClient getClient () throws GitException {
-                                return client;
-                            }
-
-                            @Override
-                            public OutputLogger getLogger () {
-                                return GitProgressSupportImpl.this.getLogger();
-                            }
-                            
-                            @Override
-                            public ProgressDelegate getProgress () {
-                                return GitProgressSupportImpl.this.getProgress();
-                            }
-                            
-                        }).execute();
-                        return null;
+                        
+                    }).execute();
+                    
+                    if (!isCanceled()) {
+                        pullSuccessful = true;
                     }
-                }, repository);
+                    
+                    return null;
+                }, repository);                
             } catch (GitException ex) {
                 setError(true);
                 GitClientExceptionHandler.notifyException(ex, true);
             } finally {
                 setDisplayName(NbBundle.getMessage(GitAction.class, "LBL_Progress.RefreshingStatuses")); //NOI18N
                 Git.getInstance().getFileStatusCache().refreshAllRoots(Collections.<File, Collection<File>>singletonMap(repository, Git.getInstance().getSeenRoots(repository)));
                 GitUtils.headChanged(repository);
+
+                // Check if tracking should be set up after successful pull
+                if (pullSuccessful && branchToMerge != null) {
+                    RepositoryInfo info = RepositoryInfo.getInstance(repository);
+                    info.refresh();
+                    GitBranch activeBranch = info.getActiveBranch();
+                    if (activeBranch != null && activeBranch.getTrackedBranch() == null) {
+                        // branchToMerge is the remote branch name (e.g., "origin/master")
+                        if (shallSetupTracking(activeBranch, branchToMerge)) {
+                            SystemAction.get(SetTrackingAction.class).setupTrackedBranchImmediately(
+                                    repository, activeBranch.getName(), branchToMerge);
+                        }
+                    }

Review Comment:
   `runWithoutIndexing` can't have part in this. It is _inside_ the `try`-block, so the finally still must be executed (try-block is line 170-236, finally is lines 240-256). I'm not aware of ways to skip execution of a finally block.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: [PR] Choose between multiple remotes instead of showing an error [netbeans]

Posted by "Chris2011 (via GitHub)" <gi...@apache.org>.
Chris2011 commented on code in PR #8922:
URL: https://github.com/apache/netbeans/pull/8922#discussion_r2651738059


##########
ide/git/src/org/netbeans/modules/git/ui/fetch/PullBranchesStep.java:
##########
@@ -129,7 +129,11 @@ public void setRemote (GitRemoteConfig remote) {
     }
 
     public void fillRemoteBranches (final Map<String, GitBranch> branches) {
-        fillRemoteBranches(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap());
+        fillRemoteBranches(branches, null);
+    }
+
+    public void fillRemoteBranches (final Map<String, GitBranch> branches, final GitBranch branchToSelect) {
+        fillRemoteBranchesInternal(Collections.<String,GitBranch>emptyMap(), Collections.<String,GitBranch>emptyMap(), null);

Review Comment:
   I tested it yes (Maybe I missed a thing, as always. When you pull a branch without upstream, nothing is selected. When you do a pull from upstream, the error came up "no tracked brach specified for local branch....". And if I remove this, nothing is selected anymore on pull from upstrean. It can be, that I need to modify the line 169 - 173.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists