From 24ba59f8b6010b70ebeba082cca9f35f8d76865a Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 11 Aug 2013 00:00:34 -0700 Subject: [PATCH] svn clones: fix prefix computation When using the -s (--stdlayout) option, git-svn tries to be smart and shorten the base if possible to perhaps grab more history and then glue the removed part of the base onto the front of each fetch/branches/tags line. The computation to determine the actual prefix that git-svn may have added was incorrect and failed to work properly when there was no prefix added at all. The new technique first computes the suffix and then removes that to generate the prefix which always works whether there's a prefix or not. --- jobd/update.sh | 8 ++++---- taskd/clone.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jobd/update.sh b/jobd/update.sh index f1dff77..d249ef1 100755 --- a/jobd/update.sh +++ b/jobd/update.sh @@ -82,8 +82,8 @@ case "$url" in gitsvnurl="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.url || :)" gitsvnfetch="$(GIT_DIR=svn-new-url git config --get svn-remote.svn.fetch || :)" gitsvnprefixnew="${gitsvnfetch%%:*}" - gitsvnprefixnew="${gitsvnfetch%/*}" - [ -z "$gitsvnprefixnew" ] || gitsvnprefixnew="$gitsvnprefixnew/" + gitsvnsuffixnew="${gitsvnprefixnew##*/}" + gitsvnprefixnew="${gitsvnprefixnew%$gitsvnsuffixnew}" rm -rf svn-new-url || : # Using GIT_DIR= with bang leaves it set to svn-new-url, so reset it to . GIT_DIR=. @@ -92,8 +92,8 @@ case "$url" in # We must update the url and replace the prefix on all config items gitsvnfetch="$(git config --get-all svn-remote.svn.fetch | head -1 || :)" gitsvnprefixold="${gitsvnfetch%%:*}" - gitsvnprefixold="${gitsvnprefixold%/*}" - [ -z "$gitsvnprefixold" ] || gitsvnprefixold="$gitsvnprefixold/" + gitsvnsuffixold="${gitsvnprefixold##*/}" + gitsvnprefixold="${gitsvnprefixold%$gitsvnsuffixold}" git config --remove-section 'svn-remote.svnnew' 2>/dev/null || : git config 'svn-remote.svnnew.url' "$gitsvnurl" { git config --get-regexp '^svn-remote\.svn\.' || :; } | \ diff --git a/taskd/clone.sh b/taskd/clone.sh index 7b4faa9..00650d6 100755 --- a/taskd/clone.sh +++ b/taskd/clone.sh @@ -60,8 +60,8 @@ case "$url" in gitsvnurl="$(git config --get svn-remote.svn.url || :)" gitsvnfetch="$(git config --get-all svn-remote.svn.fetch | tail -1 || :)" gitsvnprefix="${gitsvnfetch%%:*}" - gitsvnprefix="${gitsvnprefix%/*}" - [ -z "$gitsvnprefix" ] || gitsvnprefix="$gitsvnprefix/" + gitsvnsuffix="${gitsvnprefix##*/}" + gitsvnprefix="${gitsvnprefix%$gitsvnsuffix}" # Ask git-svn to store everything in the normal non-remote # locations being careful to use the correct prefix git config --replace-all svn-remote.svn.fetch "${gitsvnprefix}trunk:refs/heads/master" -- 2.11.4.GIT