Details
-
Bug
-
Resolution: Fixed
-
Low
-
None
-
None
-
Severity 3 - Minor
-
Description
When running git processes, Bitbucket Server typically relies on a Repository being passed, or an explicit working directory being set. If neither happens, the system defaults the working directory to $BITBUCKET_HOME/tmp.
git has a built-in behavior that, when the directory where it's run isn't a bare repository and doesn't contain a .git directory, it walks "up" parent directories searching for one.
When these two behaviors intersect, it can produce unexpected behavior. This is particularly noticeable (or perhaps unnoticeable) when running Bitbucket Server via AMPS as part of developing a plugin. In that case, $BITBUCKET_HOME tends to be in target/bitbucket/home within the Maven project, which is in a Git repository. As a result, when git processes don't have a working directory and are run in $BITBUCKET_HOME/tmp, the default behavior of walking "up" the parents finds the plugin's .git directory and considers it the repository root. This can defeat some integration tests, and result in different behavior under test than when, say, Bitbucket Server is explicitly installed on a real server (where it generally is not inside a Git repository).