html/about.html: bring some of the URLs up-to-date
[girocco.git] / jobd / update.sh
blob2d0908f02af2c4eeabdb66d0749549f62394755c
1 #!/bin/sh
3 . @basedir@/shlib.sh
5 set -e
7 if [ $# -ne 1 ]; then
8 echo "Usage: update.sh projname" >&2
9 exit 1
12 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
13 datefmt='+%a, %d %b %Y %T %z'
15 git_fetch_q_progress() {
16 if [ "${cfg_max_file_size512:-0}" != "0" ]; then
17 GIT_BIN="'$cfg_basedir/bin/ulimit512' -i -f '$cfg_max_file_size512' -- '$cfg_git_bin'" &&
18 export GIT_BIN
20 PATH="$var_git_exec_path:$cfg_basedir/bin:$PATH" @basedir@/jobd/git-fetch-q-progress.sh "$@"
23 # freshen_loose_objects full-sha ...
24 # if "$n" is a loose object, set its modification time to now
25 # otherwise silently do nothing with no error. To facilitate conversion
26 # of mirror projects to push projects we also add group write permission.
27 freshen_loose_objects() {
28 _list=
29 for _sha; do
30 _fn="${_sha#??}"
31 _shard="${_sha%$_fn}"
32 _list="$_list objects/$_shard/$_fn"
33 done
34 if [ -n "$_list" ]; then
35 chmod ug+w $_list 2>/dev/null || :
36 touch -c $_list 2>/dev/null || :
40 # darcs fast-export | git fast-import with error handling
41 git_darcs_fetch() (
42 set_utf8_locale
43 _err1=
44 _err2=
45 exec 3>&1
46 { read -r _err1 || :; read -r _err2 || :; } <<-EOT
48 exec 4>&3 3>&1 1>&4 4>&-
50 _e1=0
51 "$cfg_basedir"/bin/darcs-fast-export \
52 --export-marks="$(pwd)/dfe-marks" \
53 --import-marks="$(pwd)/dfe-marks" "$1" 3>&- || _e1=$?
54 echo $_e1 >&3
55 } |
57 _e2=0
58 git_ulimit fast-import \
59 --export-marks="$(pwd)/gfi-marks" \
60 --export-pack-edges="$(pwd)/gfi-packs" \
61 --import-marks="$(pwd)/gfi-marks" \
62 --force 3>&- || _e2=$?
63 echo $_e2 >&3
66 EOT
67 exec 3>&-
68 [ "$_err1" = 0 ] && [ "$_err2" = 0 ]
69 return $?
72 # bzr fast-export | git fast-import with error handling
73 git_bzr_fetch() (
74 set_utf8_locale
75 BZR_LOG=/dev/null
76 export BZR_LOG
77 _err1=
78 _err2=
79 exec 3>&1
80 { read -r _err1 || :; read -r _err2 || :; } <<-EOT
82 exec 4>&3 3>&1 1>&4 4>&-
84 _e1=0
85 bzr fast-export --plain \
86 --export-marks="$(pwd)/bfe-marks" \
87 --import-marks="$(pwd)/bfe-marks" "$1" 3>&- || _e1=$?
88 echo $_e1 >&3
89 } |
91 _e2=0
92 git_ulimit fast-import \
93 --export-marks="$(pwd)/gfi-marks" \
94 --export-pack-edges="$(pwd)/gfi-packs" \
95 --import-marks="$(pwd)/gfi-marks" \
96 --force 3>&- || _e2=$?
97 echo $_e2 >&3
101 exec 3>&-
102 [ "$_err1" = 0 ] && [ "$_err2" = 0 ]
103 return $?
106 [ -n "$cfg_mirror" ] || { echo "Mirroring is disabled" >&2; exit 0; }
108 umask 002
109 [ "$cfg_permission_control" != "Hooks" ] || umask 000
110 clean_git_env
112 proj="${1%.git}"
113 cd "$cfg_reporoot/$proj.git"
115 # Activate a mini-gc if needed
116 # We do this here as well as after a successful fetch so that if we're stuck
117 # in a fetch loop where fetches are succeeding in fetching new packs but the
118 # ref update is failing for some reason (perhaps a non-commit under refs/heads)
119 # and a previous invokation therefore had a "bang" exit then we will still
120 # get the .needsgc flag set in a timely fashion to avoid excess pack build up.
121 check_and_set_needsgc
123 trap 'if [ $? != 0 ]; then echo "update failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT
124 trap 'exit 130' INT
125 trap 'exit 143' TERM
127 if [ "${force_update:-0}" = "0" ] && check_interval lastrefresh $cfg_min_mirror_interval; then
128 progress "= [$proj] update skip (last at $(config_get lastrefresh))"
129 exit 0
131 if [ -e .nofetch ]; then
132 progress "x [$proj] update disabled (.nofetch exists)"
133 exit 0
135 progress "+ [$proj] update ($(date))"
137 # Any pre-existing FETCH_HEAD from a previous fetch, failed or not, is garbage
138 rm -f FETCH_HEAD
140 # Remove any stale ref locks
141 clear_stale_ref_locks
143 # A previous failed update attempt can leave a huge tmp_pack_XXXXXX file behind.
144 # Since no pushes are allowed to mirrors, we know that any such files that exist
145 # at this point in time are garbage and can be safely deleted, we do not even
146 # need to check how old they are. A tmp_idx_XXXXXX file is also created during
147 # the later stages of the fetch process, so we kill any of those as well.
148 find -L objects/pack -maxdepth 1 -type f -name "tmp_pack_?*" -exec rm -f '{}' + || :
149 find -L objects/pack -maxdepth 1 -type f -name "tmp_idx_?*" -exec rm -f '{}' + || :
151 # Make sure we have a reflogs subdirectory and abort the update if not
152 # This should not count as a normal "bang" failure if unsuccessful
153 [ -d reflogs ] || mkdir -p reflogs >/dev/null 2>&1 || :
154 [ -d reflogs ]
156 keep_bang_log=
157 do_check_after_refs=1
158 bang_setup
159 bang_action="update"
160 bang_trap() {
161 if [ -n "$1" ]; then
162 # Throttle retries
163 # Since gitweb shows the .last_refresh date, it's safe to update
164 # gitweb.lastrefresh to throttle the updates w/o corrupting the
165 # last refresh date display on the gitweb summary page
166 # It's therefore important that we do NOT touch .last_refresh here
167 config_set lastrefresh "$(date "$datefmt")"
171 bang echo "Project: $proj"
172 bang echo " Date: $(TZ=UTC date '+%Y-%m-%d %T UTC')"
173 bang echo ""
174 mail="$(config_get owner)" || :
175 url="$(config_get baseurl)" || :
176 case "$url" in *" "*|*" "*|"")
177 bang_eval 'echo "Bad mirror URL (\"$url\")"; ! :'
178 exit 1
179 esac
180 bang echo "Mirroring from URL \"$url\""
181 bang echo ""
182 statusok="$(git config --bool gitweb.statusupdates 2>/dev/null || echo true)"
183 mailaddrs=
184 [ "$statusok" = "false" ] || [ -z "$mail" ] || mailaddrs="$mail"
185 [ -z "$cfg_admincc" ] || [ "$cfg_admincc" = "0" ] || [ -z "$cfg_admin" ] ||
186 if [ -z "$mailaddrs" ]; then mailaddrs="$cfg_admin"; else mailaddrs="$mailaddrs,$cfg_admin"; fi
188 bang_eval "git for-each-ref --format '%(refname) %(objectname)' >.refs-temp"
189 bang_eval "LC_ALL=C sort -b -k1,1 <.refs-temp >.refs-before"
191 check_after_refs() {
192 [ -n "$do_check_after_refs" ] || return 0
193 bang_eval "git for-each-ref --format '%(refname) %(objectname)' >.refs-temp"
194 bang_eval "LC_ALL=C sort -b -k1,1 <.refs-temp >.refs-after"
195 refschanged=
196 cmp -s .refs-before .refs-after || refschanged=1
197 do_check_after_refs=
200 ! [ -e .delaygc ] || >.allowgc || :
202 # Make sure we don't get any unwanted loose objects
203 # Starting with Git v2.10.0 fast-import can generate loose objects unless we
204 # tweak its configuration to prevent that
205 git_add_config 'fetch.unpackLimit=1'
206 # Note the git config documentation is wrong
207 # transfer.unpackLimit, if set, overrides fetch.unpackLimit
208 git_add_config 'transfer.unpackLimit=1'
209 # But not the Git v2.10.0 and later fastimport.unpackLimit which improperly uses <= instead of <
210 git_add_config 'fastimport.unpackLimit=0'
212 # remember the starting time so we can easily combine fetched loose objects
213 # we sleep for 1 second after creating .needspack to make sure all objects are newer
214 if ! [ -e .needspack ]; then
215 rm -f .needspack
216 >.needspack
217 sleep 1
220 case "$url" in
221 svn://* | svn+http://* | svn+https://* | svn+file://* | svn+ssh://*)
222 [ -n "$cfg_mirror_svn" ] || { echo "Mirroring svn is disabled" >&2; exit 0; }
223 # Allow the username to be specified in the "svn-credential.svn.username"
224 # property and the password in the "svn-credential.svn.password" property
225 # Use an 'anonsvn' username by default as is commonly used for anonymous svn
226 # Default the password to the same as the username
227 # The password property will be ignored unless a username has been specified
228 if svnuser="$(git config --get svn-credential.svn.username)" && [ -n "$svnuser" ]; then
229 if ! svnpass="$(git config --get svn-credential.svn.password)"; then
230 svnpass="$svnuser"
232 url1="${url#*://}"
233 url1="${url1%%/*}"
234 case "$url1" in ?*"@"?*)
235 urlsch="${url%%://*}"
236 url="$urlsch://${url#*@}"
237 esac
238 else
239 # As a fallback, check in the URL, just in case
240 url1="${url#*://}"
241 url1="${url1%%/*}"
242 svnuser=
243 case "$url1" in ?*"@"?*)
244 urlsch="${url%%://*}"
245 url="$urlsch://${url#*@}"
246 url1="${url1%%@*}"
247 svnuser="${url1%%:*}"
248 if [ -n "$svnuser" ]; then
249 svnpass="$svnuser"
250 case "$url1" in *":"*)
251 svnpass="${url1#*:}"
252 esac
254 esac
255 if [ -z "$svnuser" ]; then
256 svnuser="anonsvn"
257 svnpass="anonsvn"
260 GIT_ASKPASS_PASSWORD="$svnpass"
261 export GIT_ASKPASS_PASSWORD
262 # Update the git svn url to match baseurl but be cognizant of any
263 # needed prefix changes. See the comments in taskd/clone.sh about
264 # why we need to put up with a prefix in the first place.
265 case "$url" in svn+ssh://*) svnurl="$url";; *) svnurl="${url#svn+}";; esac
266 svnurl="${svnurl%/}"
267 svnurlold="$(config_get svnurl)" || :
268 if [ "$svnurl" != "$svnurlold" ]; then
269 # We better already have an svn-remote.svn.fetch setting
270 bang test -n "$(git config --get-all svn-remote.svn.fetch)" || :
271 # the only way to truly know what the proper prefix is
272 # is to attempt a fresh git-svn init -s on the new url
273 rm -rf svn-new-url || :
274 # We require svn info to succeed on the URL otherwise it's
275 # simply not a valid URL and without using -s on the init it
276 # will not otherwise be tested until the fetch
277 bang eval 'svn --non-interactive --username "$svnuser" --password "$svnpass" info "$svnurl" >/dev/null'
278 bang mkdir svn-new-url
279 GIT_DIR=svn-new-url bang git init --bare --quiet
280 # We initially use -s for the init which will possibly shorten
281 # the URL. However, the shortening can fail if a password is
282 # not required for the longer version but is for the shorter,
283 # so try again without -s if the -s version fails.
284 cmdstr='git svn init --username="$svnuser" --prefix "" -s "$svnurl" <"$mtlinesfile" >/dev/null 2>&1 || '
285 cmdstr="$cmdstr"'git svn init --username="$svnuser" --prefix "" "$svnurl" <"$mtlinesfile" >/dev/null 2>&1'
286 GIT_DIR=svn-new-url bang eval "$cmdstr"
287 gitsvnurl="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.url)" || :
288 gitsvnfetch="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.fetch)" || :
289 gitsvnprefixnew="${gitsvnfetch%%:*}"
290 gitsvnsuffixnew="${gitsvnprefixnew##*/}"
291 gitsvnprefixnew="${gitsvnprefixnew%$gitsvnsuffixnew}"
292 rm -rf svn-new-url || :
293 # Using GIT_DIR= with bang leaves it set to svn-new-url, so reset it to .
294 GIT_DIR=.
295 if [ "$gitsvnurl" != "$(git config --get svn-remote.svn.url || :)" ]; then
296 # The url has been changed.
297 # We must update the url and replace the prefix on all config items
298 gitsvnfetch="$(git config --get-all svn-remote.svn.fetch | head -1)" || :
299 gitsvnprefixold="${gitsvnfetch%%:*}"
300 gitsvnsuffixold="${gitsvnprefixold##*/}"
301 gitsvnprefixold="${gitsvnprefixold%$gitsvnsuffixold}"
302 git config --remove-section 'svn-remote.svnnew' 2>/dev/null || :
303 git config 'svn-remote.svnnew.url' "$gitsvnurl"
304 git config --get-regexp '^svn-remote\.svn\.' |
305 while read -r sname sval; do
306 case "$sname" in
307 svn-remote.svn.fetch|svn-remote.svn.branches|svn-remote.svn.tags)
308 sname="${sname#svn-remote.svn.}"
309 sval="${sval#$gitsvnprefixold}"
310 bang git config --add "svn-remote.svnnew.$sname" "${gitsvnprefixnew}$sval"
311 esac
312 done
313 test $? -eq 0
314 bang git config -f svn/.metadata svn-remote.svn.reposRoot "$gitsvnurl"
315 bang git config --remove-section svn-remote.svn
316 bang git config --rename-section svn-remote.svnnew svn-remote.svn
318 bang config_set svnurl "$svnurl"
320 # remove any stale *.lock files greater than 1 hour old in case
321 # git-svn was killed on the last update because it took too long
322 find -L svn -type f -name '*.lock' -mmin +60 -exec rm -f '{}' + 2>/dev/null || :
323 GIROCCO_DIVERT_GIT_SVN_AUTO_GC=1
324 export GIROCCO_DIVERT_GIT_SVN_AUTO_GC
325 unset GIROCCO_SUPPRESS_AUTO_GC_UPDATE
326 saveconfig="$GIT_CONFIG_PARAMETERS"
327 git_add_config 'gc.auto=1'
328 git_add_config 'gc.autoPackLimit=1'
329 GIT_DIR=. bang git_ulimit svn fetch --log-window-size=$var_log_window_size --username="$svnuser" --quiet <"$mtlinesfile"
330 GIROCCO_SUPPRESS_AUTO_GC_UPDATE=1
331 export GIROCCO_SUPPRESS_AUTO_GC_UPDATE
332 unset GIROCCO_DIVERT_GIT_SVN_AUTO_GC
333 unset GIT_CONFIG_PARAMETERS
334 [ -z "$saveconfig" ] || {
335 GIT_CONFIG_PARAMETERS="$saveconfig"
336 export GIT_CONFIG_PARAMETERS
338 # git svn does not preserve group permissions in the svn subdirectory
339 chmod -R ug+rw,o+r svn
340 # git svn also leaves behind ref turds that end with @nnn
341 # We get rid of them now
342 git for-each-ref --format='%(refname)' |
343 LC_ALL=C sed '/^..*@[1-9][0-9]*$/!d; s/^/delete /' |
344 git_updateref_stdin
345 # handle old-style svn setup if it exists
346 if [ -n "$(git config --get remote.origin.url || :)" ]; then
347 GIT_DIR=. bang git fetch
349 unset GIT_ASKPASS_PASSWORD
351 darcs://* | darcs+http://* | darcs+https://*)
352 [ -n "$cfg_mirror_darcs" ] || { echo "Mirroring darcs is disabled" >&2; exit 0; }
353 case "$url" in
354 darcs://*) darcsurl="http://${url#darcs://}";;
355 *) darcsurl="${url#darcs+}";;
356 esac
357 # remove any stale lock files greater than 1 hour old in case
358 # darcs_fast_export was killed on the last update because it took too long
359 find -L *.darcs -maxdepth 2 -type f -name 'lock' -mmin +60 -exec rm -f '{}' + 2>/dev/null || :
360 bang git_darcs_fetch "$darcsurl"
362 bzr://*)
363 [ -n "$cfg_mirror_bzr" ] || { echo "Mirroring bzr is disabled" >&2; exit 0; }
364 bzrurl="${url#bzr://}"
365 bang git_bzr_fetch "$bzrurl"
367 hg+http://* | hg+https://* | hg+file://* | hg+ssh://*)
368 [ -n "$cfg_mirror_hg" ] || { echo "Mirroring hg is disabled" >&2; exit 0; }
369 # We just remove hg+ here, so hg+http://... becomes http://...
370 hgurl="${url#hg+}"
371 # Fetch any new updates
372 bang hg -R "$(pwd)/repo.hg" pull
373 # Do the fast-export | fast-import
374 bang git_hg_fetch
377 [ "$url" = "$(git config --get remote.origin.url || :)" ] || bang config_set_raw remote.origin.url "$url"
378 pruneopt=--prune
379 [ "$(git config --bool fetch.prune 2>/dev/null || :)" != "false" ] || pruneopt=
380 if ! is_gfi_mirror_url "$url"; then
381 lastwasclean=
382 [ "$(git config --bool girocco.lastupdateclean 2>/dev/null || :)" != "true" ] || lastwasclean=1
383 nextisclean=
384 [ "$(git config --bool girocco.cleanmirror 2>/dev/null || :)" != "true" ] || nextisclean=1
385 if [ "$nextisclean" != "$lastwasclean" ]; then
386 if [ -n "$nextisclean" ]; then
387 git config --replace-all remote.origin.fetch "+refs/heads/*:refs/heads/*"
388 git config --add remote.origin.fetch "+refs/tags/*:refs/tags/*"
389 git config --add remote.origin.fetch "+refs/notes/*:refs/notes/*"
390 git config --add remote.origin.fetch "+refs/top-bases/*:refs/top-bases/*"
391 else
392 git config --replace-all remote.origin.fetch "+refs/*:refs/*"
396 # remember the starting time so we can easily detect new packs for fast-import mirrors
397 # we sleep for 1 second after creating .gfipack to make sure all packs are newer
398 if is_gfi_mirror_url "$url" && [ ! -e .gfipack ]; then
399 rm -f .gfipack
400 >.gfipack
401 sleep 1
403 fetcharg="default"
404 git config remotes.default >/dev/null 2>&1 || fetcharg="--all"
405 fetchcmd="git_ulimit fetch"
406 [ "$show_progress" != "0" ] || fetchcmd="git_ulimit fetch -q"
407 if [ -n "$var_have_git_171" ] && [ "${show_progress:-0}" != "0" ]; then
408 # git fetch learned --progress in v1.7.1
409 case "$show_progress" in
410 [2-9]*|1[0-9]*)
411 # full volume progress with all the spammy noise
412 fetchcmd="git_ulimit fetch --progress"
415 # a kinder, gentler progress that doesn't leave one
416 # covered all over in exploded bits of spam afterwards
417 fetchcmd="git_fetch_q_progress"
419 esac
421 # It's possible for a fetch to actually do something while still returning
422 # a non-zero result (perhaps some of the refs were updated but some were
423 # not -- a malicious Git-impersonation trying to set refs/heads/... refs
424 # to non-commit objects for example).
425 GIT_SSL_NO_VERIFY=1 bang_catch eval "$fetchcmd" $pruneopt --multiple "$fetcharg"
426 # If we did fetch anything, don't treat it as an error, but do keep the log;
427 # otherwise invoke bang_failed as for a normal failure
428 if [ "${bang_errcode:-0}" != "0" ]; then
429 save_bang_errcode="$bang_errcode"
430 check_after_refs
431 if [ -n "$refschanged" ]; then
432 keep_bang_log="git fetch${pruneopt:+ $pruneopt} --multiple $fetcharg"
433 else
434 bang_cmd="git fetch${pruneopt:+ $pruneopt} --multiple $fetcharg"
435 bang_errcode="$save_bang_errcode"
436 bang_failed
439 if ! is_gfi_mirror_url "$url" && [ "$nextisclean" != "$lastwasclean" ]; then
440 if [ -n "$nextisclean" ]; then
441 # We must manually purge the unclean refs now as even prune won't do it
442 git for-each-ref --format='%(refname)' |
443 LC_ALL=C sed \
444 -e '/^refs\/heads\//d' \
445 -e '/^refs\/tags\//d' \
446 -e '/^refs\/notes\//d' \
447 -e '/^refs\/top-bases\//d' \
448 -e 's/^/delete /' |
449 git_updateref_stdin
451 git config --bool girocco.lastupdateclean ${nextisclean:-0}
453 if [ -e .gfipack ] && is_gfi_mirror_url "$url"; then
454 find -L objects/pack -type f -newer .gfipack -name "pack-$octet20*.pack" -print >>gfi-packs
455 rm -f .gfipack
458 esac
460 # The objects subdirectories permissions must be updated now.
461 # In the case of a dumb http clone, the permissions will not be correct
462 # (missing group write) despite the core.sharedrepository=1 setting!
463 # The objects themselves seem to have the correct permissions.
464 # This problem appears to have been fixed in the most recent git versions.
465 perms=g+w
466 [ "$cfg_permission_control" != "Hooks" ] || perms=go+w
467 chmod $perms $(find -L objects -maxdepth 1 -type d) 2>/dev/null || :
469 # We maintain the last refresh date in two places deliberately
470 # so that it's available as part of the config data and also
471 # as a standalone file timestamp that can be accessed without git.
472 bang config_set lastrefresh "$(date "$datefmt")"
473 { >.last_refresh; } 2>/dev/null || :
475 # Check to see if any refs changed
476 check_after_refs
478 # Update server info if any refs changed (if they didn't packs shouldn't have either)
479 [ -z "$refschanged" ] || bang git update-server-info
481 # Pack all refs if any changed to keep things as efficient as possible
482 # Project mirror updates do not occur that often therefore this is a win
483 # However, if pack-refs fails for some reason, we can just ignore and continue
484 # The "--prune" option is the default since v1.5.0 but it serves as "documentation" here
485 [ -z "$refschanged" ] || git pack-refs --all --prune || :
487 # Force a mini-gc if $Girocco::Config::delay_gfi_redelta is false and there's
488 # at least one gfi pack present now
489 if [ -z "$cfg_delay_gfi_redelta" ] && ! [ -e .needsgc ] &&
490 [ -f gfi-packs ] && [ -s gfi-packs ] && is_gfi_mirror_url "$url"; then
491 >.needsgc
494 # Activate a mini-gc if needed
495 check_and_set_needsgc
497 # Look at which refs changed and trigger ref-change for these
498 sockpath="$cfg_chroot/etc/taskd.socket"
499 if [ -n "$refschanged" ]; then
500 bang config_set lastreceive "$(date '+%a, %d %b %Y %T %z')"
501 # We always use UTC for the log timestamp so that chroot and non-chroot match up.
502 # We don't have to worry about multiple log files since only one update runs
503 lognamets="$(TZ=UTC date '+%Y%m%d_%H%M%S')"
504 loghhmmss="${lognamets##*_}"
505 logname="reflogs/${lognamets%%_*}"
506 # We freshen the mod time to now on any old or new ref that is a loose object
507 # For old refs we do it so we will be able to keep them around for 1 day
508 # For new refs we do it in case we are about to run gc and the new ref
509 # actually points to an oldish loose object that had been unreachable
510 # We probably do not need to do it for new refs as Git tries to do that,
511 # but since we're already doing it for old refs (which Git does not do),
512 # it's almost no extra work for new refs, just in case.
514 echo "ref-changes %$proj% $proj"
515 LC_ALL=C join .refs-before .refs-after |
516 LC_ALL=C sed -e '/^[^ ][^ ]* \([^ ][^ ]*\) \1$/d' |
517 while read ref old new; do
518 echo "$loghhmmss $old $new $ref" >&3
519 freshen_loose_objects "$old" "$new"
520 echo "$old $new $ref"
521 done
522 LC_ALL=C join -v 1 .refs-before .refs-after |
523 while read ref old; do
524 echo "$loghhmmss $old 0000000000000000000000000000000000000000 $ref" >&3
525 freshen_loose_objects "$old"
526 echo "$old 0000000000000000000000000000000000000000 $ref"
527 done
528 LC_ALL=C join -v 2 .refs-before .refs-after |
529 while read ref new; do
530 echo "$loghhmmss 0000000000000000000000000000000000000000 $new $ref" >&3
531 freshen_loose_objects "$new"
532 echo "0000000000000000000000000000000000000000 $new $ref"
533 done
534 git for-each-ref --format='%(objectname) %(objectname) %(refname)' refs/heads
535 echo "done ref-changes %$proj% $proj"
536 } >.refs-temp 3>>"$logname"
537 if [ -S "$sockpath" ]; then
538 trap ':' PIPE
539 nc_openbsd -w 15 -U "$sockpath" <.refs-temp || :
540 trap - PIPE
542 bang config_set lastchange "$(date '+%a, %d %b %Y %T %z')"
543 bang_eval "git for-each-ref --sort=-committerdate --format='%(committerdate:iso8601)' \
544 --count=1 refs/heads >info/lastactivity"
545 ! [ -d htmlcache ] || { >htmlcache/changed; } 2>/dev/null || :
546 rm -f .delaygc .allowgc
548 [ "${cfg_autogchack:-0}" != "0" ] &&
549 [ "$(git config --get --bool girocco.autogchack 2>/dev/null)" != "false" ]
550 then
551 mv -f .refs-after .refs-last
555 # If the repository does not yet have a valid HEAD symref try to set one
556 # If an empty repository was cloned and then later becomes unempty you just
557 # lose out on the fancy "symref=HEAD:" logic and get this version instead
558 check_and_set_head || :
560 rm -f .refs-before .refs-after .refs-temp FETCH_HEAD
562 if is_banged; then
563 [ -z "$mailaddrs" ] || ! was_banged_message_sent ||
565 echo "$proj update succeeded - failure recovery"
566 echo "this status message may be disabled on the project admin page"
567 } | mailref "update@$cfg_gitweburl/$proj.git" -s "[$cfg_name] $proj update succeeded" "$mailaddrs" || :
568 bang_reset
571 if [ -n "$keep_bang_log" ] && [ -s "$bang_log" ]; then
572 cat "$bang_log" >.banglog
573 echo "" >>.banglog
574 echo "$keep_bang_log failed with error code $save_bang_errcode" >>.banglog
577 progress "- [$proj] update ($(date))"