Skip to content

wrong lifetime for Repository Index #897

Closed
@seanaye

Description

@seanaye

I am following the example from the docs for replicating git add *

my code:

    let repo = match get_marble_store() {
        Ok(r) => Ok(r),
        Err(_) => match Repository::open(get_path(None)) {
            Ok(r) => Ok(r),
            Err(e) => Err(e),
        },
    };

    let mut index = repo?.index()?;
    index.add_all(["*"].iter(), git2::IndexAddOption::DEFAULT, None)?;

    index.write()?;
    return Ok(());

When I run this I get cannot index add all. This operation is not allowed against bare repositories. This repo is not a bare repo though.
in .git/config bare=false.

I have tried using a repo created with git init as well as with git2-rs

    let mut opts = RepositoryInitOptions::new();
    opts.no_reinit(true).mkdir(true).mkpath(true).bare(false);
    return Repository::init_opts(path, &opts);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions