Re: [PATCH] setup: update the right file in multiple checkouts
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 25, 2015, 16:38 UTC
- Message-ID
- <xmqqlhcz1fy8.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1440498646-25663-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 16 quoted lines
> 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> > --- > The code was right in v2 [1] and became "gitfile" since v3 [2]. I > need to reconsider my code quality after this :(
Heh, don't sweat it. Everybody makes mistakes and sometimes becomes sloppy.
Thanks for double checking and correcting. Perhaps this could have caught if we had some test coverage, I wonder?
Show 21 quoted lines
> [1] http://article.gmane.org/gmane.comp.version-control.git/239299 > [2] http://article.gmane.org/gmane.comp.version-control.git/242325 > > setup.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/setup.c b/setup.c > index 5f9f07d..64bf2b4 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); > }