summaryrefslogtreecommitdiff
path: root/sys/src/cmd/git/add
blob: a51e154ee1bb691364ccf440a6f5c0b0929f34ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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 $*}
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.
		if(! test -e $addpath)
			if(~ $add 'tracked' || test -e $gitfs/HEAD/tree/$f)
				touch $addpath
		rm -f $delpath
	}
}
exit ''