<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/test-path-utils.c, branch v2.7.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.7.3</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.7.3'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2016-02-22T22:51:09Z</updated>
<entry>
<title>test-path-utils: fix normalize_path_copy output buffer size</title>
<updated>2016-02-22T22:51:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-02-22T22:44:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=62f17513e7113b7139e925df76d37f3d7df6b38c'/>
<id>urn:sha1:62f17513e7113b7139e925df76d37f3d7df6b38c</id>
<content type='text'>
The normalize_path_copy function needs an output buffer that
is at least as long as its input (it may shrink the path,
but never expand it). However, this test program feeds it
static PATH_MAX-sized buffers, which have no relation to the
input size.

In the normalize_ceiling_entry case, we do at least check
the size against PATH_MAX and die(), but that case is even
more convoluted. We normalize into a fixed-size buffer, free
the original, and then replace it with a strdup'd copy of
the result. But normalize_path_copy explicitly allows
normalizing in-place, so we can simply do that.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t0060: loosen overly strict expectations</title>
<updated>2016-01-15T17:26:20Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2016-01-14T06:48:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=371471cea38cb4b5834c9e5715e1fe633829004f'/>
<id>urn:sha1:371471cea38cb4b5834c9e5715e1fe633829004f</id>
<content type='text'>
The dirname() tests file were developed and tested on only the five
platforms available to the developer at the time, namely: Linux (both 32
and 64bit), Windows XP 32-bit (MSVC), MinGW 32-bit and Cygwin 32-bit.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html
(i.e. the POSIX spec) says, in part:

	If the string pointed to by path consists entirely of the '/'
	character, basename() shall return a pointer to the string "/".
	If the string pointed to by path is exactly "//", it is
	implementation-defined whether "/" or "//" is returned.

The thinking behind testing precise, OS-dependent output values was to
document that different setups produce different values. However, as the
test failures on MacOSX illustrated eloquently: hardcoding pretty much each
and every setup's expectations is pretty fragile.

This is not limited to the "//" vs "/" case, of course, other inputs are
also allowed to produce multiple outputs by the POSIX specs.

So let's just test for all allowed values and be done with it. This still
documents that Git cannot rely on one particular output value in those
cases, so the intention of the original tests is still met.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t0060: verify that basename() and dirname() work as expected</title>
<updated>2016-01-12T18:41:34Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2016-01-12T07:57:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7d1aaa684d42964b8b287b8c9450184dfd5bce85'/>
<id>urn:sha1:7d1aaa684d42964b8b287b8c9450184dfd5bce85</id>
<content type='text'>
Unfortunately, some libgen implementations yield outcomes different
from what Git expects. For example, mingw-w64-crt provides a basename()
function, that shortens `path0/` to `path`!

So let's verify that the basename() and dirname() functions we use
conform to what Git expects.

Derived-from-code-by: Ramsay Jones &lt;ramsay@ramsayjones.plus.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test-path-utils.c: remove incorrect assumption</title>
<updated>2015-10-09T01:03:50Z</updated>
<author>
<name>Ray Donnelly</name>
<email>mingw.android@gmail.com</email>
</author>
<published>2015-10-01T19:04:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b2a7123b997f950e9785a5e7df64c3104270fef3'/>
<id>urn:sha1:b2a7123b997f950e9785a5e7df64c3104270fef3</id>
<content type='text'>
In normalize_ceiling_entry(), we test that normalized paths end with
slash, *unless* the path to be normalized was already the root
directory.

However, normalize_path_copy() does not even enforce this condition.

Even worse: on Windows, the root directory gets translated into a
Windows directory by the Bash before being passed to `git.exe` (or
`test-path-utils.exe`), which means that we cannot even know whether
the path that was passed to us was the root directory to begin with.

This issue has already caused endless hours of trying to "fix" the
MSYS2 runtime, only to break other things due to MSYS2 ensuring that
the converted path maintains the same state as the input path with
respect to any final '/'.

So let's just forget about this test. It is non-essential to Git's
operation, anyway.

