git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] clone: Make use of the strip_suffix() helper method
@ 2015-07-09 15:33 Sebastian Schuberth
  2015-07-09 17:00 ` Jeff King
  0 siblings, 1 reply; 24+ messages in thread
From: Sebastian Schuberth @ 2015-07-09 15:33 UTC (permalink / raw)
  To: git

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

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 builtin/clone.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 00535d0..d35b2b9 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;
 
 	/*
@@ -174,19 +175,17 @@ 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;
+		strip_suffix(start, ".bundle", &len);
 	} else {
-		if (end - start > 4 && !strncmp(end - 4, ".git", 4))
-			end -= 4;
+		strip_suffix(start, ".git", &len);
 	}
 
 	if (is_bare) {
 		struct strbuf result = STRBUF_INIT;
-		strbuf_addf(&result, "%.*s.git", (int)(end - start), start);
+		strbuf_addf(&result, "%.*s.git", len, start);
 		dir = strbuf_detach(&result, NULL);
 	} else
-		dir = xstrndup(start, end - start);
+		dir = xstrndup(start, len);
 	/*
 	 * Replace sequences of 'control' characters and whitespace
 	 * with one ascii space, remove leading and trailing spaces.

---
https://github.com/git/git/pull/160

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-08-05 21:05 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).