Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Difference of behavior between native git and jgit



I think that’s a bug in JGit. I agree to Tomasz that jgit and cgit should behave the same here. I can also reproduce that in step 8 we loose the unsaved content in file a. That’s a severe bug you found. The semantic which git wants to provide is described in case 16 of [1]. When we are in step 8 of your test and inspect path ‘a’ then we find

-          In HEAD we see a tree

-          In worktree we see file with content x

-          In index we see file with content x

-          In MERGE (the commit which we want to checkout) a file with content y

In this situation ‘clean’ is true and ‘I==H’ and ‘I==M’ are both false. The result is that the checkout should fail. I’ll check why we haven’t detected that in our tests up to now and maybe a fix.






From: jgit-dev-bounces@xxxxxxxxxxx [mailto:jgit-dev-bounces@xxxxxxxxxxx] On Behalf Of Axel RICHARD
Sent: Donnerstag, 28. November 2013 10:49
To: jgit-dev@xxxxxxxxxxx
Subject: [jgit-dev] Difference of behavior between native git and jgit



I found a difference between native git and jgit. I try a simple test with few steps :

1. Create file 'a'
2. Add & Commit
3. Create branch 'br1'
4. Replace file 'a' (Rm 'a') by folder 'a' with a file 'c' inside
5. Add & Commit
6. Replace folder 'a' (Rm 'a') by a new file 'a'
7. Add 'a'
8. Checkout branch 'br1'

With native git, I get this message after the checkout: "error: Your local changes to the following files would be overwritten by checkout: a
Please, commit your changes or stash them before you can switch branches. Aborting"
But with jgit, there is no error after calling the checkout, and the file 'a' is deleted from the working tree.

Is it a normal behavior to have this difference ? Did I do something wrong in my test case ?

Thank you in advance


Back to the top