How to use git2 perform git diff --name-status master origin/master

after execute command : git fetch and git diff --name-status master origin/master

i can see the differencies between the master and origin/master

but i try to run the below code, it's nothing.

    let binding = repo.revparse_single("master").unwrap();
    let local = binding.as_tree();
    let binding = repo.revparse_single(r"origin/master").unwrap();
    let remote = binding.as_tree();

    let _ = match repo.diff_tree_to_tree(local, remote, Some(&mut DiffOptions::new())) {
        Ok(diff) => {
            println!("{:?}", diff.stats());
            let _ = diff.print(DiffFormat::NameStatus, |delta, _hunk, _line| {
                println!(
                    "{:?} {} {}",
                    delta.flags(),
                    delta.new_file().path().unwrap().display(),
                    delta.old_file().path().unwrap().display(),
                );
                return true;
            });
        }
        Err(_) => todo!(),
    };

thanks.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.