Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-10437

Pre-receive hooks can only read objects from the repository being pushed to on Git 2.11+

    XMLWordPrintable

    Details

      Description

      This affects instances running with Git 2.11+

      When a PreRepositoryHook attempts to execute a command to read objects from a repository other than the one which is the subject of the push, the git commands fail because the relevant objects cannot be found.

      Git 2.11+ introduced quarantine pushes. This means that git will no longer write the objects in a push directly into the repository. Instead the objects are written to a temporary quarantine directory while the pre-receive hooks are executed. Once all hooks complete successfully the objects are copied to the repository.

      The root cause of the issue is that in the context of a pre-receive hook a quarantine environment needs to be configured so that the git commands executed by Bitbucket Server will have access to the objects being pushed. Unfortunately this environment is always applied and it means that if a pre-receive hook attempts to access a different repository it will still read the objects from the push repository.

      Workaround:

      Have the pre-receive hook move the logic to a separate thread, perhaps using the ExecutorService. The pre-receive hook can then wait on the Future#get call. This should prevent the quarantine environment from being applied to the command.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jpalacios Juan Palacios
              Reporter:
              jpalacios Juan Palacios
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: