-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
repo.references()
fails to deduplicate packed/loose refs
#1928
Comments
Thanks a lot for reporting and for figuring out a reproduction. It's going to go into the test-suite, from where I'd hope to be able to develop a patch. I perfectly agree that it's related to sorting. Since you went so far, I wouldn't want to be in your way of submitting a PR with a reproduction test-case, maybe you want to take a shot at figuring out the sorting as well? |
Sure, I'll take a look. Is it okay to add |
Thank you! And absolutely, do what you must. |
…GitoxideLabs#1928) This follows up 7b1b5bf. Since packed-refs appears to be sorted by full ref name, loose-refs should also be emitted in that order. The comparison function is copied from gix::diff::object::tree::EntryRef. Non-utf8 file names are simply mapped to "" on Windows. We could add some fallback, but callers can't handle such file names anyway.
…GitoxideLabs#1928) This follows up 7b1b5bf. Since packed-refs appears to be sorted by full ref name, loose-refs should also be emitted in that order. The comparison function is copied from gix::diff::object::tree::EntryRef. Non-utf8 file names are simply mapped to "" on Windows. We could add some fallback, but callers can't handle such file names anyway.
Meanwhile, with gix 0.71, I'm getting a similar problem to #1850 , but for remote references instead of local references this time. How do I check whether this is the same as the issue that Yuya found? $ bat src/main.rs
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
File: src/main.rs
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
use std::path::Path;
use gix::bstr::{B, BString, ByteSlice};
fn main() -> anyhow::Result<()> {
let repo = gix::discover(Path::new(
"/Users/ilyagr/dev/jj",
))?;
for b in repo.references()?.remote_branches()? {
let b = b.unwrap();
if b.name().as_bstr().find(b"squash-preserve").is_some() {
dbg!(b);
}
}
Ok(())
}
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$ cargo run
[src/main.rs:12:13] b = Reference {
name: FullName(
"refs/remotes/upstream/ig/squash-preserve-snapshot",
),
target: Object(
Sha1(cbf363db4b7036e736660218edb099ce8dfda99c),
),
peeled: None,
}
[src/main.rs:12:13] b = Reference {
name: FullName(
"refs/remotes/upstream/ig/squash-preserve-snapshot",
),
target: Object(
Sha1(389858b237528e259d9d81c1353fe5fd4dd5baa8),
),
peeled: None,
} The program that I copied above is almost identical to before: diff --git a/src/main.rs b/src/main.rs
index 6a4aba9403..b67638212e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,17 +1,14 @@
use std::path::Path;
-use gix::{
- bstr::{B, BString, ByteSlice},
- date::time::format,
- revision::walk::Sorting,
-};
+use gix::bstr::{B, BString, ByteSlice};
fn main() -> anyhow::Result<()> {
- let repo = gix::discover(Path::new("/Users/ilyagr/dev/jj"))?;
- for b in repo.references()?.local_branches()? {
+ let repo = gix::discover(Path::new(
+ "/Users/ilyagr/dev/jj",
+ ))?;
+ for b in repo.references()?.remote_branches()? {
let b = b.unwrap();
- let pat: Vec<u8> = B("pr4021").into();
- if b.name().as_bstr().find(pat.as_slice()).is_some() {
+ if b.name().as_bstr().find(b"squash-preserve").is_some() {
dbg!(b);
}
} |
#1931 fixes it! Awesome! 🎉 🎉 BTW, unsurprisingly, running To be more precise, I did diff --git a/Cargo.toml b/Cargo.toml
index 38f0489907..1f7c18f9cc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,3 +7,5 @@
anyhow = "1.0.96"
gix = "0.71.0"
+[patch.crates-io]
+gix = { git = "https://github.com/yuja/gitoxide", branch = "push-klrqpplwxrkx" } I guess the same would work for |
…itoxideLabs#1928) This follows up 7b1b5bf. Since packed-refs appears to be sorted by full ref name, loose-refs should also be emitted in that order. The comparison function is copied from gix::diff::object::tree::EntryRef. Non-utf8 file names are simply mapped to "" on Windows. We could add some fallback, but callers can't handle such file names anyway.
make `fs::walkdir_sorted_new()` sort entries by paths literally (#1928)
I have tested with |
I don't know if that really works, |
Still the same problem with |
This should fix git::import_refs() issue with gix 0.71.0. Old commits could be repopulated by importing stale refs stored in packed-refs. GitoxideLabs/gitoxide#1928 The Zlib license is added to the allow list because foldhash appears in the dependency chain.
This should fix git::import_refs() issue with gix 0.71.0. Old commits could be repopulated by importing stale refs stored in packed-refs. GitoxideLabs/gitoxide#1928 The Zlib license is added to the allow list because foldhash appears in the dependency chain.
…itoxideLabs#1928) This follows up 7b1b5bf. Since packed-refs appears to be sorted by full ref name, loose-refs should also be emitted in that order. The comparison function is copied from gix::diff::object::tree::EntryRef. Non-utf8 file names are simply mapped to "" on Windows. We could add some fallback, but callers can't handle such file names anyway.
It might help if @Byron could release I'm not sure this is a real issue, nor whether there's an easier solution, but we're thinking of making a patch release of |
Cargo will auto-upgrade to the latest available I think if |
This should fix git::import_refs() issue with gix 0.71.0. Old commits could be repopulated by importing stale refs stored in packed-refs. GitoxideLabs/gitoxide#1928 The Zlib license is added to the allow list because foldhash appears in the dependency chain.
This should fix git::import_refs() issue with gix 0.71.0. Old commits could be repopulated by importing stale refs stored in packed-refs. GitoxideLabs/gitoxide#1928 The Zlib license is added to the allow list because foldhash appears in the dependency chain.
That's good advice, thanks! |
Current behavior 😯
With the following setup,
repo.references()
emits both loose and packed refs.This generates the following packed-refs:
Create loose refs:
List all refs:
refs/heads/a/b
in packed-refs should be omitted:I think this is regression caused by the fix for #1850. Maybe we'll need to sort file-system entries in the same way as
tree::EntryRef
?Expected behavior 🤔
No response
Git behavior
No response
Steps to reproduce 🕹
No response
The text was updated successfully, but these errors were encountered: