git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mv/rm submodules
@ 2013-12-09 10:59 George Papanikolaou
  2013-12-09 17:49 ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: George Papanikolaou @ 2013-12-09 10:59 UTC (permalink / raw)
  To: git

Hi list,

I was just playing with the new features of 'git mv' in 1.8.5 and
realized that both rm
and mv don't change the .git/config file. Is that on purpuse?
Also after mv you need to run 'submodule update' and I think this should be
documented somewhere.

Thanks..

-- 
George 'papanikge' Papanikolaou
g3orge.app@gmail.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: mv/rm submodules
  2013-12-09 10:59 mv/rm submodules George Papanikolaou
@ 2013-12-09 17:49 ` Jens Lehmann
  2014-01-06 19:21   ` [PATCH] mv: better document side effects when moving a submodule Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Lehmann @ 2013-12-09 17:49 UTC (permalink / raw)
  To: George Papanikolaou, git

Am 09.12.2013 11:59, schrieb George Papanikolaou:
> I was just playing with the new features of 'git mv' in 1.8.5 and
> realized that both rm
> and mv don't change the .git/config file. Is that on purpuse?

Yes. Only the "path" entry in .gitmodules needs to be updated
when a submodule is moved. Its name stays the same and thus the
.git/config entry automatically applies to the new location.

> Also after mv you need to run 'submodule update' and I think this should be
> documented somewhere.

You're right, this should be mentioned in the mv man page. I'll
prepare a patch for that.

Thanks for your feedback.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] mv: better document side effects when moving a submodule
  2013-12-09 17:49 ` Jens Lehmann
@ 2014-01-06 19:21   ` Jens Lehmann
  2014-01-06 22:40     ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Lehmann @ 2014-01-06 19:21 UTC (permalink / raw)
  To: George Papanikolaou; +Cc: git, Junio C Hamano

The "Submodules" section of the "git mv" documentation mentions what will
happen when a submodule with a gitfile gets moved with newer git. But it
doesn't talk about what happens when the user changes between commits
before and after the move, which does not update the work tree like using
the mv command did the first time.

Explain what happens and what the user has to do manually to fix that.
Also document this in a new test.

Reported-by: George Papanikolaou <g3orge.app@gmail.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---

Am 09.12.2013 18:49, schrieb Jens Lehmann:
> Am 09.12.2013 11:59, schrieb George Papanikolaou:
>> Also after mv you need to run 'submodule update' and I think this should be
>> documented somewhere.
> 
> You're right, this should be mentioned in the mv man page. I'll
> prepare a patch for that.

Does this new paragraph make it clearer?


 Documentation/git-mv.txt | 10 ++++++++++
 t/t7001-mv.sh            | 21 +++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
index b1f7988..c9e8568 100644
--- a/Documentation/git-mv.txt
+++ b/Documentation/git-mv.txt
@@ -52,6 +52,16 @@ core.worktree setting to make the submodule work in the new location.
 It also will attempt to update the submodule.<name>.path setting in
 the linkgit:gitmodules[5] file and stage that file (unless -n is used).

+Please note that each time a superproject update moves a populated
+submodule (e.g. when switching between commits before and after the
+move) a stale submodule checkout will remain in the old location
+and an empty directory will appear in the new location. To populate
+the submodule again in the new location the user will have to run
+"git submodule update" afterwards. Removing the old directory is
+only safe when it uses a gitfile, as otherwise the history of the
+submodule will be deleted too. Both steps will be obsolete when
+recursive submodule update has been implemented.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 3bfdfed..e3c8c2c 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -442,4 +442,25 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
 	git diff-files --quiet -- sub .gitmodules
 '

+test_expect_success 'checking out a commit before submodule moved needs manual updates' '
+	git mv sub sub2 &&
+	git commit -m "moved sub to sub2" &&
+	git checkout -q HEAD^ 2>actual &&
+	echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
+	test_i18ncmp expected actual &&
+	git status -s sub2 >actual &&
+	echo "?? sub2/" >expected &&
+	test_cmp expected actual &&
+	! test -f sub/.git &&
+	test -f sub2/.git &&
+	git submodule update &&
+	test -f sub/.git &&
+	rm -rf sub2 &&
+	git diff-index --exit-code HEAD &&
+	git update-index --refresh &&
+	git diff-files --quiet -- sub .gitmodules &&
+	git status -s sub2 >actual &&
+	! test -s actual
+'
+
 test_done
-- 
1.8.5.2.230.g9325930

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] mv: better document side effects when moving a submodule
  2014-01-06 19:21   ` [PATCH] mv: better document side effects when moving a submodule Jens Lehmann
@ 2014-01-06 22:40     ` Junio C Hamano
  2014-01-07 17:57       ` Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2014-01-06 22:40 UTC (permalink / raw)
  To: Jens Lehmann; +Cc: George Papanikolaou, git

Jens Lehmann <Jens.Lehmann@web.de> writes:

> The "Submodules" section of the "git mv" documentation mentions what will
> happen when a submodule with a gitfile gets moved with newer git. But it
> doesn't talk about what happens when the user changes between commits
> before and after the move, which does not update the work tree like using
> the mv command did the first time.
>
> Explain what happens and what the user has to do manually to fix that.
> Also document this in a new test.
>
> Reported-by: George Papanikolaou <g3orge.app@gmail.com>
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
>
> Am 09.12.2013 18:49, schrieb Jens Lehmann:
>> Am 09.12.2013 11:59, schrieb George Papanikolaou:
>>> Also after mv you need to run 'submodule update' and I think this should be
>>> documented somewhere.
>> 
>> You're right, this should be mentioned in the mv man page. I'll
>> prepare a patch for that.
>
> Does this new paragraph make it clearer?

Don't we have bugs section that we can use to list the known
limitations like this?

>  Documentation/git-mv.txt | 10 ++++++++++
>  t/t7001-mv.sh            | 21 +++++++++++++++++++++

It also may make sense to express the test as "this is what we would
like to see happen eventually" in the form of test_expect_failure;
it is not a big deal though.

>  2 files changed, 31 insertions(+)
>
> diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
> index b1f7988..c9e8568 100644
> --- a/Documentation/git-mv.txt
> +++ b/Documentation/git-mv.txt
> @@ -52,6 +52,16 @@ core.worktree setting to make the submodule work in the new location.
>  It also will attempt to update the submodule.<name>.path setting in
>  the linkgit:gitmodules[5] file and stage that file (unless -n is used).
>
> +Please note that each time a superproject update moves a populated
> +submodule (e.g. when switching between commits before and after the
> +move) a stale submodule checkout will remain in the old location
> +and an empty directory will appear in the new location. To populate
> +the submodule again in the new location the user will have to run
> +"git submodule update" afterwards. Removing the old directory is
> +only safe when it uses a gitfile, as otherwise the history of the
> +submodule will be deleted too. Both steps will be obsolete when
> +recursive submodule update has been implemented.
> +
>  GIT
>  ---
>  Part of the linkgit:git[1] suite
> diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
> index 3bfdfed..e3c8c2c 100755
> --- a/t/t7001-mv.sh
> +++ b/t/t7001-mv.sh
> @@ -442,4 +442,25 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
>  	git diff-files --quiet -- sub .gitmodules
>  '
>
> +test_expect_success 'checking out a commit before submodule moved needs manual updates' '
> +	git mv sub sub2 &&
> +	git commit -m "moved sub to sub2" &&
> +	git checkout -q HEAD^ 2>actual &&
> +	echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
> +	test_i18ncmp expected actual &&
> +	git status -s sub2 >actual &&
> +	echo "?? sub2/" >expected &&
> +	test_cmp expected actual &&
> +	! test -f sub/.git &&
> +	test -f sub2/.git &&
> +	git submodule update &&
> +	test -f sub/.git &&
> +	rm -rf sub2 &&
> +	git diff-index --exit-code HEAD &&
> +	git update-index --refresh &&
> +	git diff-files --quiet -- sub .gitmodules &&
> +	git status -s sub2 >actual &&
> +	! test -s actual
> +'
> +
>  test_done

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mv: better document side effects when moving a submodule
  2014-01-06 22:40     ` Junio C Hamano
@ 2014-01-07 17:57       ` Jens Lehmann
  2014-01-07 21:30         ` [PATCH v2 0/2] better document side effects when [re]moving " Jens Lehmann
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Lehmann @ 2014-01-07 17:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: George Papanikolaou, git

