Subject: [PATCH] submodule: fix quoting in relative_path()

From: John Keeping <[email-masked]>
Date: Wed, 24 Apr 2013 09:15:36 +0100

Commit caca2c1 (submodule: drop the top-level requirement) introduced a
relative_path helper but does not quote $curdir when it is stripped from
the front of a target path.  In this particular case this should be safe
even with special characters because we only do this after checking that
$target begins with "$curdir/" which is quoted correctly, but we should
quote the variable to be certain that there is not some obscure case
where we this could strip more or less than we want.

Signed-off-by: John Keeping <[email-masked]>
---
On Fri, Apr 19, 2013 at 02:03:14PM -0700, Junio C Hamano wrote:
> Johannes Sixt <[email-masked]> writes:
> 
> > Why not just replace the six-liner by this one-liner:
> >
> > 		target=${target#"$curdir"/}
> 
> Simple enough ;-)

This seems to have arrived on next without this fix, so here's a patch
on top.

 git-submodule.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 0eee703..db9f260 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -127,7 +127,7 @@ relative_path ()
 	do
 		case "$target" in
 		"$curdir/"*)
-			target=${target#$curdir/}
+			target=${target#"$curdir"/}
 			break
 			;;
 		esac
-- 
1.8.2.1.715.gb260f47