Skip to content

Conversation

@moroten
Copy link
Contributor

@moroten moroten commented Sep 21, 2025

The upwards search for the repository directory takes a directory as input and then walks through the parents. It turns out that it was broken when the repository was the same as the working directory.

The code checked when the directory components had been stripped to "", in case the directory was replaced with cwd.parent(), so the loop missed to check cwd itself. If the input directory was "./something", then "." was checked which then succeeded.

The upwards search for the repository directory takes a directory as
input and then walks through the parents. It turns out that it was
broken when the repository was the same as the working directory.

The code checked when the directory components had been stripped to "", in
case the directory was replaced with `cwd.parent()`, so the loop missed
to check `cwd` itself. If the input directory was "./something", then
"." was checked which then succeeded.
@moroten moroten force-pushed the fix-discover-upwards-to-cwd branch from 7d03275 to 504afec Compare September 21, 2025 22:43
@EliahKagan
Copy link
Member

The failing test, changed_and_untracked_and_renamed, is not necessarily failing due to any change in this PR. It fails occasionally due to #1832, which seems to have been happening more often recently (though it's possible that is due to some other bug causing intermittent failure rather than that one; I have not investigated). The failure here seems to resemble other recent failures that have gone away when the CI job is rerun.

In view of this, I've gone ahead and rerun the failing CI job here to see whether if it fails again or not.

@Byron
Copy link
Member

Byron commented Sep 22, 2025

Thanks a lot for contributing, and for the improved and added tests!

This portion of the code is hard to understand and admittedly, I don't know why this is working better now. However, I trust that the existing code-coverage is good enough and validated the new tests. it seems sound.

As I couldn't push into this PR, I am merging the commit with #2189 instead, while closing this one.

PS: Infrastructure seems really flaky right now as Rustc installations fail on Windows.

@Byron Byron closed this Sep 22, 2025
@moroten
Copy link
Contributor Author

moroten commented Sep 22, 2025

The test fails without this patch. I discovered it when calling gix::discover::upwards("src") in the repository root failed, but gix::discover::upwards("./src"). The parent of "src" is "" but the parent of "./././src" is ".". Just checking for empty string creates the different behaviour.

@moroten moroten deleted the fix-discover-upwards-to-cwd branch September 22, 2025 06:19
@Byron
Copy link
Member

Byron commented Sep 22, 2025

I have no doubt it's not working, yet I felt I should disclose that I don't understand why it's working. It's merely me not knowing my own code anymore :D. The sibling PR is merged, so this change is included now.

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

Successfully merging this pull request may close these issues.

3 participants