git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Levedahl <mlevedahl@gmail.com>
To: gitster@pobox.com, <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, <sylvain.joyeux@dfki.de>, <hjemli@gmail.com>,
	<pkufranky@gmail.com>, Mark Levedahl <mlevedahl@gmail.com>
Subject: [PATCH] git-submodule - register submodule URL if adding in place
Date: Wed,  9 Jul 2008 21:05:41 -0400	[thread overview]
Message-ID: <1215651941-3460-2-git-send-email-mlevedahl@gmail.com> (raw)
In-Reply-To: <1215651941-3460-1-git-send-email-mlevedahl@gmail.com>

When adding a new submodule in place, meaning the user created the
submodule as a git repo in the superproject's tree first, we don't go
through "git submodule init" to register the module.  Thus, the
submodule's origin repository URL is not stored in .git/config, and no
subsequent submodule operation will ever do so.  In this case, assume the
URL the user supplies to "submodule add" is the one that should be
registered, and do so.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
Dscho's issue, so far as I can tell, was not really with this patch
but is addressed by the preceding patch eliminating the
confusing single argument "submodule add" format that lead to the
error he wanted to avoid. This patch is not changed except that it
is rebased.

 git-submodule.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index c2ce2fb..9228f56 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -172,6 +172,16 @@ cmd_add()
 		else
 			die "'$path' already exists and is not a valid git repo"
 		fi
+
+		case "$repo" in
+		./*|../*)
+			url=$(resolve_relative_url "$repo") || exit
+		    ;;
+		*)
+			url="$repo"
+			;;
+		esac
+		git config submodule."$path".url "$url"
 	else

 		module_clone "$path" "$realrepo" || exit
--
1.5.6.2.271.g73ad8

  reply	other threads:[~2008-07-10  1:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 15:00 [PATCH] fix "git-submodule add a/b/c/repository" Sylvain Joyeux
2008-07-06  6:27 ` Junio C Hamano
2008-07-06 16:11   ` Sylvain Joyeux
2008-07-06 19:05     ` Mark Levedahl
2008-07-07  6:34       ` Sylvain Joyeux
2008-07-08  2:23         ` Mark Levedahl
2008-07-08  2:42           ` Junio C Hamano
2008-07-08  3:26             ` Mark Levedahl
2008-07-08  6:02               ` Junio C Hamano
2008-07-08 23:57                 ` Mark Levedahl
2008-07-09  3:59                 ` [PATCH] git-submodule - make "submodule add" more strict, and document it Mark Levedahl
2008-07-09  6:04                   ` Junio C Hamano
2008-07-10  1:05                     ` Mark Levedahl
2008-07-10  1:05                       ` Mark Levedahl [this message]
2008-07-08  8:08               ` [PATCH] fix "git-submodule add a/b/c/repository" Sylvain Joyeux

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=1215651941-3460-2-git-send-email-mlevedahl@gmail.com \
    --to=mlevedahl@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hjemli@gmail.com \
    --cc=pkufranky@gmail.com \
    --cc=sylvain.joyeux@dfki.de \
    /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).