git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bradford C Smith <bradford.carl.smith@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.como>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	"Bradford C. Smith" <bradford.carl.smith@gmail.com>
Subject: [PATCH 2/2] use make_absolute_path() in lock_file()
Date: Fri, 27 Jul 2007 15:10:56 -0400	[thread overview]
Message-ID: <1185563460165-git-send-email-bradford.carl.smith@gmail.com> (raw)
In-Reply-To: <11855634582686-git-send-email-bradford.carl.smith@gmail.com>

From: Bradford C. Smith <bradford.carl.smith@gmail.com>

Use make_absolute_path() to get fully resolved path name for creating
the lock file.

Signed-off-by: Bradford C. Smith <bradford.carl.smith@gmail.com>
---
 lockfile.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/lockfile.c b/lockfile.c
index 9202472..57f850f 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -28,20 +28,10 @@ static void remove_lock_file_on_signal(int signo)
 static int lock_file(struct lock_file *lk, const char *path)
 {
 	int fd;
-	struct stat st;
 
-	if ((!lstat(path, &st)) && S_ISLNK(st.st_mode)) {
-		ssize_t sz;
-		static char target[PATH_MAX];
-		sz = readlink(path, target, sizeof(target));
-		if (sz < 0)
-			warning("Cannot readlink %s", path);
-		else if (target[0] != '/')
-			warning("Cannot lock target of relative symlink %s", path);
-		else
-			path = target;
-	}
-	sprintf(lk->filename, "%s.lock", path);
+	strcpy(lk->filename, path);
+	make_absolute_path(lk->filename);
+	strcat(lk->filename, ".lock");
 	fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
 	if (0 <= fd) {
 		if (!lock_file_list) {
-- 
1.5.3.rc3.9.g9ef91

  reply	other threads:[~2007-07-27 19:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27 19:10 [PATCH 0/2] another attempt at make_absolute_path() Bradford C Smith
2007-07-27 19:10 ` [PATCH 1/2] added file path helper routines Bradford C Smith
2007-07-27 19:10   ` Bradford C Smith [this message]
2007-07-27 19:22 ` [PATCH 0/2] another attempt at make_absolute_path() Johannes Schindelin

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=1185563460165-git-send-email-bradford.carl.smith@gmail.com \
    --to=bradford.carl.smith@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.como \
    /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).