summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-10-05 10:29:29 -0400
committerJunio C Hamano <gitster@pobox.com>2016-10-05 10:44:39 -0700
commit22d3b8de1b625813faec6f3d6ffe66124837b78b (patch)
treea9934c344346d06c230c1f16be9b7ce169811b0e
parent0b65a8dbdb38962e700ee16776a3042beb489060 (diff)
downloadgit-jk/clone-copy-alternates-fix.tar.gz
clone: detect errors in normalize_path_copyjk/clone-copy-alternates-fix
When we are copying the alternates from the source repository, if we find a relative path that is too deep for the source (e.g., "../../../objects" from "/repo.git/objects"), then normalize_path_copy will report an error and leave trash in the buffer, which we will add to our new alternates file. Instead, let's detect the error, print a warning, and skip copying that alternate. There's no need to die. The relative path is probably just broken cruft in the source repo. If it turns out to have been important for accessing some objects, we rely on other parts of the clone to detect that, just as they would with a missing object in the source repo itself (though note that clones with "-s" are inherently local, which may do fewer object-quality checks in the first place). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/clone.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 661639255c..adc41027c6 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -353,8 +353,11 @@ static void copy_alternates(struct strbuf *src, struct strbuf *dst,
continue;
}
abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf);
- normalize_path_copy(abs_path, abs_path);
- add_to_alternates_file(abs_path);
+ if (!normalize_path_copy(abs_path, abs_path))
+ add_to_alternates_file(abs_path);
+ else
+ warning("skipping invalid relative alternate: %s/%s",
+ src_repo, line.buf);
free(abs_path);
}
strbuf_release(&line);