git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ovidiu Gheorghioiu <ovidiug@gmail.com>
To: git@vger.kernel.org
Subject: Bug report: 'git commit --dry-run' corner case: returns error ("nothing to commit") when all conflicts resolved to HEAD
Date: Tue, 25 Aug 2015 19:21:03 -0700	[thread overview]
Message-ID: <CAPHyNCVJaJPzQpZGAuQY=SOXOCJyRMxYCOyjzc51oOweO8wiww@mail.gmail.com> (raw)

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 ..

             reply	other threads:[~2015-08-26  2:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-26  2:21 Ovidiu Gheorghioiu [this message]
     [not found] <1649296.sC1eN3ni6k@thunderbird>
2016-02-09  1:55 ` Bug report: 'git commit --dry-run' corner case: returns error ("nothing to commit") when all conflicts resolved to HEAD Stephen & Linda Smith
2016-02-12  1:04 ` Stephen & Linda Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPHyNCVJaJPzQpZGAuQY=SOXOCJyRMxYCOyjzc51oOweO8wiww@mail.gmail.com' \
    --to=ovidiug@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).