From: Nguyễn Thái Ngọc Duy Date: Tue, 25 Aug 2015 10:30:46 +0000 (+0700) Subject: setup: update the right file in multiple checkouts X-Git-Tag: v2.6.0-rc0~15^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=82fde87ff3be8d10854df18964e5816417a1d7cf;p=git-core%2Fgit.git setup: update the right file in multiple checkouts This code is introduced in 23af91d (prune: strategies for linked checkouts - 2014-11-30), and it's supposed to implement this rule from that commit's message: - 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. Note the name, "$R/gitdir", not "$R/gitfile". Correct the path to be updated accordingly. While at there, make sure I/O errors are not silently dropped. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- diff --git a/setup.c b/setup.c index 82c0cc2a1..465b42a1d 100644 --- a/setup.c +++ b/setup.c @@ -402,9 +402,9 @@ static void update_linked_gitdir(const char *gitfile, const char *gitdir) struct strbuf path = STRBUF_INIT; struct stat st; - strbuf_addf(&path, "%s/gitfile", gitdir); + strbuf_addf(&path, "%s/gitdir", gitdir); if (stat(path.buf, &st) || st.st_mtime + 24 * 3600 < time(NULL)) - write_file(path.buf, 0, "%s\n", gitfile); + write_file(path.buf, 1, "%s\n", gitfile); strbuf_release(&path); }