git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: George Papanikolaou <g3orge.app@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] mv: better document side effects when moving a submodule
Date: Mon, 06 Jan 2014 14:40:16 -0800	[thread overview]
Message-ID: <xmqq8uushgz3.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <52CB023C.2050001@web.de> (Jens Lehmann's message of "Mon, 06 Jan 2014 20:21:32 +0100")

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

  reply	other threads:[~2014-01-06 23:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=xmqq8uushgz3.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=g3orge.app@gmail.com \
    --cc=git@vger.kernel.org \
    /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).