From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org, pclouds@gmail.com, Jens.Lehmann@web.de,
jacob.keller@gmail.com, sunshine@sunshineco.com
Subject: Re: [PATCHv3 1/5] submodule: prepare recursive path from non root directory
Date: Fri, 25 Mar 2016 12:21:00 -0700 [thread overview]
Message-ID: <xmqqk2kq2wkj.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1458931156-29125-2-git-send-email-sbeller@google.com> (Stefan Beller's message of "Fri, 25 Mar 2016 11:39:12 -0700")
Stefan Beller <sbeller@google.com> writes:
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 43c68de..d83608c 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -825,8 +825,9 @@ Maybe you want to use 'update --init'?")"
> if test -n "$recursive"
> then
> (
> - prefix="$prefix$sm_path/"
> + prefix="$(relative_path $prefix$sm_path)/"
Don't you need to protect yourself from IFS chars in $prefix and
$sm_path here (the other invocation of relative_path in this patch
does not have this issue, I would think).
As I think about it more, I am more inclined to say "-C $prefix" is
going in a wrong direction, so justifying this change solely on that
move is somewhat sad.
- Making things relative should not hurt.
- Clearing wt_prefix feels like the right thing, because we are
moving to the root of the working tree of a different repository
and wt_prefix that tells us where the user originally was in the
superproject is not useful in the context of the submodule, which
after all is a separate project. The user however cannot refer
to things on the filesystem (including use of pathspecs), as they
are taken relative to the root level of each submodule by
clearing wt_prefix, though. i.e.
$ git submodule $cmd --read-from-this-file=../m/file
that is started from t/ subdirectory of the superproject that
recurses into the submodule at m/ (sitting next to t/) should be
able to read from "file" sitting at the root level of the working
tree of submodule m/ by stripping ../m/ (and relative-path should
be able to help with that), but that may become impossible
because the fact that the user named ../m/file relative to t/
subdirectory is lost by clearing wt_prefix that used to hold t/
here.
is the closest justification I can come to, which is weak ("should
not hurt" does not justify, and "users cannot ever do this without
undoing this change" does not, either).
I think the worst part of this change is that the log message does
not make it clear why it is OK not to clear wt_prefix and not to use
relative_path if you use --prefix, while the "-C $prefix" approach
has problems without these changes. Without that explanation, these
symptoms, i.e. the fact that you need the changes in this patch,
only smells like an indication that "-C $prefix" approach is somehow
flawed. I cannot quite pinpoint what that "somehow" is, though.
> clear_local_git_env
> + wt_prefix=
> cd "$sm_path" &&
> eval cmd_update
> )
> @@ -1159,6 +1160,7 @@ cmd_status()
> (
> prefix="$displaypath/"
> clear_local_git_env
> + wt_prefix=
> cd "$sm_path" &&
> eval cmd_status
> ) ||
> @@ -1239,7 +1241,8 @@ cmd_sync()
>
> if test -n "$recursive"
> then
> - prefix="$prefix$sm_path/"
> + prefix=$(relative_path "$prefix$sm_path/")
> + wt_prefix=
> eval cmd_sync
> fi
> )
next prev parent reply other threads:[~2016-03-25 19:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-25 18:39 [PATCHv3 0/5] submodule helper: cleanup prefix passing Stefan Beller
2016-03-25 18:39 ` [PATCHv3 1/5] submodule: prepare recursive path from non root directory Stefan Beller
2016-03-25 19:21 ` Junio C Hamano [this message]
2016-03-25 18:39 ` [PATCHv3 2/5] submodule--helper list: lose the extra prefix option Stefan Beller
2016-03-25 18:39 ` [PATCHv3 3/5] submodule update: add test for recursive from non root dir Stefan Beller
2016-03-25 18:39 ` [PATCHv3 4/5] submodule sync: test syncing one submodule Stefan Beller
2016-03-25 18:39 ` [PATCHv3 5/5] submodule--helper clone: lose the extra prefix option Stefan Beller
2016-03-25 19:41 ` Junio C Hamano
2016-03-25 20:54 ` Junio C Hamano
2016-03-25 22:09 ` Stefan Beller
2016-03-25 22:39 ` Junio C Hamano
2016-03-25 23:02 ` Stefan Beller
2016-03-25 23:15 ` Junio C Hamano
2016-03-25 23:51 ` Stefan Beller
2016-03-28 16:56 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk2kq2wkj.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=pclouds@gmail.com \
--cc=sbeller@google.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.