All of lore.kernel.org
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Yue Lin Ho <yuelinho777@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git update-index not delete lock file when using different worktree
Date: Thu, 17 Jul 2014 17:36:54 +0700	[thread overview]
Message-ID: <20140717103654.GA18897@lanh> (raw)
In-Reply-To: <1405585628972-7615306.post@n2.nabble.com>

On Thu, Jul 17, 2014 at 01:27:08AM -0700, Yue Lin Ho wrote:
> I see that refresh() of update_index.c calls setup_work_tree() to change dir
> to working tree.
> And the dir is not changed back to git dir before commit_lock_file() or
> rollback_lock_file() is called.
> 
> So, commit_lock_file() rename file failed.
> or rollback_lock_file() delete file failed.

I think you're on the right track. Although the problem is
hold_locked_index() in cmd_update_index() when the index path is
relative. After setup_work_tree(), the saved path points to a wrong
place and can't be unlinked anymore.

This patch seems to fix it

-- 8< --
diff --git a/lockfile.c b/lockfile.c
index 2a800ce..69fe837 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -264,7 +264,8 @@ int commit_lock_file(struct lock_file *lk)
 
 int hold_locked_index(struct lock_file *lk, int die_on_error)
 {
-	return hold_lock_file_for_update(lk, get_index_file(),
+	return hold_lock_file_for_update(lk,
+					 absolute_path(get_index_file()),
 					 die_on_error
 					 ? LOCK_DIE_ON_ERROR
 					 : 0);
-- 8< --

We could turn all lockfile's path absolute when setup_work_tree()
moves pwd, but that seems dangerous without looking through how all
lockfiles are used.

--
Duy

  reply	other threads:[~2014-07-17 10:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17  3:18 git update-index not delete lock file when using different worktree Yue Lin Ho
2014-07-17  8:27 ` Yue Lin Ho
2014-07-17 10:36   ` Duy Nguyen [this message]
2014-07-18  8:21     ` Yue Lin Ho

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=20140717103654.GA18897@lanh \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=yuelinho777@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.