From 4c3e663edc519519c6b851a22b6b2cf3256d22e4 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Mon, 24 Nov 2025 13:47:27 -0500 Subject: [PATCH 1/2] fix: Smudge non-annexed files, ensuring eol enforcement --- services/datalad/datalad_service/common/git.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/datalad/datalad_service/common/git.py b/services/datalad/datalad_service/common/git.py index 48118b1aa..19d50150b 100644 --- a/services/datalad/datalad_service/common/git.py +++ b/services/datalad/datalad_service/common/git.py @@ -163,6 +163,9 @@ async def git_commit( sentry_sdk.capture_exception(e) logger.error(f'Failed to read index after git-annex add: {e}') raise OpenNeuroGitError(f'Failed to read index: {e}') from e + # Ensure non-annexed files are smudged, e.g., update end-of-lines + # but do not "fix" unrelated paths + repo.index.add_all(file_paths) return await git_commit_index(repo, author, message, parents) From 937d9ca5caaba48608b0f1ccf152aa8ca1625eee Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Mon, 24 Nov 2025 14:30:53 -0500 Subject: [PATCH 2/2] fix: Avoid creating empty commits --- services/datalad/datalad_service/common/git.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/datalad/datalad_service/common/git.py b/services/datalad/datalad_service/common/git.py index 19d50150b..12c997b57 100644 --- a/services/datalad/datalad_service/common/git.py +++ b/services/datalad/datalad_service/common/git.py @@ -176,10 +176,14 @@ async def git_commit_index( committer = pygit2.Signature(COMMITTER_NAME, COMMITTER_EMAIL) if not author: author = committer - if parents is None: - parent_commits = [str(repo.head.target)] - else: - parent_commits = parents + + parent_commits = [repo.head.target] if parents is None else parents + if len(parent_commits) == 1 and not any( + repo.index.diff_to_tree(repo.get(parent_commits[0]).tree) + ): + # No changes to commit + return + tree = repo.index.write_tree() commit = repo.create_commit( 'refs/heads/main', author, committer, message, tree, parent_commits