ref: a15863b8ae23a26a2f825daf6107ab92e53c2669
parent: af36a8b50ad95196fdc21deac251919cd7bbd18a
author: Ori Bernstein <[email protected]>
date: Sun Oct 15 13:05:00 EDT 2023
git/add: don't include paths in the .git directory git/add .git/foo would happily add files in the .git directory, leaving it to other tools to filter them out; we shouldn't do that. While we're in here, speed things up by not iterating over long lists of files, and allow removing files that have not yet been committed.
--- a/sys/src/cmd/git/add
+++ b/sys/src/cmd/git/add
@@ -14,10 +14,6 @@
exec aux/usage
paths=`$nl{cleanname -d $gitrel $* | drop $gitroot}
-if(~ $s A)
- files=`$nl{walk -f ./$paths}
-if not
- files=`$nl{cd .git/fs/HEAD/tree && walk -f ./$paths}
-for(f in $files)
- echo $s NOQID 0 $f >> .git/INDEX9
+walk -f ./$paths | grep -v '^(./)?.git/' | \
+ sed 's/^/'$s' NOQID 0 /' >> .git/INDEX9
exit ''