git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bug] git stash generates a different diff then other commands (diff, add, etc) resulting in merge conflicts!
@ 2013-08-08  7:07 Luke San Antonio
  2013-08-08 20:54 ` Phil Hord
  0 siblings, 1 reply; 5+ messages in thread
From: Luke San Antonio @ 2013-08-08  7:07 UTC (permalink / raw)
  To: git

Hi, my name's Luke!

Today, I had a problem merging a stash after immediately creating it.
This is exactly what I did!

git stash save --keep-index
git stash pop

And BAM! Merge conflict! This was especially weird because my file had
this in it (taken directly from my code!)

<<<<<<< Updated upstream
     *
     * It should be used and passed along to member objects by GameStates!
     *
=======
     *
     * It should be used and passed along to member objects by GameStates!
     *
>>>>>>> Stashed changes

They are exactly the same!

Oh, by the way, I should mention that I did not edit any hunks to get
the index the way I wanted it, I have read that doing that causes
merge conflicts similar to this!

Then I got a hunch! I realized that git will refrain from applying a
hunk if it finds it already was applied exactly (that's correct
right?)... So I thought, maybe the patches are similar (represent the
same changes) but aren't *exactly* the same.

I was right!

After saving the stash I take a look at the diff: (git stash show -p)

     /*!
-     * \brief The default font renderer, global to all who have a pointer to
-     * the Game class.
+     * \brief The font renderer implementation, obtained from the config file.
+     *
+     * It should be used and passed along to member objects by GameStates!
      *
-     * It need not be used at all!
+     * \note It can be cached, but not between GameStates, meaning it should be
+     * cached again every time a new GameState is constructed!
      */

After that, I take a look at the diff in my index: (git diff --staged)

     /*!
-     * \brief The default font renderer, global to all who have a pointer to
-     * the Game class.
+     * \brief The font renderer implementation, obtained from the config file.
      *
-     * It need not be used at all!
+     * It should be used and passed along to member objects by GameStates!
+     *
+     * \note It can be cached, but not between GameStates, meaning it should be
+     * cached again every time a new GameState is constructed!
      */

Aha! A difference, a difference so tiny it went unnoticed by me, but not by git!

Now the housekeeping:

What I wanted to do:

Apply a stash on top of a 'kept' index.

What I did:

git stash save --keep-index
git stash pop

What I saw happen:

A merge conflict between the same changes (see above).

What I expected to see:

No merge conflict.

How are these different:

The conflict, which shouldn't happen since the changes introduced were the same!

-------------------------------------------------

It seems to me like the stash command is using a slightly different
diff algorithm...
Can anyone explain to me what's going on under the hood so I can
understand this subtle difference? Does anyone know?

Thanks in advance, I'm sure you all will be very helpful!
- Luke

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-08-16  0:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-08  7:07 [Bug] git stash generates a different diff then other commands (diff, add, etc) resulting in merge conflicts! Luke San Antonio
2013-08-08 20:54 ` Phil Hord
2013-08-12  5:29   ` Luke San Antonio
     [not found]     ` <CABURp0rWMAs9vT791vp4BEYS-Y9Jmzjmt4bbuB+po8=vkiqUWQ@mail.gmail.com>
2013-08-13  5:31       ` Luke San Antonio
2013-08-16  0:05         ` Phil Hord

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 NNTP newsgroup(s).