-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-li
More file actions
executable file
·63 lines (52 loc) · 1.2 KB
/
Copy pathgit-li
File metadata and controls
executable file
·63 lines (52 loc) · 1.2 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
# Usage: git-li [/path/to/repo] [revision]
mode2str()
{
mode=$1
modestr=
case ${mode%????} in
01 ) modestr=p ;;
02 ) modestr=c ;;
04 ) modestr=d ;;
06 ) modestr=b ;;
10 ) modestr=- ;;
12 ) modestr=l ;;
14 ) modestr=s ;;
esac
mode=${mode#???}
u=${mode%??}
g=${mode%?}
g=${g#?}
o=${mode#??}
#echo mode=$mode u=$u g=$g o=$o 1>&2
for p in $u $g $o; do
case $p in
0 ) modestr=${modestr}--- ;;
1 ) modestr=${modestr}--x ;;
2 ) modestr=${modestr}-w- ;;
3 ) modestr=${modestr}-wx ;;
4 ) modestr=${modestr}r-- ;;
5 ) modestr=${modestr}r-x ;;
6 ) modestr=${modestr}rw- ;;
7 ) modestr=${modestr}rwx ;;
esac
done
}
main()
{
case $1 in
*/* ) dir=$1 ; shift ;;
* ) dir=. ;;
esac
case $# in
0 ) set @ ;;
esac
fmt='%(objectmode) %(objectsize) %(path)'
git -C "$dir" ls-tree -r --format="$fmt" "$@" |
while read perm size file; do
mode2str $perm
printf "%s %9s %s\n" "$modestr" "$size" "$file"
done
}
main "$@"
# eof