Re: [PATCH 1/3] Use startup_info->prefix rather than prefix.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 3, 2012, 21:44 UTC
- Message-ID
- <7vbood742a.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <CACsJy8DtZLCLfeHNP_eq9kVZxjV3xh3gs6pgQCi=FDZ_Je7_Gw@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> This patch makes this function only usable when startup_info pointer > is initialized. As "git" binary is the only caller, the change is ok. > If non-builtin commands want to use this function, they need to > initialize startup_info first.
Hrm, that explanation is understandable, but it strongly makes me suspect that this change is making the code _more_ error prone in the longer term.
When somebody wants to add a new caller to a non-builtin, they need to think about what prefix to pass, and would realize that they need to call setup_git_directory() to get it. With the updated code, they can totally forget and call it without any initialized startup_info.
Adding a totally new command is rare, new non-builtin is rarer, and adding trace to it is even more so, so it may not be worth worrying about, but I wonder if there is a cheap way to check such a programming mistake.