Acked-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Ray Donnelly &lt;mingw.android@gmail.com&gt;
</content>
</entry>
<entry>
<title>path-utils test: rename mingw_path function to print_path</title>
<updated>2013-10-14T14:32:53Z</updated>
<author>
<name>Sebastian Schuberth</name>
<email>sschuberth@gmail.com</email>
</author>
<published>2013-10-10T20:49:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7ffd18fce1eef2670661c2e7fd0cb3ef0b8b7fb7'/>
<id>urn:sha1:7ffd18fce1eef2670661c2e7fd0cb3ef0b8b7fb7</id>
<content type='text'>
mingw_path was introduced in abd4284 to output a mangled path as it is
passed as an argument to main(). But the name is misleading because
mangling does not come from MinGW, but from MSYS [1]. As abd4284 does not
introduce any MSYS or MinGW specific code but just prints out argv[2] as
it is passed to main(), give the function the more generic and less
confusing name "print_path".

[1] http://www.mingw.org/wiki/Posix_path_conversion

Signed-off-by: Sebastian Schuberth &lt;sschuberth@gmail.com&gt;
Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
</content>
</entry>
<entry>
<title>test: run testcases with POSIX absolute paths on Windows</title>
<updated>2013-06-26T18:25:12Z</updated>
<author>
<name>Jiang Xin</name>
<email>worldhello.net@gmail.com</email>
</author>
<published>2013-06-25T15:53:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=abd4284bc62127a2db69c8c81501a56bb29284c8'/>
<id>urn:sha1:abd4284bc62127a2db69c8c81501a56bb29284c8</id>
<content type='text'>
Some test cases are skipped on Windows by marking with POSIX prereq.
This is because arguments look like absolute paths (such as /a/b)
for regular Windows programs (*.exe executables, no bash scripts)
are changed to Windows paths (like C:/msysgit/a/b).

There is no cygpath nor equivalent on msysGit, but it is easy to
write one. New subcommand "mingw_path" is added in test-path-utils,
so that we can get the expected absolute paths on Windows. E.g.

    COMMAND LINE                        Linux output  Windows output
    ==================================  ============  ===============
    test-path-utils mingw_path /        /             C:/msysgit
    test-path-utils mingw_path /a/b/    /a/b/         C:/msysgit/a/b/

With this utility, most skipped test cases in t0060 can be turned on
to be tested correctly on Windows.

Signed-off-by: Jiang Xin &lt;worldhello.net@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>path.c: refactor relative_path(), not only strip prefix</title>
<updated>2013-06-26T16:59:00Z</updated>
<author>
<name>Jiang Xin</name>
<email>worldhello.net@gmail.com</email>
</author>
<published>2013-06-25T15:53:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e02ca72f70ed8f0268a81f72cb3230c72e538e77'/>
<id>urn:sha1:e02ca72f70ed8f0268a81f72cb3230c72e538e77</id>
<content type='text'>
Original design of relative_path() is simple, just strip the prefix
(*base) from the absolute path (*abs).

In most cases, we need a real relative path, such as: ../foo,
../../bar.  That's why there is another reimplementation
(path_relative()) in quote.c.

Borrow some codes from path_relative() in quote.c to refactor
relative_path() in path.c, so that it could return real relative
path, and user can reuse this function without reimplementing
his/her own.  The function path_relative() in quote.c will be
substituted, and I would use the new relative_path() function when
implementing the interactive git-clean later.

Different results for relative_path() before and after this refactor:

    abs path  base path  relative (original)  relative (refactor)
    ========  =========  ===================  ===================
    /a/b      /a/b       .                    ./
    /a/b/     /a/b       .                    ./
    /a        /a/b/      /a                   ../
    /         /a/b/      /                    ../../
    /a/c      /a/b/      /a/c                 ../c
    /x/y      /a/b/      /x/y                 ../../x/y

    a/b/      a/b/       .                    ./
    a/b/      a/b        .                    ./
    a         a/b        a                    ../
    x/y       a/b/       x/y                  ../../x/y
    a/c       a/b        a/c                  ../c

    (empty)   (null)     (empty)              ./
    (empty)   (empty)    (empty)              ./
    (empty)   /a/b       (empty)              ./
    (null)    (null)     (null)               ./
    (null)    (empty)    (null)               ./
    (null)    /a/b       (segfault)           ./

