All of lore.kernel.org
 help / color / mirror / Atom feed
From: Henri GEIST <geist.henri@laposte.net>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] submodule : Add --no-separate-git-dir option to add and update command.
Date: Mon, 03 Mar 2014 21:34:26 +0100	[thread overview]
Message-ID: <1393878866.7891.22.camel@Naugrim> (raw)
In-Reply-To: <5314BFA5.2030807@web.de>

[-- Attachment #1: Type: text/plain, Size: 8138 bytes --]

Le lundi 03 mars 2014 à 17:45 +0000, Jens Lehmann a écrit :
> Am 03.03.2014 14:47, schrieb Henri GEIST:
> > This new option prevent git submodule <add|update> to clone the missing
> > submodules with the --separate-git-dir option.
> > Then the submodule will be regular repository and their gitdir will not
> > be placed in the superproject gitdir/modules directory.
> 
> And what is your motivation for this? After all submodules containing
> a .git directory are second class citizens (because they can never be
> safely removed by regular git commands).
>

I recognize most people will prefer to have the .git directory separate.
And I do not intend to make this option the default.

My reasons are:

  - As it is not clearly stated in the doc that the gitdir is separate.
    The first time I have copied one module to an USB key I had a big
    surprise.

  - This will not change anything for people not using it.

  - I use an other patch which I plane to send later which enable multiple
    level of superproject to add a gitlink to the same submodule.
    And in this case the superproject containing the separate gitdir will be
    arbitrary and depend on the processing order of the
    'git submodule update --recursive' command.

  - I have written this for myself and have using it since 2012 and send it in
    the hope it could be useful for someone else even if it is only a few
    people. But if its not the case no problem I will keep using it for myself.


> > Signed-off-by: Henri GEIST <geist.henri@laposte.net>
> > ---
> >  Documentation/git-submodule.txt |   18 ++++++++++++++++--
> >  git-submodule.sh                |   22 ++++++++++++++++++++--
> >  t/t7400-submodule-basic.sh      |   12 ++++++++++++
> >  3 files changed, 48 insertions(+), 4 deletions(-)
> > 
> > diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> > index 21cb59a..303a475 100644
> > --- a/Documentation/git-submodule.txt
> > +++ b/Documentation/git-submodule.txt
> > @@ -10,13 +10,14 @@ SYNOPSIS
> >  --------
> >  [verse]
> >  'git submodule' [--quiet] add [-b <branch>] [-f|--force] [--name <name>]
> > -	      [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
> > +	      [--reference <repository>] [--depth <depth>] [--no-separate-git-dir]
> > +	      [--] <repository> [<path>]
> >  'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
> >  'git submodule' [--quiet] init [--] [<path>...]
> >  'git submodule' [--quiet] deinit [-f|--force] [--] <path>...
> >  'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
> >  	      [-f|--force] [--rebase|--merge|--checkout] [--reference <repository>]
> > -	      [--depth <depth>] [--recursive] [--] [<path>...]
> > +	      [--depth <depth>] [--recursive] [--no-separate-git-dir] [--] [<path>...]
> >  'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
> >  	      [commit] [--] [<path>...]
> >  'git submodule' [--quiet] foreach [--recursive] <command>
> > @@ -107,6 +108,10 @@ is the superproject and submodule repositories will be kept
> >  together in the same relative location, and only the
> >  superproject's URL needs to be provided: git-submodule will correctly
> >  locate the submodule using the relative URL in .gitmodules.
> > ++
> > +If `--no-separate-git-dir` is specified, missing submodules will be cloned
> > +has normal git repository without the option `--separate-git-dir` pointing
> > +to the modules directory of the superproject gitdir.
> >  
> >  status::
> >  	Show the status of the submodules. This will print the SHA-1 of the
> > @@ -185,6 +190,10 @@ If the submodule is not yet initialized, and you just want to use the
> >  setting as stored in .gitmodules, you can automatically initialize the
> >  submodule with the `--init` option.
> >  +
> > +If `--no-separate-git-dir` is specified, missing submodules will be cloned
> > +has normal git repository without the option `--separate-git-dir` pointing
> > +to the modules directory of the superproject gitdir.
> > ++
> >  If `--recursive` is specified, this command will recurse into the
> >  registered submodules, and update any nested submodules within.
> >  +
> > @@ -363,6 +372,11 @@ for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully.
> >  	clone with a history truncated to the specified number of revisions.
> >  	See linkgit:git-clone[1]
> >  
> > +--no-separate-git-dir::
> > +	This option is valid for add and update commands. Specify that missing
> > +	submodules should be clonned as self contain repository without a
> > +	separate gitdir placed in the modules directory of the superproject
> > +	gitdir.
> >  
> >  <path>...::
> >  	Paths to submodule(s). When specified this will restrict the command
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > index a33f68d..36eaf31 100755
> > --- a/git-submodule.sh
> > +++ b/git-submodule.sh
> > @@ -5,11 +5,11 @@
> >  # Copyright (c) 2007 Lars Hjemli
> >  
> >  dashless=$(basename "$0" | sed -e 's/-/ /')
> > -USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
> > +USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--no-separate-git-dir] [--] <repository> [<path>]
> >     or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
> >     or: $dashless [--quiet] init [--] [<path>...]
> >     or: $dashless [--quiet] deinit [-f|--force] [--] <path>...
> > -   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
> > +   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--no-separate-git-dir] [--] [<path>...]
> >     or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
> >     or: $dashless [--quiet] foreach [--recursive] <command>
> >     or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
> > @@ -36,6 +36,7 @@ update=
> >  prefix=
> >  custom_name=
> >  depth=
> > +noseparategitdir=
> >  
> >  # The function takes at most 2 arguments. The first argument is the
> >  # URL that navigates to the submodule origin repo. When relative, this URL
> > @@ -270,6 +271,17 @@ module_clone()
> >  		quiet=-q
> >  	fi
> >  
> > +
> > +	if test -n "$noseparategitdir"
> > +	then
> > +		(
> > +			clear_local_git_env
> > +			git clone $quiet ${depth:+"$depth"} -n ${reference:+"$reference"} "$url" "$sm_path"
> > +		) ||
> > +		die "$(eval_gettext "Clone of '\$url' into submodule path '\$sm_path' failed")"
> > +		return
> > +	fi
> > +
> >  	gitdir=
> >  	gitdir_base=
> >  	base_name=$(dirname "$name")
> > @@ -359,6 +371,9 @@ cmd_add()
> >  		-q|--quiet)
> >  			GIT_QUIET=1
> >  			;;
> > +		--no-separate-git-dir)
> > +			noseparategitdir=1
> > +			;;
> >  		--reference)
> >  			case "$2" in '') usage ;; esac
> >  			reference_path=$2
> > @@ -758,6 +773,9 @@ cmd_update()
> >  		-f|--force)
> >  			force=$1
> >  			;;
> > +		--no-separate-git-dir)
> > +			noseparategitdir=1
> > +			;;
> >  		-r|--rebase)
> >  			update="rebase"
> >  			;;
> > diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> > index c28e8d8..aa2df3d 100755
> > --- a/t/t7400-submodule-basic.sh
> > +++ b/t/t7400-submodule-basic.sh
> > @@ -81,6 +81,18 @@ inspect() {
> >  	)
> >  }
> >  
> > +test_expect_success 'submodule add --no-separate-git-dir' '
> > +	(
> > +		cd addtest &&
> > +		rm -rf submod &&
> > +		git submodule add --no-separate-git-dir -q "$submodurl" submod >actual &&
> > +		test_must_be_empty actual &&
> > +		test -d submod/.git &&
> > +		rm -rf submod &&
> > +		git reset --hard
> > +	)
> > +'
> > +
> >  test_expect_success 'submodule add' '
> >  	echo "refs/heads/master" >expect &&
> >  	>empty &&
> > 
> 




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

  reply	other threads:[~2014-03-03 20:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-03 14:47 [PATCH] submodule : Add --no-separate-git-dir option to add and update command Henri GEIST
2014-03-03 17:45 ` Jens Lehmann
2014-03-03 20:34   ` Henri GEIST [this message]
2014-03-05 18:13     ` Jens Lehmann
2014-03-06  1:25       ` Henri GEIST
2014-03-06 19:48         ` Jens Lehmann
2014-03-06 20:15           ` Henri GEIST
2014-03-06 20:51             ` Jens Lehmann
2014-03-06 22:20               ` Henri GEIST
2014-03-07 23:00                 ` Jens Lehmann
2014-03-10  9:08                   ` Henri GEIST
2014-03-10 20:32                     ` Heiko Voigt
2014-03-11  9:55                       ` Henri GEIST
2014-03-11 20:11                         ` Heiko Voigt
2014-03-11 22:07                           ` Henri GEIST
2014-03-03 19:22 ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393878866.7891.22.camel@Naugrim \
    --to=geist.henri@laposte.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.