Re: [PATCH] submodule: test moving recursive submodule

2016-06-28 Thread Bart Bogaerts
I dit some more testing.

It is important for the bug to occur that all submodules are initialised.
So my suggestion is not yet complete, you need to add the line

git submodule update --recursive --init




Below is a complete script that show the bug occurring:



mkdir repo1 &&
mkdir repo2 &&

(
  cd repo1 &&
  git init &&
  echo "test" >> test.test &&
  git add . &&
  git commit -m "initial commit"
) &&

(
  cd repo2 &&
  git init &&
  git submodule add ../repo1 &&
  git commit -a -m "added submod"
) &&

#create the directory to test in
(
  mkdir testdir &&
  cd testdir &&
  git init &&
  git submodule add ../repo2 &&
  git commit -m "added full structure" &&
  #important to initialise .git files!
  git submodule update --recursive --init
) &&

(
  cd testdir &&
  mkdir 2015 &&
  git mv repo2 2015 &&
  git status
)

2016-06-28 9:13 GMT+03:00 Bart Bogaerts <bartbogae...@gmail.com>:
> The only thing I still see that might cause the bug is that there is no
>
> git submodule update --recursive
>
> present in your test cases .
> This command creates the .git file in the nested subsubmodule
> It is that .git file that is not correctly updated in the move.
>
> So after the line
> +   git submodule add ./outer_sub ./deep/outer_sub &&
> I would add
> +   git submodule update -- recursive &&
>
> 2016-06-28 3:15 GMT+03:00 Stefan Beller <sbel...@google.com>:
>> Signed-off-by: Stefan Beller <sbel...@google.com>
>> ---
>> This tries to reproduce the error as pointed out in
>> http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules
>> but the tests pass. This still seems to be missing a detail.
>>
>> Bart any idea how this setup may be different than what you have?
>> Instead of applying the patch, you can also checkout
>> https://github.com/stefanbeller/git/tree/submodule_recursive_mv_test
>> which is the patch below applied on top of Junios (the maintainer) master 
>> branch.
>> To look around on the filesystem, you can drop "test_pause &&" in a test and
>> then run the test with `(cd t && ./t7001-mv.sh -v)` (more info how to run 
>> tests
>> in the Git test suite in t/README, maybe -i -v -x are interested)
>>
>> Thanks,
>> Stefan
>>
>>  t/t7001-mv.sh | 43 +++
>>  1 file changed, 43 insertions(+)
>>
>> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
>> index 4a2570e..404e5bd 100755
>> --- a/t/t7001-mv.sh
>> +++ b/t/t7001-mv.sh
>> @@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '
>> mkdir -p deep/directory/hierachy &&
>> git submodule add ./. deep/directory/hierachy/sub &&
>> git commit -m "added another submodule" &&
>> +   mkdir inner_sub &&
>> +   (
>> +   cd inner_sub &&
>> +   git init &&
>> +   test_commit initial
>> +   ) &&
>> +   mkdir outer_sub &&
>> +   (
>> +   cd outer_sub &&
>> +   git init &&
>> +   test_commit initial &&
>> +   git submodule add ../inner_sub &&
>> +   git commit -a -m "add an inner submodule"
>> +   ) &&
>> +   git submodule add ./outer_sub ./deep/outer_sub &&
>> +   git commit -a -m "add outer sub" &&
>> +   git -C deep ls-tree HEAD |cut -f 2 >actual &&
>> +   cat >expect <<-EOF &&
>> +   directory
>> +   outer_sub
>> +   EOF
>> +   test_cmp expect actual &&
>> git branch submodule
>>  '
>>
>> @@ -488,6 +510,27 @@ test_expect_success 'moving a submodule in nested 
>> directories' '
>> git config -f ../.gitmodules 
>> submodule.deep/directory/hierachy/sub.path >../actual &&
>> echo "directory/hierachy/sub" >../expect
>> ) &&
>> +   test_cmp actual expect &&
>> +   git commit -a -m "mv a submodule in nested dir"
>> +'
>> +
>> +test_expect_success 'moving a submodule with a nested submodule' '
>> +   git mv deep/outer_sub outer_sub_moved &&
>> +   # git status would fail if the update of linking git dir to
>> +   # work dir of the submodule failed.
>> +   git status &&
>> +   git config -f .gitmodules submodule.deep/outer_sub.path >actual &&
>> +   echo "outer_sub_moved" >expect &&
>> +   test_cmp actual expect
>> +'
>> +
>> +test_expect_success 'moving back the submodule with a nested submodule' '
>> +   git mv outer_sub_moved deep/outer_sub &&
>> +   # git status would fail if the update of linking git dir to
>> +   # work dir of the submodule failed.
>> +   git status &&
>> +   git config -f .gitmodules submodule.deep/outer_sub.path >actual &&
>> +   echo "deep/outer_sub" >expect &&
>> test_cmp actual expect
>>  '
>>
>> --
>> 2.9.0.4.g35eb263.dirty
>>
>
>
>
> --
> Bart Bogaerts



-- 
Bart Bogaerts
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] submodule: test moving recursive submodule

2016-06-28 Thread Bart Bogaerts
The only thing I still see that might cause the bug is that there is no

git submodule update --recursive

present in your test cases .
This command creates the .git file in the nested subsubmodule
It is that .git file that is not correctly updated in the move.

So after the line
+   git submodule add ./outer_sub ./deep/outer_sub &&
I would add
+   git submodule update -- recursive &&

