git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com, git@vger.kernel.org
Cc: jacob.e.keller@intel.com, Jens.Lehmann@web.de,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH 0/2] recursive submodules: paths are hard
Date: Fri, 26 Feb 2016 12:51:50 -0800	[thread overview]
Message-ID: <1456519912-10641-1-git-send-email-sbeller@google.com> (raw)

I thought getting rid of the extra `prefix` argument in submodule helper
functions was easy up to the point of all but one test passing in the test
suite.

It turned out the implementation of that prefix patch was wrong, only caught
by tests, so we want to add tests for subtle details with submodule sync and
update which have not been tests yet.

For the record, I thought the 'prefix' patch was as easy as:

-       git submodule--helper list --prefix "$wt_prefix" "$@" | {
+       git -C "$wt_prefix" submodule--helper list "$@" | {

for all occurrences of `submodule--helper list`.

This is not the case as by doing so the recursive functionality of submodules
is broken in some edge cases.

Consider this sequence:

  mkdir untracked &&
  cd untracked &&
  git submodule <command> --recursive
  
The operation is run from within the work tree, so fro a normal submodule
operation (without --recursive) you expect the pathes to be adapted to be
prefixed by a `../` to make sense relative to the untracked directory.

In the case of recursive submodule operations, currently `git submodule`
usually does

        if test -n "$recursive"
        then
        (
                prefix="$prefix$sm_path/"
                clear_local_git_env
                cd "$sm_path" &&
                eval cmd_update
        )
        
By having a change of directory followed by the recursive call to the operation
we need to make sure the displayed path is still correctly referenced to where
the operation started.

By passing the prefix separately to git submodule--helper, this works currently
as the prefix is only used for calculating the displaypath. If it were passed
by the standard Git machinery, there is going on more, which
fails us at some point.

I think we may need to enable Git to pass in 'negative' pathes for the prefix,
i.e. 
  Although operating on this repository, your reference for displaying paths
  should be '../untracked' for the example above, when the submodule is in the
  root directory of the superproject.

This seems currently not possible with the standard way to pass down the prefix.

TL;DR: Most of the test is unrelated to the patch series, the patch series
adds some tests, which I would have found useful to stop me going the wrong
direction.

Thanks,
Stefan

Stefan Beller (2):
  Check recursive submodule update to have correct path from
    subdirectory
  submodule sync: Test we can pass individual submodules

 t/t7403-submodule-sync.sh   | 13 +++++++++----
 t/t7406-submodule-update.sh | 12 ++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

-- 
2.7.2.368.g934fe14

             reply	other threads:[~2016-02-26 20:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 20:51 Stefan Beller [this message]
2016-02-26 20:51 ` [PATCH 1/2] Check recursive submodule update to have correct path from subdirectory Stefan Beller
2016-02-26 20:51 ` [PATCH 2/2] submodule sync: Test we can pass individual submodules Stefan Beller
2016-02-27  1:58 ` [PATCH 0/2] recursive submodules: paths are hard Duy Nguyen

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456519912-10641-1-git-send-email-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jacob.e.keller@intel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).