From: Junio C Hamano <gitster@pobox.com>
To: Sebastian Schuberth <sschuberth@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] clone: Simplify string handling in guess_dir_name()
Date: Thu, 09 Jul 2015 11:05:04 -0700 [thread overview]
Message-ID: <xmqq1tghw6jz.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <0000014e73d7c3d8-413991dd-3907-430c-ab99-a0a3d93dcab0-000000@eu-west-1.amazonses.com> (Sebastian Schuberth's message of "Thu, 9 Jul 2015 17:23:17 +0000")
Sebastian Schuberth <sschuberth@gmail.com> writes:
> Subject: Re: [PATCH v2] clone: Simplify string handling in guess_dir_name()
We seem not to capitalize the first word on the subject line.
> Content-Type: multipart/mixed; boundary="----=_Part_8_836493213.1436462597065"
Please don't.
> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
> ---
> builtin/clone.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 00535d0..afdc004 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -147,6 +147,7 @@ static char *get_repo_path(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;
> + size_t len;
> char *dir;
>
> /*
> @@ -173,20 +174,9 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
> /*
> * Strip .{bundle,git}.
> */
> - if (is_bundle) {
> - if (end - start > 7 && !strncmp(end - 7, ".bundle", 7))
> - end -= 7;
> - } else {
> - if (end - start > 4 && !strncmp(end - 4, ".git", 4))
> - end -= 4;
> - }
> + strip_suffix(start, is_bundle ? ".bundle" : ".git" , &len);
This looks vastly nicer than the original.
> - if (is_bare) {
> - struct strbuf result = STRBUF_INIT;
> - strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
> - dir = strbuf_detach(&result, NULL);
> - } else
> - dir = xstrndup(start, end - start);
> + dir = is_bare ? xstrfmt("%.*s.git", (int)len, start) : xstrndup(start, len);
This however I had to read twice. I'd say
if (is_bare)
dir = xstrfmt(...);
else
dir = xstrndup(...);
is much easier to read.
next prev parent reply other threads:[~2015-07-09 18:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 15:33 [PATCH] clone: Make use of the strip_suffix() helper method Sebastian Schuberth
2015-07-09 17:00 ` Jeff King
2015-07-09 17:16 ` Sebastian Schuberth
2015-07-09 17:23 ` [PATCH v2] clone: Simplify string handling in guess_dir_name() Sebastian Schuberth
2015-07-09 18:05 ` Junio C Hamano [this message]
2015-07-09 18:16 ` Sebastian Schuberth
2015-07-09 18:20 ` [PATCH v3] " Sebastian Schuberth
2015-07-09 18:24 ` [PATCH v4] clone: simplify " Sebastian Schuberth
2015-07-09 21:21 ` Junio C Hamano
2015-07-09 21:23 ` Sebastian Schuberth
2015-08-04 4:34 ` Lukas Fleischer
2015-08-04 7:31 ` Sebastian Schuberth
2015-08-04 22:42 ` Jeff King
2015-08-05 6:08 ` Patrick Steinhardt
2015-08-05 8:41 ` Jeff King
2015-08-05 9:06 ` Patrick Steinhardt
2015-08-05 9:09 ` Jeff King
2015-08-05 8:35 ` [PATCH 0/2] fix clone guess_dir_name regression in v2.4.8 Jeff King
2015-08-05 8:36 ` [PATCH 1/2] clone: add tests for output directory Jeff King
2015-08-05 8:39 ` [PATCH 2/2] clone: use computed length in guess_dir_name Jeff King
2015-08-05 8:49 ` Sebastian Schuberth
2015-08-05 17:19 ` [PATCH 0/2] fix clone guess_dir_name regression in v2.4.8 Junio C Hamano
2015-08-05 21:04 ` Jeff King
2015-07-09 18:40 ` [PATCH v2] clone: Simplify string handling in guess_dir_name() 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=xmqq1tghw6jz.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=sschuberth@gmail.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).