From: Olivier Marin <dkr+ml.git@free.fr>
To: Nick Andrew <nick@nick-andrew.net>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] builtin-rm: fix index lock file path
Date: Sat, 19 Jul 2008 18:21:25 +0200 [thread overview]
Message-ID: <48821485.6050507@free.fr> (raw)
In-Reply-To: <20080719082314.GA15419@mail.local.tull.net>
From: Olivier Marin <dkr@freesurf.fr>
When hold_locked_index() is called with a relative git_dir and you are
outside the work tree, the lock file become relative to the current
directory. So when later setup_work_tree() change the current directory
it breaks lock file path and commit_locked_index() fails.
This patch move index locking code after setup_work_tree() call to make
lock file relative to the working tree as it should be and add a test
case.
Noticed by Nick Andrew.
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
---
builtin-rm.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin-rm.c b/builtin-rm.c
index 56454ec..ee8247b 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -146,11 +146,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
git_config(git_default_config, NULL);
- newfd = hold_locked_index(&lock_file, 1);
-
- if (read_cache() < 0)
- die("index file corrupt");
-
argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0);
if (!argc)
usage_with_options(builtin_rm_usage, builtin_rm_options);
@@ -158,6 +153,11 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (!index_only)
setup_work_tree();
+ newfd = hold_locked_index(&lock_file, 1);
+
+ if (read_cache() < 0)
+ die("index file corrupt");
+
pathspec = get_pathspec(prefix, argv);
seen = NULL;
for (i = 0; pathspec[i] ; i++)
--
1.5.6.3.440.g489d7
next prev parent reply other threads:[~2008-07-19 16:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-19 8:23 Out-of-repository file remove error Nick Andrew
2008-07-19 16:21 ` Olivier Marin [this message]
2008-07-19 16:24 ` [PATCH V2] builtin-rm: fix index lock file path Olivier Marin
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=48821485.6050507@free.fr \
--to=dkr+ml.git@free.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nick@nick-andrew.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).