Re: [PATCH 1/7] path.c: implement xdg_config_home()
- From
Stefan Beller <sbeller@google.com>
- Date
- Apr 14, 2015, 22:28 UTC
- Message-ID
- <CAGZ79kaO_1QMMTY0ni9k3hrkrt_PhqRDRzXkhZEiYuJ0EsE9Tw@mail.gmail.com>
- In-Reply-To
- <xmqqzj6a1m3c.fsf@gitster.dls.corp.google.com>
On Tue, Apr 14, 2015 at 1:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
> Johannes Schindelin <johannes.schindelin@gmx.de> writes: > >>> diff --git a/cache.h b/cache.h >>> index 3d3244b..7f9bab0 100644 >>> --- a/cache.h >>> +++ b/cache.h >>> @@ -836,6 +836,13 @@ char *strip_path_suffix(const char *path, const >>> char *suffix); >>> int daemon_avoid_alias(const char *path); >>> extern int is_ntfs_dotgit(const char *name); >>> >>> +/** >>> + * Returns the newly allocated string "$XDG_CONFIG_HOME/git/%s". If >>> + * $XDG_CONFIG_HOME is unset or empty, returns the newly allocated string >>> + * "$HOME/.config/git/%s". Returns NULL if an error occurred. >>> + */ >>> +extern char *xdg_config_home(const char *fn); >> >> Should this not be inserted close to home_config_paths()? Also, the >> name "fn" sounds more like "function" than like "filename" to me, >> especially keeping the name `config_fn_t` in mind. Maybe call the >> parameter "filename" to avoid confusion? > > It is OK to omit the name in the extern declaration here. We have > to have a sensible variable name in the definition in path.c, of > course ;-), and "filename" sounds like a very sensible suggestion. >
It is OK, but I think this is bad practice. Have a look at strbuf.h, there you'll find:
extern int strbuf_getwholeline_fd(struct strbuf *, int, int);
It's not clear what the 2 ints are, probably a fd and a max size? Even if guessed correctly, you'd still need another guess for the order.