]> git.ipfire.org Git - thirdparty/git.git/commit - setup.c
setup: add abspath_part_inside_repo() function
authorMartin Erik Werner <martinerikwerner@gmail.com>
Tue, 4 Feb 2014 14:25:19 +0000 (15:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Feb 2014 20:08:49 +0000 (12:08 -0800)
commitddc2a6281595fd24ea01497c496f88c40a59562f
tree071cfd96fe12b59ecd55d978b038c28ecbbba4c5
parente131daa4c6baa53aba22e5d8bc1defa83b443bf0
setup: add abspath_part_inside_repo() function

In order to extract the part of an absolute path which lies inside the
repo, it is not possible to directly use real_path, since that would
dereference symlinks both outside and inside the work tree.

Add an abspath_part_inside_repo() function which first checks if the
work tree is already the prefix, then incrementally checks each path
level by temporarily NUL-terminating at each '/' and comparing against
the work tree path. If a match is found, it overwrites the input path
with the remainder past the work tree (which will be the part inside the
work tree).

This function is currently only intended for use in
'prefix_path_gently'.

Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com>
Reviewed-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c