Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21168

Git core.symlinks option not correctly auto-detected on Windows

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Environment:
      Jenkins 1.509.4 running on Windows Server 2008 R2 64-bit, Git Client Plugin 1.6.0, Git Plugin 2.0
    • Similar Issues:

      Description

      There seems to be a problem related to the core.symlinks config option. Usually, if core.symlinks is not set (the default), Git will probe the target file system for symlinks support when cloning (see [1]). As Windows does not support symlinks in the POSIX sense, Git for Windows internally uses core.symlinks=false if that option is otherwise unset. However, relying on this results in this error for me (see [2]):

      Cloning the remote Git repository
      Cloning repository git://github.com/sschuberth/git.git
      Fetching upstream changes from git://github.com/sschuberth/git.git
      Checking out Revision 21d457224673682f2879170c504750db98638d2e (origin/master)
      FATAL: Could not checkout null with start point 21d457224673682f2879170c504750db98638d2e
      hudson.plugins.git.GitException: Could not checkout null with start point 21d457224673682f2879170c504750db98638d2e
      	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.checkoutBranch(CliGitAPIImpl.java:1222)
      	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:870)
      	at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:117)
      	at hudson.model.AbstractProject.checkout(AbstractProject.java:1376)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:655)
      	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:560)
      	at hudson.model.Run.execute(Run.java:1592)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
      	at hudson.model.ResourceController.execute(ResourceController.java:88)
      	at hudson.model.Executor.run(Executor.java:237)
      Caused by: hudson.plugins.git.GitException: Command "git checkout -f 21d457224673682f2879170c504750db98638d2e" returned status code 1:
      stdout: 
      stderr: error: unable to create symlink RelNotes (Function not implemented)
      Note: checking out '21d457224673682f2879170c504750db98638d2e'.
      

      Directly using Git from the command line on the server works fine to clone the repository, I do not get any errors about being unable to create symlinks then.

      The error in Jenkins disappears when I explicitly do "git config --system core.symlinks false" on the build server (see [3]).

      [1] http://stackoverflow.com/a/11664406/1127485
      [2] http://mingwgitdevenv.cloudapp.net/job/mingwGitDevEnv-test-git/32/console
      [3] http://mingwgitdevenv.cloudapp.net/job/mingwGitDevEnv-test-git/33/consoleFull

        Attachments

          Issue Links

            Activity

            Hide
            sschuberth Sebastian Schuberth added a comment -

            FYI, I was looking at CliGitAPIImpl.java to see what the plugin is doing and tried to resemble its actions as closely as possible. Here are the steps that I think the plugin is doing, and they work fine if I use them in a shell build step:

            mkdir sandbox2
            git init sandbox2
            cd sandbox2
            git remote add origin https://github.com/sschuberth/sandbox.git
            git fetch
            git checkout -f 809ea43fece46bf4995e61ddd9440193db8814fd
            git checkout -b master 809ea43fece46bf4995e61ddd9440193db8814fd

            Show
            sschuberth Sebastian Schuberth added a comment - FYI, I was looking at CliGitAPIImpl.java to see what the plugin is doing and tried to resemble its actions as closely as possible. Here are the steps that I think the plugin is doing, and they work fine if I use them in a shell build step: mkdir sandbox2 git init sandbox2 cd sandbox2 git remote add origin https://github.com/sschuberth/sandbox.git git fetch git checkout -f 809ea43fece46bf4995e61ddd9440193db8814fd git checkout -b master 809ea43fece46bf4995e61ddd9440193db8814fd
            Hide
            markewaite Mark Waite added a comment -

            Since this problem seems to be specific to the msysgit development environment version and is not visible in the msysgit distribution version, I recommend that we close this as "Won't Fix". We already have enough platform complexities with the various versions of git and the various platforms we support. I'd rather not add the development overhead of tracking differences between the msysgit development environment (or cygwin or ...) and the msysgit distribution version.

            Is that acceptable to others?

            Show
            markewaite Mark Waite added a comment - Since this problem seems to be specific to the msysgit development environment version and is not visible in the msysgit distribution version, I recommend that we close this as "Won't Fix". We already have enough platform complexities with the various versions of git and the various platforms we support. I'd rather not add the development overhead of tracking differences between the msysgit development environment (or cygwin or ...) and the msysgit distribution version. Is that acceptable to others?
            Hide
            sschuberth Sebastian Schuberth added a comment -

            I believe I've understood now what was causing this behavior: Before JGit 3.3, JGit was not setting the local core.symlinks at all when initializing a repository, which means querying core.symlinks would fall back to the global and system scopes. msysgit sets core.symlinks = false at the system scope, which is why the checkout on Windows did not try to create symlinks in that case and succeeded. mingwGitDevEnv on the other hand does not set core.symlinks at all, so it's unset at all scopes, and the checkout tries to create symlinks, which fails on Windows. My work-around to set core.symlinks = false at the system scope also for mingwGitDevEnv so is exactly what msysgit does out of the box.

            With JGit 3.3 the situation has changed in that it now (Always? See JENKINS-22376 and JENKINS-22391.) sets core.symlinks = false at the local scope, rendering the system scope setting redundant.

            So this fix to this issue is the same as for JENKINS-22376 and JENKINS-22391: Use the CLI instead of JGit to initialize the repository.

            Show
            sschuberth Sebastian Schuberth added a comment - I believe I've understood now what was causing this behavior: Before JGit 3.3, JGit was not setting the local core.symlinks at all when initializing a repository, which means querying core.symlinks would fall back to the global and system scopes. msysgit sets core.symlinks = false at the system scope, which is why the checkout on Windows did not try to create symlinks in that case and succeeded. mingwGitDevEnv on the other hand does not set core.symlinks at all, so it's unset at all scopes, and the checkout tries to create symlinks, which fails on Windows. My work-around to set core.symlinks = false at the system scope also for mingwGitDevEnv so is exactly what msysgit does out of the box. With JGit 3.3 the situation has changed in that it now (Always? See JENKINS-22376 and JENKINS-22391 .) sets core.symlinks = false at the local scope, rendering the system scope setting redundant. So this fix to this issue is the same as for JENKINS-22376 and JENKINS-22391 : Use the CLI instead of JGit to initialize the repository.
            Hide
            markewaite Mark Waite added a comment -

            Problem was a real bug, is fixied in git-client-plugin 1.7.0

            Show
            markewaite Mark Waite added a comment - Problem was a real bug, is fixied in git-client-plugin 1.7.0
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Mark Waite
            Path:
            README.md
            src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java
            http://jenkins-ci.org/commit/git-client-plugin/1ade04abc266a098bf21728016d98b053228dd28
            Log:
            Add tests for core.symlinks setting from init() and init_()

            Refer to JENKINS-22376, JENKINS-21168, and JENKINS-22391 for details.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Mark Waite Path: README.md src/test/java/org/jenkinsci/plugins/gitclient/GitAPITestCase.java http://jenkins-ci.org/commit/git-client-plugin/1ade04abc266a098bf21728016d98b053228dd28 Log: Add tests for core.symlinks setting from init() and init_() Refer to JENKINS-22376 , JENKINS-21168 , and JENKINS-22391 for details.

              People

              • Assignee:
                markewaite Mark Waite
                Reporter:
                sschuberth Sebastian Schuberth
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: