Skip to content

Commit

Permalink
setup: update the right file in multiple checkouts
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Aug 25, 2015
1 parent a17c56c commit 82fde87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 82fde87

Please sign in to comment.