rerere: Skip mismatched marker sizes like git-rerere does#95
Conversation
|
Looks good. |
|
Yes — I actually have a commit that uses def get_git_attr(repo: Repository, file: Path, attr_name: str) -> bytes:
# TODO: Batch multiple paths, attrs and cache them. Keep the process open like with cat-file.
# Result format is:
# <path> NUL <attribute> NUL <value> NUL
result = repo.git("check-attr", "--cached", "-z", attr_name, "--", file)
# Note that check-attr respects cwd, so if we want to use relative paths,
# these would be relative too.
# The response name is exactly the input, not normalized:
# if we ask for "Foo" vs "foo" vs "./foo", the value we asked for is in the response.
(resp_path, resp_attr_name, value) = result.split(b"\0", maxsplit=3)[:-1]
assert os.fsdecode(resp_path) == str(file)
assert resp_attr_name.decode() == attr_name
return value
def get_conflict_marker_size(repo: Repository, file: Path) -> int:
# See ll_merge_marker_size in git/ll-merge.c
value = get_git_attr(repo, file, "conflict-marker-size")
try:
if value != b"unspecified":
return int(value)
except ValueError:
pass
return DEFAULT_CONFLICT_MARKER_SIZE |
|
Oh, woops, my reply above refers to yet another branch which I did intend to PR, which factors that marker_size value out. I'll push that up. EDIT: See #101 |
3225bbb to
b01a1de
Compare
git-rerere strictly ignores conflict markers that are not exactly the expected length. For `<` and `>`, it also requires them to end in a space. See git/rerere.c:is_cmarker
b01a1de to
6c9f365
Compare
|
Thanks for the fix :-) |
When parsing conflicts,
git-rerereignores/preserves conflict markers that are not exactly the expected length, which defaults to 7.For
<<<<<<<and>>>>>>>, it also requires them to end in a space, to avoid ambiguity.See
git/rerere.c:is_cmarkerfor reference + additional commentary.This updates git-revise's parsing to treat them the same way.