aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-06-30 00:13:59 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-06-30 00:13:59 +1200
commitdb51de25a2dcac3850dc5862d215049378d7277b (patch)
treeb2ebdd2084fde68ed529f69e3bc5c6ec64a2ca37 /bin
parentAdd submodule with new colorscheme (diff)
downloaddotfiles-db51de25a2dcac3850dc5862d215049378d7277b.tar.gz
dotfiles-db51de25a2dcac3850dc5862d215049378d7277b.zip
Extend jfc(1) to check for changes before commit
Diffstat (limited to 'bin')
-rwxr-xr-xbin/jfc23
1 files changed, 20 insertions, 3 deletions
diff --git a/bin/jfc b/bin/jfc
index cb032a5c..1068280a 100755
--- a/bin/jfc
+++ b/bin/jfc
@@ -1,7 +1,24 @@
-#!/bin/sh
+#!/usr/bin/env bash
# jfc(1) -- Just add everything to a Git repository and quietly commit with a
# stock message
-git add --all
-git commit --message 'Committed by jfc(1)' --quiet
+# 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