]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commit
scripts/oe-setup-layers: Update how to determine if directory is git repo
authorJermain Horsman <jermain.horsman@nedap.com>
Tue, 3 Oct 2023 14:56:36 +0000 (16:56 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 Oct 2023 10:50:54 +0000 (11:50 +0100)
commit0830f53900dd7fd669a7d6492325559ad3225302
tree0dab6181c51db3ed8de93098ac948461f197a5c4
parent492559191943c9e2666c3dda1824c5aafbe487d5
scripts/oe-setup-layers: Update how to determine if directory is git repo

Previously _is_repo_git_repo() would return a result containing b'true\n' or
b'false\n' if 'git rev-parse' ran successfully, instead of True of False.

While this can be solved using e.g. result.strip().decode("utf-8") == "true",
there are some other cases to consider.
First, .git can be a file and not a directory when using a worktree.
Second, an emtpy .git directory in 'repodir' for which some parent of
'repodir' is an actual git repo will still return True in this case.

To account for these cases as well, use 'git rev-parse --show-toplevel'
and compare the result against 'repodir' instead of
using 'git rev-parse --is-inside-git-dir'.

Signed-off-by: Jermain Horsman <jermain.horsman@nedap.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/oe-setup-layers