]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - etc/git-ls-files-attr
Add git-ls-files-attr script
[pes-rpp/rpp-lib.git] / etc / git-ls-files-attr
1 #!/bin/sh
2
3 usage() { echo >&2 "Usage: $0 [ --not ] [ --set | --unset | --unspecified ] <attr> <ls-files args>..."; }
4
5 state=set
6
7 if test $1 = "--not"; then
8         not=true
9         shift
10 else
11         not=false
12 fi
13
14
15 case $1 in
16     --set)         state=set;         shift;;
17     --unspecified) state=unspecified; shift;;
18     --unset)       state=unset;       shift;;
19     -*) usage; exit 1;;
20 esac
21
22 if test -z "$1"; then usage; exit 1; fi
23
24 attr=$1
25 shift
26
27 git ls-files "$@" | git check-attr --stdin $attr | if $not; then
28         awk -F': ' -v state=$state '{ if ($3 != state) print $1 }'
29 else
30         awk -F': ' -v state=$state '{ if ($3 == state) print $1 }'
31 fi