Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: crash on ambiguous ref 'HEAD'#3425

Merged
asottile merged 1 commit intopre-commit:mainfrom
tusharsadhwani:ambiguous-ref
Mar 15, 2025
Merged

fix: crash on ambiguous ref 'HEAD'#3425
asottile merged 1 commit intopre-commit:mainfrom
tusharsadhwani:ambiguous-ref

Conversation

@tusharsadhwani
Copy link
Contributor

@tusharsadhwanitusharsadhwani commentedMar 13, 2025
edited
Loading

I lost the log when I faced this crash, but it was of the form:

CalledProcessError: ('git', 'diff', '--name-only', '--no-ext-diff', '-z', '-m', '1234abc', 'HEAD', 'MERGE_HEAD'): Ambiguous reference 'HEAD'... something about prepending '--', likegit diff ref [ref2] -- [files]

Likely happened because there is a folder namedhead in the base commit SHA.

And this fixes the issue. If you have more information on how I can create a minimal reproduction of the bug and add it as a test, I'd be happy to.

Copy link
Member

@asottileasottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

added a test which failed with:

=================================== FAILURES ===================================________________ test_get_conflicted_files_with_file_named_head ________________/home/asottile/workspace/pre-commit/tests/git_test.py:149: in test_get_conflicted_files_with_file_named_head    ret = set(git.get_conflicted_files())/home/asottile/workspace/pre-commit/pre_commit/git.py:127: in get_conflicted_files    cmd_output(/home/asottile/workspace/pre-commit/pre_commit/util.py:117: in cmd_output    returncode, stdout_b, stderr_b = cmd_output_b(*cmd, **kwargs)/home/asottile/workspace/pre-commit/pre_commit/util.py:111: in cmd_output_b    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)E   pre_commit.util.CalledProcessError: command: ('/usr/bin/git', 'diff', '--name-only', '--no-ext-diff', '-z', '-m', 'ab3e3cf46f673553f5d9ca374de5fe0d2a1989c8', 'HEAD', 'MERGE_HEAD')E   return code: 128E   stdout: (none)E   stderr:E       fatal: ambiguous argument 'HEAD': both revision and filenameE       Use '--' to separate paths from revisions, like this:E       'git <command> [<revision>...] -- [<file>...]'----------------------------- Captured stdout call -----------------------------[INFO] Checking merge-conflict files only.------------------------------ Captured log call -------------------------------INFO     pre_commit.git:git.py:115 Checking merge-conflict files only.=========================== short test summary info ============================FAILED tests/git_test.py::test_get_conflicted_files_with_file_named_head - pre_commit.util.CalledProcessError: command: ('/usr/bin/git', 'diff', '--na...================= 1 failed, 10 passed, 22 deselected in 0.56s ==================

@asottileasottile merged commitff7256c intopre-commit:mainMar 15, 2025
26 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asottileasottileasottile approved these changes

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@tusharsadhwani@asottile

[8]ページ先頭

©2009-2026 Movatter.jp