aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-config-save21
1 files changed, 21 insertions, 0 deletions
diff --git a/git-config-save b/git-config-save
index 5c040e4..dad19ef 100755
--- a/git-config-save
+++ b/git-config-save
@@ -51,6 +51,9 @@ BASENAME="`basename $0`"
BASE="$HOME/.config/gitconfigs"
DATE="`date +%Y%m%d%I%M%S`"
FILENAME="gitconfig.saved"
+OPTION="$1"
+COUNTER="$BASE/counter"
+SOMETIMES="20"
# Ensure we have a base and that is minimally safe
mkdir -p $BASE
@@ -125,6 +128,24 @@ function git_config_restore {
echo "Backup saved at $pwd/.git/config.$DATE"
}
+# Check option
+if [ ! -z "$OPTION" ] && [ "$OPTION" == "--sometimes" ]; then
+ if [ ! -e "$COUNTER" ]; then
+ echo 0 > $COUNTER
+ fi
+
+ COUNT="`cat $COUNTER`"
+
+ if (($COUNT >= $SOMETIMES)); then
+ echo 0 > $COUNTER
+ else
+ let COUNT++
+ echo $COUNT > $COUNTER
+ echo "Running only sometimes. This is run ${COUNT} of ${SOMETIMES}, skipping."
+ exit 1
+ fi
+fi
+
# Process everything we can find
find -type d -name .git | while read repo; do
# Get absolute folder