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

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

From
SSStephen & Linda Smith <ischis2@cox.net>
Date
Feb 12, 2016, 01:04 UTC
Message-ID
<2471685.OJU1dNe0yn@thunderbird>
In-Reply-To
<1649296.sC1eN3ni6k@thunderbird>
On Monday, February 08, 2016 06:55:17 PM Stephen & Linda Smith wrote:
Show 25 quoted lines
> > #!/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"

With the '--dry-run' switch, dry_run_commit() is called which returns 1 since run_status() is returning the wt_status commitable field which has a value of 0.

That field is only set in one place (wt_status_print_updated) which isn't getting called directly or indirectly by run_status. I checked this by code inspection as well as by instrumenting the code.

I'm not sure that we want to add a call to wt_status_print_updated in run_status since I don't believe we want the print statements. An alternative might be to create a new function.

> > 
> > git commit -m "Something to commit after all" && echo "Commit went through"
> > 
> > git log --pretty=oneline
Previous: Stephen & Linda Smith
Message 16 of 16 in “Re: Bug report: 'git commit --dry-run' corner case: returns error ("nothing to commit") when all conflicts resolved to HEAD”
  1. Stephen & Linda SmithFeb 9, 2016
  2. wt-status.c: set commitable bit if there is a meaningful merge.Stephen P. Smith, Feb 16, 2016
  3. Philip OakleyFeb 16, 2016
  4. Junio C HamanoFeb 16, 2016
  5. Stephen & Linda SmithFeb 16, 2016
  6. Stephen & Linda SmithFeb 16, 2016
  7. Stephen & Linda SmithFeb 16, 2016
  8. Junio C HamanoFeb 17, 2016
  9. wt-status.c: set commitable bit if there is a meaningful merge.Stephen P. Smith, Feb 17, 2016
  10. Stephen & Linda SmithFeb 17, 2016
  11. Stephen & Linda SmithMay 10, 2016
  12. Stephen SmithAug 22, 2018
  13. Junio C HamanoAug 22, 2018
  14. Junio C HamanoAug 22, 2018
  15. Stephen & Linda SmithAug 23, 2018
  16. Stephen & Linda SmithFeb 12, 2016

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.