Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix root path issue with Irmin-git, and remove allow_duplicate for root spec key #2326

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

zazedd
Copy link
Contributor

@zazedd zazedd commented Aug 29, 2024

This PR addresses an issue with the repository root path in an Irmin-git repo that follows a preceding Irmin-git repo. Additionally, it eliminates the potential for duplicate root entries in an Irmin config.

Irmin-git issue

The issue arose when trying to create two Irmin-git repos one after the other:

let users_cfg = Irmin_git.config ~bare:true "./db/users"
let pipeline_cfg = Irmin_git.config ~bare:true "./db/pipeline"

...

let* users = UserStore.Repo.v users_cfg
let* pipeline = PipelineStore.Repo.v pipeline_cfg

After creating pipeline_cfg, the users repository is unable to find its root, as when Irmin-git creates a "fresh root key", it overrides the Univ function that was able to decode the root directory string for users from the config's Univ map.
This results in a new git repo being created in the project's current working directory, which isn't the expected behavior and can even break an existing git repository.

Duplicate root entry

After fixing the issue with Irmin-git, I noticed it was only possible because of the allow_duplicates flag.
I believe that it allows for a dangerous operation that should not be performed.

Copy link
Contributor

@art-w art-w left a comment

Choose a reason for hiding this comment

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

Thanks a ton for discovering and fixing this nasty bug! A couple of minor fixes would make this PR perfect :)

src/irmin/conf.ml Outdated Show resolved Hide resolved
src/irmin-test/common.ml Show resolved Hide resolved
src/irmin-git/conf.ml Outdated Show resolved Hide resolved
@zazedd
Copy link
Contributor Author

zazedd commented Aug 30, 2024

The newest commit:

  • Removes the allow_duplicate duplicate parameter;
  • Brings back the pre-configured root name + run id for the test runs;
  • Has two new tests in tests/irmin/test_conf.ml;
  • Has formatting applied

@art-w art-w merged commit 675f08f into mirage:main Sep 10, 2024
4 checks passed
samoht added a commit to samoht/opam-repository that referenced this pull request Dec 11, 2024
CHANGES:

### Added

- **irmin-git**
  - Expose `Content_addressable` type (mirage/irmin#2329, @art-w)

### Changed

- **irmin**
  - Rename `Node.S.effect` to `read_effect` for OCaml 5.3 compatibility (mirage/irmin#2347, @art-w)

### Fixed

- **irmin-client**
  - Fix a fd leak when using `clone` (mirage/irmin#2322, @samoht)
- **irmin-git**
  - Fix git sync example (mirage/irmin#2327, @art-w)
  - Fixed issue with two subsequent `Irmin-git` repos, where one
    repo would lose the ability to find its root path (mirage/irmin#2326, @zazedd)
- **irmin**
  - Fix CI, update dependencies (mirage/irmin#2321, @smorimoto)
  - Update documentation (mirage/irmin#2323, mirage/irmin#2324, mirage/irmin#2325, @christinerose)
- **irmin-cli**
  - Fix uncaught exception (mirage/irmin#2326, @art-w)

### Removed

- **irmin**
  - Removed `?allow_duplicate` parameter from the `Conf.key` function (mirage/irmin#2326, @zazedd)
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