Am 06.01.2014 23:40, schrieb Junio C Hamano:
> Jens Lehmann <Jens.Lehmann@web.de> writes:
>> Does this new paragraph make it clearer?
> 
> Don't we have bugs section that we can use to list the known
> limitations like this?

Right, will change accordingly in v2.

>>  Documentation/git-mv.txt | 10 ++++++++++
>>  t/t7001-mv.sh            | 21 +++++++++++++++++++++
> 
> It also may make sense to express the test as "this is what we would
> like to see happen eventually" in the form of test_expect_failure;
> it is not a big deal though.

We'll get the "what we would like to see happen eventually" test for
free from the recursive submodule update framework I'm currently
implementing, so I propose we don't implement this exepected failure
in this patch.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 0/2] better document side effects when [re]moving a submodule
  2014-01-07 17:57       ` Jens Lehmann
@ 2014-01-07 21:30         ` Jens Lehmann
  2014-01-07 21:31           ` [PATCH v2 1/2] mv: better document side effects when moving " Jens Lehmann
  2014-01-07 21:32           ` [PATCH v2 2/2] rm: better document side effects when removing " Jens Lehmann
  0 siblings, 2 replies; 8+ messages in thread
From: Jens Lehmann @ 2014-01-07 21:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: George Papanikolaou, git

Am 07.01.2014 18:57, schrieb Jens Lehmann:
> Am 06.01.2014 23:40, schrieb Junio C Hamano:
>> Jens Lehmann <Jens.Lehmann@web.de> writes:
>>> Does this new paragraph make it clearer?
>>
>> Don't we have bugs section that we can use to list the known
>> limitations like this?
> 
> Right, will change accordingly in v2.

Changes from v1:

- Document side effects under the BUGS section

- Add similar documentation for "git rm"


Jens Lehmann (2):
  mv: better document side effects when moving a submodule
  rm: better document side effects when removing a submodule

 Documentation/git-mv.txt | 12 ++++++++++++
 Documentation/git-rm.txt |  9 +++++++++
 t/t3600-rm.sh            | 16 ++++++++++++++++
 t/t7001-mv.sh            | 21 +++++++++++++++++++++
 4 files changed, 58 insertions(+)

-- 
1.8.5.2.231.gfc86eb1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] mv: better document side effects when moving a submodule
  2014-01-07 21:30         ` [PATCH v2 0/2] better document side effects when [re]moving " Jens Lehmann
@ 2014-01-07 21:31           ` Jens Lehmann
  2014-01-07 21:32           ` [PATCH v2 2/2] rm: better document side effects when removing " Jens Lehmann
  1 sibling, 0 replies; 8+ messages in thread
From: Jens Lehmann @ 2014-01-07 21:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: George Papanikolaou, git

The "Submodules" section of the "git mv" documentation mentions what will
happen when a submodule with a gitfile gets moved with newer git. But it
doesn't talk about what happens when the user changes between commits
before and after the move, which does not update the work tree like using
the mv command did the first time.

Explain what happens and what the user has to do manually to fix that in
the new BUGS section. Also document this behavior in a new test.

Reported-by: George Papanikolaou <g3orge.app@gmail.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 Documentation/git-mv.txt | 12 ++++++++++++
 t/t7001-mv.sh            | 21 +++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
index b1f7988..e453132 100644
--- a/Documentation/git-mv.txt
+++ b/Documentation/git-mv.txt
@@ -52,6 +52,18 @@ core.worktree setting to make the submodule work in the new location.
 It also will attempt to update the submodule.<name>.path setting in
 the linkgit:gitmodules[5] file and stage that file (unless -n is used).

+BUGS
+----
+Each time a superproject update moves a populated submodule (e.g. when
+switching between commits before and after the move) a stale submodule
+checkout will remain in the old location and an empty directory will
+appear in the new location. To populate the submodule again in the new
+location the user will have to run "git submodule update"
+afterwards. Removing the old directory is only safe when it uses a
+gitfile, as otherwise the history of the submodule will be deleted
+too. Both steps will be obsolete when recursive submodule update has
+been implemented.
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 3bfdfed..e3c8c2c 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -442,4 +442,25 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
 	git diff-files --quiet -- sub .gitmodules
 '

+test_expect_success 'checking out a commit before submodule moved needs manual updates' '
+	git mv sub sub2 &&
+	git commit -m "moved sub to sub2" &&
+	git checkout -q HEAD^ 2>actual &&
+	echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
+	test_i18ncmp expected actual &&
+	git status -s sub2 >actual &&
+	echo "?? sub2/" >expected &&
+	test_cmp expected actual &&
+	! test -f sub/.git &&
+	test -f sub2/.git &&
+	git submodule update &&
+	test -f sub/.git &&
+	rm -rf sub2 &&
+	git diff-index --exit-code HEAD &&
+	git update-index --refresh &&
+	git diff-files --quiet -- sub .gitmodules &&
+	git status -s sub2 >actual &&
+	! test -s actual
+'
+
 test_done
-- 
1.8.5.2.231.gfc86eb1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] rm: better document side effects when removing a submodule
  2014-01-07 21:30         ` [PATCH v2 0/2] better document side effects when [re]moving " Jens Lehmann
  2014-01-07 21:31           ` [PATCH v2 1/2] mv: better document side effects when moving " Jens Lehmann
@ 2014-01-07 21:32           ` Jens Lehmann
  1 sibling, 0 replies; 8+ messages in thread
