Summary: | Show annotate on current document doesn't work in a git worktree | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | Thibault North <thibault.north> |
Component: | VCS: Git | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | |
Priority: | NOR | Keywords: | junior-jobs |
Version: | 5.0.3 | ||
Target Milestone: | --- | ||
Platform: | Fedora RPMs | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/kdevplatform/a200280a9b5b1d2ab5e9a98863db7eeaa9373174 | Version Fixed In: | 5.2.0 |
Description
Thibault North
2017-02-01 16:28:44 UTC
Interesting issue. Maybe you want to have a look at it yourself and fix the issue in KDevelop? The Git plugin is pretty much self-contained and easy to work with. To get started: https://www.kdevelop.org/contribute-kdevelop The place where this needs to be fixed I think is plugins/git/gitplugin.cpp:QUrl GitPlugin::repositoryRoot(const QUrl& path). Thanks for all the pointers. Since it's not trivial to prepare a dev environment for kdevelop *and* work at the same time ("You have to remove all KDevelop packages provided by your distribution"), I wasn't able to build/check a fix yet, but I came up with the following that might work (or not?): diff --git a/plugins/git/gitplugin.cpp b/plugins/git/gitplugin.cpp index b56d53d..b78e6bd 100644 --- a/plugins/git/gitplugin.cpp +++ b/plugins/git/gitplugin.cpp @@ -88,7 +88,18 @@ QDir dotGitDirectory(const QUrl& dirPath) if (dir.isRoot()) { qCWarning(PLUGIN_GIT) << "couldn't find the git root for" << dirPath; } - + // is this a worktree ? + QFile dotGitPotentialFile(dir.filePath(".git")); + if (!dotGitPotentialFile.exists()) { + if (dotGitPotentialFile.open(QFile::ReadOnly)) { + QTextStream content(&dotGitPotentialFile); + QString gitWorktreeFileContent; + content >> gitWorktreeFileContent; + const auto items = gitWorktreeFileContent.splitRef(' ', QString::SkipEmptyParts); + if (items.size() == 2 && items.at(0) == "gitdir:") + return QDir(items.at(1)); + } + } return dir; } (Again: I don't even know if this compiles - and maybe I'm totally off :)) Comments/feedback appreciated. Seems a bit strange, first you check whether the file does not exist, then you open it? ;) But otherwise looks good, it'd be great if you could test it and put it on phabricator.kde.org. Having a development setup is actually quite simple, you can either just use the KDevelop you work on for working as well (that works fine with --pick-session) or use the AppImage we provide on kdevelop.org/download. Hu, right, that what happens when one edits the diff... :) Ok. I'll be off for two weeks, I'll come back to this bug ASAP. Turns out only the function isValidDirectory() needs fixing. A request is now available on Phabricator here: https://phabricator.kde.org/D5014 Git commit a200280a9b5b1d2ab5e9a98863db7eeaa9373174 by Sven Brauch, on behalf of Thibault North. Committed on 11/03/2017 at 14:49. Pushed by brauch into branch 'master'. Add support for git worktrees This patch adds support for the git worktree feature (see https://git-scm.com/docs/git-worktree). In a worktree, there is no .git/ folder, rather a .git file which contains a path to the corresponding worktree within the .git folder of the repository. Differential Revision: https://phabricator.kde.org/D5014 M +18 -1 plugins/git/gitplugin.cpp https://commits.kde.org/kdevplatform/a200280a9b5b1d2ab5e9a98863db7eeaa9373174 Thanks Thibault! Thanks for the guidance and fast integration! |