aboutsummaryrefslogtreecommitdiff
path: root/bin/jfc
blob: 1068280ad381c146041ea38092538d9b135ad7d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

# jfc(1) -- Just add everything to a Git repository and quietly commit with a
# stock message

# Check we have what we need
hash git || exit

# Detect changes
if ! git diff-index --quiet HEAD ; then
    changed=1
fi

# Detect untracked files
while read -d '' -r ; do
    untracked=1
    break
done < <(git ls-files -z --others --exclude-standard)

# If either applies, add and commit
if ((changed || untracked)) ; then
    git add --all || exit
    git commit --message 'Committed by jfc(1)' --quiet || exit
fi