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

Applying diff with renamed file to Index ignores delta callback and removes old file from index #1022

Closed
aganzha opened this issue Feb 18, 2024 · 4 comments

Comments

@aganzha
Copy link

aganzha commented Feb 18, 2024

How to reproduce:

  • rename file in repository
  • apply diff from index to workdir with delta callback returning false

Estimated behaviour: index remain unchanged. no changes staged.
Current behaviour: old file deleted from index.

use git2::{
    Repository, ApplyOptions, ApplyLocation
};

fn main() {

    // just rename 1 file in repositiry and run this.
    // old file will be removed from index.
    let repo = Repository::open("./")
        .expect("can't open repo");
    let git_diff = repo.diff_index_to_workdir(None, None)
        .expect("can't get diff");

    let mut options = ApplyOptions::new();
    options.hunk_callback(|odh| -> bool {
        false
    });
    options.delta_callback(|odd| -> bool {
        false
    });

    repo.apply(
        &git_diff,
        ApplyLocation::Index,
        Some(&mut options),
    ).expect("can't apply patch");
}

@extrawurst
Copy link
Contributor

Probably best to post upstream in libgit2 repo (repro in rust is fine) as git2-rs is just bindings

@aganzha
Copy link
Author

aganzha commented Feb 18, 2024

Thank You

@aganzha
Copy link
Author

aganzha commented Feb 18, 2024

libgit2/libgit2#6643

@ehuss
Copy link
Contributor

ehuss commented Feb 19, 2024

Thanks! We don't mirror or track libgit2 issues here, so I'm going to close this as it does look like an upstream issue. If it gets fixed, we'll pick the fix up in the next update.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2024
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

No branches or pull requests

3 participants