Merge branch 'jk/clone-copy-alternates-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:14 +0000 (09:01 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Oct 2016 16:01:14 +0000 (09:01 -0700)
"git clone" of a local repository can be done at the filesystem
level, but the codepath did not check errors while copying and
adjusting the file that lists alternate object stores.

* jk/clone-copy-alternates-fix:
clone: detect errors in normalize_path_copy

builtin/clone.c
index f044a8c27f542c94c0b7f2458de1590e0d02fae2..a35d62293a9c84abb1473a1962c7af1540ed5017 100644 (file)
@@ -355,8 +355,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);