git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Bug report: 'git commit --dry-run' corner case: returns error ("nothing to commit") when all conflicts resolved to HEAD

From
OGOvidiu Gheorghioiu <ovidiug@gmail.com>
Date
Aug 26, 2015, 02:21 UTC
Message-ID
<CAPHyNCVJaJPzQpZGAuQY=SOXOCJyRMxYCOyjzc51oOweO8wiww@mail.gmail.com>
Hi git guys,

The bug is fairly simple: if we have a conflicted merge, AND all the conflicts have been resolved to the version in HEAD, the commit --dry-run error code says nothing to commit. As expected, git commit goes through.

The commit message IS correct (-ish), just not the error code:
"""
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

nothing to commit, working directory clean """

The script below demonstrates the problem; version tested was 2.5.0. Let me know if you need any more details.

Best, Ovidiu

------ #!/bin/bash mkdir test-repository || exit 1 cd test-repository git init echo "Initial contents, unimportant" > test-file git add test-file git commit -m "Initial commit" echo "commit-1-state" > test-file git commit -m "commit 1" -i test-file git tag commit-1 git checkout -b branch-2 HEAD^1 echo "commit-2-state" > test-file git commit -m "commit 2" -i test-file

# Creates conflicted state. git merge --no-commit commit-1

# Resolved entirely to commit-2, aka HEAD. echo "commit-2-state" > test-file # If we'd set to commit-1=state, all would work as expected (changes vs HEAD). git add test-file

# =====  Bug is here.
git commit --dry-run && echo "Git said something to commit" \
        || echo "Git said NOTHING to commit"
git commit -m "Something to commit after all" && echo "Commit went through"
git log --pretty=oneline
cd ..
Message 1 of 1 in “Bug report: 'git commit --dry-run' corner case: returns error ("nothing to commit") when all conflicts resolved to HEAD”
  1. Ovidiu GheorghioiuAug 26, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.