Skip to content

Allow creation of a configuration object in an in-memory repository#4263

Merged
ethomson merged 4 commits intomasterfrom
ethomson/config_for_inmemory_repo
Jun 12, 2017
Merged

Allow creation of a configuration object in an in-memory repository#4263
ethomson merged 4 commits intomasterfrom
ethomson/config_for_inmemory_repo

Conversation

@ethomson
Copy link
Copy Markdown
Member

Regression: we cannot create a configuration object against an in-memory remote, since the path to the repository configuration cannot be created.

Change git_repository_item_path to return GIT_ENOTFOUND when the path could not be constructed because the underlying directory does not exist. (For example, when requesting the config file on an in-memory repository.

Add a unit test for a concrete scenario: create an anonymous remote on an in-memory repository (to allow for emulating git ls-remote).

@ethomson
Copy link
Copy Markdown
Member Author

Found this when trying to update LibGit2Sharp with the new 0.26 release candidate, so I would like to bring this in for 0.26.

@ethomson ethomson force-pushed the ethomson/config_for_inmemory_repo branch 3 times, most recently from aa0fd40 to 10a221e Compare June 12, 2017 12:46
pks-t
pks-t previously requested changes Jun 12, 2017
Copy link
Copy Markdown
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for cleaning up after me 🙂 Just one tiny issue with tabs vs spaces in the test.

Comment thread tests/network/remote/local.c Outdated
void test_network_remote_local__anonymous_remote_inmemory_repo(void)
{
git_repository *inmemory;
git_remote *remote;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit: tabs vs spaces ;)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! My editor set up is wacky on this machine.

@ethomson ethomson force-pushed the ethomson/config_for_inmemory_repo branch from 10a221e to db26671 Compare June 12, 2017 14:53
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 12, 2017

Sorry for having the change requests tickle in, but I just noticed that the tests are added before the issue is fixed. This would break bisectability, so I'd prefer if the test commit is moved last here.

@ethomson
Copy link
Copy Markdown
Member Author

I can change this. I've done the test-first pattern for a while, as has nulltoken. I actually don't know @carlosmn 's opinion here. I know that he's opened some PRs that have failing tests, but I don't know if he ends up rewriting the history after he's made them 💚 .

I've always felt like keeping things able to be bisected for any particular test is important. That is to say that we should certainly never commit a build break. But introducing a failing unit test doesn't bother me. My assumption here is that most people are running git bisect for a single test (or a few tests) not the whole test suite, and this would not get in their way. But if this is something that you find value in doing then I can change my ways.

@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 12, 2017

I certainly think it provides some value to have a "clean" history here. I'm actually kind of inspired by upstream git, as they also very carefully avoid having commits in between that break the test suite in any way. They do have the benefit of being able to tell a real story, though:

  1. introduce a test with test_expect_failure, which actually fails in an expected way
  2. fix the bug and switch over to test_expect_success

What I like about it is that this chain demonstrates both that there actually was a failure before and that it is fixed by the respective commit, so that one can exactly pinpoint both points in time. But we're missing this feature in the clar, and my pull request has been rejected when I tried to introduce it.

But yeah. It's only been the first time that I noticed the inverted pattern here. So while I think it's a nice to have, I'll leave it to you to judge whatever suits us most.

@ethomson
Copy link
Copy Markdown
Member Author

What PR was that? I must have forgotten about this.

ethomson added 3 commits June 12, 2017 16:51
Disambiguate error values: return `GIT_ENOTFOUND` when the item cannot
exist in the repository (perhaps because the repository is inmemory or
otherwise not backed by a filesystem), return `-1` when there is a hard
failure.
When in an in-memory repository - without a configuration file - do not
fail to create a configuration object.
Given a wholly in-memory repository, ensure that we can create an
anonymous remote and perform actions on it.
@pks-t
Copy link
Copy Markdown
Member

pks-t commented Jun 12, 2017

Oh, it wasn't the lbigit2 repo but the clar repo. See clar-test/clar#77

@ethomson ethomson force-pushed the ethomson/config_for_inmemory_repo branch from db26671 to fe9a5dd Compare June 12, 2017 15:51
@pks-t pks-t dismissed their stale review June 12, 2017 15:52

Whitespace issue was fixed, introducing failing tests is under discussion

@ethomson
Copy link
Copy Markdown
Member Author

Thanks for the background. I hadn't seen that PR, or had forgotten about it completely. I'll have a think on this.

I did reorder these commits here but I think we should have a larger thought about how we want to do this or if we care. I feel like we might be getting past the point of diminishing returns, but that might just be me.

@ethomson ethomson merged commit 99e40a6 into master Jun 12, 2017
@ethomson ethomson deleted the ethomson/config_for_inmemory_repo branch January 9, 2019 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants