git-filter-repo icon indicating copy to clipboard operation
git-filter-repo copied to clipboard

Correct docs to suggest always using trailing slashes for directories with `--path-rename`

Open mcepl opened this issue 3 years ago • 2 comments

stitny~/r/nntplib (main)$ git --version
git version 2.35.1
stitny~/r/nntplib (main)$ git filter-repo --version
22826b5a68b6
stitny~/r/nntplib (main)$ git filter-repo --debug --path Doc/library/nntplib.rst --path Lib/nntplib.py --path Lib/test/test_nntplib.py --path-rename Doc/library: --path-rename Lib/test: --path-rename Lib:
[DEBUG] Passed arguments:
Namespace(analyze=False, blob_callback=None, commit_callback=None, debug=True, dry_run=False, email_callback=None, filename_callback=None, force=False, help=False, inclusive=True, mailmap=None, max_blob_size=0, message_callback=None, name_callback=None, no_ff=False, partial=False, path_changes=[('filter', 'match', b'Doc/library/nntplib.rst'), ('filter', 'match', b'Lib/nntplib.py'), ('filter', 'match', b'Lib/test/test_nntplib.py'), ('rename', 'match', [b'Doc/library', b'']), ('rename', 'match', [b'Lib/test', b'']), ('rename', 'match', [b'Lib', b''])], preserve_commit_encoding=False, preserve_commit_hashes=False, prune_degenerate='auto', prune_empty='auto', quiet=False, refname_callback=None, refs=['--all'], repack=True, replace_message=None, replace_refs=None, replace_text=None, report_dir=None, reset_callback=None, source=None, state_branch=None, stdin=False, strip_blobs_with_ids=set(), subdirectory_filter=None, tag_callback=None, tag_rename=None, target=None, to_subdirectory_filter=None, use_base_name=False, version=False)
[DEBUG] Migrating refs/remotes/origin/* -> refs/heads/*
[DEBUG] Removing 'origin' remote (rewritten history will no
        longer be related; consider re-pushing it elsewhere.
[DEBUG] Running: git fast-export --show-original-ids --signed-tags=strip --tag-of-filtered-object=rewrite --fake-missing-tagger --reference-excluded-parents --no-data --use-done-feature --mark-tags --reencode=yes --all
  (saving a copy of the output at .git/filter-repo/fast-export.original)
[DEBUG] Running: git -c core.ignorecase=false fast-import --force --quiet --date-format=raw-permissive
  (using the following file as input: .git/filter-repo/fast-export.filtered)
Parsed 1 commitsfatal: Empty path component found in input
fast-import: dumping crash report to .git/fast_import_crash_31798
Traceback (most recent call last):
  File "/usr/libexec/git/git-filter-repo", line 4004, in <module>
    main()
  File "/usr/libexec/git/git-filter-repo", line 4001, in main
    filter.run()
  File "/usr/libexec/git/git-filter-repo", line 3936, in run
    self._parser.run(self._input, self._output)
  File "/usr/libexec/git/git-filter-repo", line 1409, in run
    self._parse_commit()
  File "/usr/libexec/git/git-filter-repo", line 1260, in _parse_commit
    self._commit_callback(commit, aux_info)
  File "/usr/libexec/git/git-filter-repo", line 3483, in _tweak_commit
    if not self._prunable(commit, new_1st_parent,
  File "/usr/libexec/git/git-filter-repo", line 3239, in _prunable
    self._output.flush()
  File "/usr/libexec/git/git-filter-repo", line 2721, in flush
    self.file1.flush()
BrokenPipeError: [Errno 32] Broken pipe
stitny~/r/nntplib (main)$

Using openSUSE/Tumbleweed packages.

fast_import_crash_32751

mcepl avatar Apr 11 '22 07:04 mcepl

OK, so the problem is that contrary to the manpage's claim, it DOES matter whether --path-rename directory path ends with / or not (the former is apparently mandatory).

mcepl avatar Apr 11 '22 07:04 mcepl

Yeah, sorry about that. If there is a non-empty source and a non-empty target, then it does not matter whether a trailing slash is present (so long as the two are consistent and no other path outside the directory starts with either of those as the leading part of their name), but when renaming to or from the root directory, you have to use an empty path. We should update the documentation to just specify folks should always use a trailing slash with --path-rename.

newren avatar May 27 '22 23:05 newren