Bug 1377440

Summary: Git aliases do not work in sub-dirs of worktree
Product: [Fedora] Fedora Reporter: Jonathan Wakely <jwakely>
Component: gitAssignee: Petr Stodulka <pstodulk>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: amahdal, besser82, c.david86, chrisw, jbowes, laurent.rineau__fedora, pstodulk, tmz
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: git-2.7.4-3.fc24 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-05 06:22:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jonathan Wakely 2016-09-19 17:33:28 UTC
Description of problem:

The version of Git in F24 gives an error when trying to expand an alias in any sub-directory of a worktree created with 'git worktree add'.

Version-Release number of selected component (if applicable):

git-2.7.4-2.fc24.x86_64

How reproducible:

Always.

Steps to Reproduce:

Try to run a git alias from a sub-directory of a new worktree.

$ mkdir -p /tmp/git
$ cd /tmp/git
$ mkdir repo1
$ cd repo1
$ git init
Initialized empty Git repository in /tmp/git/repo1/.git/
$ mkdir foo
$ touch foo/bar
$ git add foo/bar
$ git ci -m 1
[master (root-commit) 7184dab] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo/bar
$ git branch b
$ git worktree add ../repo2 b
Preparing ../repo2 (identifier repo2)
HEAD is now at 7184dab 1
$ cd ../repo2
$ git config alias.s status
$ git s
On branch b
nothing to commit, working directory clean
$ cd foo
$ git s
fatal: internal error: work tree has already been set
Current worktree: /tmp/git/repo2
New worktree: /tmp/git/repo2/foo



Actual results:

fatal: internal error: work tree has already been set
Current worktree: /tmp/git/repo2
New worktree: /tmp/git/repo2/foo


Expected results:

The alias runs correctly.

Additional info:

This is discussed at http://lists-archives.com/git/855872-worktree-setup-broken-in-subdirs-with-git-alias.html but I don't understand the resolution - is the fix in a newer release? Still buggy and now fixed yet?

In any case this worked fine with F22, but I can't use aliases + worktrees on F24.

Comment 1 Laurent Rineau 2016-09-30 09:46:52 UTC
I have the exact same issue. Fixed upstream in Git v2.8.0.

Reference: http://git.661346.n2.nabble.com/BUG-worktree-setup-broken-in-subdirs-with-git-alias-td7645158.html

Comment 2 Petr Stodulka 2016-10-02 19:52:28 UTC
Thanks for link. It seems that it fixes the bug, according to reproducer.

Comment 3 Fedora Update System 2016-10-03 07:22:47 UTC
git-2.7.4-3.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b596ee7ca9

Comment 4 Fedora Update System 2016-10-05 06:22:08 UTC
git-2.7.4-3.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.