File: style

package info (click to toggle)
teg 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,036 kB
  • sloc: cpp: 16,819; xml: 1,313; makefile: 268; sh: 195; ansic: 112
file content (35 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -euo pipefail

MYSELF="$(readlink -m "$0")"

HERE="${MYSELF%/*}"

function filter_sources() {
    grep -E '\.[ch](pp)?$'
}

function get_changed_files() {
    git status --porcelain | grep '^.M ' | sed -e 's/^...//' | filter_sources
}

function get_head_files() {
    git ls-tree -r @ | cut -d\	 -f2 | filter_sources
}

case "${1:-}" in
    --changed|-c)
        readarray -t FILES <<<"$(get_changed_files)"
    ;;

    --head|-h)
        readarray -t FILES <<<"$(get_head_files)"
    ;;

    *)
        FILES=("$@")
    ;;
esac

astyle --options="$HERE"/../.astylerc --suffix=none "${FILES[@]}"