From: Jens Lehmann @ 2014-01-07 21:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: George Papanikolaou, git

The "Submodules" section of the "git rm" documentation mentions what will
happen when a submodule with a gitfile gets removed with newer git. But it
doesn't talk about what happens when the user changes between commits
before and after the removal, which does not remove the submodule from the
work tree like using the rm command did the first time.

Explain what happens and what the user has to do manually to fix that in
the new BUGS section. Also document this behavior in a new test.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 Documentation/git-rm.txt |  9 +++++++++
 t/t3600-rm.sh            | 16 ++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
index 9d731b4..f1efc11 100644
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
@@ -170,6 +170,15 @@ of files and subdirectories under the `Documentation/` directory.
 	(i.e. you are listing the files explicitly), it
 	does not remove `subdir/git-foo.sh`.

+BUGS
+----
+Each time a superproject update removes a populated submodule
+(e.g. when switching between commits before and after the removal) a
+stale submodule checkout will remain in the old location. Removing the
+old directory is only safe when it uses a gitfile, as otherwise the
+history of the submodule will be deleted too. This step will be
+obsolete when recursive submodule update has been implemented.
+
 SEE ALSO
 --------
 linkgit:git-add[1]
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 540c49b..3d30581 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -705,6 +705,22 @@ test_expect_success 'rm of a populated nested submodule with a nested .git direc
 	rm -rf submod
 '

+test_expect_success 'checking out a commit after submodule removal needs manual updates' '
+	git commit -m "submodule removal" submod &&
+	git checkout HEAD^ &&
+	git submodule update &&
+	git checkout -q HEAD^ 2>actual &&
+	git checkout -q master 2>actual &&
+	echo "warning: unable to rmdir submod: Directory not empty" >expected &&
+	test_i18ncmp expected actual &&
+	git status -s submod >actual &&
+	echo "?? submod/" >expected &&
+	test_cmp expected actual &&
+	rm -rf submod &&
+	git status -s -uno --ignore-submodules=none > actual &&
+	! test -s actual
+'
+
 test_expect_success 'rm of d/f when d has become a non-directory' '
 	rm -rf d &&
 	mkdir d &&
-- 
1.8.5.2.231.gfc86eb1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-07 21:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-09 10:59 mv/rm submodules George Papanikolaou
2013-12-09 17:49 ` Jens Lehmann
2014-01-06 19:21   ` [PATCH] mv: better document side effects when moving a submodule Jens Lehmann
2014-01-06 22:40     ` Junio C Hamano
2014-01-07 17:57       ` Jens Lehmann
2014-01-07 21:30         ` [PATCH v2 0/2] better document side effects when [re]moving " Jens Lehmann
2014-01-07 21:31           ` [PATCH v2 1/2] mv: better document side effects when moving " Jens Lehmann
2014-01-07 21:32           ` [PATCH v2 2/2] rm: better document side effects when removing " Jens Lehmann

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 NNTP newsgroup(s).