mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
fix: crash on ambiguous ref 'HEAD'
This commit is contained in:
parent
7b88c63ae6
commit
b7eb412c79
2 changed files with 10 additions and 1 deletions
|
|
@ -126,7 +126,7 @@ def get_conflicted_files() -> set[str]:
|
|||
merge_diff_filenames = zsplit(
|
||||
cmd_output(
|
||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||
'-m', tree_hash, 'HEAD', 'MERGE_HEAD',
|
||||
'-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--',
|
||||
)[1],
|
||||
)
|
||||
return set(merge_conflict_filenames) | set(merge_diff_filenames)
|
||||
|
|
|
|||
|
|
@ -141,6 +141,15 @@ def test_get_conflicted_files_unstaged_files(in_merge_conflict):
|
|||
assert ret == {'conflict_file'}
|
||||
|
||||
|
||||
def test_get_conflicted_files_with_file_named_head(in_merge_conflict):
|
||||
resolve_conflict()
|
||||
open('HEAD', 'w').close()
|
||||
cmd_output('git', 'add', 'HEAD')
|
||||
|
||||
ret = set(git.get_conflicted_files())
|
||||
assert ret == {'conflict_file', 'HEAD'}
|
||||
|
||||
|
||||
MERGE_MSG = b"Merge branch 'foo' into bar\n\nConflicts:\n\tconflict_file\n"
|
||||
OTHER_MERGE_MSG = MERGE_MSG + b'\tother_conflict_file\n'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue