Re: [PATCH v2 2/2] submodules: always use a relative path from gitdir to work tree
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 13, 2012, 19:59 UTC
- Message-ID
- <7vlio6ec7q.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <4F338156.9090507@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
> The first version was whitespace damaged, please use this instead.
Thanks. This one looks somewhat iffy (1/2 looked perfectly fine, though).
Show 9 quoted lines
> + a=$(cd "$gitdir" && pwd)
> + b=$(cd "$path" && pwd)
> + while [ "$b" ] && [ "${a%%/*}" = "${b%%/*}" ]
> + do
> + a=${a#*/} b=${b#*/};
> + done
> + rel=$(echo $a | sed -e 's|[^/]*|..|g')
> + (clear_local_git_env; cd "$path" && git config core.worktree "$rel/$b")
> }The style ([ "$b" ] vs "test -n "$b") aside, it strikes me odd that you only check $b; it is unclear what guarantees that "$a" is always longer. Maybe there is a reason but then a one-line comment here would not hurt?