Skip to content

Keep path references in merge_file_from_index#520

Merged
jdavid merged 1 commit intolibgit2:masterfrom
cjwatson:merge-index-path-refs
May 3, 2015
Merged

Keep path references in merge_file_from_index#520
jdavid merged 1 commit intolibgit2:masterfrom
cjwatson:merge-index-path-refs

Conversation

@cjwatson
Copy link
Contributor

IndexEntry._to_c requires its caller to hold a reference to the path it
returns until it no longer needs the C structure.
Repository.merge_file_from_index was not doing so, causing the merge
text to contain garbage from freed memory in some cases.

IndexEntry._to_c requires its caller to hold a reference to the path it
returns until it no longer needs the C structure.
Repository.merge_file_from_index was not doing so, causing the merge
text to contain garbage from freed memory in some cases.
@carlosmn
Copy link
Member

The single-line expression works fine for the simpler expression, but once we're getting into tuples and negations, it would look a lot more readable if we had a function which had the logic instead of copying on each line, something like

def entry_to_maybe_c(entry):
    if entry is None:
        return ffi.NULL, ffi.NULL

    return entry._to_c()

@jdavid jdavid merged commit efb49f8 into libgit2:master May 3, 2015
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.

3 participants