From: Nicolas Morey-Chaisemartin <devel-git@morey-chaisemartin.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] submodule: Add --force option for git submodule update
Date: Wed, 30 Mar 2011 20:50:38 +0200 [thread overview]
Message-ID: <4D937B7E.10808@morey-chaisemartin.com> (raw)
In-Reply-To: <4D93773C.2010807@web.de>
On 03/30/2011 08:32 PM, Jens Lehmann wrote:
> Am 30.03.2011 09:56, schrieb Nicolas Morey-Chaisemartin:
> All looking good up to here. But I wonder if the rest of git-submodule.sh
> could be changed a bit less invasive ... maybe as simple as this?
>
> @@ -458,7 +461,6 @@ cmd_update()
>
> if test "$subsha1" != "$sha1"
> then
> - force=
> if test -z "$subsha1"
> then
> force="-f"
>
> Now force will not be cleared and thus contain "-f" if the user provided
> it on the command line. All tests (including your new ones) are running
> fine with this simplification ... am I missing something?
Actually, I don't think this work.
By doing that, if you run git submodule update without -f, it will set -f when you reached the first submodule not yet checked out ( -z $subsha1 ),
and the following submodules will be checkout using --force which may throw away changes the user wanted to keep.
I know it is very intrusive. The main reason for that is I wanted the -f option to always behave the same (meaning throw away changes),
whether the submodule is already on the right commit or not.
If we accept to drop this and only drop the changes when subsha1 != sha1, the patch can be much sorter by simply keeping the force flags I used and without modifying all the case/while thing.
>>
>> +test_expect_success 'submodule update should fail due to local changes' '
>> + (cd super/submodule &&
>> + git reset --hard HEAD~1 &&
>> + echo "local change" > file
>> + ) &&
>> + (cd super &&
>> + (cd submodule &&
>> + compare_head
>> + ) &&
>> + test_must_fail git submodule update submodule
>> + )
>> +'
>
> This test is shorter and might be easier to understand rewritten as:
>
> +test_expect_success 'submodule update should fail due to local changes' '
> + (cd super &&
> + (cd submodule &&
> + git reset --hard HEAD~1 &&
> + echo "local change" > file
> + compare_head
> + ) &&
> + test_must_fail git submodule update submodule
> + )
> +'
>
Agreed.
next prev parent reply other threads:[~2011-03-30 18:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 7:56 [PATCH] submodule: Add --force option for git submodule update Nicolas Morey-Chaisemartin
2011-03-30 18:32 ` Jens Lehmann
2011-03-30 18:50 ` Nicolas Morey-Chaisemartin [this message]
2011-03-30 19:05 ` Jens Lehmann
2011-03-30 20:19 ` Nicolas Morey-Chaisemartin
2011-03-30 21:08 ` Junio C Hamano
2011-03-31 2:20 ` Nicolas Morey-Chaisemartin
2011-03-31 17:41 ` Jens Lehmann
2011-03-31 18:13 ` Nicolas Morey-Chaisemartin
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=4D937B7E.10808@morey-chaisemartin.com \
--to=devel-git@morey-chaisemartin.com \
--cc=Jens.Lehmann@web.de \
--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.
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).