git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: John Nowak <john@johnnowak.com>
To: git@vger.kernel.org
Subject: reproducible unexpected behavior for 'git reset'
Date: Sun, 10 Jul 2011 18:30:31 -0400	[thread overview]
Message-ID: <75BBC138-2BD7-41F9-9D84-CEFF23CDC235@johnnowak.com> (raw)

(Apologies if you receive this twice. I sent the first copy before confirming my list subscription and I'm not sure if it went through.)

I am able to reproduce a scenario where, after a 'commit' and a 'stash pop' that results in a merge conflict, I need to 'reset' a file twice in order to get the index back to HEAD. It appears that the first 'reset' sets the index to the merge base version instead of HEAD which was, for me, rather unexpected. I encountered this on 1.7.4 but others have reproduced it on the latest master. If this behavior is documented, I cannot find it.

A transcript to reproduce this oddity is below; note how the file is partially staged after the first 'reset' and unstaged after the second:

---

$ git init
Initialized empty Git repository in /Users/jn/test/.git/

$ echo "a" > foo

$ git add foo

$ git commit -a -m "Initial"
[master (root-commit) 5214837] Initial
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 foo

$ echo "b" >> foo

$ git stash
Saved working directory and index state WIP on master: 5214837 Initial
HEAD is now at 5214837 Initial

$ echo "c" >> foo

$ git add foo

$ git commit -a -m "Added c"
[master 69eef48] Added c
1 files changed, 1 insertions(+), 0 deletions(-)

$ git stash pop
Auto-merging foo
CONFLICT (content): Merge conflict in foo

$ git status
# On branch master
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#	both modified:      foo
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git reset foo
Unstaged changes after reset:
M	foo

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   foo
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   foo
#

$ git reset foo
Unstaged changes after reset:
M	foo

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   foo
#
no changes added to commit (use "git add" and/or "git commit -a")

             reply	other threads:[~2011-07-10 22:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-10 22:30 John Nowak [this message]
2011-07-11 21:54 ` reproducible unexpected behavior for 'git reset' Junio C Hamano
2011-07-11 22:41   ` Junio C Hamano
2011-07-14  6:01     ` Junio C Hamano
2011-07-19 18:13       ` [PATCH 0/2] refactoring diff-index Junio C Hamano
2011-07-19 18:13         ` [PATCH 1/2] diff-lib: simplify do_diff_cache() Junio C Hamano
2011-07-19 20:14           ` Jeff King
2011-07-19 21:28             ` Junio C Hamano
2011-07-19 18:13         ` [PATCH 2/2] diff-lib: refactor run_diff_index() and do_diff_cache() Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2011-07-10 22:02 reproducible unexpected behavior for 'git reset' John Nowak

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=75BBC138-2BD7-41F9-9D84-CEFF23CDC235@johnnowak.com \
    --to=john@johnnowak.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).