From 7ceb213f044a6a0347eadc98427c45ab5e37c9b4 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 8 Jun 2021 08:28:59 -0700 Subject: [PATCH] filter-repo: ensure we close files so they get written It appears that python will usually write out files even if we do not explicitly close them, but other tweaks to the code can make this not happen. Explicitly close the files to be safe. Signed-off-by: Elijah Newren --- git-filter-repo | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-filter-repo b/git-filter-repo index 4c0d22f..568cd3b 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -2666,6 +2666,10 @@ class InputFileBackup: self.input_file = input_file self.output_file = output_file + def close(self): + self.input_file.close() + self.output_file.close() + def read(self, size): output = self.input_file.read(size) self.output_file.write(output) @@ -3896,6 +3900,7 @@ class RepoFilter(object): # Make sure fast-export completed successfully if not self._args.stdin and self._fep.wait(): raise SystemExit(_("Error: fast-export failed; see above.")) # pragma: no cover + self._input.close() # If we're not the manager of self._output, we should avoid post-run cleanup if not self._managed_output: