From patchwork Mon Jan 3 18:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tilman Vogel X-Patchwork-Id: 12702726 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 09B87C433EF for ; Mon, 3 Jan 2022 18:08:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235217AbiACSIZ (ORCPT ); Mon, 3 Jan 2022 13:08:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234580AbiACSIY (ORCPT ); Mon, 3 Jan 2022 13:08:24 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2489FC061761 for ; Mon, 3 Jan 2022 10:08:24 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id d9so71458910wrb.0 for ; Mon, 03 Jan 2022 10:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:content-language:to :from:subject; bh=y2ZhzfAWL3wHtVwug90bdxiRYx8DFblGlC9pa8oFqVw=; b=RZuPgOOMnqhlpN9j8Vgad/bYVtgq/G5l8hyAmlhZA9RGEK1ka6dpwXyk0n6H7fSb3G yvi4IjWEobH9SJ5howNltM+Jrb1e+1mItvQzWgBZjF90b0IEyfOIMmMAthnK0yYtczh1 WGJDSb9iFTvpUfwDfWegZmPWNvHNv4dvi7BlfxtKICQP1yDpxbOoyYMr3UjQEcYd8EWC 2WcfPQEEP39zclkmp+/4v+xXZJ5e+CY75fN0gH3NGpemruUnNwh80osgXuJuFuh5S8Gs KO2LcI4hUHA35zQ4ubfzoIiew3fg7UTaXLXcD5qqmw5/dN4uBHkAHFleYAglzFDBAxw+ jguQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :content-language:to:from:subject; bh=y2ZhzfAWL3wHtVwug90bdxiRYx8DFblGlC9pa8oFqVw=; b=FM/z9TnLjLxv2w8VOFbsexdh95cQnezxeUwqsarrNsjkt/9Mm357q7UaRk+0n6Xde/ xzvmsUkMGfEvig4ELdnilO2z0WryCIxfGe1S4kFadbh8j7O1cs9cFdL0E+dF2qdT9rdx I9QsSvwh7Zq1vTcvV8ic9PoKIXs4kWVrxQUeOt9OGNiMmJdmOkbGlYNTs6lvWCMJMe/G xz6SuYPvXwZd1fj71NK4arxzJZFqPBs4mI6Bh8E78e1CkVuul/Aa2iEB9CJW+Tr4ARjK qUncD/CJXh3EboMr8JgPN8EN7/VYvvpnGWdHASgsfgB2dpPH+CbJX9OI4fCSOXCYQPHP wLXw== X-Gm-Message-State: AOAM5301fxa48tX0SJumATnvVjy78smwuWB0ygImoeIKzHHh4PC8Qdyc iTzYldLdxS8oaB37xG+P+DPmiz8S0Wo= X-Google-Smtp-Source: ABdhPJyiLcRsVv0IYnLpKIFwtz3YFSrQXEI9yL1unOgsFh/MMx50zmdvViCUOR+JEkzsGHE1LdzTJg== X-Received: by 2002:a05:6000:168e:: with SMTP id y14mr40675844wrd.492.1641233302716; Mon, 03 Jan 2022 10:08:22 -0800 (PST) Received: from ?IPV6:2003:d3:c71b:f700::bc3? (p200300d3c71bf7000000000000000bc3.dip0.t-ipconnect.de. [2003:d3:c71b:f700::bc3]) by smtp.gmail.com with ESMTPSA id g5sm36062996wru.48.2022.01.03.10.08.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Jan 2022 10:08:22 -0800 (PST) Sender: Tilman Vogel Message-ID: <9749fa2c-b08d-c08b-ce43-041d13852d02@web.de> Date: Mon, 3 Jan 2022 19:08:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US To: git@vger.kernel.org From: Tilman Vogel Subject: [BUG] git pull --rebase ignores rebase.autostash config when fast-forwarding Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi git-people, I ran into strange behavior when having rebase.autostash enabled and doing a git pull --rebase: > git config rebase.autostash true > git pull --rebase Updating cd9ff8a..f3c9840 error: Your local changes to the following files would be overwritten by merge: content Please commit your changes or stash them before you merge. Aborting Confusingly, this fixes the issue: > git config merge.autostash true > git pull --rebase Updating cd9ff8a..f3c9840 Created autostash: c615fda Fast-forward content | 1 + 1 file changed, 1 insertion(+) Applied autostash. Leaving me wonder why merge config options fix rebase behavior. So, in order to make it easier to check the problem, I added some test-cases to the git test-suite. Please see the attached patch. Or here: https://github.com/tvogel/git/commit/bc941f9357518a34cfa11788dfb8e7fa7f711705 I did not try to find the root-cause as I am not experienced with the code-base but if there are questions, let me know. Best regards, Tilman From bc941f9357518a34cfa11788dfb8e7fa7f711705 Mon Sep 17 00:00:00 2001 From: Tilman Vogel Date: Mon, 3 Jan 2022 18:31:59 +0100 Subject: [PATCH] t5521: Show inconsistent rebase behavior (--autostash vs. rebase.autostash) When pull --rebase can be done as a fast-forward, the rebase.autostash config is neglected such that the second test-case added in this commit will fail to autostash and succeed. In fact, setting merge.autostash as a workaround would cause autostash to be done. The other three test-cases added in this commit document that autostashing works as expected when either requested explicitly with --autostash or when pull --rebase cannot be done as a fast-forward. Signed-off-by: Tilman Vogel --- t/t5521-pull-options.sh | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh index 66cfcb09c5..4046a74cad 100755 --- a/t/t5521-pull-options.sh +++ b/t/t5521-pull-options.sh @@ -252,4 +252,56 @@ test_expect_success 'git pull --no-verify --verify passed to merge' ' test_must_fail git -C dst pull --no-ff --no-verify --verify ' +test_expect_success 'git pull --rebase --autostash succeeds on ff' ' + test_when_finished "rm -fr src dst actual" && + git init src && + test_commit -C src "initial" file "content" && + git clone src dst && + test_commit -C src --printf "more_content" file "more content\ncontent\n" && + echo "dirty" >>dst/file && + git -C dst pull --rebase --autostash >actual 2>&1 && + grep -q "Fast-forward" actual && + grep -q "Applied autostash." actual +' + +test_expect_success 'git pull --rebase with rebase.autostash succeeds on ff' ' + test_when_finished "rm -fr src dst actual" && + git init src && + test_commit -C src "initial" file "content" && + git clone src dst && + test_commit -C src --printf "more_content" file "more content\ncontent\n" && + echo "dirty" >>dst/file && + test_config -C dst rebase.autostash true && + git -C dst pull --rebase >actual 2>&1 && + grep -q "Fast-forward" actual && + grep -q "Applied autostash." actual +' + +test_expect_success 'git pull --rebase --autostash succeeds on non-ff' ' + test_when_finished "rm -fr src dst actual" && + git init src && + test_commit -C src "initial" file "content" && + git clone src dst && + test_commit -C src --printf "src_content" file "src content\ncontent\n" && + test_commit -C dst --append "dst_content" file "dst content" && + echo "dirty" >>dst/file && + git -C dst pull --rebase --autostash >actual 2>&1 && + grep -q "Successfully rebased and updated refs/heads/main." actual && + grep -q "Applied autostash." actual +' + +test_expect_success 'git pull --rebase with rebase.autostash succeeds on non-ff' ' + test_when_finished "rm -fr src dst actual" && + git init src && + test_commit -C src "initial" file "content" && + git clone src dst && + test_commit -C src --printf "src_content" file "src content\ncontent\n" && + test_commit -C dst --append "dst_content" file "dst content" && + echo "dirty" >>dst/file && + test_config -C dst rebase.autostash true && + git -C dst pull --rebase >actual 2>&1 && + grep -q "Successfully rebased and updated refs/heads/main." actual && + grep -q "Applied autostash." actual +' + test_done -- 2.34.1