Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/lab/git/add

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc -e
rfork ne
. /sys/lib/git/common.rc

gitup

flagfmt='r:remove'; args='file ...'
eval `''{aux/getflags $*} || exec aux/usage

add='tracked'
del='removed'
if(~ $remove 1){
	add='removed'
	del='tracked'
}
if(~ $#* 0)
	exec aux/usage

paths=`$nl{cleanname -d $gitrel $* | drop $gitroot}
if(~ $add tracked)
	files=`$nl{walk -f ./$paths}
if not
	files=`$nl{cd .git/index9/tracked/ && walk -f ./$paths}

for(f in $files){
	if(! ~ `$nl{cleanname $f} .git/*){
		addpath=.git/index9/$add/$f
		delpath=.git/index9/$del/$f
		mkdir -p `$nl{basename -d $addpath}
		mkdir -p `$nl{basename -d $delpath}
		# We don't want a matching qid, so that
		# git/walk doesn't think this came from
		# a checkout.
		echo -n > $addpath
		rm -f $delpath
	}
}
exit ''

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.