From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id B68DA1F506 for ; Wed, 14 Sep 2022 15:48:31 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=mathworks.com header.i=@mathworks.com header.b="WZkL4r6t"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230205AbiINPrO (ORCPT ); Wed, 14 Sep 2022 11:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbiINPrJ (ORCPT ); Wed, 14 Sep 2022 11:47:09 -0400 Received: from us-smtp-delivery-120.mimecast.com (us-smtp-delivery-120.mimecast.com [170.10.129.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE5362A81 for ; Wed, 14 Sep 2022 08:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mathworks.com; s=mimecast20180117; t=1663170427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m17wwJ7fQ4E8m58c2+thXJxRGHx8NDgg2uXCbQg2vLc=; b=WZkL4r6tQW03xle1aCxR7t8lea8XITQ90rg0uwBkcMlAAEBkgv2XaPeFs7/+yYhWhGgx3x QrNB3bIx99BTJpCGHkKlR7HahKhXiClwP0BS62Dbf384DwgHb0nFYYUp6Lv3V/WhS2Luwe 8ac4sjkz+CI359pB+Zer+TtxknvQ+mk= Received: from na01-obe.outbound.protection.outlook.com (mail-eastusazlp17010009.outbound.protection.outlook.com [40.93.11.9]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-QvGMC4cNPB29mnNqnZMPEQ-2; Wed, 14 Sep 2022 11:47:05 -0400 X-MC-Unique: QvGMC4cNPB29mnNqnZMPEQ-2 Received: from BL0PR05MB5571.namprd05.prod.outlook.com (2603:10b6:208:2f::17) by CO6PR05MB7506.namprd05.prod.outlook.com (2603:10b6:5:350::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.6; Wed, 14 Sep 2022 15:47:03 +0000 Received: from BL0PR05MB5571.namprd05.prod.outlook.com ([fe80::86c9:5cc7:6693:d9f7]) by BL0PR05MB5571.namprd05.prod.outlook.com ([fe80::86c9:5cc7:6693:d9f7%6]) with mapi id 15.20.5632.011; Wed, 14 Sep 2022 15:47:03 +0000 From: Eric DeCosta To: Junio C Hamano , Eric DeCosta via GitGitGadget CC: "git@vger.kernel.org" , Jeff Hostetler , Eric Sunshine , =?iso-8859-1?Q?Torsten_B=F6gershausen?= , =?iso-8859-1?Q?=C6var_Arnfj=F6r=F0_Bjarmason?= , Ramsay Jones , Johannes Schindelin Subject: RE: [PATCH v6 3/6] fsmonitor: relocate socket file if .git directory is remote Thread-Topic: [PATCH v6 3/6] fsmonitor: relocate socket file if .git directory is remote Thread-Index: AQHYx69LJfEHlHcOIESkrZdTmuFekq3eGAYVgAD4u/A= Date: Wed, 14 Sep 2022 15:47:03 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BL0PR05MB5571:EE_|CO6PR05MB7506:EE_ x-ms-office365-filtering-correlation-id: 6376b46e-01e1-48c0-d783-08da96685e6d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0 x-microsoft-antispam-message-info: yl94oXHy60FilQN//n7PMCo2n4YhBu2U0SRc2bC9shar+Mo5QL6q/ulhAhSS7J99BkvnZxHreqm+7I9wq91XZou9bh42k3yNTBNL06ELJ3qrn5207l0bRLKGWz5O7mAIfGFFq2DrYuQqwh+zO8kOTwghOR+VHmwhkH/eRlIBWXM2dmb7kNMWa9rhQ1eHvADvhuyOFRcDODita/IDxHN8hGe+IGUpA9Vdcf+OOOTH1jrqiOxsJoZQHD0XxPyRf0nu+pevbf25f8JiY434tJNLlAFLeXDzQ1mpION1breJ1TaPt4BV8inyXpcLynHwx0AYFP0eChfUJPvd/iP9A8XLMZgpXkEgmHBQYE+CnCEhqv/NkOtjbcu/vKALitPmTVWBS2ZcSJFBJKjM77iloDkqxW22Ym2Yah877Y2PhmLhsftc3QLtfQR4bO0namsJez16tWJZBszAyq/vI0K4dMGJshdwrr6bDJX/PF5Hi+AvT/VOij+JHHHI7ME65Mc4N4t/R++pSk1tL6ImCXe7i3OFyf/ZNIZ355Dizaz1zP4I2udc4npfFuH12HcZbqZFaMWeGqrbCkzDQK8sJcwocmyqV+aKFis/7Agq/S39qPL6ROoodUGc96sBrX5fqu06hJoPtNuD3UeVN67uoq27C0NPhkEfqk/XktlbpvioNB4X+lkHILeyoS0qY6nO+3JEwzITpklhXW3nWFh8DPVA2Qx0iZzdEUPUY1qz1i7j2xp/zWB0p9trxoFk4J/HGzetlK6b3wQDXvwK/zJ0nUpfYlx9p6KQfK11QjW3/8YdhlsRPfAltD/MsNOT7xPOTN/a+csxL0YAg6RXd1I5M439qS4mRPe86C0yOmZ9o8wFw2QEtCg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR05MB5571.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(376002)(396003)(366004)(346002)(451199015)(38100700002)(122000001)(478600001)(53546011)(2906002)(86362001)(6506007)(52536014)(55016003)(71200400001)(54906003)(64756008)(38070700005)(4326008)(76116006)(66946007)(41300700001)(33656002)(66446008)(26005)(66476007)(66556008)(5660300002)(83380400001)(66574015)(7696005)(186003)(9686003)(8676002)(8936002)(110136005)(316002)(142923001)(473944003)(414714003);DIR:OUT;SFP:1101 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ltf4UA0xkbmh1o9c2IH+C7+MzsC6xenyMsHbS1n/HIO7stjwE5yoSV6gA5?= =?iso-8859-1?Q?en0mtI+dCz8mQm/enULw8coFY687RiU6Zo6yzxMkTYEZO6rzEn25sof0Bm?= =?iso-8859-1?Q?cL7RGymZoCKLTGcggvmys+L1qoAzJnYUIhE6Ry4SxdikEnKBGUvvtmqyZs?= =?iso-8859-1?Q?XL3ElMAze7olEysGrSHx6YHmldVBXN14ftp0PMaKF0nZTLW0v+ixaA1eZp?= =?iso-8859-1?Q?smwGOWqhnys7mSq7Nire1AyAuVPYn0O2lBzqb88T0jKVpYO6HeEikgnUzz?= =?iso-8859-1?Q?tGCNkRwmb2WabHhDelWd8xff9fWcRz///vFXv7Buyw7A/Vm1rIe7cB8zVV?= =?iso-8859-1?Q?BvMSaunOvampYA+7ym/ggHGT6kP+EsgujkdfoXbWnboQFwd52fKlSMIg8K?= =?iso-8859-1?Q?LcnGhwXJxc26CeWNDix5XKTr6FoLq9jx1ERChWAx/msRlc4y5U5Vxp/e0i?= =?iso-8859-1?Q?RMqdPDpY9oYGSU9GodYloFPXU4LzJ256dtAiUh/SIK1QrfhuA5r0DSKKHl?= =?iso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Ebippz+u2w+cD9eWzL7pl?= =?iso-8859-1?Q?TXTPgdZHxHZgtOM69FjRUzhuFz/gtINthxycMUGWXY/2inrslLGl+N1FBS?= =?iso-8859-1?Q?XeTFMNKGDr3BK+78TQPmeuVU2OLQE75Zzy2NYq+HxU3b26/3Q8ZMTCApEV?= =?iso-8859-1?Q?pZ8MZBWxXmanGLRRoLbd1zSNhhT24LPeEalyoiMFcn0S7tItzobEh18PIN?= =?iso-8859-1?Q?74SOhGbeKIc/9EY9Y2YqC1x3cqyG+f/85h?= MIME-Version: 1.0 X-OriginatorOrg: mathworks.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR05MB7506 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: mathworks.com Content-Language: en-US Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org > -----Original Message----- > From: Junio C Hamano > Sent: Tuesday, September 13, 2022 8:48 PM > To: Eric DeCosta via GitGitGadget > Cc: git@vger.kernel.org; Jeff Hostetler ; Eric Sun= shine > ; Torsten B=F6gershausen ; > =C6var Arnfj=F6r=F0 Bjarmason ; Ramsay Jones > ; Johannes Schindelin > ; Eric DeCosta > Subject: Re: [PATCH v6 3/6] fsmonitor: relocate socket file if .git direc= tory is > remote >=20 > "Eric DeCosta via GitGitGadget" writes: >=20 > > +const char *fsmonitor_ipc__get_path(void) { >=20 > Looks like a bit klunky API. I would have expected it to take at least t= he path > to the worktree or a pointer to struct repository. >=20 OK, I'll change it to take a pointer to struct repository. > > +=09static const char *ipc_path; > > +=09SHA_CTX sha1ctx; > > +=09char *sock_dir; > > +=09struct strbuf ipc_file =3D STRBUF_INIT; > > +=09unsigned char hash[SHA_DIGEST_LENGTH]; > > + > > +=09if (ipc_path) > > +=09=09return ipc_path; > > + > > +=09ipc_path =3D fsmonitor_ipc__get_default_path(); > > + > > +=09/* By default the socket file is created in the .git directory */ > > +=09if (fsmonitor__is_fs_remote(ipc_path) < 1) > > +=09=09return ipc_path; > > + > > +=09SHA1_Init(&sha1ctx); > > +=09SHA1_Update(&sha1ctx, the_repository->worktree, > strlen(the_repository->worktree)); > > +=09SHA1_Final(hash, &sha1ctx); >=20 > I would not worry about SHA-1 hash collision for this use case, but would > worry more about .worktree possible being unique. >=20 > Can the .worktree string be aliased for the same directory in some way (e= .g. > depending on the initialization sequence, can it be a full pathname, a re= lative > pathname, or can a pathname that looks like a full-pathname have symbolic > link component in it?) that ends up creating two or more socket for the s= ame > worktree? >=20 .worktree is set to the real path and since hardlinks are not allowed acros= s file systems, I think we are OK. > > +=09repo_config_get_string(the_repository, "fsmonitor.socketdir", > > +&sock_dir); > > + > > +=09/* Create the socket file in either socketDir or $HOME */ > > +=09if (sock_dir && *sock_dir) > > +=09=09strbuf_addf(&ipc_file, "%s/.git-fsmonitor-%s", > > +=09=09=09=09=09sock_dir, hash_to_hex(hash)); > > +=09else > > +=09=09strbuf_addf(&ipc_file, "~/.git-fsmonitor-%s", > hash_to_hex(hash)); > > + > > +=09ipc_path =3D interpolate_path(ipc_file.buf, 1); > > +=09if (!ipc_path) > > +=09=09die(_("Invalid path: %s"), ipc_file.buf); > > + > > +=09strbuf_release(&ipc_file); > > +=09return ipc_path; > > +}