From e08919d89fb1f2dca2e7a27130da42819b12f250 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Fri, 24 Mar 2023 23:03:51 +0000 Subject: [PATCH] Fix crash on incremental bundling with warnings For example, if the HEAD is excluded: warning: ref 'refs/heads/master' is excluded by the rev-list options warning: ref 'HEAD' is excluded by the rev-list options fatal: Refusing to create empty bundle. The fatal message always appears last (though that's of course undocumented). --- codearchiver/modules/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codearchiver/modules/git.py b/codearchiver/modules/git.py index f50938c..1e6aa1e 100644 --- a/codearchiver/modules/git.py +++ b/codearchiver/modules/git.py @@ -119,7 +119,7 @@ class Git(codearchiver.core.Module): objectsToExclude = baseBundleObjects & commitsAndTags input = ''.join(f'^{o}\n' for o in objectsToExclude).encode('ascii') status, _, stderr = codearchiver.subprocess.run_with_log(cmd, cwd = directory, input = input, check = False) - if status == 128 and stderr == 'fatal: Refusing to create empty bundle.\n': + if status == 128 and (stderr == 'fatal: Refusing to create empty bundle.\n' or stderr.endswith('\nfatal: Refusing to create empty bundle.\n')): # Manually write an empty bundle instead # Cf. Documentation/technical/bundle-format.txt and Documentation/technical/pack-format.txt in git's repository for details on the formats _logger.info('Writing empty bundle directly instead')