-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
GIT_CEILING_DIRECTORIES with relative search directory #607
Comments
First of all, thanks so much for this wonderfully analysed issue! I am loving these patches, too, and have a feeling that Stacked Git helps with that :).
This ceiling dir logic is definitely something I struggled with and am sure there is plenty wrong with it and it's just lacking tests to show that. With your use-case, I believe a test should be built to reproduce it, allowing a fix.
This sounds like a bug and I am surprised there is no test-case for that 😳.
This is where However, as a library, Maybe some documentation can help to make that behaviour clearer to
I definitely welcome a PR with the patches as you see fit. If they don't break any existing behaviour I consider them correct, and I will give those patches a closer look and work with you once the PR has landed. On another note, I will be studying how stacked-git works as I am always looking to understand all workflows that git enables, so I am particularly excited to see you contribute to |
I was also seeing the difficulty in testing this. I could use some hints regarding how to add a new integration test. Would this fit in with the stuff in the top-level Alternatively, I've been looking at how feasible it would be to allow the user to provide the current directory to gitoxide. The immediate goal would be to allow unit tests to be written for this scenario, but there may be other benefits such as reducing the number of system calls. My initial audit shows the following uses of
There is already a pattern of functions that take a cwd argument. This could be extended to include
Fair enough. There are trade-offs to normalizing everything to absolute paths versus maintaining relative paths. And agreed that git maintains relative paths. I'll make sure that any changes I work on in this space take care to preserve relative paths.
I've posted #609 as a first step. I got hung up for a while because Now I'm trying to figure out why I feel pretty confident in the patch I posted above for solving this problem, but I need to get the baseline tests working and then either add integration or unit tests to cover this case. Your guidance on the testing approach is welcome.
Glad to have you take notice of StGit. I just released StGit 2.0, which was a complete rewrite in Run (from Python). gitoxide was not sufficiently capable when I started this rewrite over a year ago, so I used libgit2. I tried to only use libgit2 and avoid executing subordinate At this point, it seems like gitoxide may be sufficiently capable to replace the use of libgit2 in StGit. So I'm starting to experiment with integrating gitoxide into StGit. I like that gitoxide is fast. I like that gitoxide is config-aware. And I like that it is written in Rust. |
Indeed, I think it's enough to drop a new file into
I think you have discovered another inconsistency and I took the liberty to fix it immediately to the point where
Strange, I hope another patch for a fix is possible here as well. I imagine that not all scripts are perfectly portable though, maybe it's that as well.
I think it would be best to do that in a PR, it would allow me to experiment as well.
From what you mentioned, I believe it is even though I didn't analyse it myself yet. If you find anything lacking we should crate a tracking ticket here and I will keep you posted on the progress towards delivering the required features. PS: I have been using |
I've submitted #616 to address this issue.
I ended up adding a test in
Great! Glad to have sparked this idea.
As I've given
So
The first failure signature I ran into involved failure to decompress
That sounds great. Thanks for taking an interest in supporting StGit.
And that's especially great. Thank you for taking the time to explore StGit and give it a try. It's really gratifying for me that you've found it to be useful. I am happy to help with any StGit related trouble you might run into--just let me know. |
It's possible for those with incomplete `git-lfs` installations (and many more situations) to end up in a spot where pointer files aren't expanded. If we overwrite the with archives, files look changed which can be confusing and lead to even bigger messes to happen. Now we don't overwrite those files anyomre.
It's possible for those with incomplete `git-lfs` installations (and many more situations) to end up in a spot where pointer files aren't expanded. If we overwrite the with archives, files look changed which can be confusing and lead to even bigger messes to happen. Now we don't overwrite those files anyomre.
It's done and I was happily playing with different configurations, and if you have any other ideas for testing, it should be straightforward now to add them accordingly.
That's a fair concern and I am taking it seriously. To me the only question is if the resulting path is valid if the source path was valid, and my answer to that is positive.
When I previously tested I didn't consider that After manipulating the checkout into shape to run
That's interesting, it shouldn't be needed to install
After all that filter-madness I am not surprised that this happens. Even assuming filters worked fine these archives would probably look different on your platform than on mine so an apparent change can be expected. However, it's not nice for contributors to have to be aware of that. I am a bit unhappy that this issue evaded me for so long, and that I don't really have a solution for it either. Maybe
In the past hours I have graduated to being a fan as well despite still barely touching the surface. The key improvement
I'd love to start a conversation and ask questions, is the forum the right place for that? With all this said and done, I believe it's time to close this issue as the fix is available in |
I'd prefer using discussions for public conversations and filing issues for any unclear/unexpected behaviors.
Thanks for working with me on this issue. Glad to be able to help with gitoxide. And kudos for taking on such an ambitious project! |
Thanks for letting me know, I posted a new discussion with my most pressing question.
You are very welcome! And after having strolled through the |
Duplicates
Current behavior 😯
Calling
git_repository::ThreadSafeRepository::discover_with_environment_overrides(".")
with:GIT_CEILING_DIRECTORIES
=/absolute/path/to/repo/..
/absolute/path/to/repo
results in
Error::NoMatchingCeilingDir
.Under the hood, the crux of the problem seems to be in
find_ceiling_height()
. In this scenario, we land in this match arm:Where:
search_dir
is"."
and thus not absoluteceiling_dir
is"/absolute/path/to"
(because the "/.." was normalized away inparse_ceiling_dirs()
)cwd
isSome("/absolute/path/to/repo")
It is unclear to me the purpose of
ceiling_dir.as_ref().strip_prefix(cwd?)
in the above. It fails in this scenario becausecwd
is not a prefix ofceiling_dir
, but my question is why isn'tsearch_dir
given any consideration? Don't we want to know how many path components ofsearch_dir
remain after strippingceiling_dir
?Here is a patch that works for me. I can post a PR if this seems like the right approach:
But wait, there's more.
With the above repair in place, there is another possible issue:
Repository::git_dir()
andRepository::work_dir()
return relative paths when the search directory is relative (e.g. ".").In
git_discover::upwards_opts()
(a.k.a.discover_opts()
), the directory is "absolutized" with:However, despite its name,
absolutize()
does not convert all paths to be absolute. Specifically,"."
will remain simply"."
even whenSome(cwd)
is provided toabsolutize()
The reason I identify this as possibly being a problem is because
git2::Repository::path()
andworkdir()
always provide absolute paths. So perhaps a problem insofar as gitoxide may want to avoid surprising users coming from git2-rs.That and
absolutize()
might either be renamed ("normalize()"?) or actually ensure that absolute paths are returned when possible. Ifabsolutize()
ensured that an absolute path was returned, it would also obviate the above problem withGIT_CEILING_DIRECTORY
in addition to ensuring thatRepository::git_dir()
andwork_dir()
always return absolute paths.A patch for that might look something like this:
Expected behavior 🤔
I expect that
git_repository::ThreadSafeRepository::discover_with_environment_overrides(".")
would succeed when theGIT_CEILING_DIRECTORIES
environment variable is set.Or that the various repository discovery functions would all explicitly prohibit relative search paths.
Steps to reproduce 🕹
No response
The text was updated successfully, but these errors were encountered: