From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: jacob.keller@gmail.com, git@vger.kernel.org
Subject: Re: [PATCH 3/6] submodule status: correct path handling in recursive submodules
Date: Tue, 29 Mar 2016 16:55:48 -0700 [thread overview]
Message-ID: <xmqqk2kkvny3.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1459292558-5840-4-git-send-email-sbeller@google.com> (Stefan Beller's message of "Tue, 29 Mar 2016 16:02:35 -0700")
Stefan Beller <sbeller@google.com> writes:
> The new test which is a replica of the previous test except
> that it executes from a sub directory. Prior to this patch
> the test failed by having too many '../' prefixed:
>
> --- expect 2016-03-29 19:02:33.087336115 +0000
> +++ actual 2016-03-29 19:02:33.359343311 +0000
> @@ -1,7 +1,7 @@
> b23f134787d96fae589a6b76da41f4db112fc8db ../nested1 (heads/master)
> -+25d56d1ddfb35c3e91ff7d8f12331c2e53147dcc ../nested1/nested2 (file2)
> - 5ec83512b76a0b8170b899f8e643913c3e9b72d9 ../nested1/nested2/nested3 (heads/master)
> - 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../nested1/nested2/nested3/submodule (heads/master)
> ++25d56d1ddfb35c3e91ff7d8f12331c2e53147dcc ../../nested1/nested2 (file2)
> + 5ec83512b76a0b8170b899f8e643913c3e9b72d9 ../../../nested1/nested2/nested3 (heads/master)
> + 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../../../../nested1/nested2/nested3/submodule (heads/master)
> 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f ../sub1 (0c90624)
> 0c90624ab7f1aaa301d3bb79f60dcfed1ec4897f ../sub2 (0c90624)
> 509f622a4f36a3e472affcf28fa959174f3dd5b5 ../sub3 (heads/master)
>
> The path code in question:
> displaypath=$(relative_path "$prefix$sm_path")
> prefix=$displaypath
> if recursive:
> eval cmd_status
>
> That way we change `prefix` each iteration to contain another
> '../', because of the the relative_path computation is done
> on an already computed relative path.
>
> We must call relative_path exactly once with `wt_prefix` non empty.
> Further calls in recursive instances to to calculate the displaypath
> already incorporate the correct prefix from before. Fix the issue by
> clearing `wt_prefix` in recursive calls.
OK, nicely analyzed and explained.
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
> git-submodule.sh | 1 +
> t/t7407-submodule-foreach.sh | 21 +++++++++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index fdb5fbd..11ed32a 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -1160,6 +1160,7 @@ cmd_status()
> (
> prefix="$displaypath/"
> clear_local_git_env
> + wt_prefix=
> cd "$sm_path" &&
> eval cmd_status
> ) ||
Makes sense.
Thanks.
> diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
> index 776b349..4b35e12 100755
> --- a/t/t7407-submodule-foreach.sh
> +++ b/t/t7407-submodule-foreach.sh
> @@ -277,6 +277,27 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
> test_cmp expect actual
> '
>
> +nested2sha1=$(git -C clone3/nested1/nested2 rev-parse HEAD)
> +
> +cat > expect <<EOF
> + $nested1sha1 ../nested1 (heads/master)
> ++$nested2sha1 ../nested1/nested2 (file2)
> + $nested3sha1 ../nested1/nested2/nested3 (heads/master)
> + $submodulesha1 ../nested1/nested2/nested3/submodule (heads/master)
> + $sub1sha1 ../sub1 ($sub1sha1_short)
> + $sub2sha1 ../sub2 ($sub2sha1_short)
> + $sub3sha1 ../sub3 (heads/master)
> +EOF
> +
> +test_expect_success 'test "status --recursive" from sub directory' '
> + (
> + cd clone3 &&
> + mkdir tmp && cd tmp &&
> + git submodule status --recursive > ../../actual
> + ) &&
> + test_cmp expect actual
> +'
> +
> test_expect_success 'use "git clone --recursive" to checkout all submodules' '
> git clone --recursive super clone4 &&
> (
next prev parent reply other threads:[~2016-03-29 23:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 23:02 [PATCHv3 0/6] Fix path bugs in submodule commands executed from sub dir Stefan Beller
2016-03-29 23:02 ` [PATCH 1/6] submodule foreach: correct path display in recursive submodules Stefan Beller
2016-03-29 23:49 ` Junio C Hamano
2016-03-29 23:02 ` [PATCH 2/6] submodule update --init: correct path handling " Stefan Beller
2016-03-29 23:54 ` Junio C Hamano
2016-03-30 1:00 ` Stefan Beller
2016-03-29 23:02 ` [PATCH 3/6] submodule status: " Stefan Beller
2016-03-29 23:55 ` Junio C Hamano [this message]
2016-03-29 23:02 ` [PATCH 4/6] submodule update: align reporting path for custom command execution Stefan Beller
2016-03-29 23:57 ` Junio C Hamano
2016-03-29 23:02 ` [PATCH 5/6] submodule update: test recursive path reporting from subdirectory Stefan Beller
2016-03-29 23:02 ` [PATCH 6/6] t7407: make expectation as clear as possible Stefan Beller
-- strict thread matches above, loose matches on Subject: below --
2016-03-29 22:23 [PATCHv2 0/6] Fix path bugs in submodule commands executed from sub dir Stefan Beller
2016-03-29 22:23 ` [PATCH 3/6] submodule status: correct path handling in recursive submodules Stefan Beller
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=xmqqk2kkvny3.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=sbeller@google.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.