Is the Revert() API broken?

7 views
Skip to first unread message

David Ebbo

unread,
Apr 22, 2011, 2:34:53 AM4/22/11
to GitSharp
Been playing with GitSharp and loving it. But I'm not having much luck
performing a Checkout(). I run into problems in various scenarios, but
here is a simple one that shows some strangeness:

- On a simple test repo, make an (uncommitted) change to a file
- Try to revert the local change using GitSharp, with code like this

using (var repository = new Repository(@"D:\test")) {
repository.Branches["master"].Checkout();
}

Result:
Even though the change is reverted, running gitk shows that there is
still an empty list of 'Local uncommitted changes'.

This seems harmless in this case, but things get worse in more complex
scenarios that I can describe if needed (like trying to check out an
earlier revision). But since this basic scenario shows some
strangeness, I thought I'd start with that :)

Is there a problem with Checkout(), or am I not running it correctly?

thanks!
David

Meinrad Recheis

unread,
Apr 22, 2011, 5:58:58 PM4/22/11
to gits...@googlegroups.com
Hi David,

On Fri, Apr 22, 2011 at 8:34 AM, David Ebbo <david...@gmail.com> wrote:
Been playing with GitSharp and loving it. But I'm not having much luck
performing a Checkout(). I run into problems in various scenarios, but
here is a simple one that shows some strangeness:

- On a simple test repo, make an (uncommitted) change to a file
- Try to revert the local change using GitSharp, with code like this

           using (var repository = new Repository(@"D:\test")) {
               repository.Branches["master"].Checkout();
           }

Result:
Even though the change is reverted, running gitk shows that there is
still an empty list of 'Local uncommitted changes'.

Hmm, I was never completely sure if the implementation of Checkout was right, so
there might be some corner case bugs in it.


This seems harmless in this case, but things get worse in more complex
scenarios that I can describe if needed (like trying to check out an
earlier revision). But since this basic scenario shows some
strangeness, I thought I'd start with that :)

Is there a problem with Checkout(), or am I not running it correctly?

OK, I don't see a problem in your code snippet so I am assuming some kind of error.
I looked into the source of Branch.Checkout. It calls Branch.ResetHard() Which calls Index.Write() and
then calls WorkdirCheckout.Checkout() in GitSharp.Core (the java port). I am not sure
if the implementation of the GitSharp api is to blame or the WorkdirCheckout algorithm. However, I got
a feeling that it has something to do with the index.

You would need to check out the source and dig into this. Sorry, but I completely lack the time
to check it out myself. If you do this, be sure to have a look at the testcases of Branch.Checkout and Reset
so you get a feeling what is supposed to work.

Cheers,
-- henon


thanks!
David

--
For infos about GitSharp visit http://www.eqqon.com/index.php/GitSharp
To join this group visit http://groups.google.com/group/gitsharp

David Ebbo

unread,
Apr 22, 2011, 8:20:56 PM4/22/11
to GitSharp
Thanks Henon, I'll try to debug through it to see what's going on.

David
Reply all
Reply to author
Forward
0 new messages