summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-07-03 14:46:55 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-07-10 13:49:02 +0200
commitf234434a6fa2118b10765cff2f75bbc3196fec39 (patch)
tree3cfd2b1d40b6081a28677d72fed816e0d9430369 /bin
parent14715e3da452dd73363bc86f92cd9e5b9fdb3a7b (diff)
downloadjustbuild-f234434a6fa2118b10765cff2f75bbc3196fec39.tar.gz
just-mr: Fix handling of .gitignore files in git repositories
The command 'git add .' does not include paths found in .gitignore files in the directory tree where the command is issued. This is not the desired behaviour, as we expect for a tree with a given commit id to contain all of the entries, irrespective of their meaning to Git. This commit addresses the issue as described. For the just-mr.py script we modified the staging command to 'git add -f .'. For the compiled just-mr, simply adding the force flag to 'git_index_add_all' did not work as intended for files found in ignored subdirectories. This is a known libgit2 issue which has been fixed in v1.6.3. Until we can upgrade our libgit2 version, a workaround was implemented: we recursively read the directory entries ourselves and add each of them iteratively using 'git_index_add_bypath', making sure to ignore the root '.git' subtree (which cannot be staged). At the moment the handling of Git submodules remains an open issue, as Git does not allow '.git' subtrees to be forcefully added to the index, and thus such directory entries will currently not be considered as part of a git tree. This however is consistent behavior between Git and libgit2.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/just-mr.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/just-mr.py b/bin/just-mr.py
index a5a521a3..216c1390 100755
--- a/bin/just-mr.py
+++ b/bin/just-mr.py
@@ -474,7 +474,7 @@ def import_to_git(target, repo_type, content_id):
env=dict(os.environ, **GIT_NOBODY_ENV),
)
run_cmd(
- ["git", "add", "."],
+ ["git", "add", "-f", "."],
cwd=target,
env=dict(os.environ, **GIT_NOBODY_ENV),
)
@@ -582,7 +582,9 @@ def distdir_checkout(desc, repos):
content[get_distfile(repo_desc)] = content_id
# Hash the map as unique id for the distdir repo entry
- distdir_content_id = git_hash(json.dumps(content, sort_keys=True, separators=(',', ':')).encode('utf-8'))
+ distdir_content_id = git_hash(
+ json.dumps(content, sort_keys=True,
+ separators=(',', ':')).encode('utf-8'))
target_distdir_dir = distdir_repo_dir(distdir_content_id)
# Check if content already exists