Skip to content

Repository::commit should use an Option for some of its arguments #390

Open
@akhilkpdasan

Description

@akhilkpdasan

The libgit2 API says that author and message can be left NULL in git_rebase_commit function to keep the original author and message Doc. However, in git2-rs the commit method on Rebase struct takes values instead of Options for author and message.
I ended up with something like this

while let Some(Ok(op)) = rebase.next() {
    let commit = repo.find_commit(op.id())?;
    let msg = commit.message().unwrap_or("");
    let sig = commit.author();
    rebase.commit(&sig, &sig, msg)?;
}

I couldn't get a for loop to work

for operation in rebase { //value moved here
    let commit = repo.find_commit(operation?.id())?;
    let sig = commit.author();
    let msg = commit.message().unwrap_or("");
    rebase.commit(&sig, &sig, msg)?; //value borrowed here after move
}

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