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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Aug 25, 2015 at 17:30 UTC 82fde87ff3be8d10854df18964e5816417a1d7cf
1 file changed +2 -2
setup.c
+2 -2
@@ -402,9 +402,9 @@ static void update_linked_gitdir(const char *gitfile, const char *gitdir)
402 struct strbuf path = STRBUF_INIT;
403 struct stat st;
404
405 - strbuf_addf(&path, "%s/gitfile", gitdir);
405 + strbuf_addf(&path, "%s/gitdir", gitdir);
406 if (stat(path.buf, &st) || st.st_mtime + 24 * 3600 < time(NULL))
407 - write_file(path.buf, 0, "%s\n", gitfile);
407 + write_file(path.buf, 1, "%s\n", gitfile);
408 strbuf_release(&path);
409 }
410