mdisk: Remove color from "Already mounted" message
[sunny256-utils.git] / ga-ignore-remote
blob0c92b0b5cafc95e05e75337c303f1e04ecfc3160
1 #!/usr/bin/env bash
3 #=======================================================================
4 # ga-ignore-remote
5 # File ID: ff8df730-a2ed-11e5-9f07-fefdb24f8e10
7 # Disable automatic push from git-annex to a Git remote
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
13 progname=ga-ignore-remote
14 VERSION=0.5.0
16 ARGS="$(getopt -o "\
21 " -l "\
22 help,\
23 quiet,\
24 unignore,\
25 verbose,\
26 version,\
27 " -n "$progname" -- "$@")"
28 test "$?" = "0" || exit 1
29 eval set -- "$ARGS"
31 opt_help=0
32 opt_quiet=0
33 opt_verbose=0
34 while :; do
35 case "$1" in
36 -h|--help) opt_help=1; shift ;;
37 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
38 -u|--unignore) opt_unignore=$(($opt_quiet + 1)); shift ;;
39 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
40 --version) echo $progname $VERSION; exit 0 ;;
41 --) shift; break ;;
42 *) echo $progname: Internal error >&2; exit 1 ;;
43 esac
44 done
45 opt_verbose=$(($opt_verbose - $opt_quiet))
47 if test "$opt_help" = "1"; then
48 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
49 cat <<END
51 Disable automatic push from git-annex to a Git remote
53 Usage: $progname [options] REMOTE [REMOTES ...]
55 Options:
57 -h, --help
58 Show this help.
59 -q, --quiet
60 Be more quiet. Can be repeated to increase silence.
61 -u, --unignore
62 Enable push to the remotes, remove the annex-readonly value from Git
63 config.
64 -v, --verbose
65 Increase level of verbosity. Can be repeated.
66 --version
67 Print version information.
69 END
70 exit 0
73 ignore_remote() {
74 remote="$1"
75 shift
76 if test -z "$(git remote | grep "^$remote\$")"; then
77 echo $progname: $remote: Git remote not found >&2
78 return 1
81 if test "$opt_unignore" = "1"; then
82 git config --unset remote.$remote.annex-readonly
83 else
84 git config remote.$remote.annex-readonly true
87 if test $opt_verbose -ge 0; then
88 git config -l | grep ^remote.$remote.annex
89 echo
91 return 0
94 for r in "$@"; do
95 ignore_remote "$r"
96 done