From 76ce82ea2d44212c985ebe94b3ccdcb31da0f83f Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Mon, 6 Jan 2020 18:27:31 +0100
Subject: Add git-mkbare
---
.local/bin/git-mkbare | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100755 .local/bin/git-mkbare
(limited to '.local/bin/git-mkbare')
diff --git a/.local/bin/git-mkbare b/.local/bin/git-mkbare
new file mode 100755
index 0000000..bd9615c
--- /dev/null
+++ b/.local/bin/git-mkbare
@@ -0,0 +1,64 @@
+#! /usr/bin/env sh
+
+main()
+{
+ # Handle opts
+ opts "$@"
+ shift "$OPTS"
+ unset OPTS
+
+ # Show help
+ [ "$OPT_HELP_ONLY" ] && usage && exit 0
+
+ location=$(readlink -f "${1:-$PWD}")
+
+ # Prompt for location
+ printf "%s: [%s] " "Path" "$location"
+ read -r input
+ [ -z "$input" ] || location=$(readlink -f "$input")
+ unset input
+
+ # Prompt for description
+ printf "%s: " "Description"
+ read -r description
+
+ # Create the bare git repository
+ mkdir -p "$location"
+ cd -- "$location"
+ git --bare init
+
+ # Update the description, if given
+ printf "%s\n" "$description" > "$location/description"
+}
+
+opts()
+{
+ OPTS=0
+
+ while getopts ":h" opt
+ do
+ case "$opt" in
+ h) OPT_HELP_ONLY=1 ;;
+ *)
+ printf "Invalid option passed: %s\n" "$OPTARG" >&2
+ ;;
+ esac
+ done
+
+ unset opt
+}
+
+usage()
+{
+ cat <