Re: [PATCH v3 2/4] branch: fix die_if_checked_out() when ignore_current_worktree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Feb 05 2023, Rubén Justo wrote:

> -	wt = find_shared_symref(worktrees, "HEAD", branch);
> -	if (wt && (!ignore_current_worktree || !wt->is_current)) {
> -		skip_prefix(branch, "refs/heads/", &branch);
> -		die(_("'%s' is already checked out at '%s'"), branch, wt->path);
> +	for (int i = 0; worktrees[i]; i++) {

I see that there are existing "int i" for counting worktrees in
worktree.c, FWIW for new code I wouldn't mind if it's "size_t i"
instead, to make it future proof (and to eventually get rid of cast
warnings as we move more things from "int" to "size_t").
> @@ -435,10 +435,9 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
>  					  const char *target)
>  {
>  
> -	for (int i = 0; worktrees[i]; i++) {
> +	for (int i = 0; worktrees[i]; i++)
>  		if (is_shared_symref(worktrees[i], symref, target))
>  			return worktrees[i];
> -	}

You added this function in the last commit, let's just skip adding the
braces to begin with, rather than this style-fix after the fact.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux