setup_git_directory_gently_1(): resolve symlinks in ceiling paths
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 28 Oct 2012 16:16:26 +0000 (17:16 +0100)
committerJeff King <peff@peff.net>
Mon, 29 Oct 2012 06:34:58 +0000 (02:34 -0400)
commit1b77d83cab798668d8a54a05b3fa0262486f7dfc
tree4fb68b8b55c5e54486adc75c8a6a31ea9d081cf4
parent9e2326c7e1efb1ae42b17e3fa38c16711a8d0bd8
setup_git_directory_gently_1(): resolve symlinks in ceiling paths

longest_ancestor_length() relies on a textual comparison of directory
parts to find the part of path that overlaps with one of the paths in
prefix_list.  But this doesn't work if any of the prefixes involves a
symbolic link, because the directories will look different even though
they might logically refer to the same directory.  So canonicalize the
paths listed in GIT_CEILING_DIRECTORIES using real_path_if_valid()
before passing them to longest_ancestor_length().  (Also rename
normalize_ceiling_entry() to canonicalize_ceiling_entry() to reflect
the change.)

path is already in canonical form, so doesn't need to be canonicalized
again.

This fixes some problems with using GIT_CEILING_DIRECTORIES that
contains paths involving symlinks, including t4035 if run with --root
set to a path involving symlinks.

Please note that test t0060 is *not* changed analogously, because that
would make the test suite results dependent on the contents of the
local root directory.  However, real_path() is already tested
independently, and the "ancestor" tests cover the non-normalization
aspects of longest_ancestor_length(), so coverage remains sufficient.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jeff King <peff@peff.net>
setup.c