{"thread":{"id":"40177","subject":"Bug report: 'git commit --dry-run' corner case: returns error (\"nothing to commit\") when all conflicts resolved to HEAD","startedAt":"2015-08-26T02:21:03Z","lastAt":"2015-08-26T02:21:03Z","messageCount":1,"participants":["Ovidiu Gheorghioiu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"268709","messageId":"CAPHyNCVJaJPzQpZGAuQY=SOXOCJyRMxYCOyjzc51oOweO8wiww@mail.gmail.com","threadId":"40177","inReplyTo":null,"subject":"Bug report: 'git commit --dry-run' corner case: returns error (\"nothing to commit\") when all conflicts resolved to HEAD","fromName":"Ovidiu Gheorghioiu","fromEmail":"ovidiug@gmail.com","sentAt":"2015-08-26T02:21:03Z","receivedAt":"2015-08-26T02:21:03Z","isPatch":false,"sender":{"key":"ovidiug@gmail.com","avatar":null},"body":"Hi git guys,\n\nThe bug is fairly simple: if we have a conflicted merge, AND all the\nconflicts have been resolved to the version in HEAD, the commit\n--dry-run error code says nothing to commit. As expected, git commit\ngoes through.\n\nThe commit message IS correct (-ish), just not the error code:\n\n\"\"\"\nAll conflicts fixed but you are still merging.\n  (use \"git commit\" to conclude merge)\n\nnothing to commit, working directory clean\n\"\"\"\n\nThe script below demonstrates the problem; version tested was 2.5.0.\nLet me know if you need any more details.\n\nBest,\nOvidiu\n\n------\n#!/bin/bash\nmkdir test-repository || exit 1\ncd test-repository\ngit init\necho \"Initial contents, unimportant\" > test-file\ngit add test-file\ngit commit -m \"Initial commit\"\necho \"commit-1-state\" > test-file\ngit commit -m \"commit 1\" -i test-file\ngit tag commit-1\ngit checkout -b branch-2 HEAD^1\necho \"commit-2-state\" > test-file\ngit commit -m \"commit 2\" -i test-file\n\n# Creates conflicted state.\ngit merge --no-commit commit-1\n\n# Resolved entirely to commit-2, aka HEAD.\necho \"commit-2-state\" > test-file\n# If we'd set to commit-1=state, all would work as expected (changes vs HEAD).\ngit add test-file\n\n# =====  Bug is here.\ngit commit --dry-run && echo \"Git said something to commit\" \\\n        || echo \"Git said NOTHING to commit\"\n\ngit commit -m \"Something to commit after all\" && echo \"Commit went through\"\n\ngit log --pretty=oneline\n\ncd ..\n"}]}