Thanks to visit codestin.com
Credit goes to github.com

Skip to content

index: canonicalize inserted paths safely #3534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2015

Conversation

ethomson
Copy link
Member

@ethomson ethomson commented Dec 3, 2015

When adding to the index, we look to see if a portion of the given
path matches a portion of a path in the index. If so, we will use
the existing path information. For example, when adding foo/bar.c,
if there is an index entry to FOO/other and the filesystem is case
insensitive, then we will put bar.c into the existing tree instead
of creating a new one with a different case.

Use strncmp to do that instead of memcmp. When we bsearch
into the index, we locate the position where the new entry would
go. The index entry at that position does not necessarily have
a relation to the entry we're adding, so we cannot make assumptions
and use memcmp. Instead, compare them as strings.

When canonicalizing paths, we look for the first index entry that
matches a given substring.

FIxes #3533

When adding to the index, we look to see if a portion of the given
path matches a portion of a path in the index.  If so, we will use
the existing path information.  For example, when adding `foo/bar.c`,
if there is an index entry to `FOO/other` and the filesystem is case
insensitive, then we will put `bar.c` into the existing tree instead
of creating a new one with a different case.

Use `strncmp` to do that instead of `memcmp`.  When we `bsearch`
into the index, we locate the position where the new entry would
go.  The index entry at that position does not necessarily have
a relation to the entry we're adding, so we cannot make assumptions
and use `memcmp`.  Instead, compare them as strings.

When canonicalizing paths, we look for the first index entry that
matches a given substring.
carlosmn added a commit that referenced this pull request Dec 3, 2015
index: canonicalize inserted paths safely
@carlosmn carlosmn merged commit 2d36e14 into libgit2:master Dec 3, 2015
@ethomson ethomson deleted the index_canonicalize_fix branch February 29, 2016 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants