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: Jonathan Johnson <me@jondavidjohn.com>,
	Git Mailing List <git@vger.kernel.org>,
	Heiko Voigt <hvoigt@hvoigt.net>
Subject: Re: [PATCH 0/2] Let "git submodule add" fail when .git/modules/<name> already exists
Date: Sat, 29 Sep 2012 21:47:33 -0700	[thread overview]
Message-ID: <7vtxugglqy.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <50677E76.1050204@web.de> (Jens Lehmann's message of "Sun, 30 Sep 2012 01:04:22 +0200")

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

>> The only long term solution I can think of is to use some kind of UUID for
>> the name, so that the names of newly added submodules won't have a chance
>> to clash anymore. For the short term aborting "git submodule add" when a
>> submodule of that name already exists in .git/modules of the superproject
>> together with the ability to provide a custom name might at least solve
>> the local clashes.

That assumes that the addition of the submodule for the second time
is to add a completely different submodule at the same location and
is done on purpose, but is that a sensible assumption?

If a superproject that is about an embedded appliance used to have a
submodule A bound at its path "kernel", but for some reason stopped
shipping with "kernel" and then later reintroduced the directory
"kernel" bound to some submodule B, my gut feeling is that it is
just as likely (if not more likely) that A and B are indeed the same
submodule (i.e. it shares the same history) as they are totally
unrelated.

Could it be that it is a user error combined with the immaturity of
"git submodule" tool that does not yet support "it used to be here,
but it disappears for a while and then it reappears in the history
of the superproject" very well that caused the user to manually add
a "new" submodule which in fact is the same submodule at the same
path?

I think failing with a better error message is a good idea. It
should suggest to either resurrect the submodule that is stashed
away in "$GIT_DIR/modules/$name" if it indeed is the same, or to
give it a different name (perhaps "kernel" used to be pointing at
the Linux kernel history, then the user is replacing it with a
totally different implementation that is really from different
origin and do not share any history, perhaps BSD).  In such a case,
the user may want to pick bsd-kernel or something as its name, to
differentiate it.

> Using some kind of UUID can easily be added in a subsequent patch,...

I would suggest thinking really long and hard before saying UUID.
It is an easy cop-out to ensure uniqueness, but risks to allow two
people (or one person at two different time) to give two unrelated
names to a single thing that actually is the same.

A better alternative might be to use the commit object name at the
root of the history of the submodule, which would catch the simplest
and most common case of the mistake, I would think.

  parent reply	other threads:[~2012-09-30  4:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26  4:18 Bug in Submodule add Jonathan Johnson
2012-09-26 20:56 ` Jens Lehmann
2012-09-29 23:04   ` [PATCH 0/2] Let "git submodule add" fail when .git/modules/<name> already exists Jens Lehmann
2012-09-29 23:05     ` [PATCH 1/2] Teach "git submodule add" the --name option Jens Lehmann
2012-09-29 23:07     ` [PATCH 2/2] submodule add: Fail when .git/modules/<name> already exists Jens Lehmann
2012-09-30  4:47     ` Junio C Hamano [this message]
2012-09-30 19:19       ` [PATCH 0/2] Let "git submodule add" fail " Jens Lehmann
2012-09-30 21:01         ` [PATCH v2 2/2] submodule add: Fail when .git/modules/<name> already exists unless forced Jens Lehmann
2012-10-01  0:06           ` Junio C Hamano

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=7vtxugglqy.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=me@jondavidjohn.com \
    /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).