summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-21 08:37:26 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-21 08:37:26 -0400
commit1b1abf00833cd4796c98dc410978d042eaf8d001 (patch)
tree334ff14eac1af023a0bf94297f898cd83fc68cde
parentbb0b8efa06e504a5b82dbc0fb5f22721701dcb42 (diff)
pbs-plumb-shlib: add documentation for git functions
-rw-r--r--pbs-plumb-shlib16
1 files changed, 12 insertions, 4 deletions
diff --git a/pbs-plumb-shlib b/pbs-plumb-shlib
index ccbdffb..ded9825 100644
--- a/pbs-plumb-shlib
+++ b/pbs-plumb-shlib
@@ -4,28 +4,36 @@
# "Primitive" git functions ##########################################
+# Usage: in_git
+# Returns 0 if somewhere in a git repository, nonzero if not.
in_git() {
git rev-parse --git-dir &>/dev/null
}
+# Usage: gitdir
+# Prints the .git directory for the repository we're in
gitdir() {
git rev-parse --git-dir
}
+# Usage: gitroot
+# Prints the root directory of the git checkout
gitroot() {
git rev-parse --show-toplevel
}
+# Usage: gitbranch
+# Prints the current git branch
gitbranch() {
git rev-parse --abbrev-ref HEAD
}
+# Usage: have_file $file
+# Returns 0 if `$(gitroot)/$file` exists.
have_file() {
local file=$1
- if in_git; then
- if [[ -f "$(gitroot)/$file" ]]; then
- return 0;
- fi
+ if in_git && [[ -f "$(gitroot)/$file" ]]; then
+ return 0;
fi
return 1
}