Re: [PATCH 3/5] worktree: teach "repair" to fix outgoing links to worktrees
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 28, 2020, 02:15 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2008280413450.56@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20200827082129.56149-4-sunshine@sunshineco.com>
Hi Eric,
On Thu, 27 Aug 2020, Eric Sunshine wrote:
Show 25 quoted lines
> diff --git a/worktree.c b/worktree.c
> index 029ce91fdf..6ade4f0d8b 100644
> --- a/worktree.c
> +++ b/worktree.c
> @@ -624,3 +624,77 @@ void repair_worktrees(worktree_repair_cb *cb, void *cb_data)
> repair_dotgit(*wt, cb, cb_data);
> free_worktrees(worktrees);
> }
> +
> +static int is_main_worktree_path(const char *path)
> +{
> + struct strbuf target = STRBUF_INIT;
> + struct strbuf main = STRBUF_INIT;
> + int cmp;
> +
> + strbuf_add_real_path(&target, path);
> + strbuf_strip_suffix(&target, "/.git");
> + strbuf_add_real_path(&main, get_git_common_dir());
> + strbuf_strip_suffix(&main, "/.git");
> + cmp = fspathcmp(main.buf, target.buf);
> +
> + strbuf_release(&main);
> + strbuf_release(&target);
> + return !cmp;
> +}This breaks our `linux-gcc` job, and I need this on top, to make it even build:
-- snipsnap -- From: Johannes Schindelin <johannes.schindelin@gmx.de> Subject: [PATCH] fixup??? worktree: teach "repair" to fix outgoing links to worktrees
This is needed to shut up GCC's "‘main’ is usually a function [-Werror=main]" error.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- worktree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/worktree.c b/worktree.c index 6ade4f0d8b2b..5471915d4680 100644 --- a/worktree.c +++ b/worktree.c @@ -628,16 +628,16 @@ void repair_worktrees(worktree_repair_cb *cb, void *cb_data) static int is_main_worktree_path(const char *path) { struct strbuf target = STRBUF_INIT; - struct strbuf main = STRBUF_INIT; + struct strbuf main_worktree = STRBUF_INIT; int cmp; strbuf_add_real_path(&target, path); strbuf_strip_suffix(&target, "/.git"); - strbuf_add_real_path(&main, get_git_common_dir()); - strbuf_strip_suffix(&main, "/.git"); - cmp = fspathcmp(main.buf, target.buf); + strbuf_add_real_path(&main_worktree, get_git_common_dir()); + strbuf_strip_suffix(&main_worktree, "/.git"); + cmp = fspathcmp(main_worktree.buf, target.buf); - strbuf_release(&main); + strbuf_release(&main_worktree); strbuf_release(&target); return !cmp; } -- 2.28.0.windows.1