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 v2 08/32] reflog: avoid constructing .lock path with git_path Date: Thu, 11 Sep 2014 05:41:44 +0700 Message-ID: <1410388928-32265-9-git-send-email-pclouds@gmail.com> References: <1409387642-24492-1-git-send-email-pclouds@gmail.com> <1410388928-32265-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 Thu Sep 11 00:42:53 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 1XRqbE-0001RY-In for gcvg-git-2@plane.gmane.org; Thu, 11 Sep 2014 00:42:52 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753041AbaIJWms convert rfc822-to-quoted-printable (ORCPT ); Wed, 10 Sep 2014 18:42:48 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:49031 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752985AbaIJWms (ORCPT ); Wed, 10 Sep 2014 18:42:48 -0400 Received: by mail-pa0-f43.google.com with SMTP id fa1so7948596pad.2 for ; Wed, 10 Sep 2014 15:42:46 -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=GzzLZWyanTSqrGXiazAN/gukwyPFzQp4vKraixB0IOU=; b=ypafUyJXF9XX4s2npAxE6vd9d+vEGlZcq8647wlHTQPf5Dtvx6ORZom/x68z3NOfGG hKlWFa/NGxjTtOy7+gZxM+HxHBh2Sg4lXFwPiY8DEsw//V993thc53mUcj+AhgdhfEk2 aTq4rWg5ka2Pj02k/OauvWQKmAMNVHRCER66hseEE7Fqhy2TBnWPExV4uZ1+nVzqda7s GnIIlyAG2Hdd5GY4rIQSGZLc+td5QOXNOtaAhzdph1XRDqF42D+P5ZKXdcdxDs3Pui/3 bxn+IkAoGrz8tjGGfu1IFof+qtgdxg3c7Wy2tBNpvgI4qjrfzj+IVSxZGS+m2Tg19mFC 7Hng== X-Received: by 10.66.129.139 with SMTP id nw11mr70290837pab.16.1410388966152; Wed, 10 Sep 2014 15:42:46 -0700 (PDT) Received: from lanh ([115.73.197.210]) by mx.google.com with ESMTPSA id j5sm15622136pdp.9.2014.09.10.15.42.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2014 15:42:45 -0700 (PDT) Received: by lanh (sSMTP sendmail emulation); Thu, 11 Sep 2014 05:43:06 +0700 X-Mailer: git-send-email 2.1.0.rc0.78.gc0d8480 In-Reply-To: <1410388928-32265-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 Signed-off-by: Junio C Hamano --- 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 2.1.0.rc0.78.gc0d8480