Skip to content

Following example repo fails in status result & branch switching #340

yishaigalatzer opened this Issue Feb 18, 2013 · 13 comments

5 participants


Version taken from 2/18/2013 libgit2sharp vNext branch

See example zipped repo:

status will return modified for one of the files, but CLI returns (correctly) unchanged.
branch checkout fails in libgit2sharp but not in CLI.

To create this repo:

Use libgit2sharp for all actions unless CLI is specified.

Init an empty folder
Drop a text file
stage and commit
Create a new local branch
Checkout the branch
Drop a second text file

{CLI}git add -A
{CLI}git commit -m "message"

Back to libgit2sharp
checkout the original master branch (FAIL)

This is the first and more critical issue.

Now zip up the folder (which I was doing just to get a neat repro example)
Extract all the files to another folder

Get Status from libgit2sharp (the second file shows up as modified)
{CLI}git status -> no changes detected
Back to libgit2sharp (the second file shows as no changes)

Branch checkout still does not work

** Comment: I don't always see the branch checkout fail. I haven't figured out when it doesn't but having a CLI window open in the folder helps to make it fail

libgit2 member

status will return modified for one of the files, but CLI returns (correctly) unchanged.

@yishaigalatzer Sorry, but I can't reproduce this. I unzipped the provided in D:\Temp\ and the following test pass against 3a7ec78. Did I miss anything?

public void Issue340()
    using (var repo = new Repository(@"D:\Temp\Branched"))
        var st = repo.Index.RetrieveStatus();

FWIW, below the output of git-bash

$ git log
commit b8f010f873031c32eaf99422396b0fc35a9f3faa
Author: bbvcbvc <>
Date:   Mon Feb 18 12:18:20 2013 -0800

    from CLI

commit 1fc7c10f3891c79c8333b94aa9757dee74ded72b
Author: bbvcbvc <>
Date:   Mon Feb 18 12:17:50 2013 -0800


$ git status
# On branch NewBranch
nothing to commit, working directory clean
libgit2 member
dahlbyk commented Feb 19, 2013

Maybe related to autocrlf? With true I see no files changed, but with false I see one file changed:


The funny thing is after running a CLI git status (msysgit 1.8.0) this issue goes away. Also pre zipping this didn't show up, only after zip + unzip using the built in windows 8 (and not running the CLI status) I've seen this popup.

I'm more concerned with the branch.checkout failing. In general for our current purposes we just found two more discrepancies between CLI checkout and libgit2sharp checkout, so we will have to let libgit2sharo.checkout go for now until it stabilizes.

I have on my list of todos to create a full mstest project that will show this behavior. I'm hoping to get to it this week.

libgit2 member
arrbee commented Feb 19, 2013

@yishaigalatzer Can you provide more information about the details of your Git environment and about the specific failure messages you are seeing? In particular, can you tell us the contents of your .gitconfig (both in your home directory and for your system - presumably installed by msysgit)? Also, when you say "checkout the original master branch (FAIL)", what options are you passing to checkout and what error message are you getting back?

To me, it sounds like you are actually reporting a single problem, not two separates ones; namely, that libgit2 thinks your new file is modified, probably due to a difference in how crlf is being handled. I assume, although you don't provide details on this, that you are probably using GIT_CHECKOUT_SAFE and so checkout is "failing" because it doesn't want to overwrite apparent modifications to a local file. But to actually help you, we need a little more information about the environment in which you are running into this problem.

Additionally, instead of alluding to other differences between the CLI checkout and the libgit2sharp checkout, can you actually provide details about what those differences are so we can try to resolve them? Hinting at them without details doesn't really help.



  • First part of your question: As my comment above says, I am going to add the tests and the data when I get around to it. BUT note that this issue doesn't happen with the original unzipped version of the repository, and it goes away after calling the CLI: git status.

Install and cli use details:
My install is plain vanilla msysgit 1.8.0.

In home folder, there is nothing interesting (username, email and credential helper).

the global config:
symlinks = false
autocrlf = true
diff = auto
status = auto
branch = auto
interactive = true
packSizeLimit = 2g
format = html
sslCAinfo = /bin/curl-ca-bundle.crt
smtpserver = /bin/msmtp.exe

[diff "astextplain"]
textconv = astextplain
autosquash = true

CLI call: branchName = e.g. master
git checkout branchName

  • Second part
    I tend to agree

  • Third part
    I'm not alluding to anything, I simply cannot use branch.Checkout at its current state as my deadline is fast approaching. I'll do my best to contribute tests to highlight the issues, but I have other/higher priorities above diving into these repro scenario details, at this point unfortunately I have to cut my losses and move on.

