From: Jens Lehmann <Jens.Lehmann@web.de>
To: Nicolas Morey-Chaisemartin <devel-git@morey-chaisemartin.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] submodule: Add --force option for git submodule update
Date: Wed, 30 Mar 2011 21:05:45 +0200 [thread overview]
Message-ID: <4D937F09.10000@web.de> (raw)
In-Reply-To: <4D937B7E.10808@morey-chaisemartin.com>
Am 30.03.2011 20:50, schrieb Nicolas Morey-Chaisemartin:
> 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.
You are right, I just came to that conclusion myself ... but with a loop
local variable initialized from force on every iteration it should work.
> 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.
Hmm, I don't know if that is a good thing to do. People are used to
"git submodule update" to only touch those submodule where the HEAD
differs from the commit recorded in the superproject (And I often
find myself using "-f" if the command didn't succeed without it).
But when using "-f" touches other submodules than not using it the
user might experience a rather unpleasant surprise, I'm not sure we
want to go that way.
> 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.
Yes.
next prev parent reply other threads:[~2011-03-30 19:06 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
2011-03-30 19:05 ` Jens Lehmann [this message]
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=4D937F09.10000@web.de \
--to=jens.lehmann@web.de \
--cc=devel-git@morey-chaisemartin.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.
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).