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

insert-beginning: Files outside of the repository can be added to the repository

Open CervEdin opened this issue 4 years ago • 1 comments

It appears one can add a file outside of the repo using the insert-beginning demo.

Steps to reproduce

mkdir insert-outside && cd insert-outside
git init && git commit --allow-empty -m init
echo outside! > ../an-outside-file
insert-beginning --file ../an-outside-file

This will result in something like

$ git log -p
commit 61116276d40336ab23974003597ed167d36bf2d6 (HEAD -> main)
Author: Erik Cervin Edin <[email protected]>
Date:   Tue Jun 15 16:34:50 2021 +0200

    init

diff --git a/../an-outside-file b/../an-outside-file
new file mode 100755
index 0000000..b454f01
--- /dev/null
+++ b/../an-outside-file
@@ -0,0 +1 @@
+outside!

Trying to undo results in

$ git filter-repo --paths ../an-outside-file --invert
Parsed 1 commitserror: invalid path '../an-outside-file'
fatal: Could not reset index file to revision 'HEAD'.

or

$ git filter-repo --path-rename "../an-outside-file:an-outside-file"
Error: Invalid path component '..' found in '../an-outside-file:an-outside-file'

It seems possible to really mess up a repository doing this.

CervEdin avatar Jun 15 '21 14:06 CervEdin

Wow, that looks bad! I don't have time at the moment to investigate, but thanks for reporting. I'll try to look at it soon.

newren avatar Jun 15 '21 20:06 newren