summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2024-08-03 12:30:17 -0400
committerFurkan Sahin <furkan-dev@proton.me>2024-08-03 12:30:17 -0400
commit1c246df1db3af1b2af9a4f967cb4b4e833faee39 (patch)
tree86d2d795bc350c2d650cb3a43212cf18f1fb111a
parentae1d14534b5b596afdcbe61196ca30ffb145c9c0 (diff)
build: avoid git repository discovery when determining version
When attempting to use Git to populate commit/branch information in a version string, it is possible through repository discovery that it uses Git information not relevant to project. For example, if repository content is extract into an interim build location when using an embedded build framework (e.g. Buildroot), the project will not have its Git repository to refer to. When it cannot find its repository, it will look into its parent folders and may find the Git repository of another project and use its branch/commit information. This commit provides an explicit path to the project's Git repository when consider commit/branch information. This will prevent any repository discovery from occurring. Signed-off-by: James Knight <james.d.knight@live.com> (cherry picked from commit 6e4ccb99c3a2197468f8f34c290b7cd5612ff80b)
-rw-r--r--meson.build4
1 files changed, 2 insertions, 2 deletions
diff --git a/meson.build b/meson.build
index c602d008..6999e199 100644
--- a/meson.build
+++ b/meson.build
@@ -160,8 +160,8 @@ add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir
version = '"@0@"'.format(meson.project_version())
git = find_program('git', native: true, required: false)
if git.found()
- git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
- git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
+ git_commit = run_command([git, '--git-dir=.git', 'rev-parse', '--short', 'HEAD'], check: false)
+ git_branch = run_command([git, '--git-dir=.git', 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
if git_commit.returncode() == 0 and git_branch.returncode() == 0
version = '"@0@-@1@ (" __DATE__ ", branch \'@2@\')"'.format(
meson.project_version(),