3 # Update all out-of-date config in all current projects and add missing bits
5 # If one or more project names are given, just update those instead
7 # update-all-config [--dry-run] [projname]...
15 [ "$1" != "--force" -a "$1" != "-f" ] ||
{ force
=1; shift; }
16 [ "$1" != "--dry-run" -a "$1" != "-n" ] ||
{ dryrun
=1; shift; }
17 case "$1" in -*) echo "Invalid options: $1" >&2; exit 1;; esac
22 drwxmode
='ug+rwx,o+rx'
26 if [ -z "$cfg_owning_group" ]; then
27 if [ -z "$force" ]; then
28 echo "No owning_group set, refusing to run without --force" >&2
40 ls -ldH "$1" | cut
-d ' ' -f 1
44 ls -ldH "$1" |
awk '{print $4}'
49 [ -n "$hdr" ] ||
{ hdr
=1; [ -z "$wrote" ] ||
echo ""; echo "$proj:"; }
56 oldperm
="$(get_perm "$1")"
57 [ -n "$dryrun" ] ||
chmod $dmode "$1" 2>/dev
/null || result
=$?
58 pmsg
"$1/:" "$oldperm" '->' "$dperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
63 oldperm
="$(get_perm "$1")"
64 if [ -n "$wall" ]; then
67 scratch
="${oldperm#????????}"
68 newperm
="drwxrwxr${scratch%?}x"
70 [ -n "$dryrun" ] ||
[ "$oldperm" = "$newperm" ] ||
chmod $drwxmode "$1" 2>/dev
/null || result
=$?
71 pmsg
"$1/:" "$oldperm" '->' "$newperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
76 oldperm
="$(get_perm "$1")"
77 scratch
="${oldperm#??}"
78 newperm
="dr${scratch%???????}xr"
79 scratch
="${scratch#???}"
80 newperm
="$newperm${scratch%????}xr"
81 scratch
="${scratch#???}"
82 newperm
="$newperm${scratch%?}x"
83 [ -n "$dryrun" ] ||
[ "$oldperm" = "$newperm" ] ||
chmod a
+rx
"$1" 2>/dev
/null || result
=$?
84 pmsg
"$1/:" "$oldperm" '->' "$newperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
89 oldgrp
="$(get_grp "$1")"
90 [ -n "$dryrun" ] || chgrp
"$cfg_owning_group" "$1" 2>/dev
/null || result
=$?
92 ! [ -d "$1" ] || isdir
='/'
93 pmsg
"$1$isdir:" group
"$oldgrp" '->' "$cfg_owning_group" ${result:+FAILED!} ${dryrun:+(dryrun)}
98 oldperm
="$(get_perm "$1")"
100 [ "$oldperm" = "$fperm" ] ||
{ msg
=1; [ -n "$dryrun" ]; } ||
chmod $fmode "$1" 2>/dev
/null || result
=$?
101 [ -z "$msg" ] || pmsg
"$1:" "$oldperm" '->' "$fperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
106 oldperm
="$(get_perm "$1")"
107 scratch
="${oldperm#??}"
108 newperm
="-r${scratch%??????}"
109 scratch
="${scratch#???}"
110 newperm
="${newperm}r${scratch%???}"
111 scratch
="${scratch#???}"
112 newperm
="${newperm}r$scratch"
113 [ -n "$dryrun" ] ||
[ "$oldperm" = "$newperm" ] ||
chmod a
+r
"$1" 2>/dev
/null || result
=$?
114 pmsg
"$1:" "$oldperm" '->' "$newperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
119 oldperm
="$(get_perm "$1")"
120 newperm
="${oldperm%???????}-"
121 scratch
="${oldperm#????}"
122 newperm
="${newperm}${scratch%????}-"
123 scratch
="${scratch#???}"
124 newperm
="${newperm}${scratch%?}-"
125 [ -n "$dryrun" ] ||
[ "$oldperm" = "$newperm" ] ||
chmod a-x
"$1" 2>/dev
/null || result
=$?
126 pmsg
"$1:" "$oldperm" '->' "$newperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
131 oldperm
="$(get_perm "$1")"
132 newperm
="${oldperm%???????}x"
133 scratch
="${oldperm#????}"
134 newperm
="${newperm}${scratch%????}x"
135 scratch
="${scratch#???}"
136 newperm
="${newperm}${scratch%?}x"
137 [ -n "$dryrun" ] ||
[ "$oldperm" = "$newperm" ] ||
chmod a
+x
"$1" 2>/dev
/null || result
=$?
138 pmsg
"$1:" "$oldperm" '->' "$newperm" ${result:+FAILED!} ${dryrun:+(dryrun)}
143 [ -n "$dryrun" ] || mkdir
"$1" 2>/dev
/null ||
[ -d "$1" ] || result
=1
144 pmsg
"$1/:" created
${result:+FAILED!} ${dryrun:+(dryrun)}
150 if [ -n "$dryrun" ] && ! [ -e config
]; then
153 configlist
="$(git config --list --file config)"
154 [ -z "$configlist" ] || configlist
="$configlist$nl"
159 while read -r _item
; do
160 case "$_item" in "$1"=*)
161 printf '%s' "${_item#*=}"
171 case "$1" in 1|
[Tt
][Rr
][Uu
][Ee
]|
[Yy
][Ee
][Ss
]|
[Oo
][Nn
]) return 0; esac
176 case "$1" in 0|
[Ff
][Aa
][Ll
][Ss
][Ee
]|
[Nn
][Oo
]|
[Oo
][Ff
][Ff
]) return 0; esac
181 isbooltrue
"$1" || isboolfalse
"$1" ||
return 1
187 [ "$1" != "--unset" ] ||
{ unset=1; shift; _x
="$1"; shift; msg
="$*"; set -- "$_x"; }
191 oldval
="$(configitem "$item")" || existsnot
=1
194 [ -n "$existsnot" -o -z "$unset" ] ||
[ $
(printf '%s' "$configlist" |
grep "^${item%%.*}\.[^.][^.]*=" | wc -l) -ne 1 ] || { ccmd="remove-section"; arg="${item%%.*}"; }
195 [ -n "$dryrun" ] || [ -n "$unset" -a -n "$existsnot" ] || git config --file config ${unset:+--$ccmd} "$arg" "$@
" 2>/dev/null || result=1
196 if [ -n "$existsnot" ]; then
197 [ -n "$unset" ] || pmsg "config
$item:" created "\"$
*\"" ${result:+FAILED!} ${dryrun:+(dryrun)}
199 if [ -n "$unset" ]; then
200 pmsg "config
$item:" removed $msg "\"$oldval\"" ${result:+FAILED!} ${dryrun:+(dryrun)}
202 pmsg "config
$item:" "\"$oldval\"" '->' "\"$
*\"" ${result:+FAILED!} ${dryrun:+(dryrun)}
207 mkdirs='refs info hooks ctags htmlcache objects objects/info'
208 mkfiles='config info/lastactivity'
209 fixdpermsdirs='. refs info ctags htmlcache objects objects/info'
210 fixdpermsrwx='refs objects'
211 fixfpermsfiles='HEAD config description packed-refs README.html info/lastactivity'
212 fixfpermsfiles="$fixfpermsfiles info
/alternates info
/http-alternates info
/packs
"
213 fixfpermsdirs='ctags'
215 boolvars='gitweb.statusupdates'
216 falsevars='receive.denynonfastforwards'
217 false0vars='gc.auto receive.autogc'
218 truevars='receive.updateserverinfo repack.writebitmaps'
220 base="${cfg_reporoot%/}"
221 cmd='cut -d : -f 1 < "$cfg_chroot/etc
/group
" | grep -v ^_repo'
222 [ $# -eq 0 ] || cmd='printf "%s
\n" "$@
"'
225 while read -r proj; do
226 proj="${proj#$base/}"
228 projdir="$base/$proj.git
"
229 [ -d "$projdir" ] || { echo "$proj: does not exist
-- skipping
"; continue; }
230 is_git_dir "$projdir" || { echo "$proj: is not a .git directory
-- skipping
"; continue; }
231 ! [ -e "$projdir/.noconfig
" ] || { echo "$proj: found .noconfig
-- skipping
"; continue; }
235 for mdir in $mkdirs; do
236 if ! [ -d "$mdir" ]; then
237 if [ -e "$mdir" ]; then
238 echo "$proj: bypassing project
, exists but not directory
: $mdir" >&2
245 [ -z "$bad" ] || continue
246 while read -r fixdir; do
247 [ -z "$fixdir" ] || change_dperm "$fixdir"
249 $(find $fixdpermsdirs -xdev -maxdepth 0 -type d -not -perm $dmode -print 2>/dev/null)
251 while read -r fixdir; do
252 [ -z "$fixdir" ] || change_dpermrwx "$fixdir"
254 $(find $fixdpermsrwx -xdev -type d -not -perm -$drwxmode -print 2>/dev/null)
256 while read -r fixdir; do
257 [ -z "$fixdir" ] || change_dpermrx "$fixdir"
259 $(find . -xdev -type d -not -perm -a+rx -print)
261 for mkfile in $mkfiles; do
262 if [ -e "$mkfile" ]; then
263 if ! [ -f "$mkfile" ]; then
264 echo "$proj: bypassing project
, exists but not
file: $mkfile" >&2
270 [ -n "$dryrun" ] || { >"$mkfile"; } 2>/dev/null || result=1
271 pmsg "$mkfile:" created ${result:+FAILED!} ${dryrun:+(dryrun)}
274 [ -z "$bad" ] || continue
275 [ -n "$dryrun" ] || change_fperm config
277 grpshr="$
(configitem core.sharedrepository ||
:)"
278 if [ -z "$grpshr" ] || isboolfalse "$grpshr"; then
279 do_config core.sharedrepository 1
280 elif ! isbooltrue "$grpshr"; then
281 pmsg "WARNING
: odd core.sharedrepository value left unchanged
: \"$grpshr\""
283 isbooltrue "$
(configitem core.bare ||
:)" || pmsg "WARNING
: core.bare is not true
(left unchanged
)"
284 for bvar in $boolvars; do
285 ! old="$
(configitem
"$bvar")" || isbool "$old" || do_config --unset "$bvar" "(not a boolean
)"
287 for fvar in $falsevars; do
288 old="$
(configitem
"$fvar" ||
:)"
289 isboolfalse "$old" || do_config "$fvar" false
291 for fvar in $false0vars; do
292 old="$
(configitem
"$fvar" ||
:)"
293 isboolfalse "$old" || do_config "$fvar" 0
295 for tvar in $truevars; do
296 old="$
(configitem
"$tvar" ||
:)"
297 isbooltrue "$old" || do_config "$tvar" true
299 if [ -n "$cfg_owning_group" ]; then
300 while read -r fixgrp; do
301 [ -z "$fixgrp" ] || change_group "$fixgrp"
303 $(find . -xdev \( -type d -o -type f \) -not -group $cfg_owning_group -print)
306 for fixfile in $fixfpermsfiles; do
307 if [ -e "$fixfile" ]; then
308 if ! [ -f "$fixfile" ]; then
309 echo "$proj: bypassing project
, exists but not
file: $fixfile" >&2
313 change_fperm "$fixfile"
316 [ -z "$bad" ] || continue
317 for fixfile in $(find $fixfpermsdirs -xdev -type f -not -perm $fmode -print 2>/dev/null); do
318 change_fperm "$fixfile"
320 while read -r fixfileread; do
321 [ -z "$fixfileread" ] || change_fpermr "$fixfileread"
323 $(find . -xdev -type f -not -perm -a+r -print)
325 while read -r fixfilenox; do
326 [ -z "$fixfilenox" ] || change_fpermnox "$fixfilenox"
328 $(find . -xdev -type d \( -path ./hooks -o -path ./mob/hooks \) -prune -o -type f -perm +a+x -print)
330 while read -r fixfilex; do
331 case "$fixfilex" in ""|*.sample) :;; *) change_fpermx "$fixfilex"; esac
333 $(! [ -d hooks ] || find hooks -xdev -type f -not -perm -a+x -print
334 ! [ -d mob/hooks ] || find mob/hooks -xdev -type f -not -perm -a+x -print)
336 bu="$
(configitem gitweb.baseurl ||
:)"
337 [ -n "$bu" -o -e .nofetch ] || pmsg "WARNING
: gitweb.baseurl is empty and .nofetch does not exist
"
338 [ -z "$bu" -o ! -e .nofetch ] || pmsg "WARNING
: .nofetch exists but gitweb.baseurl is not empty
"