3 if [[ -n "${PPG_DEBUG}" ]]; then
7 pushd /etc
/puppet
>/dev
/null ||
exit 1
9 PPG_EXEC_PATH
=$
( dirname $
(readlink
-f "${BASH_SOURCE[0]}" ) )
10 GIT_EXEC_PATH
=$
(git
--exec-path)
11 GIT_DIR
=$
(git rev-parse
--git-dir)
12 GIT_SSH
="${PPG_EXEC_PATH}/ppg-ssh"
14 .
${PPG_EXEC_PATH}/ppg-functions
17 if [ -z "$GIT_DIR" ]; then
18 echo >&2 "Not in a git checkout"
27 export GIT_DIR
=/etc
/puppet
/.ppg
29 refs
/heads
/${hostname}:refs
/heads
/${hostname} ||
exit $?
31 # reports are tiny, we can spool a month of them safely
32 # if you want it shorter, configure it so :-)
33 expiry
="one.month.ago"
34 config_expiry
=$
(git config
--get ppg.reportexpiry
)
35 if [ -n "$config_expiry" ]; then
36 expiry
="$config_expiry"
39 for head in $
(git branch|
sed 's/^..//'); do
40 graft_sha1
=$
(git log
--until="$expiry" -n1 --pretty=format
:%H
${head})
41 if [[ -z "$graft_sha1" ]]; then
45 # is it already grafted?
46 if grep -q "^${graft_sha1} " "${GIT_DIR}/info/grafts" &>/dev
/null
; then
47 # don't duplicate the graft
52 # skip git read-tree --empty, we get the same with
53 export GIT_INDEX_FILE
=/tmp
/ppg-emptytree.$$
54 empty_tree
="$(git write-tree)"
57 empty_commit
=$
(echo empty | git commit-tree
${empty_tree})
58 echo "${graft_sha1} ${empty_commit}" >> ${GIT_DIR}/info/grafts
61 if [[ -z "$some_grafted" ]]; then
66 # ppg-repack makes the unreachable objects "loose
"
67 # git prune --expire actually deletes them
68 $PPG_EXEC_PATH/ppg-repack -AFfd
69 git prune --expire=now
71 ### Cleanup stale grafts
72 # current grafts points are reachable,
73 # pruned graft points (made obsolete by a newer graft)
74 # cannot be retrieved and git cat-file exit code is 128
75 touch ${GIT_DIR}/info/grafts.tmp.$$
77 graftpoint=$(echo "${line}" | cut -d' ' -f1)
78 if git cat-file commit ${graftpoint} &>/dev/null ; then
79 echo ${line} >> ${GIT_DIR}/info/grafts.tmp.$$
81 done < "${GIT_DIR}/info
/grafts
"
83 if [ -s ${GIT_DIR}/info/grafts.tmp.$$ ]; then
84 mv ${GIT_DIR}/info/grafts.tmp.$$ ${GIT_DIR}/info/grafts