public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Raul E Rangel <rrangel@chromium•org>
To: git@vger•kernel.org
Subject: Parallel worktree checkouts result in index.lock exists
Date: Tue, 21 Feb 2023 10:33:28 -0700	[thread overview]
Message-ID: <Y/UAaC4oBPIby4kV@google.com> (raw)

Hello,
I'm trying to extract multiple trees in parallel so I can create a
tarball of the trees. I can't use `git archive` since it doesn't
currently produce hermetic output, and I need to support older git
versions.

In essence what I'm trying to do is:

    git --work-tree ~/tmp/bob1 checkout ff27f5415797ead8bc775518a08f3a4ab24abd53 -- . &
    git --work-tree ~/tmp/bob2 checkout e70ebd7c76b9f9ad44b59e3002a5c57be5b9dc12 -- . &

When I do this though, I get the following error:
    [1] 4027482
    [2] 4027483
    fatal: Unable to create '/home/rrangel/cros-bazel/.repo/project-objects/chromiumos/platform/vboot_reference.git/./index.lock': File exists.
    
    Another git process seems to be running in this repository, e.g.
    an editor opened by 'git commit'. Please make sure all processes
    are terminated then try again. If it still fails, a git process
    may have crashed in this repository earlier:
    remove the file manually to continue.

Is this expected? I'm not sure why the index is coming into play here.
Is there another method I should be using to extract a tree into a
directory?

If the index.lock isn't actually protecting me from anything, I was
thinking of creating a symlink clone of the .git directory for each
parallel invocation. This way the each index.lock gets written to its
own directory:

    mkdir ../vboot_reference.git.1
    find . -mindepth 1 -maxdepth 1 -exec echo ln -s '../vboot_reference.git/{}' ../vboot_reference.git.1/ \;
    
    mkdir ../vboot_reference.git.r2
    find . -mindepth 1 -maxdepth 1 -exec echo ln -s '../vboot_reference.git/{}' ../vboot_reference.git.2/ \;

    git -C ../vboot_reference.git.1 --work-tree ~/tmp/bob1 checkout ff27f5415797ead8bc775518a08f3a4ab24abd53 -- . &
    git -C ../vboot_reference.git.2 --work-tree ~/tmp/bob2 checkout e70ebd7c76b9f9ad44b59e3002a5c57be5b9dc12 -- . &

Though if there is another way to handle this it would be great.

Thanks,
Raul

             reply	other threads:[~2023-02-21 17:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 17:33 Raul E Rangel [this message]
2023-02-22  0:06 ` Parallel worktree checkouts result in index.lock exists brian m. carlson
2023-03-07 17:25   ` Raul Rangel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/UAaC4oBPIby4kV@google.com \
    --to=rrangel@chromium$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox