]> git.ipfire.org Git - thirdparty/git.git/commit
t0060: fix EBUSY in MinGW when setting up runtime prefix
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Jan 2025 11:31:57 +0000 (12:31 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Jan 2025 17:15:36 +0000 (09:15 -0800)
commitb537af720ec22c0283923afcdbbc1df306907542
treea8e3fcc8874aa04e2cb7836da19e8133df29b859
parent1b4e9a5f8b5f048972c21fe8acafe0404096f694
t0060: fix EBUSY in MinGW when setting up runtime prefix

Two of our tests in t0060 verify that the runtime prefix functionality
works as expected by creating a separate directory hierarchy, copying
the Git executable in there and then creating scripts relative to that
executable.

These tests fail quite regularly in GitLab CI with the following error:

    expecting success of 0060.218 '%(prefix)/ works':
            mkdir -p pretend/bin &&
            cp "$GIT_EXEC_PATH"/git$X pretend/bin/ &&
            git config yes.path "%(prefix)/yes" &&
            GIT_EXEC_PATH= ./pretend/bin/git config --path yes.path >actual &&
            echo "$(pwd)/pretend/yes" >expect &&
            test_cmp expect actual
    ++ mkdir -p pretend/bin
    ++ cp /c/GitLab-Runner/builds/gitlab-org/git/git.exe pretend/bin/
    cp: cannot create regular file 'pretend/bin/git.exe': Device or resource busy
    error: last command exited with $?=1
    not ok 218 - %(prefix)/ works

Seemingly, the "git.exe" binary we are trying to overwrite is still
being held open. It is somewhat puzzling why exactly that is: while the
preceding test _does_ write to and execute the same path, it should have
exited and shouldn't keep any backgrounded processes around. So it must
be held open by something else, either in MinGW or in Windows itself.

While the root cause is puzzling, the workaround is trivial enough:
instead of writing the file twice we simply pull the common setup into a
separate test case so that we won't observe EBUSY in the first place.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0060-path-utils.sh