Open Alberth289346 opened 5 hours ago
Path concatenation should be done with os.path
instead of string manipulations.
To handle the possible }/
that causes the //
you can extend the pattern with [\\/]?
which matches /
or \
so it gets discarded together with the }
Git has machine readable output forms, but they don't seem used.
eg in
repo_reader.py
I read (around line 313):This is fragile. A filename like
x=>y
is quite trivially produced (touch x=\>y
), filenames with curly braces and spaces can exist too.Instead of relying on a user to produce non-conflicting filenames, use the machine readable output form (
-p
or--porcelain
forgit log
orgit blame
, there is also--line-porcelain
).For the above code fragment, a regular expression is generally recommended so you get the entire pattern, including eg a space character at the start or end of a filename like
" my_file "
:If you don't want to use an RE, `split does have an optional max matching count, to avoid getting 2 or more matches.