tags: explicitly white list a few tags
[girocco.git] / hooks / pre-receive
blobe342ec8c9396556f88af3ae1d1ee5c476dbb86b6
1 #!/bin/sh
3 # Keep track of the last time we modified the object store
5 # Beware, we MAY be running in a chroot!
7 set -e
9 git config gitweb.lastreceive "$(date '+%a, %d %b %Y %T %z')"
11 # Read the incoming refs and freshen old loose objects
12 # If we waited until post-receive a gc could have already nuked them
13 # We freshen the new ref in case it's being resurrected to protect it from gc
14 # We probably do not need to do it for new refs as Git tries to do that,
15 # but since we're already doing it for old refs (which Git does not do),
16 # it's almost no extra work for new refs, just in case. We also attempt
17 # to make all packs user and group writable so they can be touched later.
19 octet='[0-9a-f][0-9a-f]'
20 octet4="$octet$octet$octet$octet"
21 octet20="$octet4$octet4$octet4$octet4$octet4"
22 chmod ug+w objects/pack/pack-$octet20.pack 2>/dev/null || :
24 while read -r old new ref; do
25 oldp=
26 newp=
27 if [ "$old" != "0000000000000000000000000000000000000000" ]; then
28 # freshen mod time on recently unref'd loose objects
29 fn="${old#??}"
30 shard="${old%$fn}"
31 oldp="objects/$shard/$fn"
33 if [ "$new" != "0000000000000000000000000000000000000000" ]; then
34 # prevent imminent pruning of a ref being resurrected
35 fn="${new#??}"
36 shard="${new%$fn}"
37 newp="objects/$shard/$fn"
39 chmod ug+w $oldp $newp 2>/dev/null || :
40 touch -c $oldp $newp 2>/dev/null || :
41 done