diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-06-30 00:13:59 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-06-30 00:13:59 +1200 |
commit | db51de25a2dcac3850dc5862d215049378d7277b (patch) | |
tree | b2ebdd2084fde68ed529f69e3bc5c6ec64a2ca37 /bin | |
parent | Add submodule with new colorscheme (diff) | |
download | dotfiles-db51de25a2dcac3850dc5862d215049378d7277b.tar.gz dotfiles-db51de25a2dcac3850dc5862d215049378d7277b.zip |
Extend jfc(1) to check for changes before commit
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/jfc | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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 |