git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: '.git file' alternative, native (cross-platform) workdir support.

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 29, 2008, 14:14 UTC
Message-ID
<m3lk53kfy6.fsf@localhost.localdomain>
In-Reply-To
<47C80786.4070701@trolltech.com>
Marius Storm-Olsen <marius@trolltech.com> writes:
Show 40 quoted lines
> Johannes Schindelin said the following on 29.02.2008 13:54:
>> On Fri, 29 Feb 2008, Marius Storm-Olsen wrote:
>>>
>>> However, wouldn't simply redirecting everything into a real repo
>>> then create problems with shared index file and more? A problem
>>> which could be tacled by file suffixes or other methods, I'm
>>> sure, but which would require even more patches to achieve the
>>> goal.
>>
>> Not only would it requre these patches, but it would actually make
>> a _safe_ multiple-workdirs feature possible.
>> ATM the problem is that you can change a ref that is checked out
>> elsewhere, and if you are not a Git expert, it will just make your
>> life miserable.
>> However, if we do not pretend to have different repositories, but
>> actually use the _identical_ repository for multiple working
>> directories, we can make the mechanisms safe!
>> This is basically the reason why I do not like the current
>> new-workdir script (and the patch in my private tree where I taught
>> git-branch about it).
> 
> Sure, I'm aware of that. The initial goal was to make something which
> works as the current contrib/workdir/git-new-workdir, just
> cross-platform. Then we can take it from there, step by step, until we
> have something which works safely; instead of taking a single big leap.
> 
> I'm actually not sure that it's impossible to make it safe.
> My implementation works by redirecting files into the real
> repo. However, we can also detect when redirection is in effect, and
> do extra 'maintainance' things then, to avoid the bad effects.
> 
> For example, when setting up a workdir, we could duplicate
>          <real repo>/.git/refs/*
> into    <real repo>/.git/refs/workdir-<sha1>/*
> (<sha1> being the sha1 of the abs path to the workdir)
> and have the redirection mechanism redirect all git_path("refs/*") to
> the duplicated locations. That way, when pulling in the workdir, it
> wouldn't create havok with the real repo's refs. Then in the real
> repo, you can easily refer to the refs in from the workdir too, when
> you need to.

I have had yet another idea, namely of shadow / unionfs-alike, which I have abandoned due to perceived difficulties in implementing it. But perhaps this would be the best solution for multiple working directories problem.

The idea is to add core.gitdir variable to the config, which would point to "master" (main) GIT_DIR.

When requesting any file from repository, be it .git/refs/HEAD, .git/index, .git/refs/heads/master or any other file, git would first try to find it in the current GIT_DIR, as existing heuristics find it, and if not found try with GIT_DIR set to core.gitdir. When trying to create any file, git would check if directories / path leading to file in GIT_DIR exists, and if not create it under GIT_DIR set to core.gitdir.

The only exception would be config file, where current GIT_DIR config would be fourth layer, on top of system-wide config, global (per-user) config and core.gitdir config.

What do you think of this idea?
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Marius Storm-OlsenNext: Johannes Schindelin
Message 4 of 8 in “'.git file' alternative, native (cross-platform) workdir support.”
  1. Marius Storm-OlsenFeb 29, 2008
  2. Johannes SchindelinFeb 29, 2008
  3. Marius Storm-OlsenFeb 29, 2008
  4. Jakub NarebskiFeb 29, 2008
  5. Johannes SchindelinFeb 29, 2008
  6. Marius Storm-OlsenFeb 29, 2008
  7. Junio C HamanoFeb 29, 2008
  8. Marius Storm-OlsenFeb 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.