<table><tr><td style="">tnorth created this revision.<br />Restricted Application added a subscriber: kdevelop-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D5014" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>This patch adds support for the git worktree feature (see <a href="https://git-scm.com/docs/git-worktree" class="remarkup-link" target="_blank" rel="noreferrer">https://git-scm.com/docs/git-worktree</a> ).<br />
In a worktree, there is no <tt style="background: #ebebeb; font-size: 13px;">.git/</tt> folder, rather a <tt style="background: #ebebeb; font-size: 13px;">.git</tt> file which contains a path to the corresponding worktree within the <tt style="background: #ebebeb; font-size: 13px;">.git</tt> folder of the repository.</p>

<p>The only change required in kdevplatform is a modification of the <tt style="background: #ebebeb; font-size: 13px;">isValidDirectory()</tt> function, which currently checks that a file called <tt style="background: #ebebeb; font-size: 13px;">HEAD</tt> actually exists in the <tt style="background: #ebebeb; font-size: 13px;">.git/</tt> directory. In the case of a worktree, <tt style="background: #ebebeb; font-size: 13px;">.git</tt> is a file instead, on the function returns false.</p>

<p>With this modification, <tt style="background: #ebebeb; font-size: 13px;">isValidDirectory</tt> now also checks if <tt style="background: #ebebeb; font-size: 13px;">.git</tt> is a file. If it is, the content is retrieved. If the file content matches the typical format of a worktree <tt style="background: #ebebeb; font-size: 13px;">.git</tt> file, the directory is said to be valid. <br />
Sources that lie in a git worktree are now detected as being in a git directory, and the git integration is functional (git, commit, annotate, etc.).</p></div></div><br /><div><strong>TEST PLAN</strong><div><ul class="remarkup-list">
<li class="remarkup-list-item">clone some git repository</li>
<li class="remarkup-list-item">checkout some branch in a new worktree</li>
<li class="remarkup-list-item">open the worktree location in Kdevelop</li>
<li class="remarkup-list-item">ensure that the branch is visible in the projects tab</li>
<li class="remarkup-list-item">ensure that the Git menu is available when right-clicking on an item in the document view</li>
<li class="remarkup-list-item">ensure that the annotation feature works</li>
</ul>

</div></div><br /><div><strong>REPOSITORY</strong><div><div>R33 KDevPlatform</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D5014" rel="noreferrer">https://phabricator.kde.org/D5014</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>plugins/git/gitplugin.cpp</div></div></div><br /><div><strong>To: </strong>tnorth, KDevelop<br /><strong>Cc: </strong>kdevelop-devel<br /></div>