From patchwork Thu Dec 2 17:36:29 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: 12653189 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 98B46C433EF for ; Thu, 2 Dec 2021 17:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348258AbhLBRkC (ORCPT ); Thu, 2 Dec 2021 12:40:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348195AbhLBRkA (ORCPT ); Thu, 2 Dec 2021 12:40:00 -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 6814BC06174A for ; Thu, 2 Dec 2021 09:36:37 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id v11so293275wrw.10 for ; Thu, 02 Dec 2021 09:36:37 -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=aYEd2RcwaIw1U0ocZs3cjdiIdvLtSZCl7bV5iJil4kxCIGxSiuSKF9vUxuRcuuI96W HVkkpx9C/Ww+nsmhdXUk1GDjrZrrhf0n4t6hJ4rfzGJx13ZPf9viT6Ud01ooKEypSX+J LyrNONcJCJlWJa35Rh+r49VZuYbV296gPXwM2mGKnxeKxtQgU+GqUIlI/G6et0H8PnUX /ri6dC4HdY1IVd7G0/E8PxjsPyS9yk3bEmdIZ9ZpQOtLIq1ouZZysD1nHlrQCVoJIT6z SLS/TVUrFdIPJNwyt/lNxtsJThHrKig8xr5OgrIMAc/jPplxjoevwShXAcmfKtk/94I7 yl8A== 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=8P8bW0jZ9nW6Rz1tRfSiy1A3ixYudjsOyiF/s/FFqyxKqc1HDieTnThI8Tg1HtSPGR XRG6J/1lMBt2cD9Fbwm6Wiyhqdj8L0G10XKUN0xVE3zxLqSjy7Lsn//hdBzqcy3BhAfk 2uNGAJqdE/vNXsULVA87ED6zM2g61Mvcaq0M6AoBPABxTzcN2iwoz8NQKuxVNUPCtf7g dQ52PRtvkLi2cnpmz/mGGdXrL1jT9mGGHWGx9BliSS9NBM/A/zdx4nR41eOxuT7vByRN x0L09PxBEtJMd+wDZyuP2ncQy/I+wtMNgDYe0GT+6g59LLCKQvhDTT886khEdMt9YB6Z nRFw== X-Gm-Message-State: AOAM533FTIWYYDNdcFR5p1XIRGnt7CAohNV+OmAXnrfUfXJWqtqVOTEI 9M7LJARHZiHI9pmK0EKlKjM+V+LBPBE= X-Google-Smtp-Source: ABdhPJw1KGuJvjkfbAQlU66ipb6lSssBkhL5seyVRvBADwvbrPahbvb1PHeUmGz5ODmlbwJef+N3sw== X-Received: by 2002:a5d:6a4b:: with SMTP id t11mr15526144wrw.78.1638466595821; Thu, 02 Dec 2021 09:36:35 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l26sm314604wms.15.2021.12.02.09.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:36:35 -0800 (PST) Message-Id: <6e94a6fbe05e38c849c1311b18b0a95030af21ba.1638466593.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 02 Dec 2021 17:36:29 +0000 Subject: [PATCH v3 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 Dec 2 17:36:30 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: 12653197 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 04E5EC433F5 for ; Thu, 2 Dec 2021 17:36:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376389AbhLBRkP (ORCPT ); Thu, 2 Dec 2021 12:40:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348203AbhLBRkA (ORCPT ); Thu, 2 Dec 2021 12:40:00 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22A4DC06174A for ; Thu, 2 Dec 2021 09:36:38 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso2922380wms.2 for ; Thu, 02 Dec 2021 09:36:38 -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=nL9nfaQRNgp3+nKpsfDXv0L+XfADnJ2jSOK5uvxCCM8=; b=qWe67C/zBDRdcBhhRV7Z5D8A2sSXUsAOYaL/PYynNdGd1m3QHj3cXITJsiAmO5RCDE RtYBbtOARlE6O6qhFhqlu9viFKqNpE7UN88s66DXVL4U3EbIYEOrtxBsz2sOw5UU87cZ dMJoCggTWp12OBzRTU9pKML541HEmmO/Oq3VWl8fgr3LiK01BDkCHo9kh7qkoXKZ0Y5m E3qeKUT5KGmZyVYI28FQJ0oA6q6fxQTHUTJ51Y6dhIA89x0oRy8Y8TkocXwOME+LMlob avEQjn4qIlBhA6pJziNui3ZVx7YV78qWJ7JiEIkcaTtP3d2tzgoXoT27b28t0WDY9kpL CIqg== 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=nL9nfaQRNgp3+nKpsfDXv0L+XfADnJ2jSOK5uvxCCM8=; b=Jx28FHj9usyjadbrspZ2H7A7do0KvdeD/jJxZ9E1edL+b23MB9iB/0dFD2od061W2Y 0rA70s0BT4hkiEhFpnkm/fsQbwGex3gQjjqceQM8e93zcdGbg39s/fvYm6Q1cT7YqlXK l7xxb56NiI4xyEXKBZFIAgVvfKgv94ZS9hMaBKdQPKMCxTzTm73JO59jxmOeg47Jn8GU wy9INEvLPM1gZJtt285PRqPlQt7nnZsYDYOo1nvrqnMo/El4hqGdpDm/UvZmBVUQjuhl IGXwaysdDacnoHT47TGApC1oiiJ/BlxEH3Yq4RAT+43PDFbsGq8K6HN6GPySNf5kuR1D k82A== X-Gm-Message-State: AOAM533lMBzkAe8uxDJgMVWUh7bD2H81MGgm1fAJb1KOYWOoC28OzBhA iAQogzS9ea45m5+o1Fil9YnModgLAfk= X-Google-Smtp-Source: ABdhPJxLd+YLq1Y61ZuzmNmpcYFz4PamJkCiD5tq2yvbxXp1Ps+1mVXiOIl8j1k0xztLhuJCr0TDTg== X-Received: by 2002:a05:600c:3c85:: with SMTP id bg5mr8013784wmb.58.1638466596591; Thu, 02 Dec 2021 09:36:36 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x4sm2678752wmi.3.2021.12.02.09.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:36:36 -0800 (PST) Message-Id: <062481ffece8415260c84fb4fd3a68a566c15135.1638466593.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 02 Dec 2021 17:36:30 +0000 Subject: [PATCH v3 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 By convention, reflog messages always end in '\n', 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 3986665037a..5ac33dfb598 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -152,9 +152,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 Dec 2 17:36:31 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: 12653195 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 AD181C433EF for ; Thu, 2 Dec 2021 17:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348257AbhLBRkM (ORCPT ); Thu, 2 Dec 2021 12:40:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348208AbhLBRkB (ORCPT ); Thu, 2 Dec 2021 12:40:01 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEB9CC061757 for ; Thu, 2 Dec 2021 09:36:38 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id p3-20020a05600c1d8300b003334fab53afso2896360wms.3 for ; Thu, 02 Dec 2021 09:36:38 -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=pcXPXBDZpDMJDCBuD+tCENz2qtrU1YsANd4f4DfUfK73KLyNNr11ywrdBt4oR+E33u EOjNEHZmNKzyiEpH1Ep2u64d8mAyPVnVg9sVMlMldtivzUMb1CvYC0xrQrjJ0qfzJXRq hNlod22IMRlW61C+Z+E/vyS3xqwZgxiJtplleEd50S7cnCkFVK+HkHLXX4daoZag3Wjx EyOvgnhHjDAh/3kxyU4hf+MoYb963nnMC10dmY5dtqVTHQg500nwUAjGwQJoNe6RVRh9 eLls661b01m9wJ2NjleNPik7Lp6SaSQz5mVJuYQFd8BUHRAmz0NFdUItmvfXFebdnGpg Gy3Q== 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=lW+XtpzIR4RqVmzmW7AD2m2UVqILg5lj5oIGxz+nxt+AwUS7VTFzbCzU8TXSWNbfog VOq52Rjcgg7FHTJuHxTJ6cqvchX2avWVbJg21JiXu3SgSowO056D9XzS/bZ8cNDUpKUa tRNkBUves6KxIKPdamsFO6FShk1SJVGtUOHpyrDqIuRbD6AUaIAu+nX0tkVoThLlc79G dwsuIsbRoenONJx6FVgeDqEHARiMUX2OvoVF2SdujvaTEzIaf+ZfbbRhfnzPN03XNcsw dGxkc9IUUhUJ6dF5LTW8uXYichDHHkzVcBZh4zOxfCg7c63ss5a3oowCtzrebZ4Jhxvv ELfg== X-Gm-Message-State: AOAM531KNy4VcMCsRb4mg8L38x/1Yxn3Biht+RVs1ZnxS8vTbRRv7mWd tN9GFGGHv/2jlcTgMxuuV97a/p+G4sg= X-Google-Smtp-Source: ABdhPJxCxnz0bBoeW5PcBVcWuVcigmp0yY3EYi4RDyINZ4Xw49s/gUeblkUzoEwyjGAtiYOaCfi4Jw== X-Received: by 2002:a05:600c:210a:: with SMTP id u10mr8006852wml.33.1638466597216; Thu, 02 Dec 2021 09:36:37 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q4sm364497wrs.56.2021.12.02.09.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:36:36 -0800 (PST) Message-Id: <46a8e13a5e6d04b2265b3bd4f06e81408e63fe98.1638466593.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 02 Dec 2021 17:36:31 +0000 Subject: [PATCH v3 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 Dec 2 17:36:32 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: 12653193 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 936A7C433FE for ; Thu, 2 Dec 2021 17:36:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348279AbhLBRkL (ORCPT ); Thu, 2 Dec 2021 12:40:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348253AbhLBRkC (ORCPT ); Thu, 2 Dec 2021 12:40:02 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB971C06175A for ; Thu, 2 Dec 2021 09:36:39 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id 137so381644wma.1 for ; Thu, 02 Dec 2021 09:36:39 -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=1BZh/t0ymUFfsqomhePzDDHwHXDn9QscnvyFCjOlys0=; b=Ls0wt5ZZLGvDwD9WP01tbr0Bz6RV/6fWqGFH29qf+K0P8/U7WLf79CxrRi9nwr6gnG NfZ3lhjr9OgpIPDaPRrItRNKiwsv3Yn5qaxcSq9tUkwVYJpDyxdz+Sp68eItDQVaLV3N Zcxth1QukHxZeAGTWVpXJ3ltbtlojtYCu7Gzd88sIJrv9qOwFNGDLqFVb6n8f4dQ5fK0 VsT7JD9tq8XZujWHhzJELoV9dOgqC9eV5Dj9k5NHrnHnUv/BthHGheSlm+caJHcE+3JG /1SPdrqKfjQabaEfW/PL19pCOcry/wRD4Afn5BCp8plZ4OCZTLAJ1qCDjVg1+Bgo7E2V FKNQ== 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=1BZh/t0ymUFfsqomhePzDDHwHXDn9QscnvyFCjOlys0=; b=sivUDass1fXL2oP9F2ZdF6yTA0FPpZpn18CbZl8XZ3MtSM3lPaoEjiCdNazXxV081G GGDXyWOWfxFwNpi4Q2heU35WZA83k9kZhXdErfmqzf/e6hfxqwiYLj7SJ8BEbvC9HTsj RfZhikRR0EH968bK//aSoJ9o11yZSBeUqRV11cfqFsfbk793LYcWmuA3cQAwzrdYdl4g INm2I0Ks2yNZLAlV2tdAwdOixCClhYW/yXFC7jfDKzBexJGPXEvzQMDGgJVOvO5gc5gR 1EX9gHTsHw7TkeEvW+eahMW1dh81Pe+j3TmO3cwjN2wVaSMnUsatCoPcVBeefezK9TAx YDUA== X-Gm-Message-State: AOAM531vDmcrHV0NNqbhYDShAf3zLukC+mxFMllg9FqsxVRmK/npO1oz e9E4IWgKBj7Mi9KaDVjKk+1FyQyu3jY= X-Google-Smtp-Source: ABdhPJzQPsR0WhcTWGJwfz6gU3dXzwnQbm/gfLeIgDgB26aFEOxOwQNDiBOHWCvJqFSnHkpsaisyjw== X-Received: by 2002:a05:600c:378b:: with SMTP id o11mr8133306wmr.157.1638466598061; Thu, 02 Dec 2021 09:36:38 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r17sm326110wmq.11.2021.12.02.09.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:36:37 -0800 (PST) Message-Id: <40ba92dbf0d0a772534d8c00f86b375a08d25a12.1638466593.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 02 Dec 2021 17:36:32 +0000 Subject: [PATCH v3 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 5ac33dfb598..775e5da5b95 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -152,8 +152,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..ef8fdcef466 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 Dec 2 17:36:33 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: 12653191 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 97F57C433F5 for ; Thu, 2 Dec 2021 17:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348225AbhLBRkK (ORCPT ); Thu, 2 Dec 2021 12:40:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376360AbhLBRkE (ORCPT ); Thu, 2 Dec 2021 12:40:04 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5346EC06175C for ; Thu, 2 Dec 2021 09:36:40 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id a9so317152wrr.8 for ; Thu, 02 Dec 2021 09:36:40 -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=YPuHjyUe58NKnqxWJN/lGzTi0JbU5A1GnQrgggUF/5M=; b=EVpZ6CAd/pAwKvegRbJ1+P5/y9M7sqTHI2lxFhSJZcdW5t9QT+AAvMlXJxSezgpox2 7r6G86Nbv//gY9C8D0nembWsJRYex5IEMRb92qt273lP/DXWdmUMbzMZFzsepWpacQLX WoY74wHBRh2BXxoCZ3wZv55mMC34Krfzs2CPHB4iewSvAxn77f0dVJHkNA6YH+ikZ+io TY6SUZQLLHqSwpQGhAaylSyZxgM9cdloqYm8FjlxbEVKUxY/+N3THOeDIqm7iSUFYEep jtYPRMwMzb/PzCXjMNcr139HRUSKd4uZvXlAPDOOw4ZV7ORCjWbs1xb8HOs2wo1RsZFI CQJw== 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=YPuHjyUe58NKnqxWJN/lGzTi0JbU5A1GnQrgggUF/5M=; b=ytAbfYvUgKsq7jbstDvgCT/Qpe9QJ8/TbDBrK6ifr95IBSGcLCbPnr8d0phz4wNMa2 tjXRqE/XmxbQnMQL/n/bHk+NIlKZqzXtneQvFmkAHWLVaEP0+fPqdQ457G0PzJzQUQ5i lWZhpv1JCMFkBQd1csgleVaEgEOp/dq/HcRDa6T6mPeT7rmhVvV3n7Ay+NHcnEho0/BP fTQzSsOG61NAQcfZtcdf5n06hEBiVPUm0bqjLiGwRv8t0r5leN+2LgKgOPiUmFHT78vw R0HdJo1fpJCEAHVemH8jL3Sl7PPExiSLathddu8260Myv/+z4VGRBziwrbzoV4/hLRcv chfA== X-Gm-Message-State: AOAM532DYM7Jo4oWJq1XnoxQ/dcHnz9A5SohNH8+RsR2258jBZ7OQ8Uw Gv9a33DVqoa+r1sRm5JwCIPCkU1YuoE= X-Google-Smtp-Source: ABdhPJxFOxB/TcmSlYY0gq/dLdiAzuQ8HPa5ot9/E49RGKmdq96pEqYXuChF+FyU4uMf/dy2J9SQ4w== X-Received: by 2002:adf:db04:: with SMTP id s4mr15480261wri.467.1638466598820; Thu, 02 Dec 2021 09:36:38 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s63sm327712wme.22.2021.12.02.09.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 09:36:38 -0800 (PST) Message-Id: <751f713a0257126f45d9dc8f86bf38cfa2f923e6.1638466594.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 02 Dec 2021 17:36:33 +0000 Subject: [PATCH v3 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/refs/debug.c b/refs/debug.c index 8667c640237..2defaa9c52e 100644 --- a/refs/debug.c +++ b/refs/debug.c @@ -284,6 +284,7 @@ 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"; + char *msgend = strchrnul(msg, '\n'); if (old_oid) oid_to_hex_r(o, old_oid); if (new_oid) @@ -291,8 +292,10 @@ static int debug_print_reflog_ent(struct object_id *old_oid, 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); + 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, (int)(msgend - msg), msg); return ret; }