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 v3 23/32] prune: strategies for linked checkouts Date: Sun, 28 Sep 2014 08:22:37 +0700 Message-ID: <1411867366-3821-24-git-send-email-pclouds@gmail.com> References: <1411867366-3821-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?= , Marc Branchaud To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Sep 28 03:25:03 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 1XY3EU-0002fZ-3j for gcvg-git-2@plane.gmane.org; Sun, 28 Sep 2014 03:25:02 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753457AbaI1BY5 convert rfc822-to-quoted-printable (ORCPT ); Sat, 27 Sep 2014 21:24:57 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:53530 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753183AbaI1BY5 (ORCPT ); Sat, 27 Sep 2014 21:24:57 -0400 Received: by mail-pa0-f44.google.com with SMTP id et14so513471pad.31 for ; Sat, 27 Sep 2014 18:24:56 -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=We/ot2KAR6XXabYZ//uL/NbIK3TO9BsC5kxj7d4SRUY=; b=OTpEX9eRVwShufWyO4a9VJqfvGYuqlGoRzvaXFEbQ1HtV5Zd/TyCV/t34EieXaFb6m Mt8P1LBM8S6pDielDVCxL6XQApDh5cfqSMbZyurbPrOMqhnvrDWI6ryjlbIWdTbJ5iQQ VUERtJTNigHLJxFAUkupBgyACwTfDDEcgMyStFdGzyqNx7WhTCDjUeO6mj9cah2FW54l yDLUGzgEskZcOXjdD5n9GE+0dbz8WFPwsDGwMbOwMcHeCJV1HP35CxmmT1rmGH8v5TM2 MLwImgnISU9EPPLKLyAj5JeRE0wpqiIdZvlWgMoMrT7krfJzmHVvgUkaPJ6qan7fzLaU mI9A== X-Received: by 10.70.87.169 with SMTP id az9mr58246373pdb.63.1411867496573; Sat, 27 Sep 2014 18:24:56 -0700 (PDT) Received: from lanh ([115.73.212.224]) by mx.google.com with ESMTPSA id cz1sm8522332pdb.85.2014.09.27.18.24.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Sep 2014 18:24:55 -0700 (PDT) Received: by lanh (sSMTP sendmail emulation); Sun, 28 Sep 2014 08:24:59 +0700 X-Mailer: git-send-email 2.1.0.rc0.78.gc0d8480 In-Reply-To: <1411867366-3821-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. Helped-by: Marc Branchaud Helped-by: Eric Sunshine Signed-off-by: Marc Branchaud Signed-off-by: Nguy=E1=BB=85n Th=C3=A1i Ng=E1=BB=8Dc Duy --- Documentation/git-checkout.txt | 20 +++++++ 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, 251 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 c101575..35675da 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -434,6 +434,26 @@ 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 with a linked working tree you can simply delete it. +You can clean up any stale $GIT_DIR/worktrees entries via `git prune +--worktrees` in the main or any linked working tree. + +If you move a linked working directory to another file system, or +within a file system that does not support hard links, you need to run +at least one git command inside the linked working directory +(e.g. `git status`) in order to update its entry in $GIT_DIR/worktrees +so that it does not get automatically removed. + +To prevent `git prune --worktrees` from deleting a $GIT_DIR/worktrees +entry (which can be useful in some situations, such as when the +entry's working tree is stored on a portable device), add a file named +'locked' to the entry's directory. The file contains the reason in +plain text. For example, if a linked working tree's `.git` file points +to `/path/main/.git/worktrees/test-next` then a file named +`/path/main/.git/worktrees/test-next/locked` will prevent the +`test-next` entry from being pruned. See +linkgit:gitrepository-layout[5] for details. + EXAMPLES -------- =20 diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt index 7a493c8..1cf3bed 100644 --- a/Documentation/git-prune.txt +++ b/Documentation/git-prune.txt @@ -48,6 +48,9 @@ OPTIONS --expire