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

Apply inverted '--path' filtering after '--path-rename'?

Open MarkusMit opened this issue 1 year ago • 2 comments

I have a repository like this:

my-repo/
├── folder_a/
├── folder_b/
│   ├── folder_b_1/
│   ├── folder_b_2/
│   └── folder_b_3/
├── folder_c/
...
└── folder_z/

and - as part of a bigger restructuring - I want to change it like this: folder_b_3 should be moved up to root, and folder folder_b with all its remaining contents should be removed:

my-repo/
├── folder_a/
├── folder_b_3/
├── folder_c/
...
└── folder_z/

I tried to do this with inverted path filtering (--invert-paths), but it seems the --path filtering is always executed before the --path-rename regardless of the order of the commands:

python3 'git-filter-repo' --force --invert-paths              \
            --path-rename 'folder_b/folder_b_3/:folder_b_3/'  \
            --path 'folder_b/' 

So, the current (undesired) result is, that nothing of folder_b survives:

my-repo/
├── folder_a/
├── folder_c/
...
└── folder_z/

Since "ordering issues" are mentioned with (positive) path filtering and renames in the user manual, I thought it should also be considered accordingly with inverted path filtering.

MarkusMit avatar Sep 21 '23 15:09 MarkusMit

Yeah, sorry, can you split this into two steps?

   python3 'git-filter-repo' --force \
            --path-rename 'folder_b/folder_b_3/:folder_b_3/'
   python3 'git-filter-repo' --invert-paths \
            --path 'folder_b/' 

newren avatar Aug 02 '24 00:08 newren

Yeah, since this was already some months ago, I already found a solution for it. ;-)

But my main intend was anyway that this behaviour may be worth mentioning in the documentation.

MarkusMit avatar Aug 03 '24 11:08 MarkusMit