summaryrefslogtreecommitdiffstats
path: root/gitscope
blob: 250a7a0202a03dd01cd3bac6cd015339d9db13e8 (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
41
42
43
44
45
46
#!/bin/zsh
[[ -n $NOHOOK ]] && exit 12
#while pidof cscope;do
    #echo "Cscope already running"
    #exit
#done
isgit=0
genfile=0
[[ -d .git ]] && isgit=1
if  [[ $SHLVL -gt 6 ]];then
    echo "Not required here"
    exit 
fi
if [[  ( -n $1 && $1 == $2) || $3 = 0 ]];then
    exit 
fi
#if [[ isgit = 1 && ((! $1 =~ [0]{40} && $1 != $2) || ! -f cscope.files)  ]];then
if [[ $isgit = 1 ]];then
    if [[  ( -f cscope.files && $1 != $2 ) || ! -f cscope.files ]];then
        genfile=1
    fi
fi
# post-merge too ?
#if [[ $1 =~ [0]{40} ]];then
# Kernel mode
if [[ -f Kconfig ]];then
    epattern="arm|alpha|avr32|blackfin|cris|frv|h8300|ia64|m32r|m68k|microblaze|mips|mn10300|parisc|powerpc|s390|score|sh|sparc|tile|unicore32|xtensa"
    #make ARCH=x86 cscope
    if [[ $genfile = 1 ]];then
        #git ls-files | /bin/grep -v -E "^arch/($epattern)|^Documentation|^drivers" | /bin/grep -E '\.[chS]$' >| cscope.files
        git ls-files | /bin/grep -v -E "^arch/($epattern)|^Documentation" | /bin/grep -E '\.[chS]$' >| cscope.files
    fi
    /usr/bin/cscope -b -q -k
else 
    if [[ $genfile = 1 ]];then
        git ls-files >| cscope.files
        /usr/bin/cscope -b -q 
    else
        /usr/bin/cscope -b -R -q 
    fi
fi
    #exit
#fi
#scopefile="/tmp/gitscope.$$"
#git --no-pager diff  --diff-filter=AMRC --name-only $1 $2 >| $scopefile && \
    #(cscope -b -q -R  && rm $scopefile) &!