Subject: Re: [PATCH 2/6] git rm: Support for removing submodules

From: Junio C Hamano <[email-masked]>
Date: Fri, 12 Sep 2008 15:42:54 -0700

Petr Baudis <[email-masked]> writes:

>> >> +{
>> >> +	char *key = submodule_by_path(name);
>> >> +	char *sectend = strrchr(key, '.');
>> >> +
>> >> +	assert(sectend);
>> >> +	*sectend = 0;
>> >
>> > Here is one caller I questioned in my comments on [1/6]...
>> 
>> Another thing --- can submodule_by_path() ever return NULL saying "I do
>> not see one in the configuration"?
>
> No, it would rather die().

Hmmmm.  If I did...

        $ git init
	$ create and add normal paths
        $ git clone git://..../gitk.git gitk
        $ git add gitk
        : heh, I changed my mind
        $ git rm gitk

the last step would die, because I changed my mind before fully
initializing gitk repository as a proper submodule?

How would I get rid of the index entry to recover from the mistake?

        $ rm -fr gitk
        $ git rm gitk

would presumably fail the same way, no?  I hope I am misreading the
code...

We need to be extremely careful not to break people who do not (yet) have
[submodule "xyzzy"] entries in config and/or .gitmodules when dealing with
the gitlink entries in the index.