summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-08-10 17:48:22 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-08-10 11:01:05 -0700
commitdb2e220447f7b02278d64417c8f05f73710f5b8b (patch)
treef5b7b6ac2b3d0a171b2f203c8906a7d5845334ab /http-fetch.c
parentclone: add tests for output directory (diff)
downloadtgif-db2e220447f7b02278d64417c8f05f73710f5b8b.tar.xz
clone: use computed length in guess_dir_name
Commit 7e837c6 (clone: simplify string handling in guess_dir_name(), 2015-07-09) changed clone to use strip_suffix instead of hand-rolled pointer manipulation. However, strip_suffix will strip from the end of a NUL-terminated string, and we may have already stripped some characters (like directory separators, or "/.git"). This leads to commands like: git clone host:foo.git/ failing to strip the ".git". We must instead convert our pointer arithmetic into a computed length and feed that to strip_suffix_mem, which will then reduce the length further for us. It would be nicer if we could drop the pointer manipulation entirely, and just continually strip using strip_suffix. But that doesn't quite work for two reasons: 1. The early suffixes we're stripping are not constant; we need to look for is_dir_sep, which could be one of several characters. 2. Mid-way through the stripping we compute the pointer "start", which shows us the beginning of the pathname. Which really give us two lengths to work with: the offset from the start of the string, and from the start of the path. By using pointers for the early part, we can just compute the length from "start" when we need it. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Sebastian Schuberth <sschuberth@gmail.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-fetch.c')
0 files changed, 0 insertions, 0 deletions