From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Subject: [PATCH v6 10/32] reflog: avoid constructing .lock path with git_path Date: Wed, 9 Jul 2014 14:32:55 +0700 Message-ID: <1404891197-18067-11-git-send-email-pclouds@gmail.com> References: <1404891197-18067-1-git-send-email-pclouds@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Junio C Hamano , =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Wed Jul 09 09:34:27 2014 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X4mOY-0003NL-9u for gcvg-git-2@plane.gmane.org; Wed, 09 Jul 2014 09:34:26 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754745AbaGIHeW convert rfc822-to-quoted-printable (ORCPT ); Wed, 9 Jul 2014 03:34:22 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:42625 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610AbaGIHeV (ORCPT ); Wed, 9 Jul 2014 03:34:21 -0400 Received: by mail-pa0-f47.google.com with SMTP id kq14so8766931pab.34 for ; Wed, 09 Jul 2014 00:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=67MkH1d0Zo6xqJXkPIIet2ewhntnflljwcVx9f55UDs=; b=YsqQm5qxOcCC5DKCJ3I5xhdH3nbvT+8xQe32nxwfrx6ecYIXCkoakMLvEdzn+oOLt1 fcYtP5JvYkipnFM4Fmig05aAdv6OjtAzf9ZC1ATPD9XDRVterstzlq+4pGF6Pk4cfclW m7nwdN9X2WJz3PpngNdwS7ut7p8Hp8SdUGH0Qnb+BVCj561zAS4Yzf0SaTqrnO8vl+Re +ImlsrDDWgo8v1rXHdEmNs+vd41TBVUiBqto/7v9b8k3yqz/rxzzH3AcKzBgsrouf3fo ghSUT0Zgtkm3OolKtRVmMYEAGN+TWv2YFMVr2jC+zhIoNK6EaTDFCM0nX5Yajp2kA7D+ 4jZA== X-Received: by 10.66.237.8 with SMTP id uy8mr39985426pac.95.1404891260779; Wed, 09 Jul 2014 00:34:20 -0700 (PDT) Received: from lanh ([115.73.209.165]) by mx.google.com with ESMTPSA id xy4sm43786237pac.19.2014.07.09.00.34.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 00:34:20 -0700 (PDT) Received: by lanh (sSMTP sendmail emulation); Wed, 09 Jul 2014 14:34:17 +0700 X-Mailer: git-send-email 1.9.1.346.ga2b5940 In-Reply-To: <1404891197-18067-1-git-send-email-pclouds@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Among pathnames in $GIT_DIR, e.g. "index" or "packed-refs", we want to automatically and silently map some of them to the $GIT_DIR of the repository we are borrowing from via $GIT_COMMON_DIR mechanism. When we formulate the pathname for its lockfile, we want it to be in the same location as its final destination. "index" is not shared and needs to remain in the borrowing repository, while "packed-refs" is shared and needs to go to the borrowed repository. git_path() could be taught about the ".lock" suffix and map "index.lock" and "packed-refs.lock" the same way their basenames are mapped, but instead the caller can help by asking where the basename (e.g. "index") is mapped to git_path() and then appending ".lock" after the mapping is done. Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy --- builtin/reflog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index e8a8fb1..9bd874d 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -372,7 +372,7 @@ static int expire_reflog(const char *ref, const uns= igned char *sha1, int unused, if (!reflog_exists(ref)) goto finish; if (!cmd->dry_run) { - newlog_path =3D git_pathdup("logs/%s.lock", ref); + newlog_path =3D mkpathdup("%s.lock", log_file); cb.newlog =3D fopen(newlog_path, "w"); } =20 --=20 1.9.1.346.ga2b5940