Hi,

At $dayjob we have some simple "code quality" checks that we run to
make sure that things are heading in the right direction. These are
usually run as part of our automated builds but people occasionally
run them when merging updates from other teams or preparing to merge
to the integration branch.

The typical invocation is something like
  git checkout HEAD^
  score1=$(script.sh)
  git checkout master
  score2=$(script.sh)
  # compare scores ...

The problem is that if this is run after resolving merge conflicts but
before committing the changes (i.e. the merge resolution is in the
index) the fact that a merge was in progress is lost. I have modified
script.sh to check for a clean work tree but I'm wondering if this is
actually a bug worth fixing.

Here's a simple reproduction (apologies in advance for gmails wrapping)

  $ git --version
  git version 1.8.4.rc2
  $ git init
  $ for x in a b c d e f; do echo "$x" >"${x}.txt"; git add
"${x}.txt"; git commit -m"Add ${x}.txt"; done
  $ git checkout -b foo HEAD^^^
  $ for x in d e f; do echo "x" >"${x}.txt"; git add "${x}.txt"; git
commit -m"Add ${x}.txt"; done
  $ git checkout master
  $ git merge foo
  $ git mergetool

  # At this point the conflict resolution is in the index as expected

  $ git checkout HEAD^
  error: Your local changes to the following files would be
overwritten by checkout:
        f.txt
  Please, commit your changes or stash them before you can switch branches.
  Aborting

  # OK so far so good. Checkout failed and we're still in a mergey state

  $ ll .git
  drwxr-xr-x  2 chrisp swdept 4096 Sep  4 17:47 info/
  drwxr-xr-x  3 chrisp swdept 4096 Sep  4 17:49 logs/
  -rw-r--r--  1 chrisp swdept   41 Sep  4 17:51 MERGE_HEAD
  -rw-r--r--  1 chrisp swdept    0 Sep  4 17:51 MERGE_MODE
  -rw-r--r--  1 chrisp swdept   52 Sep  4 17:51 MERGE_MSG
  -rw-r--r--  1 chrisp swdept  141 Sep  4 17:51 MERGE_RR
  drwxr-xr-x 40 chrisp swdept 4096 Sep  4 17:52 objects/
  -rw-r--r--  1 chrisp swdept   41 Sep  4 17:51 ORIG_HEAD

  $ git checkout master
  M       d.txt
  M       e.txt
  M       f.txt
  Already on 'master'

  # Hmm, that kind of indicates that it did something but "Already on
'master'" makes me think it was a noop

  $ ll .git
  drwxr-xr-x  2 chrisp swdept 4096 Sep  4 17:47 info/
  drwxr-xr-x  3 chrisp swdept 4096 Sep  4 17:49 logs/
  drwxr-xr-x 40 chrisp swdept 4096 Sep  4 17:52 objects/
  -rw-r--r--  1 chrisp swdept   41 Sep  4 17:51 ORIG_HEAD

  # mergey state is lost but the changes are still in the index.

Cheers,
Chris
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to