newren/git-filter-repo

Issues with providing relative paths with backslashes on windows

Open

#324 建立於 2022年1月17日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)Python (6,745 star) (674 fork)batch import
enhancementgood first issue

描述

I can see that on lines 1640-1643 there's a check to prevent relative paths. Unfortunately in the preceding lines the path string is split only by forward slashes thus resulting in relative paths with back slashes going undetected. As a result filter-repo considers no files to keep and deletes every file. As for why I was using relative directories with backslashes, that's the autocomplete windows supplies when hitting tab.

Since it looks like relative paths aren't something that want to be supported, maybe add a warning in the documentation? As this is something that only affects windows(or maybe there are other OSes that do this too...) and backslashes are legal file name characters in linux and macos a quick fix would be to add a check if the system is windows and then replace backslashes with forward slashes and then proceed with the rest of the processing as normal.

import platform

# In AppendFilter.__call__ and/or any other place 
# that depends on processing forward slashes as path delimiters.
if platform.system() == 'Windows':
    values.replace(b'\\', b'/')

貢獻者指南