From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 5FE911F4B4 for ; Thu, 10 Sep 2020 19:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbgIJTRZ convert rfc822-to-8bit (ORCPT ); Thu, 10 Sep 2020 15:17:25 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:39290 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726267AbgIJTPh (ORCPT ); Thu, 10 Sep 2020 15:15:37 -0400 Received: by mail-ed1-f66.google.com with SMTP id c10so7486945edk.6 for ; Thu, 10 Sep 2020 12:15:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=qWZ9YvcMcrK62d5QvxhiDZb1ZNHiC5j0HhwuF2EqRIc=; b=lcmSXNERDyBKfkMVdHqFUBkpqCZGXKftdfFlxtT62SAkvKYaspkaEIdAuYv5mdIZKS O1BKXfzzQiUUDCQwQaFWiotdRsy6K82etL51juDcRc/PfAU63HQdqMJD8lj7A2QOKXnp HdbXPBZJNs7yxVaYjFkraVIvEU1/NzpIH6tplM1maVsF0zgJZPGJB5y9GejYpqcW2dU2 Pqy7PgSVKa+juoMoClCQQEMR9yfd2x4+nhFGLosdAVhj4GF5Wo/vddZoB8Jik+DVXL7w 0zHkNJyGxduBqRS4vu9PmN8f76iN2BlKsXXtYZBOHYIeZz5DtDjMbq46236pqDVPXcmB bsXw== X-Gm-Message-State: AOAM530+en3DlPsJ0PlaA1c3SHcOsxGp739IVfmrW6l62M1nvoVVIrxw XLEKUbipPJKxPgkrXQV/8KBGAQV7JR6Qg7OHx3s= X-Google-Smtp-Source: ABdhPJxfBhEmoLWcsuz1RLVvrsAFohI7Hydgsi+xVrCe/S1y10yHcRTRRuLa5wBGKdMtwMkFQRyLYnOe5TQOR0OiwJE= X-Received: by 2002:a05:6402:17ed:: with SMTP id t13mr11162684edy.163.1599765320665; Thu, 10 Sep 2020 12:15:20 -0700 (PDT) MIME-Version: 1.0 References: <58a2469cc18839e57b45f687b6e484d69161a34c.1599762679.git.martin.agren@gmail.com> In-Reply-To: <58a2469cc18839e57b45f687b6e484d69161a34c.1599762679.git.martin.agren@gmail.com> From: Eric Sunshine Date: Thu, 10 Sep 2020 15:15:09 -0400 Message-ID: Subject: Re: [PATCH 4/8] worktree: drop useless call to strbuf_reset To: =?UTF-8?Q?Martin_=C3=85gren?= Cc: Git List , Junio C Hamano Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Thu, Sep 10, 2020 at 3:08 PM Martin Ågren wrote: > There's no need to reset the strbuf immediately after initializing it. > > Signed-off-by: Martin Ågren > --- > diff --git a/worktree.c b/worktree.c > @@ -552,7 +552,6 @@ const char *worktree_ref(const struct worktree *wt, const char *refname) > { > static struct strbuf sb = STRBUF_INIT; > > - strbuf_reset(&sb); > strbuf_worktree_ref(wt, &sb, refname); > return sb.buf; > } I think this patch is wrong and should be dropped. That strbuf is static, and the called strbuf_worktree_ref() does not reset it, so each call to worktree_ref() will now merely append to the existing content (which is undesirable) following this change.