From b125df676a8f006ea570ab3f19eeae0c65bb1661 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 19 Nov 2006 14:05:49 +0100 Subject: [PATCH] cg-clone --reference: Fix up relative paths properly Paths passed are obviously relative to the user's cwd when calling cg-clone, but we need to fix them up to be relative to the new repository's object store. Brought up by Jonas. --- cg-clone | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cg-clone b/cg-clone index f0f04c0..6f229dd 100755 --- a/cg-clone +++ b/cg-clone @@ -160,9 +160,21 @@ repoloc="$location" [ ! -d "$repoloc/.git/objects" ] || repoloc="$repoloc/.git" [ "$alternate" ] && echo "$repoloc/objects" >> "$_git/objects/info/alternates" for ref in "${reference[@]}"; do + relpath= + [ "${ref#/}" != "$ref" ] || relpath=1 + # Relative path; reference is relative to the object repository; we + # need to add one .. for objects, another .. for .git/, another .. for + # projdir unless ! same_Dir + + if [ ! "$same_dir" ] && [ "$relpath" ]; then + # Relative path, account for project subdir + ref="../$ref" + fi + [ -d "$ref" ] || die "referenced repository $ref not found" [ ! -d "$ref/.git/objects" ] || reference="$ref/.git" [ -d "$ref/objects" ] || die "reference $ref not a git repository" + [ ! "$relpath" ] || ref="../../$ref" echo "$ref/objects" >>"$_git/objects/info/alternates" done -- 2.11.4.GIT