Re: 'git mv' doesn't move submodule if it's in a subdirectory

2016-04-15 Thread Albin Otterhäll
On 2016-04-15 19:18, Stefan Beller wrote:
> On Fri, Apr 15, 2016 at 1:14 AM, Albin Otterhäll  wrote:
>> I've a submodule located in a subdirectory
>> ({git_rep}/home/{directory}/{submodule}), and I wanted to move the whole
>> directory up a level ({git_rep}/{directory}/{submodule}). But when I
>> used 'git mv {directory} ../' the '.gitmodule' file didn't get modified.
>>
>> Best regards,
>> Albin Otterhäll
> 
> Thanks for the bug report!
> Which version of Git do you use? (Did you try different versions?)
> 

I'm using 2.8.0 (on an Arch system). Haven't tested on any other version.

--
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' doesn't move submodule if it's in a subdirectory

2016-04-15 Thread Stefan Beller
On Fri, Apr 15, 2016 at 11:21 AM, Junio C Hamano  wrote:
> Stefan Beller  writes:
>
>> I think I can reproduce the problem. A regression test (which currently 
>> fails)
>> could look like
>
> Thanks.  I however do not think this is a regression.
>
> Changes around 0656781f (mv: update the path entry in .gitmodules
> for moved submodules, 2013-08-06) did introduce "git mv dir1 dir2"
> when 'dir1' is a submodule, but I do not think it went beyond that.
> I do not see any effort to treat a submodule that is discovered by
> scanning a directory that was given from the command line,
> i.e. prepare_move_submodule() is not called for them, and the
> entries in the submodule_gitfile[] array that correspond to them are
> explicitly set to NULL in the loop.

Also I just realize this is not exactly the same bug as reported.
Albin complains about the .gitmodules file not being adjusted, whereas
the test case I wrote breaks commands in your superproject, i.e. `git status`
or `git diff` just dies.

(Manually inspecting the .gitmodules file turns out it is not adjusted as well.)

>
>
>> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
>> index 4008fae..3b96a9a 100755
>> --- a/t/t7001-mv.sh
>> +++ b/t/t7001-mv.sh
>> @@ -292,6 +292,9 @@ test_expect_success 'setup submodule' '
>> echo content >file &&
>> git add file &&
>> git commit -m "added sub and file" &&
>> +   mkdir -p deep/directory/hierachy &&
>> +   git submodule add ./. deep/directory/hierachy/sub &&
>> +   git commit -m "added another submodule" &&
>> git branch submodule
>>  '
>>
>> @@ -475,4 +478,14 @@ test_expect_success 'mv -k does not accidentally
>> destroy submodules' '
>> git checkout .
>>  '
>>
>> +test_expect_failure 'moving a submodule in nested directories' '
>> +   (
>> +   cd deep &&
>> +   git mv directory ../ &&
>> +   git status
>> +   # currently git status exits with 128
>> +   # fatal: Not a git repository:
>> directory/hierachy/sub/../../../../.git/modules/deep/directory/hierachy/sub
>> +   )
>> +'
>> +
>>  test_done
--
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' doesn't move submodule if it's in a subdirectory

2016-04-15 Thread Junio C Hamano
Stefan Beller  writes:

> I think I can reproduce the problem. A regression test (which currently fails)
> could look like

Thanks.  I however do not think this is a regression.

Changes around 0656781f (mv: update the path entry in .gitmodules
for moved submodules, 2013-08-06) did introduce "git mv dir1 dir2"
when 'dir1' is a submodule, but I do not think it went beyond that.
I do not see any effort to treat a submodule that is discovered by
scanning a directory that was given from the command line,
i.e. prepare_move_submodule() is not called for them, and the
entries in the submodule_gitfile[] array that correspond to them are
explicitly set to NULL in the loop.


> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
> index 4008fae..3b96a9a 100755
> --- a/t/t7001-mv.sh
> +++ b/t/t7001-mv.sh
> @@ -292,6 +292,9 @@ test_expect_success 'setup submodule' '
> echo content >file &&
> git add file &&
> git commit -m "added sub and file" &&
> +   mkdir -p deep/directory/hierachy &&
> +   git submodule add ./. deep/directory/hierachy/sub &&
> +   git commit -m "added another submodule" &&
> git branch submodule
>  '
>
> @@ -475,4 +478,14 @@ test_expect_success 'mv -k does not accidentally
> destroy submodules' '
> git checkout .
>  '
>
> +test_expect_failure 'moving a submodule in nested directories' '
> +   (
> +   cd deep &&
> +   git mv directory ../ &&
> +   git status
> +   # currently git status exits with 128
> +   # fatal: Not a git repository:
> directory/hierachy/sub/../../../../.git/modules/deep/directory/hierachy/sub
> +   )
> +'
> +
>  test_done
--
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' doesn't move submodule if it's in a subdirectory

2016-04-15 Thread Stefan Beller
On Fri, Apr 15, 2016 at 10:18 AM, Stefan Beller  wrote:
> On Fri, Apr 15, 2016 at 1:14 AM, Albin Otterhäll  wrote:
>> I've a submodule located in a subdirectory
>> ({git_rep}/home/{directory}/{submodule}), and I wanted to move the whole
>> directory up a level ({git_rep}/{directory}/{submodule}). But when I
>> used 'git mv {directory} ../' the '.gitmodule' file didn't get modified.
>>
>> Best regards,
>> Albin Otterhäll
>
> Thanks for the bug report!
> Which version of Git do you use? (Did you try different versions?)

I think I can reproduce the problem. A regression test (which currently fails)
could look like
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 4008fae..3b96a9a 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -292,6 +292,9 @@ test_expect_success 'setup submodule' '
echo content >file &&
git add file &&
git commit -m "added sub and file" &&
+   mkdir -p deep/directory/hierachy &&
+   git submodule add ./. deep/directory/hierachy/sub &&
+   git commit -m "added another submodule" &&
git branch submodule
 '

@@ -475,4 +478,14 @@ test_expect_success 'mv -k does not accidentally
destroy submodules' '
git checkout .
 '

+test_expect_failure 'moving a submodule in nested directories' '
+   (
+   cd deep &&
+   git mv directory ../ &&
+   git status
+   # currently git status exits with 128
+   # fatal: Not a git repository:
directory/hierachy/sub/../../../../.git/modules/deep/directory/hierachy/sub
+   )
+'
+
 test_done
--
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' doesn't move submodule if it's in a subdirectory

2016-04-15 Thread Stefan Beller
On Fri, Apr 15, 2016 at 1:14 AM, Albin Otterhäll  wrote:
> I've a submodule located in a subdirectory
> ({git_rep}/home/{directory}/{submodule}), and I wanted to move the whole
> directory up a level ({git_rep}/{directory}/{submodule}). But when I
> used 'git mv {directory} ../' the '.gitmodule' file didn't get modified.
>
> Best regards,
> Albin Otterhäll

Thanks for the bug report!
Which version of Git do you use? (Did you try different versions?)
--
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