diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:06:39 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-04-05 20:46:47 +1200 |
commit | c8ab406749124d2e762ad5cf53963070113afd0f (patch) | |
tree | 54c9721a06957ebe7098a211eea803b0230c0f5d /bin/gscr.sh | |
parent | Handle POSIX correctness in ~/.bash_profile (diff) | |
download | dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.tar.gz dotfiles-c8ab406749124d2e762ad5cf53963070113afd0f.zip |
Apply runtime shebanging to POSIX shell
Diffstat (limited to 'bin/gscr.sh')
-rw-r--r-- | bin/gscr.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/gscr.sh b/bin/gscr.sh new file mode 100644 index 00000000..2fbee05a --- /dev/null +++ b/bin/gscr.sh @@ -0,0 +1,28 @@ +# Scrub and pack Git repositories + +# Iterate through given directories; default to the current one +for arg in "${@:-.}" ; do ( + + # Note the "exit" calls here in lieu of "continue" are deliberate; we're in + # a subshell, so leaving it will continue the loop. + + # Enter either bare repository or .git subdir + case $arg in + *.git) + cd -- "$arg" || exit + ;; + *) + cd -- "$arg"/.git || exit + ;; + esac + + # Check for bad references or other integrity/sanity problems + git fsck || exit + + # Expire dangling references + git reflog expire --expire=now || exit + + # Remove dangling references + git gc --prune=now --aggressive || exit + +) done |