git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 2/6] worktree: stop supporting moving worktrees manually
Date: Mon, 18 Jan 2016 18:21:30 +0700	[thread overview]
Message-ID: <1453116094-4987-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1453116094-4987-1-git-send-email-pclouds@gmail.com>

The current update_linked_gitdir() has a bug that can create "gitdir"
file in non-multi-worktree setup. Worse, sometimes it can write relative
path to "gitdir" file, which will not work (e.g. "git worktree list"
will display the worktree's location incorrectly)

Instead of fixing this, we step back a bit. The original design was
probably not well thought out. For now, if the user manually moves a
worktree, they have to fix up "gitdir" file manually or the worktree
will get pruned.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-worktree.txt |  6 ++----
 setup.c                        | 12 ------------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 5b9ad04..4814f48 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -33,10 +33,8 @@ The working tree's administrative files in the repository (see
 clean up any stale administrative files.
 
 If you move a linked working tree 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 tree
-(e.g. `git status`) in order to update its administrative files in the
-repository so that they do not get automatically pruned.
+within a file system that does not support hard links, you need to update
+$GIT_DIR/worktrees/<id>/gitdir so that they do not get automatically pruned.
 
 If a linked working tree is stored on a portable device or network share
 which is not always mounted, you can prevent its administrative files from
diff --git a/setup.c b/setup.c
index d343725..6ee2b23 100644
--- a/setup.c
+++ b/setup.c
@@ -434,17 +434,6 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 	return ret;
 }
 
-static void update_linked_gitdir(const char *gitfile, const char *gitdir)
-{
-	struct strbuf path = STRBUF_INIT;
-	struct stat st;
-
-	strbuf_addf(&path, "%s/gitdir", gitdir);
-	if (stat(path.buf, &st) || st.st_mtime + 24 * 3600 < time(NULL))
-		write_file(path.buf, "%s", gitfile);
-	strbuf_release(&path);
-}
-
 /*
  * Try to read the location of the git directory from the .git file,
  * return path to git directory if found.
@@ -514,7 +503,6 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
 		error_code = READ_GITFILE_ERR_NOT_A_REPO;
 		goto cleanup_return;
 	}
-	update_linked_gitdir(path, dir);
 	path = real_path(dir);
 
 cleanup_return:
-- 
2.7.0.96.g5373197

  parent reply	other threads:[~2016-01-18 11:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 11:21 [PATCH v2 0/6] Kill and replace update_linked_gitdir() Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` [PATCH v2 1/6] worktree.c: fix indentation Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` Nguyễn Thái Ngọc Duy [this message]
2016-01-18 18:24   ` [PATCH v2 2/6] worktree: stop supporting moving worktrees manually Eric Sunshine
2016-01-18 11:21 ` [PATCH v2 3/6] worktree.txt: how to fix up after moving a worktree Nguyễn Thái Ngọc Duy
2016-01-18 18:30   ` Eric Sunshine
2016-01-19  5:20     ` Duy Nguyen
2016-01-18 11:21 ` [PATCH v2 4/6] abspath.c: add and use real_path_dup() Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` [PATCH v2 5/6] setup.c: record the location of .git file Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` [PATCH v2 6/6] worktree: new command to fix up worktree's info after moving Nguyễn Thái Ngọc Duy
2016-01-18 13:07   ` Philip Oakley
2016-01-19 18:25   ` Junio C Hamano
2016-01-22  8:35 ` [PATCH v3 0/2] Kill and replace update_linked_gitdir() Nguyễn Thái Ngọc Duy
2016-01-22  8:35   ` [PATCH v3 1/2] worktree.c: fix indentation Nguyễn Thái Ngọc Duy
2016-01-22  8:35   ` [PATCH v3 2/2] worktree: stop supporting moving worktrees manually Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453116094-4987-3-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).