Skip to content

gitutil can not cope with worktrees #3423

@jonasbadstuebner

Description

@jonasbadstuebner

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I cloned my fork as worktree and ran make test.

Expected behaviour

Running make test on a freshly cloned main (/master) branch should finish without errors.

Actual behaviour

I got the following error:

=== Failed
=== FAIL: util/gitutil TestGit (0.00s)
    gitutil_test.go:16: 
                Error Trace:    /src/util/gitutil/gitutil_test.go:16
                Error:          Received unexpected error:
                                fatal: not a git repository: /home/user/docker-buildx/.bare/worktrees/main
                                github.com/docker/buildx/util/gitutil.(*Git).clean
                                        /src/util/gitutil/gitutil.go:162
                                github.com/docker/buildx/util/gitutil.(*Git).Run
                                        /src/util/gitutil/gitutil.go:131
                                github.com/docker/buildx/util/gitutil_test.TestGit
                                        /src/util/gitutil/gitutil_test.go:15
                                testing.tRunner
                                        /usr/local/go/src/testing/testing.go:1792
                                runtime.goexit
                                        /usr/local/go/src/runtime/asm_amd64.s:1700
                Test:           TestGit

DONE 745 tests, 1 skipped, 1 failure in 51.145s
buildx-test-cache
make: *** [Makefile:46: test-unit] Fehler 1

Buildx version

not relevant

Docker info


Builders list

not relevant

Configuration

$> cat /home/user/docker-buildx/main/.git
gitdir: /home/user/docker-buildx/.bare/worktrees/main

Build logs


Additional info

I tried to fix it myself, but I don't really understand why it is reading the gitdir from .git file in the worktree directory to run git status and does not use git rev-parse --show-toplevel, which points to the correct path.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions