threads / patch / 2161

patchcg-fetch: handle tags with funny chars, retrieve missing commits

Subject: [PATCH] cg-fetch: handle tags with funny chars, retrieve missing commits

## tl;dr

One message between Oct 20, 2005 and Oct 20, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Martin Langhoff· Oct 20, 2005, 05:07 UTC · lore
 + handles tags with funny chars a bit better
 + will check tagrefs, trying to ensure it actually has the relevant
   commits. If the commits are missing, it'll go out and fetch them.
 + if the tagref points to a blob and we have it, it'll skip it

This isn't a complete solution for cg-fetch -- git-fetch is actually much smarter now, and cg-fetch should perhaps be a thin wrapper around it, dropping all the duplicate code.

This version uses ^0 instead of ^{commit} which does a more thorough check, so we don't need to call git-cat-file.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
---
 cg-fetch |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

applies-to: 38ed7981343a8e2bb734d64e019186a8a482dbef 6adda5a9a938adbc313c6ed40156257d62707757

Show changes to cg-fetch +3 −2
diff --git a/cg-fetch b/cg-fetch
index 7694584..ec9fff3 100755
--- a/cg-fetch
+++ b/cg-fetch
@@ -416,8 +416,9 @@ $get -i -s -u -d "$uri/refs/tags" "$_git
 	cd $_git/refs/tags
 	for tag in *; do
 		[ "$tag" = "*" ] && break
-		tagid=$(cat $tag)
-		GIT_DIR=../.. git-cat-file -t "$tagid" >/dev/null 2>&1 && continue
+		tagid=$(cat "$tag")
+		GIT_DIR=../.. git-rev-parse --verify "$tag"^0 2>/dev/null >> /dev/null && continue
+		GIT_DIR=../.. git-cat-file blob `git-rev-parse --verify "$tag"^{blob} 2>/dev/null` 2>/dev/null >> /dev/null && continue
 		echo -n "Missing object of tag $tag... "
 		if [ "$fetch" != "fetch_rsync" ] && GIT_DIR=../.. $fetch "$tagid" "$uri" 2>/dev/null >&2; then
 			echo "retrieved"
---
0.99.8.GIT

← back to recent threads