You may notice that return value "." has been changed to "./".
It is because:

 * Function quote_path_relative() in quote.c will show the relative
   path as "./" if abs(in) and base(prefix) are the same.

 * Function relative_path() is called only once (in setup.c), and
   it will be OK for the return value as "./" instead of ".".

Signed-off-by: Jiang Xin &lt;worldhello.net@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test: add test cases for relative_path</title>
<updated>2013-06-26T16:30:26Z</updated>
<author>
<name>Jiang Xin</name>
<email>worldhello.net@gmail.com</email>
</author>
<published>2013-06-25T15:53:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=203439b2840c4c384060df2fa192994e4b6740ed'/>
<id>urn:sha1:203439b2840c4c384060df2fa192994e4b6740ed</id>
<content type='text'>
Add subcommand "relative_path" in test-path-utils, and add test cases
in t0060.

Johannes tested an earlier version of this patch on Windows, and
found that some relative_path tests should be skipped on
Windows. This is because the bash on Windows rewrites arguments of
regular Windows programs, such as git and the test helpers, if the
arguments look like absolute POSIX paths. As a consequence, the
actual tests performed are not what the tests scripts expect.

The tests that need *not* be skipped are those where the two paths passed
to 'test-path-utils relative_path' have the same prefix and the result is
expected to be a relative path. This is because the rewriting changes
"/a/b" to "D:/Src/MSysGit/a/b", and when both inputs are extended the same
way, this just cancels out in the relative path computation.

Signed-off-by: Jiang Xin &lt;worldhello.net@gmail.com&gt;
Helped-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>longest_ancestor_length(): require prefix list entries to be normalized</title>
<updated>2012-10-29T06:34:58Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2012-10-28T16:16:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9e2326c7e1efb1ae42b17e3fa38c16711a8d0bd8'/>
<id>urn:sha1:9e2326c7e1efb1ae42b17e3fa38c16711a8d0bd8</id>
<content type='text'>
Move the responsibility for normalizing prefixes from
longest_ancestor_length() to its callers. Use slightly different
normalizations at the two callers:

In setup_git_directory_gently_1(), use the old normalization, which
ignores paths that are not usable.  In the next commit we will change
this caller to also resolve symlinks in the paths from
GIT_CEILING_DIRECTORIES as part of the normalization.

In "test-path-utils longest_ancestor_length", use the old
normalization, but die() if any paths are unusable.  Also change t0060
to only pass normalized paths to the test program (no empty entries or
non-absolute paths, strip trailing slashes from the paths, and remove
tests that thereby become redundant).

The point of this change is to reduce the scope of the ancestor_length
tests in t0060 from testing normalization+longest_prefix to testing
only mostly longest_prefix.  This is necessary because when
setup_git_directory_gently_1() starts resolving symlinks as part of
its normalization, it will not be reasonable to do the same in the
test suite, because that would make the test results depend on the
contents of the root directory of the filesystem on which the test is
run.  HOWEVER: under Windows, bash mangles arguments that look like
absolute POSIX paths into DOS paths.  So we have to retain the level
of normalization done by normalize_path_copy() to convert the
bash-mangled DOS paths (which contain backslashes) into paths that use
forward slashes.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
</content>
</entry>
<entry>
<title>longest_ancestor_length(): take a string_list argument for prefixes</title>
<updated>2012-10-29T06:34:58Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2012-10-28T16:16:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31171d9e454d71144685866cfd6476b8ac69d314'/>
<id>urn:sha1:31171d9e454d71144685866cfd6476b8ac69d314</id>
<content type='text'>
Change longest_ancestor_length() to take the prefixes argument as a
string_list rather than as a colon-separated string.  This will make
it easier for the caller to alter the entries before calling
longest_ancestor_length().

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
</content>
</entry>
</feed>