To summarize my (indeed) rough understanding: When there are conflicts (and as we all know well there are many kinds of conflicts), branch.Checkout doesn't behave 1:1 with the CLI. I'd expect libgit2 to honor the global and user settings. Is there a way to map the global setting to libgit2?


@dahlbyk & @arrbee

The system options was a great lead. I'm investigating, as I didn't pass repository options when constructing repository. That might lead to some of the non matching behaviors.

Edit: I played around with passing the global config location, and it still seems to repro for me. Is there a way to directly turn on and off the CRLF option?

libgit2 member
arrbee commented Feb 20, 2013

@yishaigalatzer I understand you are busy and I'm not trying to ask you to write more tests and data. I'm just looking for a few additional details about the actual error you're reporting.

I'd expect libgit2 to honor the global and user settings.

It does, to the best of its ability. If you are passing the global config location and still seeing this error, then maybe this is not a problem with libgit2 not finding the core.autocrlf setting. Just in case, can you tell us the full path to the global config file you pasted above? Thanks.

Is there a way to directly turn on and off the CRLF option?

You could try repo.Config.Set("core.autocrlf", true); before trying the checkout and see if that makes any difference. Given the other information you've provided, I suspect that won't help, but it will give some useful information if you care to try it.

What would be helpful is telling us the error message from "checkout the original master branch (FAIL)". I'm assuming that the call to repo.Checkout is throwing an exception. Can you indicate what type of exception it is and what the Message is on the exception? I assume that the message is "1 conflicts prevent checkout" but without knowing that for certain, this is a lot of speculation.

I'll do my best to contribute tests to highlight the issues, but I have other/higher priorities above diving into these repro scenario details, at this point unfortunately I have to cut my losses and move on.

I totally understand that. I'm not looking for you to spend more time on this save for giving us a little more information about what actually happened. I'd like to track down these checkout issues so when you are able to come back to this they can be resolved. But with this error report as it is, there is not enough for me to pursue it further.

I'm not alluding to anything.

When you write "we just found two more discrepancies between CLI checkout and libgit2sharp checkout" in an earlier comment, are those two additional discrepancies just further instances of this same bug (i.e. conflicts preventing checkout) or are they different behavior discrepancies?


Respecting options: Looks like in most cases it does, on another machine that did not have msysgit installed passing a temp file path with the CRLF option did make a difference. if i'll find a concrete repro I'll add here or open a separate issue. I would suggest that the default options match the default of msysgit, such that if msysgit is not installed or installed with default options the behavior will be the same.

The gitconfig file is under c:\program files (x86)\git\etc\gitconfig

Regarding the bugs:
These are all conflict scenarios. Over time the discrepancies between the CLI and lg2# are when edits where made to files, or when different kinds of conflicts happen. One was a delete conflict, and one an edit conflict.

I do take seriously my promise to write the tests, and provide the examples. I just need another day to get through other bugs, If I don't get to it, @justbe promised to help (wink wink)



The only think I can think of, is that by adding the zip to git OR because I use Ionic.Zip to extract the files during the unit test run.

I'm getting a bit free'd up so hopefully tomorrow I will be able to share Unit tests.


@arrbee Thanks for you patience, I finally got around to writing these test in lg2#.

I pushed the first test out to

New Tests Are:

CheckoutShouldFailOnDeleteConflict - Fails
StatusForThisRepoIsDifferentThanCLI - Fails
CheckoutShouldSucceed - Passes

libgit2 member
arrbee commented Feb 22, 2013

Thank you @yishaigalatzer - I'll check it out!


Interesting feedback:
On my machine CheckoutShouldFailOnDeleteConflict fails because no exception is thrown
It fails on @jamill 's machine because an exception of type MergeConflictException is thrown (going to modify the test shortly so MergeConflictException is a pass).

Here is my test log:
Test Name: CheckoutShouldFailOnDeleteConflict
Test FullName: LibGit2Sharp.Tests.CheckoutFixture.CheckoutShouldFailOnDeleteConflict
Test Source: c:\Users\yigalatz\Documents\GitHub\libgit2sharp\LibGit2Sharp.Tests\CheckoutFixture.cs : line 406
Test Outcome: Failed
Test Duration: 0:00:00.311

Result Message:
Assert.Throws() Failure
Expected: System.Exception
Actual: (No exception was thrown)
Result StackTrace: at LibGit2Sharp.Tests.CheckoutFixture.CheckoutShouldFailOnDeleteConflict() in c:\Users\yigalatz\Documents\GitHub\libgit2sharp\LibGit2Sharp.Tests\CheckoutFixture.cs:line 394

libgit2 member

We've had a ton of fixes around the workdir which should have taken care of all of this. If there are issues, it's bound to be a brand new bug, so I'm closing this report.

@carlosmn carlosmn closed this Apr 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.