-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpush
executable file
·51 lines (46 loc) · 1.06 KB
/
push
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
41
42
43
44
45
46
47
48
49
50
51
#!/bin/rc -e
rfork en
. /sys/lib/git/common.rc
gitup
flagfmt='a:pushall, b:branch branch, f:force, d:debug,
r:remove remove, u:upstream upstream' args=''
eval `''{aux/getflags $*} || exec aux/usage
if(! ~ $#* 0)
exec aux/usage
if(~ $pushall 1)
branch=`$nl{cd .git/refs/heads && walk -f}
if(~ $#branch 0)
branch=`{git/branch}
if(~ $#branch 0)
die 'no branches'
if(~ $force 1)
force=-f
if(~ $debug 1)
debug='-d'
if(~ $#upstream 0)
upstream=origin
remotes=`$nl{git/conf -a 'remote "'$upstream'".url'}
if(~ $#remotes 0)
remotes=$upstream
branch=-b^$branch
if(! ~ $#remove 0)
remove=-r^$remove
for(remote in $remotes){
updates=`$nl{git/send $debug $force $branch $remove $remote || die $status}
for(ln in $updates){
u=`{echo $ln}
refpath=`{echo $u(2) | subst '^refs/heads/' '.git/refs/remotes/'$upstream'/'}
switch($u(1)){
case update;
mkdir -p `{basename -d $refpath}
echo $u(4) > $refpath
echo $u(2)^':' $u(3) '=>' $u(4)
case delete;
echo $u(2)^': removed'
rm -f $refpath
case uptodate;
echo $u(2)^': up to date'
}
}
}
exit ''