From patchwork Mon Jun 24 18:13:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11013915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AEFB1398 for ; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F3E628BB0 for ; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41BDC28BBE; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B73128BC1 for ; Mon, 24 Jun 2019 18:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731931AbfFXSNa (ORCPT ); Mon, 24 Jun 2019 14:13:30 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33505 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731820AbfFXSN3 (ORCPT ); Mon, 24 Jun 2019 14:13:29 -0400 Received: by mail-wr1-f67.google.com with SMTP id n9so14973021wru.0 for ; Mon, 24 Jun 2019 11:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lAj1UyL6S9MtquN4j4m9IdZ4FBisgTrZBixRsl0N33c=; b=BhWd84+TfVQslyqtnnrl9rFl1rpJ0KxmBIHz/gVPn0XsMdcawA+N3X5IcNTZuBOiYB rbd6Hcp824EIJcJq9PDSanHB/4yITxzTc+RRtZjdcBTJw5e6hJFu/IA6MPeFA2Eeb3tk lWkDeAO+ZCDNyNEILfK2fWqm+ArXhaSBU3hyENXNN4clITKKysODro3Q4Z45YNwo/wJy PRwjKfxEcwt2eLYeCLbUJ1VfW3orgwDB3Cg76k0b5wNV+IimL3OerNqIyDd94QDfNF11 4di/Ngx6XK7H54GSIOqH028CCpNUmSadSjKYjDvQX3+O7mdwEQuDBsYdMIO1O1fWZhEB Bckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lAj1UyL6S9MtquN4j4m9IdZ4FBisgTrZBixRsl0N33c=; b=hQCyIvfaMfJnxFhoTe5lkETc4LQQESoT9Lahgfc8pVjZqLfCWXSI2QAU1QK4YVYyhT /qx22dPgjSKjmV97MSrI9Of0H1N629HEDUEf4icwL1WVKIIQ73hOmoRb6H1AF/l7NA0E kulYXXNukxa8a6pp1LbKDfvBQF38dR/MsEUKQiWcbWGI2vUfwn+np5iRCJ7lguyLlZQC 4/hyYDibNFhlz18oMq47WLLIDDMzbPN6bfK1/hwIuhSS7Lc2r+qCaVgnjk04xBnDsVvG yhuUmLv/+SzBG8jl5SmyMr3adsCfbVQeSYtq/nzysSand1u/Dp7OinJG7atfTkyuBuuh lpRw== X-Gm-Message-State: APjAAAX3tHY/NbmA/qXGw1B8UChe8hyvvghiVIUzTxL8r77/+EezwFP9 hpP3xyfzn5WhCvGi+kUzD/w= X-Google-Smtp-Source: APXvYqyO9oYtUqMtzmjwwdG7Jgj0KhLxYPXos6kyx8FlEp1CVQVWQBOlnJFyUXfmcsceTi8EZGEAog== X-Received: by 2002:adf:f050:: with SMTP id t16mr91114266wro.99.1561400006101; Mon, 24 Jun 2019 11:13:26 -0700 (PDT) Received: from localhost.localdomain (x4db9a89d.dyn.telefonica.de. [77.185.168.157]) by smtp.gmail.com with ESMTPSA id v65sm401349wme.31.2019.06.24.11.13.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jun 2019 11:13:25 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: Johannes Schindelin , git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 1/5] t3404: modernize here doc style Date: Mon, 24 Jun 2019 20:13:14 +0200 Message-Id: <20190624181318.17388-2-szeder.dev@gmail.com> X-Mailer: git-send-email 2.22.0.589.g5bd7971b91 In-Reply-To: <20190624181318.17388-1-szeder.dev@gmail.com> References: <20190611130320.18499-1-szeder.dev@gmail.com> <20190624181318.17388-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In 't3404-rebase-interactive.sh' the expected output of several tests is prepared from here documents, which are outside of 'test_expect_success' blocks and have spaces around redirection operators. Move these here documents into the corresponding 'test_expect_success' block and avoid spaces between filename and redition operators. Furthermore, quote the here docs' delimiter word to prevent parameter expansions and what not, where applicable. Signed-off-by: SZEDER Gábor --- t/t3404-rebase-interactive.sh | 123 ++++++++++++++++------------------ 1 file changed, 58 insertions(+), 65 deletions(-) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 1723e1a858..9146f9d47b 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -75,11 +75,10 @@ test_expect_success 'rebase --keep-empty' ' test_line_count = 6 actual ' -cat > expect <expect <<-\EOF && + error: nothing to do + EOF set_fake_editor && test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 && test_i18ncmp expect actual @@ -237,25 +236,23 @@ test_expect_success 'exchange two commits' ' test G = $(git cat-file commit HEAD | sed -ne \$p) ' -cat > expect << EOF -diff --git a/file1 b/file1 -index f70f10e..fd79235 100644 ---- a/file1 -+++ b/file1 -@@ -1 +1 @@ --A -+G -EOF - -cat > expect2 << EOF -<<<<<<< HEAD -D -======= -G ->>>>>>> 5d18e54... G -EOF - test_expect_success 'stop on conflicting pick' ' + cat >expect <<-\EOF && + diff --git a/file1 b/file1 + index f70f10e..fd79235 100644 + --- a/file1 + +++ b/file1 + @@ -1 +1 @@ + -A + +G + EOF + cat >expect2 <<-\EOF && + <<<<<<< HEAD + D + ======= + G + >>>>>>> 5d18e54... G + EOF git tag new-branch1 && set_fake_editor && test_must_fail git rebase -i master && @@ -495,15 +492,14 @@ test_expect_success 'commit message retained after conflict' ' git branch -D conflict-squash ' -cat > expect-squash-fixup << EOF -B - -D +test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' ' + cat >expect-squash-fixup <<-\EOF && + B -ONCE -EOF + D -test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' ' + ONCE + EOF git checkout -b squash-fixup E && base=$(git rev-parse HEAD~4) && set_fake_editor && @@ -799,13 +795,12 @@ test_expect_success 'rebase -i can copy notes' ' test "a note" = "$(git notes show HEAD)" ' -cat >expect <expect <<-\EOF && + an earlier note + + a note + EOF git reset --hard n3 && git notes add -m"an earlier note" n2 && set_fake_editor && @@ -1304,27 +1299,26 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' ' actual ' -cat >expect <expect <<-EOF && + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + To avoid this message, use "drop" to explicitly remove a commit. + + Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings. + The possible behaviours are: ignore, warn, error. + + Rebasing (1/4) + Rebasing (2/4) + Rebasing (3/4) + Rebasing (4/4) + Successfully rebased and updated refs/heads/missing-commit. + EOF test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && set_fake_editor && @@ -1335,21 +1329,20 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' ' test D = $(git cat-file commit HEAD | sed -ne \$p) ' -cat >expect <expect <<-EOF && + Warning: some commits may have been dropped accidentally. + Dropped commits (newer to older): + - $(git rev-list --pretty=oneline --abbrev-commit -1 master) + - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2) + To avoid this message, use "drop" to explicitly remove a commit. + + Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings. + The possible behaviours are: ignore, warn, error. + + You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''. + Or you can abort the rebase with '\''git rebase --abort'\''. + EOF test_config rebase.missingCommitsCheck error && rebase_setup_and_clean missing-commit && set_fake_editor && From patchwork Mon Jun 24 18:13:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11013911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 403D41398 for ; Mon, 24 Jun 2019 18:13:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 345A328BB7 for ; Mon, 24 Jun 2019 18:13:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28A1C28BC1; Mon, 24 Jun 2019 18:13:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCCF28BB7 for ; Mon, 24 Jun 2019 18:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731903AbfFXSN3 (ORCPT ); Mon, 24 Jun 2019 14:13:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43584 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731826AbfFXSN2 (ORCPT ); Mon, 24 Jun 2019 14:13:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id p13so14897753wru.10 for ; Mon, 24 Jun 2019 11:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BGcojx7+3HUj12ltHR1P2b7XaEPWcyBj+x8DgkICdzI=; b=J5iLihZZUkeYGJtPNNKTM4OuiQkik3KGqTiIYSLgKiOtkGaodoDD4+no0flaNKw+ry H6DNu7FDPIy8iG8AkCMPNSP4cYLOQ8uzQQl0klsuP995VCR2on65XKKAQ/cnKjb71bhg a4zsaiRCZLix224nLgJgy9eNQhrrUs4txzdrd/kHwVUZNaw4mi6vbrF6HFi035x6FbKR uQoD8tmFaxT8RMSsftu5DrEgSrdyxCuvVni69+dy+zS3SgbqzJePEgYIzKqq4zxB4MDg EDbAeNgGbMFhCosVRaj4pbLl4WJvpoSyWE+97DEsWNug2Zy3OdX+Se6PswFtgrQLzr7A atGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BGcojx7+3HUj12ltHR1P2b7XaEPWcyBj+x8DgkICdzI=; b=J4/lPFfCIJ6HX7PiMiYoZygSutQ+m1JJhffzL3Hc5PIC74jRlLdRtbckg+FyXAWuiN s4Qx4AwZ3q0A+vYENfNI8KLxB+Fzp8/qt8nCiPySGha10yVEHoX6uoFRw5ApAPkGmZwl vNk3l/riTFhINz9reGJuIJkFAoj27Zto3TEyHQyU2MuLQPJbvp4i8UI7dpaq6di39Psv G6feCf+u+Q9FpaVAhesY7LreRZ6GEh2vkLSp/Zk5/Pc3/UolDG/KWVJ3c9xBI83cVs+C C+EZGjZADn5MvqdZ5xiJLT9EZ3I70jOWH8bG9MEmNNq40vkaZci0ffaYELg6OOM0J+gs 3+IQ== X-Gm-Message-State: APjAAAXEun2+nbiXbmnOeOuidZPKi8fmBIGWaJ4dGasOVB5ibHahle9w gF8sdmW2xy8quBcVTxG534TMnibs X-Google-Smtp-Source: APXvYqxH2EDYvr5nqhnT0asHr+///s2GodiOCV905I7Jg/kmMJAoHWeDfq7CCHkWuEWVmYvlSNG7nw== X-Received: by 2002:adf:f246:: with SMTP id b6mr52559305wrp.92.1561400007193; Mon, 24 Jun 2019 11:13:27 -0700 (PDT) Received: from localhost.localdomain (x4db9a89d.dyn.telefonica.de. [77.185.168.157]) by smtp.gmail.com with ESMTPSA id v65sm401349wme.31.2019.06.24.11.13.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jun 2019 11:13:26 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: Johannes Schindelin , git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 2/5] t3404: make the 'rebase.missingCommitsCheck=ignore' test more focused Date: Mon, 24 Jun 2019 20:13:15 +0200 Message-Id: <20190624181318.17388-3-szeder.dev@gmail.com> X-Mailer: git-send-email 2.22.0.589.g5bd7971b91 In-Reply-To: <20190624181318.17388-1-szeder.dev@gmail.com> References: <20190611130320.18499-1-szeder.dev@gmail.com> <20190624181318.17388-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test 'rebase -i respects rebase.missingCommitsCheck = warn' is mainly interested in the warning about the dropped commits, but it checks the whole output of 'git rebase', including progress lines and what not that are not at all relevant to 'rebase.missingCommitsCheck', but make it necessary to update this test whenever e.g. the way we show progress is updated (as it will happen in one of the later patches of this series). Modify the test to verify only the first four lines of 'git rebase's output that contain all the important lines, notably the line containing the "Warning:" itself and the oneline log of the dropped commit. Signed-off-by: SZEDER Gábor --- t/t3404-rebase-interactive.sh | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 9146f9d47b..0b8267c97c 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1299,32 +1299,19 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' ' actual ' -cr_to_nl () { - tr '\015' '\012' -} - test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' ' cat >expect <<-EOF && Warning: some commits may have been dropped accidentally. Dropped commits (newer to older): - $(git rev-list --pretty=oneline --abbrev-commit -1 master) To avoid this message, use "drop" to explicitly remove a commit. - - Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings. - The possible behaviours are: ignore, warn, error. - - Rebasing (1/4) - Rebasing (2/4) - Rebasing (3/4) - Rebasing (4/4) - Successfully rebased and updated refs/heads/missing-commit. EOF test_config rebase.missingCommitsCheck warn && rebase_setup_and_clean missing-commit && set_fake_editor && FAKE_LINES="1 2 3 4" \ git rebase -i --root 2>actual.2 && - cr_to_nl actual && + head -n4 actual.2 >actual && test_i18ncmp expect actual && test D = $(git cat-file commit HEAD | sed -ne \$p) ' From patchwork Mon Jun 24 18:13:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11013913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4CC2E1398 for ; Mon, 24 Jun 2019 18:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4044828BB8 for ; Mon, 24 Jun 2019 18:13:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C2F928BC4; Mon, 24 Jun 2019 18:13:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF14628BB6 for ; Mon, 24 Jun 2019 18:13:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732742AbfFXSNc (ORCPT ); Mon, 24 Jun 2019 14:13:32 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33756 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731900AbfFXSNa (ORCPT ); Mon, 24 Jun 2019 14:13:30 -0400 Received: by mail-wm1-f66.google.com with SMTP id h19so528650wme.0 for ; Mon, 24 Jun 2019 11:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2jjjOIKj+RGusBRxxlzthlITZIX/tPrLiawA3qHT6WM=; b=AUP1+lv4XHahxvZUprSEmH3Hp78626wYErVxySjaUwRy5gaGlCkfZuPc72/EoyAK0J qi6XO/8FAIsomtW2qQPXRNgVNEUX492crDXjqLRlw9B+pNU0gA8ednstqxDMqi2zJvXu aSiq7OCjHoziwPF2hpHrmkEKRFm39krw1oVovp6w1/XDaj0Aiu9sD6g+rbJ65uU5/yl4 91DaJvNA/3Lc4zjGMLWevingTrAiZQQdq26dwcM9HO43sA7D+J2IchjaVNp/MYs7IKiF D8pJjoDxB6UbKRaVFjB48I+CKbB+Aav+Vl1xpI3WbmmmH8XPghtwo0fQg6jas2DdZxlL 2qiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2jjjOIKj+RGusBRxxlzthlITZIX/tPrLiawA3qHT6WM=; b=tZP/evva57fsOotC4CsKHwny9uD+KQYJIY4OmnOURsbUhs6tM+2UpQ3L+a+BrBUeUk ryY8RRGi9xbZ5gmKkCsBl+yRW2Y6gr42DrBMryTpKrHKOhNSpvTNwjZjIJ8SX5WLek/E q49PNcO0JOXNTxI5/SNSw6DDrmlwAS5ZdzPrX4C2ms45TFlu2yjOygt0sJaddnK53zlI L5+ihjEmNPAGeD43tv32RV3lDacLJeuVJwMs5CncPNF9h1Artbk4RSGhj0c57woyARHN CSEJY8a5qHYMavRw14RiglVAhh8wwL39+ZmgD2Pw4auZe97a7ImuTmsQ+wLYX9XP6Nck LeCQ== X-Gm-Message-State: APjAAAV83VQ61ny7qtm532H512LYPgzpmps3TpMFN0J5+OJNCE+T4i0t UTkRBqtRcrJGQhuYmb0v3IQ= X-Google-Smtp-Source: APXvYqzh4LVJZG7cO1opvx2aZcoWvNZIXoCnB4/RawJhyn2EAZxaInvMTdtIOWsUx/YwehIcHH0bdg== X-Received: by 2002:a1c:618a:: with SMTP id v132mr16640776wmb.17.1561400008375; Mon, 24 Jun 2019 11:13:28 -0700 (PDT) Received: from localhost.localdomain (x4db9a89d.dyn.telefonica.de. [77.185.168.157]) by smtp.gmail.com with ESMTPSA id v65sm401349wme.31.2019.06.24.11.13.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jun 2019 11:13:27 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: Johannes Schindelin , git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 3/5] pager: add a helper function to clear the last line in the terminal Date: Mon, 24 Jun 2019 20:13:16 +0200 Message-Id: <20190624181318.17388-4-szeder.dev@gmail.com> X-Mailer: git-send-email 2.22.0.589.g5bd7971b91 In-Reply-To: <20190624181318.17388-1-szeder.dev@gmail.com> References: <20190611130320.18499-1-szeder.dev@gmail.com> <20190624181318.17388-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are a couple of places where we want to clear the last line on the terminal, e.g. when a progress bar line is overwritten by a shorter line, then the end of that progress line would remain visible, unless we cover it up. In 'progress.c' we did this by always appending a fixed number of space characters to the next line (even if it was not shorter than the previous), but as it turned out that fixed number was not quite large enough, see the fix in 9f1fd84e15 (progress: clear previous progress update dynamically, 2019-04-12). From then on we've been keeping track of the length of the last displayed progress line and appending the appropriate number of space characters to the next line, if necessary, but, alas, this approach turned out to be error prone, see the fix in 1aed1a5f25 (progress: avoid empty line when breaking the progress line, 2019-05-19). The next patch in this series is about to fix a case where we don't clear the last line, and on occasion do end up with such garbage at the end of the line. It would be great if we could do that without the need to deal with that without meticulously computing the necessary number of space characters. So add a helper function to clear the last line on the terminal using an ANSI escape sequence, which has the advantage to clear the whole line no matter how wide it is, even after the terminal width changed. Such an escape sequence is not available on dumb terminals, though, so in that case fall back to simply print a whole terminal width (as reported by term_columns()) worth of space characters. In 'editor.c' launch_specified_editor() already used this ANSI escape sequence, so replace it with a call to this function. Signed-off-by: SZEDER Gábor --- cache.h | 1 + editor.c | 6 +++--- pager.c | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index b4bb2e2c11..5b2cd32bad 100644 --- a/cache.h +++ b/cache.h @@ -1759,6 +1759,7 @@ void setup_pager(void); int pager_in_use(void); extern int pager_use_color; int term_columns(void); +void term_clear_line(void); int decimal_width(uintmax_t); int check_pager_config(const char *cmd); void prepare_pager_args(struct child_process *, const char *pager); diff --git a/editor.c b/editor.c index 71547674ab..f079abbf11 100644 --- a/editor.c +++ b/editor.c @@ -96,10 +96,10 @@ static int launch_specified_editor(const char *editor, const char *path, if (print_waiting_for_editor && !is_terminal_dumb()) /* - * Go back to the beginning and erase the entire line to - * avoid wasting the vertical space. + * Erase the entire line to avoid wasting the + * vertical space. */ - fputs("\r\033[K", stderr); + term_clear_line(); } if (!buffer) diff --git a/pager.c b/pager.c index 4168460ae9..41446d4f05 100644 --- a/pager.c +++ b/pager.c @@ -177,6 +177,26 @@ int term_columns(void) return term_columns_at_startup; } +/* + * Clear the entire line, leave cursor in first column. + */ +void term_clear_line(void) +{ + if (is_terminal_dumb()) + /* + * Fall back to print a terminal width worth of space + * characters (hoping that the terminal is still as wide + * as it was upon the first call to term_columns()). + */ + fprintf(stderr, "\r%*s\r", term_columns(), ""); + else + /* + * On non-dumb terminals use an escape sequence to clear + * the whole line, no matter how wide the terminal. + */ + fputs("\r\033[K", stderr); +} + /* * How many columns do we need to show this number in decimal? */ From patchwork Mon Jun 24 18:13:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11013919 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B4CB91908 for ; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8731288BD for ; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C8C128BB6; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1961D288BD for ; Mon, 24 Jun 2019 18:13:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732744AbfFXSNd (ORCPT ); Mon, 24 Jun 2019 14:13:33 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33515 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731914AbfFXSNc (ORCPT ); Mon, 24 Jun 2019 14:13:32 -0400 Received: by mail-wr1-f67.google.com with SMTP id n9so14973184wru.0 for ; Mon, 24 Jun 2019 11:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=65rO36WSLnylF4hXcIFmcOqhzVCiWoecYPeejmt35hU=; b=U0TKHFzuubx48q5xaDxnljajzLuAisP/HJQCYl1nBWZ1EzpQTtGCMNQxcutLNYt3wM 2Vo9+YJe5d5LKasUZCAoc5nkMdCAbEcAjTy1wH5/BgbKnQ8uHuOEZO7tyHSFcIo4/fcc iqiWVQJ5BxKagyRTBMSG/1WdY2rDqhirVNcP/KW46E+61hB065I1E1fFSaJI4bEOcQXP PkA43227toK2Vo2ivMrh08qhSfdWOZUkYPp05XjbvMs9MVcOXoBo9eh/xeKGY7Jt2s/u iKzXXlqiar1EbPeVoWbI/w1bLil2nvpyhdq2wXknm1IrOiy4cZY5rtGIMgW5+Gf0c8i9 I9BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=65rO36WSLnylF4hXcIFmcOqhzVCiWoecYPeejmt35hU=; b=IaB5SA44Ra2B4DHVFhYwrIg5addseeFWiBX8MVOy/MJiuSXthY3mBzdkZ1xecuYMjL 0dwykaV+MDUaTJAGcOi7JhBRSvtlocKUzpw0FXXALhbg87r+6Y4Z2GTIU+3BsRCVDdhU 4JiW01RBkTsgHhOJwbfRLN7eGQAgOPp7D4muoPq36jaQTBfdZLoAtFkvQ66h80ggn9FT vii9+pSUhspsgeDLYkb4LIx1IxhLQCHgc8Pzhf+K0M+zs6n2VqdtXVc622+YKudQrWWC DEoh4lgKDS1U6Owk91ouer3H8DV1WBA8rZSJD3We7tuZkLxTOt+9Dr4uUoJ7JlTqjHk9 2RUA== X-Gm-Message-State: APjAAAWmKb+YUkZszlvEixz3g4c13luCKUf4nCectJRDOwlk0IhcTiyn QqCFfL589I8BFh1SZadDbEVirpAL X-Google-Smtp-Source: APXvYqxvMiufxCC5/Q3o1ZuMxCzf9X/X9aU6hmoxpsIzaumNaQSZU8u73qAuJX0Cnr8YGQZXpw0Xqg== X-Received: by 2002:a5d:6050:: with SMTP id j16mr40722154wrt.20.1561400009667; Mon, 24 Jun 2019 11:13:29 -0700 (PDT) Received: from localhost.localdomain (x4db9a89d.dyn.telefonica.de. [77.185.168.157]) by smtp.gmail.com with ESMTPSA id v65sm401349wme.31.2019.06.24.11.13.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jun 2019 11:13:28 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: Johannes Schindelin , git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 4/5] rebase: fix garbled progress display with '-x' Date: Mon, 24 Jun 2019 20:13:17 +0200 Message-Id: <20190624181318.17388-5-szeder.dev@gmail.com> X-Mailer: git-send-email 2.22.0.589.g5bd7971b91 In-Reply-To: <20190624181318.17388-1-szeder.dev@gmail.com> References: <20190611130320.18499-1-szeder.dev@gmail.com> <20190624181318.17388-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When running a command with the 'exec' instruction during an interactive rebase session, or for a range of commits using 'git rebase -x', the output can be a bit garbled when the name of the command is short enough: $ git rebase -x true HEAD~5 Executing: true Executing: true Executing: true Executing: true Executing: true) Successfully rebased and updated refs/heads/master. Note the ')' at the end of the last line. It gets more garbled as the range of commits increases: $ git rebase -x true HEAD~50 Executing: true) [ repeated 3 more times ] Executing: true0) [ repeated 44 more times ] Executing: true00) Successfully rebased and updated refs/heads/master. Those extra numbers and ')' are remnants of the previously displayed "Rebasing (N/M)" progress lines that are usually completely overwritten by the "Executing: " lines, unless 'cmd' is short and the "N/M" part is long. Make sure that the previously displayed "Rebasing (N/M)" line is cleared by using the term_clear_line() helper function added in the previous patch. A couple of other rebase commands print similar messages, e.g. "Stopped at ... " for the 'edit' or 'break' commands, or the "Successfully rebased and updated ." at the very end. These are so long that they practically always overwrite that "Rebasing (N/M)" progress line, but let's be prudent, and clear the last line before printing these, too. In 't3420-rebase-autostash.sh' two helper functions prepare the expected output of four tests that check the full output of 'git rebase' and thus are affected by this change, so adjust their expectations to account for the new line clearing. Note that this patch doesn't completely eliminate the possibility of similar garbled outputs, e.g. some error messages from rebase or the "Auto-merging " message from withing the depths of the merge machinery might not be long enough to completely cover the last "Rebasing (N/M)" line. This patch doesn't do anything about them, because dealing with them individually would result in way too much churn, while having a catch-all term_clear_line() call in the common code path of pick_commits() would hide the "Rebasing (N/M)" line way too soon, and it would either flicker or be invisible. Signed-off-by: SZEDER Gábor --- sequencer.c | 17 ++++++++++++++--- t/t3420-rebase-autostash.sh | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sequencer.c b/sequencer.c index f88a97fb10..63b09cfceb 100644 --- a/sequencer.c +++ b/sequencer.c @@ -3731,8 +3731,11 @@ static int pick_commits(struct repository *r, unlink(git_path_merge_head(the_repository)); delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF); - if (item->command == TODO_BREAK) + if (item->command == TODO_BREAK) { + if (!opts->verbose) + term_clear_line(); return stopped_at_head(r); + } } if (item->command <= TODO_SQUASH) { if (is_rebase_i(opts)) @@ -3754,11 +3757,14 @@ static int pick_commits(struct repository *r, } if (item->command == TODO_EDIT) { struct commit *commit = item->commit; - if (!res) + if (!res) { + if (!opts->verbose) + term_clear_line(); fprintf(stderr, _("Stopped at %s... %.*s\n"), short_commit_name(commit), item->arg_len, arg); + } return error_with_patch(r, commit, arg, item->arg_len, opts, res, !res); } @@ -3796,6 +3802,8 @@ static int pick_commits(struct repository *r, int saved = *end_of_arg; struct stat st; + if (!opts->verbose) + term_clear_line(); *end_of_arg = '\0'; res = do_exec(r, arg); *end_of_arg = saved; @@ -3954,10 +3962,13 @@ static int pick_commits(struct repository *r, } apply_autostash(opts); - if (!opts->quiet) + if (!opts->quiet) { + if (!opts->verbose) + term_clear_line(); fprintf(stderr, "Successfully rebased and updated %s.\n", head_ref.buf); + } strbuf_release(&buf); strbuf_release(&head_ref); diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index 2d1094e483..9186e90127 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -49,7 +49,7 @@ create_expected_success_interactive () { $(grep "^Created autostash: [0-9a-f][0-9a-f]*\$" actual) HEAD is now at $(git rev-parse --short feature-branch) third commit Rebasing (1/2)QRebasing (2/2)QApplied autostash. - Successfully rebased and updated refs/heads/rebased-feature-branch. + Q QSuccessfully rebased and updated refs/heads/rebased-feature-branch. EOF } @@ -73,7 +73,7 @@ create_expected_failure_interactive () { Rebasing (1/2)QRebasing (2/2)QApplying autostash resulted in conflicts. Your changes are safe in the stash. You can run "git stash pop" or "git stash drop" at any time. - Successfully rebased and updated refs/heads/rebased-feature-branch. + Q QSuccessfully rebased and updated refs/heads/rebased-feature-branch. EOF } From patchwork Mon Jun 24 18:13:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11013921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21F881398 for ; Mon, 24 Jun 2019 18:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CF528BAC for ; Mon, 24 Jun 2019 18:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 094AE28BA0; Mon, 24 Jun 2019 18:13:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8641F28BAC for ; Mon, 24 Jun 2019 18:13:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732753AbfFXSNf (ORCPT ); Mon, 24 Jun 2019 14:13:35 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34234 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731820AbfFXSNd (ORCPT ); Mon, 24 Jun 2019 14:13:33 -0400 Received: by mail-wr1-f65.google.com with SMTP id k11so14946795wrl.1 for ; Mon, 24 Jun 2019 11:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=08oo5kXeqGBZVSQi1iecIauL4nW/6JU4igUWM/AIHQw=; b=V0eBmfifyeLHdDLL6GPgtCki8FBarioFSnLgdhdXONzF1BBBPxPQ6Nl9HSCX4BTTbk 5uO9lttrSdUTKN566CfAGWZmXEpj0QOSrqekrbrcSiy0tGM3sf6Qhy9NSjz5cr12zuA1 n370wZPrWzdJ0hhWZo6EK1qkKmTtfz5RiirItlkz9YlMWuPADTi83JDX3PFIOWIZrz9C hcyRDPTk1w+G79fvno5+9gGXXeHWUN1qNhq+h3TAg5ehqDMd4OtP5q1pKeXVlb25WJbK BFYpCQW6LBQUzaAYg+fZz/nVGDSM2JROeJ3FqVIqPO/Tu8guTfJT4nNdE+PGZYH6OfOH UDhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=08oo5kXeqGBZVSQi1iecIauL4nW/6JU4igUWM/AIHQw=; b=jy3AEFCy9XrV2A2VaQyvegk+1MgwiZkmJb9Xh2k3GJSEnWQcqEF95VgzNrUMFbSZ4L jQfq+GCyIMQ21z+BrYX9kd0WBO6Sh/SmY+L/mDNCplFTO13Z6ILuSZ2WDXhTWv9/ONgc 9a2UNt15c86TPgw9LIAGhpa2AjCEkMxRMyfW3hyaPCg91iX7h95RVpTLhsuOOdMwBPE6 OlMyuccUyFEBdRfG0gwc0Ev3ExfYLz0XBTfJ5J0X13OgyTNo9c5rNMNSrwvy7MpESgqY zQMXlkh1Oq4BlfWhhJVE0BciDbE1/AMuupz34hz0TvVzd6rQDf9FGwUqss09GEqp+6+v WTaw== X-Gm-Message-State: APjAAAWpjuMo1tE2x5ZXmmx6/+d+1XughCMAJ9vb7cxAmD9Yj9+acGKK TjQgbeBjbcAcHL7f/3PRIPY= X-Google-Smtp-Source: APXvYqwnLETTZvJ5a3KI+ZWXMDE6eJOL2GcXTRebtZc1s1/DYTHWOwTUbV9Fn7wyTzddLRSaFyq61A== X-Received: by 2002:adf:8183:: with SMTP id 3mr97741759wra.181.1561400010815; Mon, 24 Jun 2019 11:13:30 -0700 (PDT) Received: from localhost.localdomain (x4db9a89d.dyn.telefonica.de. [77.185.168.157]) by smtp.gmail.com with ESMTPSA id v65sm401349wme.31.2019.06.24.11.13.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Jun 2019 11:13:30 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: Junio C Hamano Cc: Johannes Schindelin , git@vger.kernel.org, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v3 5/5] progress: use term_clear_line() Date: Mon, 24 Jun 2019 20:13:18 +0200 Message-Id: <20190624181318.17388-6-szeder.dev@gmail.com> X-Mailer: git-send-email 2.22.0.589.g5bd7971b91 In-Reply-To: <20190624181318.17388-1-szeder.dev@gmail.com> References: <20190611130320.18499-1-szeder.dev@gmail.com> <20190624181318.17388-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To make sure that the previously displayed progress line is completely covered up when the new line is shorter, commit 545dc345eb (progress: break too long progress bar lines, 2019-04-12) added a bunch of calculations to figure out how many characters it needs to overwrite with spaces. Use the just introduced term_clear_line() helper function to, well, clear the last line, making all these calculations unnecessary, and thus simplifying the code considerably. Three tests in 't5541-http-push-smart.sh' 'grep' for specific text shown in the progress lines at the beginning of the line, but now those lines begin either with the ANSI escape sequence or with the terminal width worth of space characters clearing the line. Relax the 'grep' patterns to match anywhere on the line. Note that only two of these three tests fail without relaxing their 'grep' pattern, but the third looks for the absence of the pattern, so it still succeeds, but without the adjustment would potentially hide future regressions. Note also that with this change we no longer need the length of the previously displayed progress line, so the strbuf added to 'struct progress' in d53ba841d4 (progress: assemble percentage and counters in a strbuf before printing, 2019-04-05) is not strictly necessary anymore. We still keep it, though, as it avoids allocating and releasing a strbuf each time the progress is updated. Signed-off-by: SZEDER Gábor --- progress.c | 28 +++++++++++----------------- t/t5541-http-push-smart.sh | 6 +++--- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/progress.c b/progress.c index a2e8cf64a8..095dcd0ddf 100644 --- a/progress.c +++ b/progress.c @@ -88,7 +88,6 @@ static void display(struct progress *progress, uint64_t n, const char *done) const char *tp; struct strbuf *counters_sb = &progress->counters_sb; int show_update = 0; - int last_count_len = counters_sb->len; if (progress->delay && (!progress_update || --progress->delay)) return; @@ -116,26 +115,21 @@ static void display(struct progress *progress, uint64_t n, const char *done) if (show_update) { if (is_foreground_fd(fileno(stderr)) || done) { const char *eol = done ? done : "\r"; - size_t clear_len = counters_sb->len < last_count_len ? - last_count_len - counters_sb->len + 1 : - 0; - size_t progress_line_len = progress->title_len + - counters_sb->len + 2; - int cols = term_columns(); + term_clear_line(); if (progress->split) { - fprintf(stderr, " %s%*s", counters_sb->buf, - (int) clear_len, eol); - } else if (!done && cols < progress_line_len) { - clear_len = progress->title_len + 1 < cols ? - cols - progress->title_len - 1 : 0; - fprintf(stderr, "%s:%*s\n %s%s", - progress->title, (int) clear_len, "", - counters_sb->buf, eol); + fprintf(stderr, " %s%s", counters_sb->buf, + eol); + } else if (!done && + /* The "+ 2" accounts for the ": ". */ + term_columns() < progress->title_len + + counters_sb->len + 2) { + fprintf(stderr, "%s:\n %s%s", + progress->title, counters_sb->buf, eol); progress->split = 1; } else { - fprintf(stderr, "%s: %s%*s", progress->title, - counters_sb->buf, (int) clear_len, eol); + fprintf(stderr, "%s: %s%s", progress->title, + counters_sb->buf, eol); } fflush(stderr); } diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh index 8ef8763e06..2e4802e206 100755 --- a/t/t5541-http-push-smart.sh +++ b/t/t5541-http-push-smart.sh @@ -213,7 +213,7 @@ test_expect_success TTY 'push shows progress when stderr is a tty' ' cd "$ROOT_PATH"/test_repo_clone && test_commit noisy && test_terminal git push >output 2>&1 && - test_i18ngrep "^Writing objects" output + test_i18ngrep "Writing objects" output ' test_expect_success TTY 'push --quiet silences status and progress' ' @@ -228,7 +228,7 @@ test_expect_success TTY 'push --no-progress silences progress but not status' ' test_commit no-progress && test_terminal git push --no-progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep ! "^Writing objects" output + test_i18ngrep ! "Writing objects" output ' test_expect_success 'push --progress shows progress to non-tty' ' @@ -236,7 +236,7 @@ test_expect_success 'push --progress shows progress to non-tty' ' test_commit progress && git push --progress >output 2>&1 && test_i18ngrep "^To http" output && - test_i18ngrep "^Writing objects" output + test_i18ngrep "Writing objects" output ' test_expect_success 'http push gives sane defaults to reflog' '