-
-
Notifications
You must be signed in to change notification settings - Fork 400
[RFC] Repository: get all values from git_merge_file_from_index #1376
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -682,9 +682,15 @@ def merge_file_from_index( | |
ancestor: typing.Union[None, IndexEntry], | ||
ours: typing.Union[None, IndexEntry], | ||
theirs: typing.Union[None, IndexEntry], | ||
) -> str: | ||
"""Merge files from index. Return a string with the merge result | ||
containing possible conflicts. | ||
return_full: bool = False, | ||
) -> typing.Union[str, tuple[bool, str, int, typing.Union[str, None]]]: | ||
"""Merge files from index. | ||
|
||
Returns: A string with the content of the file containing | ||
possible conflicts. | ||
If return_full then it returns a tuple containing | ||
whether the file is automergeable, the content of the file, | ||
the filemode and the path. | ||
|
||
ancestor | ||
The index entry which will be used as a common | ||
|
@@ -693,6 +699,8 @@ def merge_file_from_index( | |
The index entry to take as "ours" or base. | ||
theirs | ||
The index entry which will be merged into "ours" | ||
return_full | ||
Whether to return the full output of the low-level call. | ||
""" | ||
cmergeresult = ffi.new('git_merge_file_result *') | ||
|
||
|
@@ -709,10 +717,16 @@ def merge_file_from_index( | |
) | ||
check_error(err) | ||
|
||
ret = ffi.string(cmergeresult.ptr, cmergeresult.len).decode('utf-8') | ||
automergeable = cmergeresult.automergeable != 0 | ||
content = ffi.string(cmergeresult.ptr, cmergeresult.len).decode('utf-8') | ||
filemode = cmergeresult.mode | ||
path = cmergeresult.path | ||
C.git_merge_file_result_free(cmergeresult) | ||
|
||
return ret | ||
if not return_full: | ||
return content | ||
|
||
return automergeable, content, filemode, path | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you return a smarter object, like a dataclass? With the name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep... will do both things. Thanks for the feedback. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unit tests too please. Thanks! |
||
|
||
def merge_commits( | ||
self, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a deprecation warning?