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

fix 13773 - 'cargo build' fails when list_files() with gix is triggered #13777

Merged
merged 2 commits into from Apr 19, 2024

Conversation

Byron
Copy link
Member

@Byron Byron commented Apr 18, 2024

Fixes #13773.

Tasks

  • reproduce issue with new test-case
  • update fixed gix-dir in Cargo.lock to turn test green

@rustbot
Copy link
Collaborator

rustbot commented Apr 18, 2024

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 18, 2024
Byron added a commit to Byron/cargo that referenced this pull request Apr 18, 2024
@Byron Byron force-pushed the fix-13773 branch 2 times, most recently from 4741df6 to 5cfd783 Compare April 18, 2024 20:32
@Byron Byron marked this pull request as ready for review April 19, 2024 05:09
@Byron Byron marked this pull request as draft April 19, 2024 05:12
@Byron Byron marked this pull request as ready for review April 19, 2024 06:21
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Always amazed how quick you respond to an issue :)

Would you like to follow the pattern as #13770 that first commit a test showing the problematic behavior, and the following commit fixes both test and bug? I am fine with it if you don't have time.

Also, I am too dumb to understand the change in git-dir. Not a blocker but would love to learn more:

assure worktree-roots aren't pruned with pathspecs that are never meant for them.
Previously, when pathspecs were defined, the classification of the worktree-root
would also be using them. This means that depending on the pathspec, worktree-roots would
be pruned, which in turn makes it impossible to recurse into them.

Now pathspecs are disabled when classifying the worktree-root directory.

What are worktree-roots, and what does classification of worktree-root do?

@Byron
Copy link
Member Author

Byron commented Apr 19, 2024

Thanks for the fix! Always amazed how quick you respond to an issue :)

Thanks :)!

Would you like to follow the pattern as #13770 that first commit a test showing the problematic behavior, and the following commit fixes both test and bug? I am fine with it if you don't have time.

Actually I think I did. The first commit 07d2bd7 adds a test and fails exactly like it should, the second commit includes the fix. Is there anything I am missing?

Also, I am too dumb to understand the change in git-dir. Not a blocker but would love to learn more:

assure worktree-roots aren't pruned with pathspecs that are never meant for them.
Previously, when pathspecs were defined, the classification of the worktree-root
would also be using them. This means that depending on the pathspec, worktree-roots would
be pruned, which in turn makes it impossible to recurse into them.
Now pathspecs are disabled when classifying the worktree-root directory.

What are worktree-roots, and what does classification of worktree-root do?

The worktree root is basically invisible, or Path::new("") if you will, what matters to pathspec checks are worktree-relative paths (which are never empty, unless it's the worktree root itself). Previously, it would classify the worktree-root, an empty relative path, and even though usually that would mean… I don't even know how useful that is, but most importantly, that could lead to the empty path being excluded as 'pruned', which led to the traversal root itself being rejected as directory to traverse into, which in turn led to our error here.

Now that I write this, the question really is if empty paths should ever be excluded by pathspecs, and if the pathspec-check makes a mistake. Right now it's fixed by having an empty pathspec check the empty path, which indeed considers it to be included. In fact that should also work for any other pathspec (I suppose). Something to look into again, maybe the bug is fixed in the wrong location, and the trick would be to simply always incude the empty path.

Byron added a commit to Byron/gitoxide that referenced this pull request Apr 19, 2024
Byron added a commit to Byron/gitoxide that referenced this pull request Apr 19, 2024
@Byron
Copy link
Member Author

Byron commented Apr 19, 2024

Thanks so much for asking that question :) - it made me think again, less rushed this time.

After revisiting this I realized that the underlying problem was indeed related to handling empty input paths with pathspecs. These, I think I have fixed and tested there now, while having cleaned up gix-dir which now is entirely unchanged. This also means I don't have a direct test for this in the gix-dir codebase, only an indirect one related to the gix-pathspec handling of empty paths. Interestingly, that might even be the better test of the two, so I will probably stop the investigation.

An immediate change to what's released isn't necessary, I think, so these improvements will come in with the next natural release in a month or so.

Thanks again!

@weihanglo
Copy link
Member

Actually I think I did. The first commit 07d2bd7 adds a test and fails exactly like it should, the second commit includes the fix. Is there anything I am missing?

Yes, you did it pretty good. For myself, I also match the failure output in the test in the first commit, so the next commit we shows both fix and test change.

Should we wait for Byron/gitoxide@5dea6f1 and update to the new version?

@weihanglo
Copy link
Member

Ok okay I missed this:

An immediate change to what's released isn't necessary, I think, so these improvements will come in with the next natural release in a month or so.

Let's merge this. Thanks!

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 19, 2024

📌 Commit 3fd120b has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 19, 2024
@bors
Copy link
Collaborator

bors commented Apr 19, 2024

⌛ Testing commit 3fd120b with merge 80d5b60...

@bors
Copy link
Collaborator

bors commented Apr 19, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 80d5b60 to master...

@bors bors closed this in 3fd120b Apr 19, 2024
@bors bors merged commit 80d5b60 into rust-lang:master Apr 19, 2024
23 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2024
Update cargo

8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036
2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000
- fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777)
- fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780)
- fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775)
- fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769)
- fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771)
- fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770)
- test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767)
- feat(install): Including Locking message (rust-lang/cargo#13764)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2024
Update cargo

8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036
2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000
- fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777)
- fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780)
- fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775)
- fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769)
- fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771)
- fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770)
- test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767)
- feat(install): Including Locking message (rust-lang/cargo#13764)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 20, 2024
Update cargo

8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036
2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000
- fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777)
- fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780)
- fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775)
- fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769)
- fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771)
- fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770)
- test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767)
- feat(install): Including Locking message (rust-lang/cargo#13764)

r? ghost
@rustbot rustbot added this to the 1.79.0 milestone Apr 20, 2024
@Byron Byron deleted the fix-13773 branch April 20, 2024 05:46
@Byron
Copy link
Member Author

Byron commented Apr 20, 2024

Yes, you did it pretty good. For myself, I also match the failure output in the test in the first commit, so the next commit we shows both fix and test change.

Oh, right! I don't know how I could miss this opportunity - I just visually inspected the output. With a test-assertion on stderr, it would have been far clearer though, as the test would still have failed. Next time, even though I hope there won't be, who needs bugs ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error building path dependency inside symlinked git repository
4 participants