Re: [PATCH v3 1/2] rev-parse: add --prefix option
- From
John Keeping <john@keeping.me.uk>
- Date
- Apr 19, 2013, 11:25 UTC
- Message-ID
- <20130419112524.GH2278@serenity.lan>
- In-Reply-To
- <CALkWK0kbXSfghZ69qypfaFF8orWy-bZLRPXcV5WMc5YQ=-18GA@mail.gmail.com>
On Fri, Apr 19, 2013 at 04:45:38PM +0530, Ramkumar Ramachandra wrote:
Show 20 quoted lines
> John Keeping wrote:
> > I'm not actually sure this is better. I'm more afraid of the condition
> > for outputting files changing in the future than of passing
> > output_prefix around, so I'd much rather keep that condition in one
> > place.
> >
> > If you really feel strongly about it, I'd prefer to extract the if
> > condition to a function and use that directly when deciding whether to
> > print "--".
>
> Yeah, it would probably make more sense to extract the conditional. I
> just thought it was unnecessary to pass the argument around, but feel
> free to go either way on this one.
>
> > [Also, you introduce a potential segfault via passing a NULL prefix to
> > strlen.]
>
> Isn't prefix guaranteed to be set by setup_git_directory()? If I
> wanted to check it nevertheless, I'd probably put in a die("internal
> error") before this line. Feel free to go either way though.It looks to me like setup_git_directory() returns NULL if we're at the top of the working tree so we do need that check. I suspect that's so that "!prefix" does the right thing.