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 23/32] prune: strategies for linked checkouts Date: Thu, 11 Sep 2014 05:41:59 +0700 Message-ID: <1410388928-32265-24-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:44:17 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 1XRqca-0002Gt-Q7 for gcvg-git-2@plane.gmane.org; Thu, 11 Sep 2014 00:44:17 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753389AbaIJWoM convert rfc822-to-quoted-printable (ORCPT ); Wed, 10 Sep 2014 18:44:12 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:61679 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753361AbaIJWoL (ORCPT ); Wed, 10 Sep 2014 18:44:11 -0400 Received: by mail-pa0-f41.google.com with SMTP id bj1so7249730pad.0 for ; Wed, 10 Sep 2014 15:44:10 -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=cG8zOrw1iwscZzXPdlYRG2bbY2g8AN1Yqe3cmccqGBE=; b=iGkZqlyfZGRQfxJQDBe0AVihtvAM8C28KtmCBcvgn+WeU9Im0VTtlYrQ1zo6gWK6Y1 TFEHMH3Hu1DTSAIVOxyMbf896IKsxp0m2++1WLwU9Q1xtd+g6oi1SlC5QapyjQJ7YeAv Ncf5y3Z17Vuft2XEpPqAn/3QEWlICSvzeokJJNIvW0Y9A3bOvsNHRr81TwA0FDFY7K01 IzZM0ZLLlaJQsyxYK1BWqXMfuEq8om+3wPggCdFNqStFcJulSGUi15hRhhUh2EK+9k/2 I76fhLEQ3+xNrUb4HUL06mj7++GlkFJdnl8eoADXxZXidPE3qH8iVdvvDLERtke9Wp76 HtOw== X-Received: by 10.70.2.228 with SMTP id 4mr30912621pdx.44.1410389050555; Wed, 10 Sep 2014 15:44:10 -0700 (PDT) Received: from lanh ([115.73.197.210]) by mx.google.com with ESMTPSA id yw4sm15420451pbc.69.2014.09.10.15.44.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Sep 2014 15:44:09 -0700 (PDT) Received: by lanh (sSMTP sendmail emulation); Thu, 11 Sep 2014 05:44:25 +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: (alias R=3D$GIT_COMMON_DIR/worktrees/) - linked checkouts are supposed to keep its location in $R/gitdir up to date. The use case is auto fixup after a manual checkout move. - linked checkouts are supposed to update mtime of $R/gitdir. If $R/gitdir's mtime is older than a limit, and it points to nowhere, worktrees/ is to be pruned. - If $R/locked exists, worktrees/ is not supposed to be pruned. If $R/locked exists and $R/gitdir's mtime is older than a really long limit, warn about old unused repo. - "git checkout --to" is supposed to make a hard link named $R/link pointing to the .git file on supported file systems to help detect the user manually deleting the checkout. If $R/link exists and its link count is greated than 1, the repo is kept. Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy --- Documentation/git-checkout.txt | 18 ++++++ Documentation/git-prune.txt | 3 + Documentation/gitrepository-layout.txt | 19 ++++++ builtin/checkout.c | 19 +++++- builtin/prune.c | 95 ++++++++++++++++++++++= ++++++++ setup.c | 13 ++++ t/t2026-prune-linked-checkouts.sh (new +x) | 84 ++++++++++++++++++++++= ++++ 7 files changed, 249 insertions(+), 2 deletions(-) create mode 100755 t/t2026-prune-linked-checkouts.sh diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkou= t.txt index bd0fc1d..a29748e 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -431,6 +431,24 @@ thumb is do not make any assumption about whether = a path belongs to $GIT_DIR or $GIT_COMMON_DIR when you need to directly access something inside $GIT_DIR. Use `git rev-parse --git-path` to get the final path. =20 +When you are done, simply deleting the linked working directory would +suffice. $GIT_DIR/worktrees can be cleaned up using `git prune +--worktrees`. + +After you move a linked working directory to another file system, or +on a file system that does not support hard link, execute any git +command (e.g. `git status`) in the new working directory so that it +could update its location in $GIT_DIR/worktrees and not be +accidentally pruned. + +To stop `git prune --worktrees` from deleting a specific working +directory (e.g. because it's on a portable device), you could add the +file 'locked' to $GIT_DIR/worktrees. For example, if `.git` file of +the new working directory points to `/path/main/worktrees/test-next`, +the full path of the 'locked' file would be +`/path/main/worktrees/test-next/locked`. See +linkgit:gitrepository-layout[5] for details. + EXAMPLES -------- =20 diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt index 7a493c8..a0ea381 100644 --- a/Documentation/git-prune.txt +++ b/Documentation/git-prune.txt @@ -48,6 +48,9 @@ OPTIONS --expire