Re: [PATCH v9 2/6] fsmonitor: relocate socket file if .git directory is remote
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Sep 19, 2022, 19:57 UTC
- Message-ID
- <CAPig+cRzbXJ+npc29bXi4Jtmp9O+vhRF2wJQX6y4QFDVnzAkBg@mail.gmail.com>
- In-Reply-To
- <68709d788d531805d9328e16f53381fcd8d7bd5e.1663616277.git.gitgitgadget@gmail.com>
On Mon, Sep 19, 2022 at 3:38 PM Eric DeCosta via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 21 quoted lines
> If the .git directory is on a remote file system, create the socket
> file in 'fsmonitor.socketDir' if it is defined, else create it in $HOME.
>
> Signed-off-by: Eric DeCosta <edecosta@mathworks.com>
> ---
> diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
> @@ -0,0 +1,48 @@
> +const char *fsmonitor_ipc__get_path(struct repository *r)
> +{
> + char *sock_dir;
> +
> + repo_config_get_string(r, "fsmonitor.socketdir", &sock_dir);
> +
> + /* Create the socket file in either socketDir or $HOME */
> + if (sock_dir && *sock_dir) {
> + strbuf_addf(&ipc_file, "%s/.git-fsmonitor-%s",
> + sock_dir, hash_to_hex(hash));
> + free(sock_dir);
> + } else {
> + strbuf_addf(&ipc_file, "~/.git-fsmonitor-%s", hash_to_hex(hash));
> + }This is still leaking `sock_dir`, isn't it, if repo_config_get_string() returns it as a zero-length string?
Probably want to move free() below the entire conditional.
Show 12 quoted lines
> diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
> @@ -0,0 +1,9 @@
> +#include "config.h"
> +#include "fsmonitor-ipc.h"
> +
> +const char *fsmonitor_ipc__get_path(struct repository *r) {
> + static char *ret;
> + if (!ret)
> + ret = git_pathdup("fsmonitor--daemon.ipc");
> + return ret;
> +}
> \ No newline at end of fileStill an incomplete line.