mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #3425 from tusharsadhwani/ambiguous-ref
fix: crash on ambiguous ref 'HEAD'
This commit is contained in:
commit
ff7256cedf
2 changed files with 10 additions and 1 deletions
|
|
@ -126,7 +126,7 @@ def get_conflicted_files() -> set[str]:
|
||||||
merge_diff_filenames = zsplit(
|
merge_diff_filenames = zsplit(
|
||||||
cmd_output(
|
cmd_output(
|
||||||
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
'git', 'diff', '--name-only', '--no-ext-diff', '-z',
|
||||||
'-m', tree_hash, 'HEAD', 'MERGE_HEAD',
|
'-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--',
|
||||||
)[1],
|
)[1],
|
||||||
)
|
)
|
||||||
return set(merge_conflict_filenames) | set(merge_diff_filenames)
|
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'}
|
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"
|
MERGE_MSG = b"Merge branch 'foo' into bar\n\nConflicts:\n\tconflict_file\n"
|
||||||
OTHER_MERGE_MSG = MERGE_MSG + b'\tother_conflict_file\n'
|
OTHER_MERGE_MSG = MERGE_MSG + b'\tother_conflict_file\n'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue