[bug fix] git remote set-head doesn't work with bare repo

This commit is contained in:
z4yx 2020-05-22 22:01:43 +08:00
parent b72c0e82eb
commit 1681a26ea2
5 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,8 @@ function update_font_git() {
echo "==== SYNC $repo_dir START ===="
git remote set-url origin "$UPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
git remote set-head origin --auto || true
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
objs=$(find objects -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')

View File

@ -14,7 +14,8 @@ function update_cocoapods_git() {
echo "==== SYNC $repo_dir START ===="
git remote set-url origin "$UPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
git remote set-head origin --auto || true
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
objs=$(find objects -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')

View File

@ -10,7 +10,8 @@ function update_repo_git() {
echo "==== SYNC repo.git START ===="
git remote set-url origin "$UPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
git remote set-head origin --auto
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')
sz=$(($sz*1024))

View File

@ -12,7 +12,8 @@ function update_homebrew_git() {
echo "==== SYNC $repo_dir START ===="
git remote set-url origin "$UPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
git remote set-head origin --auto
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
objs=$(find objects/ -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')

View File

@ -12,7 +12,8 @@ function repo_update() {
echo "==== SYNC $repo_dir START ===="
git remote set-url origin "$UPSTREAM"
/usr/bin/timeout -s INT 3600 git remote -v update -p
git remote set-head origin --auto
head=$(git remote show origin | awk '/HEAD branch:/ {print $NF}')
[[ -n "$head" ]] && echo "ref: refs/heads/$head" > HEAD
objs=$(find objects/ -type f | wc -l)
[[ "$objs" -gt 8 ]] && git repack -a -b -d
sz=$(git count-objects -v|grep -Po '(?<=size-pack: )\d+')