Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Fix handling of long recursive paths #113

Closed
wants to merge 1 commit into from

Conversation

vangdfang
Copy link

The commit in #86 attempted to better handle recursive
paths that would exceed MAX_PATH on Windows, since the paths would
be too long to fit in Git's buffers when expressed relatively,
but could easily fit when reduced back to a canonical path. This
also adds a testcase that was lacking from the original commit that
attempts to describe the behavior.

Also, #111 attempted to work around a bug that
#86 introduced. This partially reverts the change,
but it keeps the concept of checking for the special device names
using string lists as a better way to detect if a path should
not be manipulated.

Finally, it is not documented clearly in the Windows API, but
GetFullPathNameW() actually may require a string longer than the
actual output length, so we use a temp buffer that is twice as
long. Windows is able to resolve the relative path, even if
the relative path is longer than 260 characters, since the
function doesn't actually check for a valid name. There is a bit
of a red herring that it is limited to MAX_PATH characters, and
while that may be true of the input string (such as, you cannot
have a relative path longer than MAX_PATH), the temporary space
needed may be longer, but the output still needs to be less than
MAX_PATH characters without using "?".

Signed-off-by: Doug Kelly [email protected]

The commit in msysgit#86 attempted to better handle recursive
paths that would exceed MAX_PATH on Windows, since the paths would
be too long to fit in Git's buffers when expressed relatively,
but could easily fit when reduced back to a canonical path.  This
also adds a testcase that was lacking from the original commit that
attempts to describe the behavior.

Also, msysgit#111 attempted to work around a bug that
msysgit#86 introduced.  This partially reverts the change,
but it keeps the concept of checking for the special device names
using string lists as a better way to detect if a path should
not be manipulated.

Finally, it is not documented clearly in the Windows API, but
GetFullPathNameW() actually may require a string longer than the
actual output length, so we use a temp buffer that is twice as
long.  Windows is able to resolve the relative path, even if
the relative path is longer than 260 characters, since the
function doesn't actually check for a valid name. There is a bit
of a red herring that it is limited to MAX_PATH characters, and
while that may be true of the input string (such as, you cannot
have a relative path longer than MAX_PATH), the temporary space
needed may be longer, but the output still needs to be less than
MAX_PATH characters without using "\\?\".

Signed-off-by: Doug Kelly <[email protected]>
@vangdfang
Copy link
Author

@dscho @kblees This should clean up based on the feedback in #86 in addition to adding the testcase. Please let me know what comments you have, and I'll be more than happy to address them.

@dscho
Copy link
Member

dscho commented Feb 17, 2014

Closed in favor of #122.

@dscho dscho closed this Feb 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants