# [PATCH] worktree: fix order of arguments in error message

2 messages from 2020-11-20 to 2020-11-20. Participants: Matheus Tavares, Eric Sunshine.
Thread: https://gitlist.dev/t/54680

## Matheus Tavares, 2020-11-20 15:09

Subject: [PATCH] worktree: fix order of arguments in error message
Message-ID: <1d740e0d4fc08a9f420373c6cd0a554b3b4b1f40.1605883395.git.matheus.bernardino@usp.br>
URL: https://gitlist.dev/e/1d740e0d4fc08a9f420373c6cd0a554b3b4b1f40.1605883395.git.matheus.bernardino%40usp.br

```
`git worktree add` (without --force) errors out when given a path
that is already registered as a worktree and the path is missing on
disk. But the `cmd` and `path` strings are switched on the error
message. Let's fix that.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
---
 builtin/worktree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index ce56fdaaa9..197fd24a55 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -304,9 +304,9 @@ static void check_candidate_path(const char *path,
 	}
 
 	if (locked)
-		die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), cmd, path);
+		die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), path, cmd);
 	else
-		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), cmd, path);
+		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
 static int add_worktree(const char *path, const char *refname,
-- 
2.28.0


```

## Eric Sunshine, 2020-11-20 16:24

Subject: Re: [PATCH] worktree: fix order of arguments in error message
Message-ID: <CAPig+cS7SEARwoBn25SsxhkvdJfDe56FyVjDGk+sJq2kXfDbjQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcS7SEARwoBn25SsxhkvdJfDe56FyVjDGk%2BsJq2kXfDbjQ%40mail.gmail.com
In-Reply-To: <1d740e0d4fc08a9f420373c6cd0a554b3b4b1f40.1605883395.git.matheus.bernardino@usp.br>

```
On Fri, Nov 20, 2020 at 10:09 AM Matheus Tavares
<matheus.bernardino@usp.br> wrote:
> `git worktree add` (without --force) errors out when given a path
> that is already registered as a worktree and the path is missing on
> disk. But the `cmd` and `path` strings are switched on the error
> message. Let's fix that.

Thanks. This problem was introduced quite recently by d179af679b
(worktree: generalize candidate worktree path validation, 2020-06-10).

> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> ---
> -               die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), cmd, path);
> +               die(_("'%s' is a missing but locked worktree;\nuse '%s -f -f' to override, or 'unlock' and 'prune' or 'remove' to clear"), path, cmd);

The fix is obviously correct. For what it's worth, this patch is:

Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>

```
