filter-repo: add a --date-order option

This adds a --date-order option to filter-repo, which passes it along to
fast-export.  Once upon a time, this option might have caused problems
for git-fast-export, as per git.git commit 784f8affe4 ("fast-export:
ensure we traverse commits in topological order", 2009-02-10), but it
should be safe with Git >= 2.35 due to git.git commit 726a228dfb
("fast-export: fix surprising behavior with --first-parent",
2021-12-16).

Signed-off-by: HassanAkbar <hassanakbar2@gmail.com>
pull/306/head
HassanAkbar 8 months ago
parent c42dad92a3
commit 52e577994a

@ -1964,6 +1964,10 @@ EXAMPLES
location.add_argument('--target', type=os.fsencode,
help=_("Git repository to overwrite with filtered history"))
order = parser.add_argument_group(title=_("Ordering of commits"))
order.add_argument('--date-order', action='store_true',
help=_("Sort the commits by date of creation."))
misc = parser.add_argument_group(title=_("Miscellaneous options"))
misc.add_argument('--help', '-h', action='store_true',
help=_("Show this help message and exit."))
@ -3662,11 +3666,14 @@ class RepoFilter(object):
if self._args.preserve_commit_encoding is not None: # pragma: no cover
reencode = 'no' if self._args.preserve_commit_encoding else 'yes'
extra_flags.append('--reencode='+reencode)
if self._args.date_order:
extra_flags.append('--date-order')
location = ['-C', self._args.source] if self._args.source else []
fep_cmd = ['git'] + location + ['fast-export', '--show-original-ids',
'--signed-tags=strip', '--tag-of-filtered-object=rewrite',
'--fake-missing-tagger', '--reference-excluded-parents'
] + extra_flags + self._args.refs
self._fep = subproc.Popen(fep_cmd, bufsize=-1, stdout=subprocess.PIPE)
self._input = self._fep.stdout
if self._args.dry_run or self._args.debug:

Loading…
Cancel
Save