Bug 319828 - Branch name in project explorer not updated in certain scenarios
Summary: Branch name in project explorer not updated in certain scenarios
Status: RESOLVED FIXED
Alias: None
Product: kdevplatform
Classification: Developer tools
Component: project (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: 1.3.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-14 13:48 UTC by Kevin Funk
Modified: 2013-05-15 15:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
subproject branch change patch (2.18 KB, patch)
2013-05-14 18:01 UTC, Aleix Pol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Funk 2013-05-14 13:48:43 UTC
The branch name won't be updated in case one switches branches in certain scenarios.

Example:
Repository is located in /foo, hence there will be /foo/.git
Project is located in /foo/myproject
Project is opened in KDevelop from /foo/myproject/
In case one switches branch, KDevelop won't notice it.

I think the reason is that KDevelop tries to detect branch changes by tracking some file in $PROJECT_ROOT/.git, but in this special case .git/ is not located in $PROJECT_ROOT.

Reproducible: Always
Comment 1 Aleix Pol 2013-05-14 13:55:22 UTC
Sounds likely, can you check if this patch fixes the problem?

http://paste.ubuntu.com/5664541
Comment 2 Kevin Funk 2013-05-14 17:46:56 UTC
Your patch won't work because of the later code in VcsOverlayProxyModel:

void VcsOverlayProxyModel::repositoryBranchChanged(const KUrl& url)
{
    IProject* project = ICore::self()->projectController()->findProjectForUrl(url);
    ...
}

So we probably need a findProjectByRepositoryRoot(url) function (in either ProjectController or as local function)
Comment 3 Aleix Pol 2013-05-14 18:01:30 UTC
Created attachment 79888 [details]
subproject branch change patch

This patch changes the behavior so the projects' branches under the changed repository are fetched again.
Comment 4 Kevin Funk 2013-05-15 06:32:08 UTC
I fear that there are more problems wrt this issue:

Another scenario is that one has two projects open that reside in a single repository. In this case only one of the projects will be updated with VCS information in the project explorer.
Correct me if I'm wrong.

I can have a closer look at it at some point.
Comment 5 Aleix Pol 2013-05-15 15:26:31 UTC
No, in those cases it will be sent to all projects (while probably unneeded, but optimizable in the future).

I'll just commit it, then we can iterate over it.
Comment 6 Aleix Pol 2013-05-15 15:29:22 UTC
Git commit 5833edd1cdf42fd156f1b5b28f0319578311c991 by Aleix Pol.
Committed on 15/05/2013 at 17:29.
Pushed by apol into branch 'master'.

Bear in mind that the project root might not be the repository root

In the git side, look up the project root.
In the consumer side, don't assume it's the root url.

M  +1    -1    plugins/git/gitplugin.cpp
M  +12   -10   plugins/projectmanagerview/vcsoverlayproxymodel.cpp

http://commits.kde.org/kdevplatform/5833edd1cdf42fd156f1b5b28f0319578311c991