diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2021-04-23 09:13:26 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2021-04-23 09:13:26 -0300 |
commit | 690975594fa4003011dedf26d2356d47bae4942e (patch) | |
tree | 63f27aa64b15f320d77cff7e5ef6d887b2e51db2 /git-config-save | |
parent | c46b83b1220b80537da31e7dddd13fe01e6dbb46 (diff) | |
download | utils-git-690975594fa4003011dedf26d2356d47bae4942e.tar.gz utils-git-690975594fa4003011dedf26d2356d47bae4942e.tar.bz2 |
Fix: git-config-save: adds --sometimes flag
Diffstat (limited to 'git-config-save')
-rwxr-xr-x | git-config-save | 21 |
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 |