git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcus Griep <marcus@griep.us>
To: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] clone --bare: Add ".git" suffix to the directory name to clone into
Date: Fri, 01 Aug 2008 10:01:16 -0400	[thread overview]
Message-ID: <4893172C.1060203@griep.us> (raw)
In-Reply-To: <alpine.DEB.1.00.0808011601200.9611@pacific.mpi-cbg.de.mpi-cbg.de>

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

Does this patch forgo adding a ".git" suffix if one is already present?

Marcus

Johannes Schindelin wrote:
> We have a tradition that bare repositories live in directories ending
> in ".git".  To make this more a convention than just a tradition, teach
> "git clone --bare" to add a ".git" suffix to the directory name.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> 
> 	This patch is only conceptionally dependent on patch 1/2.
> 
>  builtin-clone.c  |   10 ++++++++--
>  t/t5601-clone.sh |    7 +++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/builtin-clone.c b/builtin-clone.c
> index a45179c..82f5b67 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -95,7 +95,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)
>  	return NULL;
>  }
>  
> -static char *guess_dir_name(const char *repo, int is_bundle)
> +static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
>  {
>  	const char *end = repo + strlen(repo), *start;
>  
> @@ -131,6 +131,12 @@ static char *guess_dir_name(const char *repo, int is_bundle)
>  			end -= 4;
>  	}
>  
> +	if (is_bare) {
> +		char *result = xmalloc(end - start + 5);
> +		sprintf(result, "%.*s.git", (int)(end - start), start);
> +		return result;
> +	}
> +
>  	return xstrndup(start, end - start);
>  }
>  
> @@ -388,7 +394,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>  	if (argc == 2)
>  		dir = xstrdup(argv[1]);
>  	else
> -		dir = guess_dir_name(repo_name, is_bundle);
> +		dir = guess_dir_name(repo_name, is_bundle, option_bare);
>  
>  	if (!stat(dir, &buf))
>  		die("destination directory '%s' already exists.", dir);
> diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
> index 4b2533f..e0a68ab 100755
> --- a/t/t5601-clone.sh
> +++ b/t/t5601-clone.sh
> @@ -80,4 +80,11 @@ test_expect_success 'clone --mirror' '
>  
>  '
>  
> +test_expect_success 'clone --bare names the local repository <name>.git' '
> +
> +	git clone --bare src &&
> +	test -d src.git
> +
> +'
> +
>  test_done

-- 
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 793 bytes --]

  reply	other threads:[~2008-08-01 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-01 14:00 [PATCH 1/2] clone: Add an option to set up a mirror Johannes Schindelin
2008-08-01 14:01 ` [PATCH 2/2] clone --bare: Add ".git" suffix to the directory name to clone into Johannes Schindelin
2008-08-01 14:01   ` Marcus Griep [this message]
2008-08-01 15:34     ` Bert Wesarg
2008-08-01 14:27 ` [PATCH 1/2] clone: Add an option to set up a mirror Miklos Vajna
2008-08-02 18:55 ` Junio C Hamano
2008-08-02 19:38   ` [PATCH v2] " Johannes Schindelin
2008-08-02 19:39     ` Johannes Schindelin
2008-08-02 20:46     ` 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=4893172C.1060203@griep.us \
    --to=marcus@griep.us \
    --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).