2016-06-28 3:15 GMT+03:00 Stefan Beller <sbel...@google.com>:
> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
> This tries to reproduce the error as pointed out in
> http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules
> but the tests pass. This still seems to be missing a detail.
>
> Bart any idea how this setup may be different than what you have?
> Instead of applying the patch, you can also checkout
> https://github.com/stefanbeller/git/tree/submodule_recursive_mv_test
> which is the patch below applied on top of Junios (the maintainer) master 
> branch.
> To look around on the filesystem, you can drop "test_pause &&" in a test and
> then run the test with `(cd t && ./t7001-mv.sh -v)` (more info how to run 
> tests
> in the Git test suite in t/README, maybe -i -v -x are interested)
>
> Thanks,
> Stefan
>
>  t/t7001-mv.sh | 43 +++
>  1 file changed, 43 insertions(+)
>
> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
> index 4a2570e..404e5bd 100755
> --- a/t/t7001-mv.sh
> +++ b/t/t7001-mv.sh
> @@ -295,6 +295,28 @@ test_expect_success 'setup submodule' '
> mkdir -p deep/directory/hierachy &&
> git submodule add ./. deep/directory/hierachy/sub &&
> git commit -m "added another submodule" &&
> +   mkdir inner_sub &&
> +   (
> +   cd inner_sub &&
> +   git init &&
> +   test_commit initial
> +   ) &&
> +   mkdir outer_sub &&
> +   (
> +   cd outer_sub &&
> +   git init &&
> +   test_commit initial &&
> +   git submodule add ../inner_sub &&
> +   git commit -a -m "add an inner submodule"
> +   ) &&
> +   git submodule add ./outer_sub ./deep/outer_sub &&
> +   git commit -a -m "add outer sub" &&
> +   git -C deep ls-tree HEAD |cut -f 2 >actual &&
> +   cat >expect <<-EOF &&
> +   directory
> +   outer_sub
> +   EOF
> +   test_cmp expect actual &&
> git branch submodule
>  '
>
> @@ -488,6 +510,27 @@ test_expect_success 'moving a submodule in nested 
> directories' '
> git config -f ../.gitmodules 
> submodule.deep/directory/hierachy/sub.path >../actual &&
> echo "directory/hierachy/sub" >../expect
> ) &&
> +   test_cmp actual expect &&
> +   git commit -a -m "mv a submodule in nested dir"
> +'
> +
> +test_expect_success 'moving a submodule with a nested submodule' '
> +   git mv deep/outer_sub outer_sub_moved &&
> +   # git status would fail if the update of linking git dir to
> +   # work dir of the submodule failed.
> +   git status &&
> +   git config -f .gitmodules submodule.deep/outer_sub.path >actual &&
> +   echo "outer_sub_moved" >expect &&
> +   test_cmp actual expect
> +'
> +
> +test_expect_success 'moving back the submodule with a nested submodule' '
> +   git mv outer_sub_moved deep/outer_sub &&
> +   # git status would fail if the update of linking git dir to
> +   # work dir of the submodule failed.
> +   git status &&
> +   git config -f .gitmodules submodule.deep/outer_sub.path >actual &&
> +   echo "deep/outer_sub" >expect &&
> test_cmp actual expect
>  '
>
> --
> 2.9.0.4.g35eb263.dirty
>



-- 
Bart Bogaerts
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Git mv -- submodule -- recursive

2016-06-27 Thread Bart Bogaerts
Hi,

I tested this on git version 2.9 and it still fails (exactly the same
behaviour as on the stackoverflow post; also the workarounded I posted
there still works).
Some output showing the bug follows below:


bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
bartb@EB-Latitude-E5450 ~/Documents/papers $ git --version
git version 2.9.0
bartb@EB-Latitude-E5450 ~/Documents/papers $ git mv fo-c-revisited/ 2016
bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
fatal: Not a git repository:
idp-latex/../../.git/modules/fo-c-revisited/modules/idp-latex
fatal: 'git status --porcelain' failed in submodule 2016/fo-c-revisited
bartb@EB-Latitude-E5450 ~/Documents/papers $ rm
2016/fo-c-revisited/idp-latex/.git
bartb@EB-Latitude-E5450 ~/Documents/papers $ git submodule update
bartb@EB-Latitude-E5450 ~/Documents/papers $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD ..." to unstage)

modified:   .gitmodules
renamed:fo-c-revisited -> 2016/fo-c-revisited

bartb@EB-Latitude-E5450 ~/Documents/papers $

2016-06-27 19:57 GMT+03:00 Stefan Beller <sbel...@google.com>:
> On Sun, Jun 26, 2016 at 11:01 PM, Bart Bogaerts <bartbogae...@gmail.com> 
> wrote:
>> With a repo structured as follows
>>
>> main-files
>> |- submod
>> |- subsubmodule
>>
>> git mv submod newlocation
>>
>> does not do what it is supposed to do. It actually breaks the git repository.
>> It can be fixed easily.
>> A complete description of the bug, including a workaround, can be found on
>> http://stackoverflow.com/q/32782382/2274140
>
> Which version of Git are you using?
> I think this is fixed in a127331cd81233 (mv: allow moving nested
> submodules, 2016-04-19), which is first included in v2.8.3
> (or v2.9 and later).
>
> Thanks,
> Stefan
>
>>
>> --
>> Bart Bogaerts
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Bart Bogaerts
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Git mv -- submodule -- recursive

2016-06-27 Thread Bart Bogaerts
With a repo structured as follows

main-files
|- submod
|- subsubmodule

git mv submod newlocation

does not do what it is supposed to do. It actually breaks the git repository.
It can be fixed easily.
A complete description of the bug, including a workaround, can be found on
http://stackoverflow.com/q/32782382/2274140

-- 
Bart Bogaerts
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Git mv does not work with recursive submodules

2015-10-06 Thread Bart Bogaerts
For a complete description of this bug, see
http://stackoverflow.com/questions/32782382/git-moving-submodules-recursively-nested-submodules/32924692?noredirect=1#comment53760394_32924692

-- 
Bart Bogaerts
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html