git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C HamanoNext: Eric Sunshine
Message 14 of 22 in “add "git worktree repair" command”
  1. 0/5 add "git worktree repair" commandEric Sunshine, Aug 27, 2020
  2. 1/5 worktree: add skeleton "repair" commandEric Sunshine, Aug 27, 2020
  3. Junio C HamanoAug 27, 2020
  4. Eric SunshineAug 27, 2020
  5. 5/5 init: make --separate-git-dir work from within linked worktreeEric Sunshine, Aug 27, 2020
  6. 4/5 init: teach --separate-git-dir to repair linked worktreesEric Sunshine, Aug 27, 2020
  7. 2/5 worktree: teach "repair" to fix worktree back-links to main worktreeEric Sunshine, Aug 27, 2020
  8. Junio C HamanoAug 27, 2020
  9. Eric SunshineAug 30, 2020
  10. 3/5 worktree: teach "repair" to fix outgoing links to worktreesEric Sunshine, Aug 27, 2020
  11. Junio C HamanoAug 27, 2020
  12. Eric SunshineAug 30, 2020
  13. Junio C HamanoAug 31, 2020
  14. Johannes SchindelinAug 28, 2020
  15. Eric SunshineAug 28, 2020
  16. 0/5 add "git worktree repair" commandEric Sunshine, Aug 31, 2020
  17. 1/5 worktree: add skeleton "repair" commandEric Sunshine, Aug 31, 2020
  18. 3/5 worktree: teach "repair" to fix outgoing links to worktreesEric Sunshine, Aug 31, 2020
  19. 5/5 init: make --separate-git-dir work from within linked worktreeEric Sunshine, Aug 31, 2020
  20. 2/5 worktree: teach "repair" to fix worktree back-links to main worktreeEric Sunshine, Aug 31, 2020
  21. 4/5 init: teach --separate-git-dir to repair linked worktreesEric Sunshine, Aug 31, 2020
  22. Junio C HamanoAug 31, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.