From 1681a26ea27e1acca8db17c87d0941d93565ee0e Mon Sep 17 00:00:00 2001 From: z4yx Date: Fri, 22 May 2020 22:01:43 +0800 Subject: [PATCH] [bug fix] git remote set-head doesn't work with bare repo --- adobe-fonts.sh | 3 ++- cocoapods.sh | 3 ++- git-repo.sh | 3 ++- homebrew.sh | 3 ++- llvm.sh | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/adobe-fonts.sh b/adobe-fonts.sh index 803c7e7..b678491 100755 --- a/adobe-fonts.sh +++ b/adobe-fonts.sh @@ -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+') diff --git a/cocoapods.sh b/cocoapods.sh index adf5de5..6b379ea 100755 --- a/cocoapods.sh +++ b/cocoapods.sh @@ -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+') diff --git a/git-repo.sh b/git-repo.sh index 579187d..3478a5a 100755 --- a/git-repo.sh +++ b/git-repo.sh @@ -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)) diff --git a/homebrew.sh b/homebrew.sh index a1b7282..f4b3e38 100755 --- a/homebrew.sh +++ b/homebrew.sh @@ -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+') diff --git a/llvm.sh b/llvm.sh index cc83902..9384078 100755 --- a/llvm.sh +++ b/llvm.sh @@ -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+')