diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-01 15:10:07 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-01 15:10:07 +1200 |
commit | 02b1903b0ca41787675c3061b88e0a2172b5599a (patch) | |
tree | aabd5c1d39ce6cb5c08d11ee11efa9c249b4c0a2 | |
parent | Add rndl(1) (diff) | |
download | dotfiles-02b1903b0ca41787675c3061b88e0a2172b5599a.tar.gz dotfiles-02b1903b0ca41787675c3061b88e0a2172b5599a.zip |
Add isgr(1)
-rw-r--r-- | README.markdown | 2 | ||||
-rwxr-xr-x | bin/isgr | 8 | ||||
-rw-r--r-- | man/man1/isgr.1 | 18 |
3 files changed, 28 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown index 52a2d4b0..2cdafdb3 100644 --- a/README.markdown +++ b/README.markdown @@ -328,6 +328,8 @@ Installed by the `install-bin` target: look for `help` topics. You could use it from the shell too. * `igex(1)` wraps around a command to allow you to ignore error conditions that don't actually worry you, exiting with 0 anyway. +* `isgr(1)` quietly tests whether the given directory appears to be a Git + repository * `jfc(1)` adds and commits lazily to a Git repository. * `jfcd(1)` watches a directory for changes and runs `jfc(1)` if it sees any. * `maybe(1)` is like `true(1)` or `false(1)`; given a probability of success, diff --git a/bin/isgr b/bin/isgr new file mode 100755 index 00000000..9cb37c1a --- /dev/null +++ b/bin/isgr @@ -0,0 +1,8 @@ +#!/bin/sh +# Return an exit status for whether the current directory appears to be in a +# Git working copy +exec >/dev/null 2>&1 +cd -- "${1:-.}" || exit +git symbolic-ref --quiet HEAD || +git rev-parse --short HEAD || +exit 1 diff --git a/man/man1/isgr.1 b/man/man1/isgr.1 new file mode 100644 index 00000000..f997d17a --- /dev/null +++ b/man/man1/isgr.1 @@ -0,0 +1,18 @@ +.TH ISGR 1 "August 2016" "Manual page for isgr" +.SH NAME +.B isgr +\- print a count of entries in a directory +.SH SYNOPSIS +.B isgr +.br +.B isgr +/path/to/dir +.SH DESCRIPTION +.B isgr +exits with 0 if the given directory (or the current directory if one is not +given) appears to be a working copy of a Git repository. It exits 1 otherwise. +All output from the git(1) commands used to check this is suppressed. +.SH SEE ALSO +git(1), gscr(1), fgscr(1) +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> |