From patchwork Thu Nov 25 15:57:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89CCFC433F5 for ; Thu, 25 Nov 2021 16:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356565AbhKYQNm (ORCPT ); Thu, 25 Nov 2021 11:13:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356420AbhKYQMp (ORCPT ); Thu, 25 Nov 2021 11:12:45 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0670EC061397 for ; Thu, 25 Nov 2021 07:57:56 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id g191-20020a1c9dc8000000b0032fbf912885so4984483wme.4 for ; Thu, 25 Nov 2021 07:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=OuCqtHRK/vK4Q099RfeF3vUiPh0kfiXb7vMkw7ScbpY=; b=MMF04sY9+A+/ZpWg/hnb2x1Z76QLB1f3dnpti2V1Svytf7qU42EU0X7hECdF2LWBKk 8qHPVf5nI7DgfOaIuBI5xMsx1vji5Dhw40/a9Um+FV0dLvK6NjCP0Ruh88AoIkLO56qf SICY+eKQYIzdIP0cpTOMAjA0TnLHDnhsM/yYKO9ZuhupsX6Q1CS6n1MH0h33O5vcYptt HiGRBPYIX4dG8snmM3N5RWYeDXx8zOQZeJW6GjLLjfwWD1Uqvt6Cn/D3X2e8U3FlgIyd WRMJ/KmpiQ5aZglCMxVn26wN+ktBxGyhkrPImjdv9aM7pnCvqYazxPIrJotPU5oTONik f7yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=OuCqtHRK/vK4Q099RfeF3vUiPh0kfiXb7vMkw7ScbpY=; b=Lnz+w6Lkfwkvv8GQFnVLWr9i16bC6P2FdtxMll+MvMt67YlMu6vnQZhvIuY7sJoL+W 2c68gecc0cvwIYG5WQ5HQ5fbUfAC5jFvYKdFATAZwK1wyUbIvq6TzdY297VJTxZcyLsL K9jKFFUMKCdBTkUXXUUBS+z3HqjiLeaPVL/WbNk5CVhX2ju/iCOg7ieMUgOC4HrmFfun aUTiBtXI9YoShyleyrkRnjnT0kXJ31A0UvC5qYNdChBV7TMR+jSh4YsGXen1hjCw90Dc X/VonUbsjeloKhlQcegG+1QwbPTsLdYz42x1kn6NPBzGQjdC2kNc64zg+vzlaZF5r+5L NXmQ== X-Gm-Message-State: AOAM532jsbnhy2/DlGVXzlw6wSGgQhEeH0POzvngbgZbMvfaH5hUIXoa nzlh4YifPmXXB5EJ3om4+VTEDAf1lQM= X-Google-Smtp-Source: ABdhPJxxeUYhXX6R5TgN6lnCKvAgDqZOE5+X4p2Ke7BR2xPRKzaea6qaL3miVyCRBs1QyZcD/ETo3w== X-Received: by 2002:a05:600c:4154:: with SMTP id h20mr8481002wmm.189.1637855874448; Thu, 25 Nov 2021 07:57:54 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ay29sm3071033wmb.44.2021.11.25.07.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:57:53 -0800 (PST) Message-Id: <9d8394d8c7666b13403394332d826a3729a1a3e0.1637855872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:57:48 +0000 Subject: [PATCH v2 1/5] show-branch: show reflog message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Han-Wen Nienhuys , Bagas Sanjaya , Elijah Newren , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys Before, --reflog option would look for '\t' in the reflog message. As refs.c already parses the reflog line, the '\t' was never found, and show-branch --reflog would always say "(none)" as reflog message Add test. Signed-off-by: Han-Wen Nienhuys --- builtin/show-branch.c | 12 +++++++----- t/t3202-show-branch.sh | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 082449293b5..f1e8318592c 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -761,6 +761,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) char *logmsg; char *nth_desc; const char *msg; + char *end; timestamp_t timestamp; int tz; @@ -770,11 +771,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) reflog = i; break; } - msg = strchr(logmsg, '\t'); - if (!msg) - msg = "(none)"; - else - msg++; + + end = strchr(logmsg, '\n'); + if (end) + *end = '\0'; + + msg = (*logmsg == '\0') ? "(none)" : logmsg; reflog_msg[i] = xstrfmt("(%s) %s", show_date(timestamp, tz, DATE_MODE(RELATIVE)), diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index ad9902a06b9..d4d64401e4b 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -4,6 +4,9 @@ test_description='test show-branch' . ./test-lib.sh +# arbitrary reference time: 2009-08-30 19:20:00 +GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW + test_expect_success 'setup' ' test_commit initial && for i in $(test_seq 1 10) @@ -146,4 +149,16 @@ test_expect_success 'show branch --merge-base with N arguments' ' test_cmp expect actual ' +test_expect_success 'show branch --reflog=2' ' + sed "s/^> //" >expect <<-\EOF && + > ! [refs/heads/branch10@{0}] (4 years, 5 months ago) commit: branch10 + > ! [refs/heads/branch10@{1}] (4 years, 5 months ago) commit: branch10 + > -- + > + [refs/heads/branch10@{0}] branch10 + > ++ [refs/heads/branch10@{1}] initial + EOF + git show-branch --reflog=2 >actual && + test_cmp actual expect +' + test_done From patchwork Thu Nov 25 15:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AB14C433EF for ; Thu, 25 Nov 2021 16:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356590AbhKYQNt (ORCPT ); Thu, 25 Nov 2021 11:13:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356418AbhKYQMp (ORCPT ); Thu, 25 Nov 2021 11:12:45 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B00DEC061398 for ; Thu, 25 Nov 2021 07:57:56 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id s13so12670423wrb.3 for ; Thu, 25 Nov 2021 07:57:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=e6+WnkX6yxU+fTCEoT1Ezugcrp1CvRrsB10irWdpGMI=; b=SPTWA+UZZta4jhwxqaJa+r28BqOu+5UhO7fFtYatRGpzdzKhYk5rLRv7iG3MGZX6rU rL1xvFtbVeA9OWEMksf4DsFVENZwuxEZWexCVWHaFU1qjRwrXkIzWp0GZsXQr7W42CFo 4RX7lM5N9qyubf2hqqeQKkPbouZAQJpqQUE3QjUMaKaDRLf1wcI0vAMQQc9NTf7fefTP 4HGjjP87UEhDj6Ihjy3tpUstoWXHwbVp/uVCUYdjSYpIlws7B7KatO69HS/yOntObBGf Km1WRdUmrTBtThxIUtpA3h5hWUnbgshjM/h0+acTSvmOSue6JYBFVTBxfbNA7wM+pQXV LtrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=e6+WnkX6yxU+fTCEoT1Ezugcrp1CvRrsB10irWdpGMI=; b=NoSnnqbbtzJNZkLDJjiig1MoxN2JJZb/0/QppMyqMwNfPVZWWdtWzQh0chrHn9Eyf1 EujNMqNhuuptnVXySZOKYeMZIbo4CJpPO4wDjZTlr5KEl+E2lkFXQMKO7zCSlqZKD8I1 a5HEoLIXNVIwA0X7BsQV34wKVKdhT03LHh+WFjEeCoNmoQDgnaCwjMfPWbB2TP1Oc+mK 971hvDEZyA+2F5DzTvnBcDqf/iI17Y6dv4uBatwOb+Cv2kDDGWFcQ4ZOZxQt+D/jwCUm Pbu1EqGc4QjKQ5NXzf+mHqehm+RPZKLwdfII0b4ScBvYc53H+4qIqnSQqCnIwLFLKU8o lyDg== X-Gm-Message-State: AOAM531xuiBa5fo8q+qG5m/ObDgu9s5cfkcdC3op0zUN4GW00ICJXJAI vJzL/G11bPFYZrGiEE2EpFrPW9QVT6I= X-Google-Smtp-Source: ABdhPJwNFEelFyg9bVo3talGERdFCqHyaBpodYlMPPUAHWECdmj3YkSDMCJiSWcX/bOvDZOF8qUzoA== X-Received: by 2002:adf:d0d0:: with SMTP id z16mr7837228wrh.601.1637855875190; Thu, 25 Nov 2021 07:57:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d6sm3275730wrn.53.2021.11.25.07.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:57:54 -0800 (PST) Message-Id: <4a86d21258918ea8124caef1cd2e435b465f67c5.1637855872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:57:49 +0000 Subject: [PATCH v2 2/5] test-ref-store: don't add newline to reflog message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Han-Wen Nienhuys , Bagas Sanjaya , Elijah Newren , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys The files backend produces a newline for messages automatically, so before we would print blank lines between entries. Signed-off-by: Han-Wen Nienhuys --- t/helper/test-ref-store.c | 5 ++--- t/t1405-main-ref-store.sh | 5 ++--- t/t1406-submodule-ref-store.sh | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index b314b81a45b..ef244aa6b27 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -151,9 +151,8 @@ static int each_reflog(struct object_id *old_oid, struct object_id *new_oid, const char *committer, timestamp_t timestamp, int tz, const char *msg, void *cb_data) { - printf("%s %s %s %"PRItime" %d %s\n", - oid_to_hex(old_oid), oid_to_hex(new_oid), - committer, timestamp, tz, msg); + printf("%s %s %s %" PRItime " %d %s", oid_to_hex(old_oid), + oid_to_hex(new_oid), committer, timestamp, tz, msg); return 0; } diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh index 49718b7ea7f..a600bedf2cd 100755 --- a/t/t1405-main-ref-store.sh +++ b/t/t1405-main-ref-store.sh @@ -89,13 +89,12 @@ test_expect_success 'for_each_reflog()' ' test_expect_success 'for_each_reflog_ent()' ' $RUN for-each-reflog-ent HEAD >actual && head -n1 actual | grep one && - tail -n2 actual | head -n1 | grep recreate-main + tail -n1 actual | grep recreate-main ' test_expect_success 'for_each_reflog_ent_reverse()' ' $RUN for-each-reflog-ent-reverse HEAD >actual && - head -n1 actual | grep recreate-main && - tail -n2 actual | head -n1 | grep one + tail -n1 actual | grep one ' test_expect_success 'reflog_exists(HEAD)' ' diff --git a/t/t1406-submodule-ref-store.sh b/t/t1406-submodule-ref-store.sh index 0a87058971e..b0365c1fee0 100755 --- a/t/t1406-submodule-ref-store.sh +++ b/t/t1406-submodule-ref-store.sh @@ -74,13 +74,13 @@ test_expect_success 'for_each_reflog()' ' test_expect_success 'for_each_reflog_ent()' ' $RUN for-each-reflog-ent HEAD >actual && head -n1 actual | grep first && - tail -n2 actual | head -n1 | grep main.to.new + tail -n1 actual | grep main.to.new ' test_expect_success 'for_each_reflog_ent_reverse()' ' $RUN for-each-reflog-ent-reverse HEAD >actual && head -n1 actual | grep main.to.new && - tail -n2 actual | head -n1 | grep first + tail -n1 actual | grep first ' test_expect_success 'reflog_exists(HEAD)' ' From patchwork Thu Nov 25 15:57:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D37C433F5 for ; Thu, 25 Nov 2021 16:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356537AbhKYQNY (ORCPT ); Thu, 25 Nov 2021 11:13:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356372AbhKYQMq (ORCPT ); Thu, 25 Nov 2021 11:12:46 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BCF8C061399 for ; Thu, 25 Nov 2021 07:57:57 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id l16so12613177wrp.11 for ; Thu, 25 Nov 2021 07:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ItUp8M/atyI9K4rx4P6QdD53E0D10J9MuhiA1jbk01M=; b=LbYrufGVQUI7xnfQ6n2ssKUHqu81SYSAijrUIRDmD3OBNYKbyTmp5SY4KwOrDCoUzJ 1BHi5Ebf42ulYhVZbYcLdNbHI09fu9c+iMkg+sCnWvnznDmONUusMPgd2klAPN7yZ47g IGEgc1GpqA3B8QD56KwCVejmeRmmQGoD2kJ5FNeeEzC7ACcwcmcGUsfJ2KOPkM4+scKS oMzjCPWEne2ciAOO7tvxcyE6jJnt/77oujsnZGGldl8U0CnotGZgL60OE3Z2af4Wwd11 0GgDz6YUXLNHtSrxSaD+8xB2wnah+IF4e74gCf/WLBPTCl3yZy42PbxyN0xW4PFWmWeg JlNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ItUp8M/atyI9K4rx4P6QdD53E0D10J9MuhiA1jbk01M=; b=WxXP070VHUpR+Zd/umXu2biotIVWQE7r3B+MLTDw+G7VdhkwU0l8xrHE/uWDk3fH9H SCLY3CTGeK65BZrmUWw7RtdczvhCQxiGTJKZFoYIv6WjRobwKyzMCb0Q1N9l8cXFX8Qd V4TK2URXM+WpJOvMv/BdMBa9iH7nYXv0eBW7x4LJ1rhdz0ZjZA+UQ0iooLDTGNMHqXpf JRQ+yOUrFPRYAh0cVy+Gqhi7s2l+qHSZvg8ldKSdobxETiYUU311MJOKQVMk/q9Z+Zvy AuVKYuNZVm8tIoUklO7FHd/wfLyGoaA21Xa8TDDxqj9ZIWl95VGt/wSSb/5SoF8B8WUl +PoA== X-Gm-Message-State: AOAM531Z553p41aK/9qGBbYFEAzssY/wE22zIOUuurtbyqZosv3jUkSv 27H4ZKwE9EYOZOGbX+fmD0tsiovWABQ= X-Google-Smtp-Source: ABdhPJw9OpWShM6Q8b39MGmAM5C6Hq6wyyMJ+gOFCkhfRFFe1WjxXhrIYm4niHUC+diGBOMWYcFQ+Q== X-Received: by 2002:a5d:4cd1:: with SMTP id c17mr7617906wrt.31.1637855875758; Thu, 25 Nov 2021 07:57:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v6sm8226830wmh.8.2021.11.25.07.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:57:55 -0800 (PST) Message-Id: <0319503045ba8ab93eb09434ed4bada0050c5f8a.1637855872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:57:50 +0000 Subject: [PATCH v2 3/5] t1405: check for_each_reflog_ent_reverse() more thoroughly Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Han-Wen Nienhuys , Bagas Sanjaya , Elijah Newren , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys If we are checking for a certain ordering, we should check that there are two entries. Do this by mirroring the preceding test. Signed-off-by: Han-Wen Nienhuys --- t/t1405-main-ref-store.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh index a600bedf2cd..76b15458409 100755 --- a/t/t1405-main-ref-store.sh +++ b/t/t1405-main-ref-store.sh @@ -94,6 +94,7 @@ test_expect_success 'for_each_reflog_ent()' ' test_expect_success 'for_each_reflog_ent_reverse()' ' $RUN for-each-reflog-ent-reverse HEAD >actual && + head -n1 actual | grep recreate-main && tail -n1 actual | grep one ' From patchwork Thu Nov 25 15:57:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4458CC433EF for ; Thu, 25 Nov 2021 16:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356596AbhKYQNw (ORCPT ); Thu, 25 Nov 2021 11:13:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356374AbhKYQMq (ORCPT ); Thu, 25 Nov 2021 11:12:46 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF8F6C06139A for ; Thu, 25 Nov 2021 07:57:57 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id o29so5980329wms.2 for ; Thu, 25 Nov 2021 07:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=I/XcjhTXOahDGN3s2nzZ6+d0TIy2qW88yldrIIBGgbE=; b=hek6EJcv1++Iw1LqgdjDut0+sfhXihdoaLqqoZnrrCAwfYXtleC8fUJONv/S1YI68r ojpbHK8ufMnUUicmb8Sd6xV/2zQPB+D9ovjl03cvFIufPHyKXMSCpWQgd4f18l//5s0m 2fS/5+X34syxBuMbg7Ru89KJKW+chdDtLkZI5qzWbWjKZPgVyC4Co6OYImHbaFNSYlHk q9VnWDfdmN7v5vLRgTAGRSV/Fl4eO820YJ0XlsJriFBwxDbrwz07tJh6/OeLp2RNKsrX xYaV0Juh3CMvx4d3GinBNAG5a382BCrTfViNpj31ahXIfSZWQ3U+tQhMD7vBBYhAa8ym 2KiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=I/XcjhTXOahDGN3s2nzZ6+d0TIy2qW88yldrIIBGgbE=; b=xfyD5TH16k+nOMlfT2KVDpksC4BwxJKx/6dNaVdfMFUe+KJwVXiBqpPnMNvFtSAAs/ XniDq3K+y6BhyXdU+qOrgTylV8FhWWpn9r9qcJF2oeljp63HFNC3brAalg2dn1gPePcf zIaged1N1TQJaon3VlPAzBjzaf1eZmwLShI0Z/t6FYW+U6lBdo12otZ6GX5yZ2V7vER0 A+ifpU7ONVKSUM96XB1e8ieIhR+0zF/ns2iExHfqV4LApjprDZlSHauHv9qFxEaFZw8M foyJ80oOJDIkr0NyAxR9c4jxIFMnG31vEsyELeCeqFbaR/tAW9B9IYpC7KcqGGKqvEIq QbIg== X-Gm-Message-State: AOAM5313F9of9vem0Nk1iBAVS/arIiMV90nDEFuCwFUNhAbz+/pXfrur TAc5b+t6QSVzPo4kc5TAWvUaYt4iFz8= X-Google-Smtp-Source: ABdhPJw9cQPOTapP+HZvWG/mHDEHU7OU7/GUNa/91olDgwuxeEvujGeCGoT+SCaxGRzuXj+Z3/3GCA== X-Received: by 2002:a1c:ed0a:: with SMTP id l10mr8413557wmh.104.1637855876454; Thu, 25 Nov 2021 07:57:56 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h17sm3109780wrp.34.2021.11.25.07.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:57:56 -0800 (PST) Message-Id: <62f5cb8a8243f9e5c2af5c148ed586a2504c8cee.1637855872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:57:51 +0000 Subject: [PATCH v2 4/5] test-ref-store: tweaks to for-each-reflog-ent format Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Han-Wen Nienhuys , Bagas Sanjaya , Elijah Newren , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys We have some tests that read from files in .git/logs/ hierarchy when checking if correct reflog entries are created, but that is too specific to the files backend. Other backends like reftable may not store its reflog entries in such a "one line per entry" format. Update for-each-reflog-ent test helper to produce output that is identical to lines in a reflog file files backend uses. That way, (1) the current tests can be updated to use the test helper to read the reflog entries instead of (parts of) reflog files, and perform the same inspection for correctness, and (2) when the ref backend is swapped to another backend, the updated test can be used as-is to check the correctness. Adapt t1400 to use the for-each-reflog-ent test helper. Signed-off-by: Han-Wen Nienhuys --- t/helper/test-ref-store.c | 5 +++-- t/t1400-update-ref.sh | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index ef244aa6b27..2b13d09a0be 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -151,8 +151,9 @@ static int each_reflog(struct object_id *old_oid, struct object_id *new_oid, const char *committer, timestamp_t timestamp, int tz, const char *msg, void *cb_data) { - printf("%s %s %s %" PRItime " %d %s", oid_to_hex(old_oid), - oid_to_hex(new_oid), committer, timestamp, tz, msg); + printf("%s %s %s %" PRItime " %+05d%s%s", oid_to_hex(old_oid), + oid_to_hex(new_oid), committer, timestamp, tz, + *msg == '\n' ? "" : "\t", msg); return 0; } diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 0d4f73acaa8..0d46a488032 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -321,8 +321,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 EOF test_expect_success "verifying $m's log (logged by touch)" ' - test_when_finished "rm -rf .git/$m .git/logs expect" && - test_cmp expect .git/logs/$m + test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test-tool ref-store main for-each-reflog-ent $m > actual && + test_cmp actual expect ' test_expect_success "create $m (logged by config)" ' @@ -350,8 +351,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000 EOF test_expect_success "verifying $m's log (logged by config)" ' - test_when_finished "rm -f .git/$m .git/logs/$m expect" && - test_cmp expect .git/logs/$m + test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test-tool ref-store main for-each-reflog-ent $m > actual && + test_cmp actual expect ' test_expect_success 'set up for querying the reflog' ' @@ -467,7 +469,8 @@ $h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000 co $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit. EOF test_expect_success 'git commit logged updates' ' - test_cmp expect .git/logs/$m + test-tool ref-store main for-each-reflog-ent $m >actual && + test_cmp expect actual ' unset h_TEST h_OTHER h_FIXED h_MERGED From patchwork Thu Nov 25 15:57:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12639473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44908C433F5 for ; Thu, 25 Nov 2021 16:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356498AbhKYQNa (ORCPT ); Thu, 25 Nov 2021 11:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356422AbhKYQMq (ORCPT ); Thu, 25 Nov 2021 11:12:46 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4572C06139B for ; Thu, 25 Nov 2021 07:57:58 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id j3so12668414wrp.1 for ; Thu, 25 Nov 2021 07:57:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=uBrYERAbNA+nKYS59J7yvvLJABgzXblwiIGK1C6wKao=; b=A3U/L8WaD3i9kvQGn3wRu4KX4QqLC36Wye6HkDpHi+eDuhqvMeONfrwZ7Mb6ejV6kT 8IXFerAB1eH/YJNa0dB7XsTgXebhk4lgnSoXusx/9dPY+wGR/aJA68VMqecBjguugPFm cPzrZThXfkTvZ6Ci19E3H4fMJYsLRXZylI5/BhBGmxZZVfF2IvnJzjdoYDFG0LOAZKHA XeYs81SgLqlV7D8ZWJRwmPPrCPlRGhIrrVRODzmm+MRYnxASo20aCSHZ2hDIOOiZe54k U1GrcWSdCNOpSYFu0Kv9PvVxl0NKVgc0PNm7eKwwmaQNOq3cCo+uKv7i1ffaFkCZqlAW xl5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=uBrYERAbNA+nKYS59J7yvvLJABgzXblwiIGK1C6wKao=; b=ihKQSnLY6shA/GhOmNlI9cdijE6OeFX73Xg9XpYOTc4V/mfxjm2sDh6pQCv8uH9SCy LGUu9RHADavHYcJbfR+T9bPsJJyjEXlOxIGuFwoNDGzcZnamhu/tD8CE6Dm21eIUlCwn DAmZq+zRNLGB2n1W+aeaqYT+pWTMse99W2G1Ng2O0+J6P9jWWOnbkhwONGmt6OK/8aoo ly6VjNPtiRnIZ0hA2MqnPf5k82WgQj3Pfa0Dxw2ntJURodMZMtmZ2Dtv/SvZ8d7fLrTD I4Gya1pxlaIMrR0RL9sRjPf+D9Nrs9J/a1HvNTEWiz2vGbd5doIbBhRdqAtAb6ehdO+t xv1g== X-Gm-Message-State: AOAM532WHFZWFfUSBZllJD6202/s0geFzgbqNz8Vv2vY28Ayeoos622p 7ddp4RBC8lcocWWoTJZyKJ3YjQHh6P0= X-Google-Smtp-Source: ABdhPJzyzPg51QJPvCbo4CXhpB0hgrS/rJiXHi6Xf3Cp7NuxbKgkzf3DKMcaCVtClijOnj63RHTkMg== X-Received: by 2002:adf:fe8e:: with SMTP id l14mr7850514wrr.177.1637855877088; Thu, 25 Nov 2021 07:57:57 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h16sm3312002wrm.27.2021.11.25.07.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Nov 2021 07:57:56 -0800 (PST) Message-Id: <0288e743eb2e96e2effd6b0b90c6f885009bf337.1637855872.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 25 Nov 2021 15:57:52 +0000 Subject: [PATCH v2 5/5] refs/debug: trim trailing LF from reflog message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Han-Wen Nienhuys , Bagas Sanjaya , Elijah Newren , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys On iteration, the reflog message is always terminated by a newline. Trim it to avoid clobbering the console with is this extra newline. Signed-off-by: Han-Wen Nienhuys --- refs/debug.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/refs/debug.c b/refs/debug.c index 8667c640237..2631210795b 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -284,15 +284,21 @@ static int debug_print_reflog_ent(struct object_id *old_oid, int ret; char o[GIT_MAX_HEXSZ + 1] = "null"; char n[GIT_MAX_HEXSZ + 1] = "null"; + struct strbuf trimmed = STRBUF_INIT; if (old_oid) oid_to_hex_r(o, old_oid); if (new_oid) oid_to_hex_r(n, new_oid); + strbuf_addstr(&trimmed, msg); ret = dbg->fn(old_oid, new_oid, committer, timestamp, tz, msg, dbg->cb_data); - trace_printf_key(&trace_refs, "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%s\"\n", - dbg->refname, ret, o, n, committer, (long int)timestamp, msg); + strbuf_trim_trailing_newline(&trimmed); + trace_printf_key(&trace_refs, + "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%s\"\n", + dbg->refname, ret, o, n, committer, + (long int)timestamp, trimmed.buf); + strbuf_release(&trimmed); return ret; }