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

Short "git commit $file" syntax fails in the face of a resolved conflict

From
Asheesh Laroia <asheesh@asheesh.org>
Date
Jan 21, 2009, 21:00 UTC
Message-ID
<alpine.DEB.2.00.0901211549070.15860@vellum.laroia.net>

I have found what seems to be a bug in the short "git commit $file" mode of interaction with git. To reproduce it, you can:

1. Create a repository with some content.
 	$ (mkdir a ; cd a ; git init ; echo hi > file ; git add file ; git commit -m 'initial commit')
 	Initialized empty Git repository in /tmp/playground.2009-01-21.w15613/a/.git/
 	Created initial commit 276d6eb: initial commit
 	 1 files changed, 1 insertions(+), 0 deletions(-)
 	 create mode 100644 file
2. Clone that repository.
 	$ git clone a b
 	Initialized empty Git repository in /tmp/playground.2009-01-21.w15613/b/.git/
3. Create changes in "a" that are not yet cloned into "b".
 	$ (cd a ; echo ho > file ; git add file ; git commit -m update)
 	Created commit 91deff9: update
 	 1 files changed, 1 insertions(+), 1 deletions(-)
4. Make changes in "b", the clone.
 	$ echo lol > file
 	$ git add file ; git commit -m 'Some changes'
 	Created commit 5d74b5b: Some changes
 	 1 files changed, 1 insertions(+), 1 deletions(-)
5. Fetch and merge (AKA pull) from the first repo.
 	$ git pull
 	remote: Counting objects: 5, done.
 	remote: Total 3 (delta 0), reused 0 (delta 0)
 	Unpacking objects: 100% (3/3), done.
 	From /tmp/playground.2009-01-21.w15613/a/
 	   276d6eb..91deff9  master     -> origin/master
 	Auto-merged file
 	CONFLICT (content): Merge conflict in file
 	Automatic merge failed; fix conflicts and then commit the result.
6. Resolve the conflict (in our case, by discarding the changes in the "b" 
clone).
 	$ echo ho > file
7. Commit the resolved conflict.
NOTE: The normal way to do step 6 is to "git add file ; git commit -m 
yay". But I will now try to use the "git commit file" shorthand:
 	$ git commit file -m 'Resolved conflict'
 	fatal: cannot do a partial commit during a merge.
8. Declare a bug.

I believe that the "git commit file" command issued in step 6 should have worked as well as the "git add file ; git commit" that us old-time git users do.

9. Discuss on the git list.

Do y'all agree that the git behavior is strange and unnecessarily user-impeding here?

Cheers!
-- Asheesh.

P.S. I'm not the one who ran into the bad behavior here; Nathan (CC:d) is the one who did. You don't have to keep him CC:d, though.

-- 
Avoid gunfire in the bathroom tonight.
Next: Michael J Gruber
Message 1 of 17 in “Short "git commit $file" syntax fails in the face of a resolved conflict”
  1. Asheesh LaroiaJan 21, 2009
  2. Michael J GruberJan 21, 2009
  3. Nathan YerglerJan 21, 2009
  4. Johannes SixtJan 22, 2009
  5. Nanako ShiraishiJan 23, 2009
  6. Asheesh LaroiaJan 23, 2009
  7. Junio C HamanoJan 23, 2009
  8. 1/3 Add "partial commit" tests during a conflicted mergeJunio C Hamano, Jan 23, 2009
  9. Johannes SixtJan 23, 2009
  10. Junio C HamanoJan 23, 2009
  11. Johannes SixtJan 23, 2009
  12. Junio C HamanoJan 23, 2009
  13. 2/3 builtin-commit: shorten eye-sore overlong linesJunio C Hamano, Jan 23, 2009
  14. 3/3 git commit: pathspec without -i/-o implies -i semantics during a mergeJunio C Hamano, Jan 23, 2009
  15. Pieter de BieJan 23, 2009
  16. Junio C HamanoJan 23, 2009
  17. Michael J GruberJan 22, 2009

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.