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

git lock files (Was: GIT for Microsoft Access projects)

From
Stefan Beller <sbeller@google.com>
Date
Jun 9, 2015, 17:19 UTC
Message-ID
<1433870383-7631-1-git-send-email-sbeller@google.com>
In-Reply-To
<5576F02B.4040002@gmail.com>

Just because Git allows distributed workflows, doesn't mean we should only focus on being distributed IMHO.

The question for content not being mergable easily pops up all the time. (Game/Graphics designers, documents, all this binary stuff, where there is no good merge driver).

I could imagine a "git lock" command which looks like this:
    git config lock.centralServer origin
    git config lock.defaultBranch master
    git lock add [branch]  [--] <path/to/file>
    git lock remove [branch] [--] <path/to/file>
    git lock ls [<branch>]

And the way this is implemented is roughly (unoptimized, just showing how you would achieve this with todays command set):

    git fetch --depth=1 $(git config --get lock.centralServer) refs/locks/$(git config --get lock.defaultBranch)
    git checkout refs/locks/$(git config --get lock.centralServer)/$(git config --get lock.defaultBranch)
    switch(option) {
    case add:
        if exist <path/to/file>
            return -1
        else
            echo $(git config --get user.name) $(date) > <path/to/file>
            git add <path/to/file> && git commit "add new lock"
        fi
    case remove:
        if exist <path/to/file>
            # todo: check if the same user locked it before
            rm  <path/to/file>
        else
            return -1
        fi
    case ls:
        ls -R .
    }
    git push $(git config --get lock.centralServer) refs/locks/$(git config --get lock.defaultBranch)
    git <restore working tree, branch>

That said you could just manipulate the git objects directly, no need to check out to the working dir.

The server would only need to allow pushes to a refs/locks directory and be done. the client side would need to have a plumbing command, so you could easily integrate a git locking to your application if you don't want to provide a merge driver.

Thanks, Stefan

Previous: Sitaram ChamartyNext: hackerp@suddenlink.net
Message 5 of 12 in “GIT for Microsoft Access projects”
  1. hackerp@suddenlink.netJun 8, 2015
  2. Konstantin KhomoutovJun 8, 2015
  3. Randall S. BeckerJun 8, 2015
  4. Sitaram ChamartyJun 9, 2015
  5. git lock files (Was: GIT for Microsoft Access projects)Stefan Beller, Jun 9, 2015
  6. hackerp@suddenlink.netJun 9, 2015
  7. Konstantin KhomoutovJun 9, 2015
  8. Stefan BellerJun 9, 2015
  9. Fredrik GustafssonJun 10, 2015
  10. Stefan BellerJun 10, 2015
  11. Junio C HamanoJun 10, 2015
  12. Thomas KochJun 15, 2015

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.