From c06697f275263f4771d6ff3a91e0eaeb3e7604fd Mon Sep 17 00:00:00 2001 From: Edvinas Sabaliauskas Date: Mon, 25 Mar 2024 14:55:53 +0200 Subject: [PATCH] Only remove .gitrepo on appropriate patches Limit the removal of .gitrepo files to commits on the repo hosting the subrepo. When using filter-branch and it encountered a merge commit, continuing the filter on the second branch rewrites all of those commits, despite that not being necessary for pre-commit. If the rewritten commits were GPG signed the change in the hash results in the inability to push to the remote repo. If during development you were to change to a different branch on the remote repo that contained a merge, you would not be able to push upstream because the rewrite would not match the upstream SHAs. fixes issue #613 fixes isseu #602 --- lib/git-subrepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git-subrepo b/lib/git-subrepo index f213c596..954380b8 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -869,7 +869,7 @@ subrepo:branch() { local filter=$branch [[ $first_gitrepo_commit ]] && filter=$first_gitrepo_commit..$branch FAIL=false RUN git filter-branch -f --prune-empty --tree-filter \ - "rm -f .gitrepo" "$filter" + "rm -f .gitrepo" -- "$filter" --first-parent git:create-worktree "$branch"