Byron / Byron/crates-index-diff-rs
Cancelled error on invalid index entries
- Dominant language
- Rust
- Stars
- 19
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
`crates-index-diff` now yields `DiffForEach(Diff(Cancelled))` error on seemingly-okay git history (version 12 worked fine):
```console
$ git init repo
$ mkdir -p repo/aw/s-
$ echo '{"name":"aws-foo","vers":"0.0.1","deps":[],"cksum":"","features":{},"yanked":false}' > repo/aw/s-/aws-foo
$ git -C repo add .
$ git -C repo commit -m 'commit'
# note down the commit hash here
$ echo '{"name":"aws-foo","vers":"0.0.2","deps":[],"cksum":"","features":{},"yanked":false}' >> repo/aw/s-/aws-foo
$ git -C repo add .
$ git -C repo commit -m 'commit'
# note down this commit hash too
$ git -C repo remote add origin origin
$ git -C repo diff ..
diff --git a/aw/s-/aws-foo b/aw/s-/aws-foo
index f512d82..9bff708 100644
--- a/aw/s-/aws-foo
+++ b/aw/s-/aws-foo
@@ -1 +1,2 @@
{"name":"aws-foo","vers":"0.0.1","deps":[],"cksum":"","features":{},"yanked":false}
+{"name":"aws-foo","vers":"0.0.2","deps":[],"cksum":"","features":{},"yanked":false}
$ cargo new --bin whatever && cd whatever
$ echo 'crates-index-diff = "15"' >> Cargo.toml
$ cat src/main.rs
use crates_index_diff::{git, index::CloneOptions, Index};
use std::sync::atomic::AtomicBool;
fn main() {
let repo = git::open("../repo").unwrap();
let origin_url = repo
.find_remote("origin")
.unwrap()
.url(git::remote::Direction::Fetch)
.unwrap()
.to_bstring()
.to_string();
let index = Index::from_path_or_cloned_with_options(
"../repo",
git::progress::Discard,
&AtomicBool::default(),
CloneOptions {
url: origin_url,
..Default::default()
},
)
.unwrap();
index.changes("", "").unwrap();
}
$ cargo r
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DiffForEach(Diff(Cancelled))', src/main.rs:24:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
The `origin_url` bit is to ensure we always use the existing path rather than ever try to clone. At least that was the intent, and that worked back in version 12. Don't know if it's relevant here.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the reproducer in src/main.rs, especially Index::from_path_or_cloned_with_options and index.changes, and compare the behavior with crates-index-diff version 12. Recreate the two-commit invalid-index history and trace why the diff returns DiffForEach(Diff(Cancelled)). Done means the supplied history can be processed without that error, with regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100