Re: [PATCH v4 05/25] midx: clear auxiliary .rev after replacing the MIDX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 30, 2021 at 09:21:31PM -0400, Derrick Stolee wrote:

> Yes, supporting non-alternates is a historical accident. Supporting
> alternates that are not actually the core object database of a full
> repository is on purpose.
> 
> So, hopefully the remaining discussion that I am seeing can be
> solved by a decision such as:
> 
>   "If we add the restriction that the builtin always runs with a
>    repository and --object-dir always points to its objects dir
>    or one of its registered alternates, then we have access to a
>    local config file to learn how to interpret that object directory."

I left a similar comment in the other part of the thread. :)

> >> I wonder if it is safe to assume that in practice a directory given
> >> to the "--object-dir" option is always the "objects" subdirectory in
> >> a repository, and it is an error if there is no "config" file next
> >> to the directory.  Then, we could check ../config relative to the
> >> given directory and error out if they use different hash.
> 
> I would say that is not always the case, and we should not error out.
> 
> I think taking a look to see if ../config exists to use the data
> might be helpful for some cases, but should not be a blocker for
> completing the requested operation. The config from the non-alternate
> repo should be sufficient for this (somewhat strange) case.

Yes, agreed. We have long supported these kind of "bare" alternates, and
I wouldn't be surprised if they are in wide use (though I do wonder how
folks actually modify them, since most commands that touch objects
really do want to be in a repository).

In other cases where we may benefit from their being a containing repo
(e.g., accessing the ref tips of the alternate), we speculatively look
at ".." and see if there are any refs. See refs_from_alternate_cb()[0].

The natural extension for the hash-format problem would probably be to
call check_repository_format_gently() on the parent directory of the
alternate-objects dir. If it succeeds, then we can pull out the
hash_algo parameter from its repository_format struct. And if not, then
we just assume it matches the main repo.

But I suspect all of this is moot for now, beyond being able to return a
nicer error message. The rest of the code is not at all ready to handle
packs with two different hashes in the same process. And I suspect it
would take a reasonable amount of refactoring to make it so. If somebody
wants to work on that, I won't stop them, but I kind of doubt it is
worth anybody's time.

[0] Looking at refs_from_alternate_cb(), I did wonder if it would work
    at all with a reftable alternate, but I suspect it would. I think we
    ended up still having a "refs/" directory in that case, so we'd
    recognize it as a repo (though really, it ought to be using
    is_git_directory() instead of its hacky check). And then we farm out
    the actual ref iteration to a separate for-each-ref process, passing
    along --git-dir, which will read that alternate repo's config. So it
    should Just Work, even with a different ref backend. It's almost
    certainly broken if the hash algorithms don't match, though, because
    we'd get oddly sized results from for-each-ref's output.

    That's all just interesting tangent, though. :)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux