path: root/test-path-utils.c
AgeCommit message (Collapse)Author
2011-03-17Name make_*_path functions more accuratelyCarlos Martín Nieto
Rename the make_*_path functions so it's clearer what they do, in particlar make clear what the differnce between make_absolute_path and make_nonrelative_path is by renaming them real_path and absolute_path respectively. make_relative_path has an understandable name and is renamed to relative_path to maintain the name convention. The function calls have been replaced 1-to-1 in their usage. Signed-off-by: Carlos Martín Nieto <> Signed-off-by: Junio C Hamano <>
2009-02-20Introduce the function strip_path_suffix()Johannes Schindelin
The function strip_path_suffix() will try to strip a given suffix from a given path. The suffix must start at a directory boundary (i.e. "core" is not a path suffix of "libexec/git-core", but "git-core" is). Arbitrary runs of directory separators ("slashes") are assumed identical. Example: strip_path_suffix("C:\\msysgit/\\libexec\\git-core", "libexec///git-core", &prefix) will set prefix to "C:\\msysgit" and return 0. Signed-off-by: Johannes Schindelin <> Acked-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2009-02-07Test and fix normalize_path_copy()Johannes Sixt
This changes the test-path-utils utility to invoke normalize_path_copy() instead of normalize_absolute_path() because the latter is about to be removed. The test cases in t0060 are adjusted in two regards: - normalize_path_copy() more often leaves a trailing slash in the result. This has no negative side effects because the new user of this function, longest_ancester_length(), already accounts for this behavior. - The function can fail. The tests uncover a flaw in normalize_path_copy(): If there are sufficiently many '..' path components so that the root is reached, such as in "/d1/s1/../../d2", then the leading slash was lost. This manifested itself that (assuming there is a repository at /tmp/foo) $ git add /d1/../tmp/foo/some-file reported 'pathspec is outside repository'. This is now fixed. Moreover, the test case descriptions of t0060 now include the test data and expected outcome. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2009-02-07Make test-path-utils more robust against incorrect useJohannes Sixt
Previously, this test utility happily returned with exit code 0 if garbage was thrown at it. Now it reports failure if an unknown function name was given on the command line. Signed-off-by: Johannes Sixt <> Signed-off-by: Junio C Hamano <>
2009-01-27test-path-utils: Fix off by one, found by valgrindJohannes Schindelin
When normalizing an absolute path, we might have to add a slash _and_ a NUL to the buffer, so the buffer was one too small. Let's just future proof the code and alloc PATH_MAX + 1 bytes. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
2008-05-23Add support for GIT_CEILING_DIRECTORIESDavid Reiss
Make git recognize a new environment variable that prevents it from chdir'ing up into specified directories when looking for a GIT_DIR. Useful for avoiding slow network directories. For example, I use git in an environment where homedirs are automounted and "ls /home/nonexistent" takes about 9 seconds. Setting GIT_CEILING_DIRS="/home" allows "git help -a" (for bash completion) and "git symbolic-ref" (for my shell prompt) to run in a reasonable time. Signed-off-by: David Reiss <> Signed-off-by: Junio C Hamano <>
2008-05-23Fold test-absolute-path into test-path-utilsDavid Reiss
Signed-off-by: David Reiss <> Signed-off-by: Junio C Hamano <>
2008-05-23Implement normalize_absolute_pathDavid Reiss
normalize_absolute_path removes several oddities form absolute paths, giving nice clean paths like "/dir/sub1/sub2". Also add a test case for this utility, based on a new test program (in the style of test-sha1). Signed-off-by: David Reiss <> Signed-off-by: Junio C Hamano <>