From patchwork Fri Jun 7 16:30:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13690509 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6364343ADE for ; Fri, 7 Jun 2024 16:30:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777822; cv=none; b=o3TtAzEri9/eKQMOiS+z0ldfMg5NyO0fDOmd7lO2SwDPXRgGu+rn9xCuEJyhbcqoJVpv4W7MKuNl3tOW2p4n3FmNS02NaW1OkTmPmXFZW19il7nFBAADt1cmxzRkwG6VLKLuQr1CY0qOXdTD2UDXaThYoCUg5si/z39zHP5McCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777822; c=relaxed/simple; bh=q+S9eVicHl33BaFc+gGKoQVO0m5AdBp0C1abu8oYs1M=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=TWaa62oAvKtYkp1MtVMXfjcYZTalSyzegS45UDNE5BYqVGpVX1zaDXzLFN1LHENSq+GZjRqqDEhlSNBMHlq2e3DRN4CLNZ3+YnvWrHP9OEiEzHIayNDkCq5XfO3rzRj8CKue6bAWNK1WKuDbyf/gVjKOJydPc7Xos6UEuwTwFLQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AMtTum2r; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AMtTum2r" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-35ef3a037a0so1369383f8f.0 for ; Fri, 07 Jun 2024 09:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717777819; x=1718382619; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=iTDhSvnkX0upqRdGVxDCCUvuBwLmhZJTWh96jCDT6Ew=; b=AMtTum2rdrQLiu/BDSU9vDdpvlwpX+/EhZkhs5Z82LfmDhyuyTgndVn617yr/V4Wcd WAGC+FA0NtEYho6cIOn3b88lpfAj+FAs9rUf+Vo45565y7mb+kWykzUP9vsd4cVzCdhA zlr+zSyMIFFjIasLmeKNejgoeRcY7/zCihtrWHL/IK8kpafW5JWPROPHFSm/awSQeQ+O /2q1fvV8z0Yv3gNdwwfWVbU4gad+Pte0e1J8p+F4wNOqFLHZCdgpfcHqjCEbj6XL9s4m dn/uYAt+WqjHUXaL5DAVRTqaGIzzo2pNM3ewU6Nsx3bf01AwMnllkbWBxoZQ4c6Q4/Cy NJcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717777819; x=1718382619; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iTDhSvnkX0upqRdGVxDCCUvuBwLmhZJTWh96jCDT6Ew=; b=HVVK0NgIgBGIoKLHRE+z0Cya4HoOWAj2zIFBQtMY9dtEMtwoa6XT9mjIEMIKBviZlq fLlyGEiMuKQK4Ds9ldjUE9Bc7b41hKgVA+Efj5jo2FhdM3P2JCz4URZe0YfZSWSjS6an hpVYnzN28Klqx2vwUg5U6WGrrGzlWHwjyxEx4G6PH9eR+flgORrYuIWgHN8sbnJpmLA4 1V349aVi1u+62ShV4h6naNIjvmLKOrE1f8zFoShi5udS2Qw//i7laezxooyFoFktGzgU xa8wESH9LO8t5ey0WDkaxLgZr7gDRsmKD3XtDWDMUkprbMEKKVihlfBQYAicAjMLkXi1 kekw== X-Gm-Message-State: AOJu0YwdqO5UTU1ICdUhsrozElNmEW35zhaHGGwnHWIB1lcPtj3rVPJG mzmM6hhjuxYpZx36jhg3e91QpZyKK60TnYNy2+nyNplQOk1oJhbRsSmqUw== X-Google-Smtp-Source: AGHT+IF+rl447YstyxXzA1TNHXd9smcfC08OKiX6UEUfkjmGcS3VmGIJPS6zpB5Qo54fYzVMMQmuhQ== X-Received: by 2002:a5d:6d8f:0:b0:34c:7ed4:55a with SMTP id ffacd0b85a97d-35ef0ddb092mr7294938f8f.33.1717777818599; Fri, 07 Jun 2024 09:30:18 -0700 (PDT) Received: from gmail.com (200.red-88-14-44.dynamicip.rima-tde.net. [88.14.44.200]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f0ce4b62fsm962970f8f.80.2024.06.07.09.30.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jun 2024 09:30:18 -0700 (PDT) Message-ID: <20b95372-12cf-49bd-b1b7-dc069e7c86dd@gmail.com> Date: Fri, 7 Jun 2024 18:30:17 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v4 1/2] t4014: cleanups in a few tests From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List , Junio C Hamano Cc: Patrick Steinhardt References: <6269eed5-f1ff-43f3-9249-d6a0f1852a6c@gmail.com> <14365d68-ed04-44fe-823b-a3959626684e@gmail.com> <9f520828-f87e-49b1-aa4b-c00ec6bb0133@gmail.com> Content-Language: en-US In-Reply-To: <9f520828-f87e-49b1-aa4b-c00ec6bb0133@gmail.com> Arrange things we are going to create to be removed at end, and then start creating them. That way, we will clean them up even if we fail after creating some but before the end of the command. Signed-off-by: Rubén Justo --- t/t4014-format-patch.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index e37a1411ee..5fb5250df4 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -820,8 +820,8 @@ test_expect_success 'format-patch --notes --signoff' ' ' test_expect_success 'format-patch notes output control' ' + test_when_finished "git notes remove HEAD" && git notes add -m "notes config message" HEAD && - test_when_finished git notes remove HEAD && git format-patch -1 --stdout >out && ! grep "notes config message" out && @@ -848,10 +848,10 @@ test_expect_success 'format-patch notes output control' ' ' test_expect_success 'format-patch with multiple notes refs' ' + test_when_finished "git notes --ref note1 remove HEAD; + git notes --ref note2 remove HEAD" && git notes --ref note1 add -m "this is note 1" HEAD && - test_when_finished git notes --ref note1 remove HEAD && git notes --ref note2 add -m "this is note 2" HEAD && - test_when_finished git notes --ref note2 remove HEAD && git format-patch -1 --stdout >out && ! grep "this is note 1" out && @@ -892,10 +892,10 @@ test_expect_success 'format-patch with multiple notes refs' ' test_expect_success 'format-patch with multiple notes refs in config' ' test_when_finished "test_unconfig format.notes" && + test_when_finished "git notes --ref note1 remove HEAD; + git notes --ref note2 remove HEAD" && git notes --ref note1 add -m "this is note 1" HEAD && - test_when_finished git notes --ref note1 remove HEAD && git notes --ref note2 add -m "this is note 2" HEAD && - test_when_finished git notes --ref note2 remove HEAD && git config format.notes note1 && git format-patch -1 --stdout >out && From patchwork Fri Jun 7 16:30:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13690510 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8C61199222 for ; Fri, 7 Jun 2024 16:30:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777836; cv=none; b=rtfMtHBoTJqCTbUWjLXgftP75ghasOofmjMpfXfVxX38Ywk7WWJ2nw4DKjRobdLfKptrnaaEH30Gi+h+Y1AvmImRVlq3XD/7AMc0vQlO1gJAH+m6viW6o+s8ha69af29Rm7Ec/U3mhduh43lXv2Z0O32N9GCUnuZ/7ayRk+K+uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717777836; c=relaxed/simple; bh=yCmJ7ZCK16aLQ+Q80yYQAtfP0wkjCSO8jpS4sMEugbM=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=Zea6sj+oMMUUKFFuHLf65Xte/KBhwNar87bFoCwO+JeTWX85FBunb3Ir2fV98odKoqgzvKv4Q8qwXlr3hrrTkQaed5lPJsCfAvKPijbK2llFj2CzgEb9qn+92l9Fr/VTfCbsKq4um5OhQyNyJzWHFJMmcvRrOgHhiud+wHtFn0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G85UJrbL; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G85UJrbL" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so24070255e9.0 for ; Fri, 07 Jun 2024 09:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717777833; x=1718382633; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jnl2uf91JmNKof6pBpcQi+QoPKRhsPX1pvj9XIWifl8=; b=G85UJrbLl9qFaQyYdEEgxe5XQWRWT6NP4rGY7a0XPTpxor5cs5WjO35bbqJIzOrpQu n1K9F2GxmMvMH3446hs/NzuPy2G3oJE3vg2z+1zbQSeGeixLzQ6XC1pg0mnjV1EedEeH Oh7SlGIft2WCoU5UeS5WDbz7NSkJjP8fEEEqYkcqlDRkTys3ZQK+adrRGeIaGZfj1vuf C0aqTp0zobG608RUiu1qVsKIgVNLuDGVj6sJbkJQCZTn4LZNJuX4TNGfR5NhMN4bgkgf KrLYfMQsFxn6/ttbRTINd0R0vAmKFNHOeeNrX8Bjus0S/0PuBLE7RXV5HJwWG2Z5Lc/b WOuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717777833; x=1718382633; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jnl2uf91JmNKof6pBpcQi+QoPKRhsPX1pvj9XIWifl8=; b=hnVnE+UP2wcbtFqYmkvaWREFwT+GiKpszwUY5Di247pTq9Ho/MBjbh72IYZGgdDKn5 S6Fg8TEhc8s2DFgAdqdaOEHAj1W2LOLgXgh5IQg8ylt2qo3y45716H0IimuD/BAVhrMy uIqS9NFOMuYndqR4hqXNG9SpI3SJN8BIX3Mffsyn+T60cYmwBnTiwt6lgaFCEISP8QQY F7bWAwsI/XuPzWNsUzIzYcQLKNfugo1cBoOwqRNPHtQQRpRPWm/32860woQdEe/Eu4IH Scw61FJVd9jDNGy29xCbcYDgCPo4t/ZIzRKUIqUM2AOJCje3ji5is1WZnuvbPCcVsJUB JVrA== X-Gm-Message-State: AOJu0Yy2VElwTCB6OtbNbwZbR2IhCIKavyZHnQLYmurbVSC3dzIBJ/zE 0/I5iFyJMaD2kKHdC8zMUKjopQidDxqTjf/E0y+bMJZGHeUdYylwS8XNgQ== X-Google-Smtp-Source: AGHT+IGHy4OIhJOwMWbn7y6oSeY7Ax7HWxLpwiZ6qjx3/a5APKVnTTZo+BilUZYMLvxcOjBpJxEQlw== X-Received: by 2002:a05:600c:1c24:b0:416:bc18:2a00 with SMTP id 5b1f17b1804b1-42164a3665emr29108085e9.38.1717777833046; Fri, 07 Jun 2024 09:30:33 -0700 (PDT) Received: from gmail.com (200.red-88-14-44.dynamicip.rima-tde.net. [88.14.44.200]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2d7935sm55879375e9.48.2024.06.07.09.30.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jun 2024 09:30:32 -0700 (PDT) Message-ID: Date: Fri, 7 Jun 2024 18:30:32 +0200 Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v4 2/2] format-patch: assume --cover-letter for diff in multi-patch series Content-Language: en-US From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List , Junio C Hamano Cc: Patrick Steinhardt References: <6269eed5-f1ff-43f3-9249-d6a0f1852a6c@gmail.com> <14365d68-ed04-44fe-823b-a3959626684e@gmail.com> <9f520828-f87e-49b1-aa4b-c00ec6bb0133@gmail.com> In-Reply-To: <9f520828-f87e-49b1-aa4b-c00ec6bb0133@gmail.com> When we deal with a multi-patch series in git-format-patch(1), if we see `--interdiff` or `--range-diff` but no `--cover-letter`, we return with an error, saying: fatal: --range-diff requires --cover-letter or single patch or: fatal: --interdiff requires --cover-letter or single patch This makes sense because the cover-letter is where we place the diff from the previous version. However, considering that `format-patch` generates a multi-patch as needed, let's adopt a similar "cover as necessary" approach when using `--interdiff` or `--range-diff`. Therefore, relax the requirement for an explicit `--cover-letter` in a multi-patch series when the user says `--iterdiff` or `--range-diff`. Still, if only to return the error, respect "format.coverLetter=no" and `--no-cover-letter`. Signed-off-by: Rubén Justo --- builtin/log.c | 2 ++ t/t3206-range-diff.sh | 14 ++++++++++++++ t/t4014-format-patch.sh | 15 +++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index c0a8bb95e9..d61cdbf304 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -2255,6 +2255,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (cover_letter == -1) { if (config_cover_letter == COVER_AUTO) cover_letter = (total > 1); + else if ((idiff_prev.nr || rdiff_prev) && (total > 1)) + cover_letter = (config_cover_letter != COVER_OFF); else cover_letter = (config_cover_letter == COVER_ON); } diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index 7b05bf3961..a767c3520e 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -545,6 +545,20 @@ do ' done +test_expect_success "--range-diff implies --cover-letter for multi-patch series" ' + test_when_finished "rm -f v2-000?-*" && + git format-patch -v2 --range-diff=topic main..unmodified && + test_grep "^Range-diff against v1:$" v2-0000-cover-letter.patch +' + +test_expect_success "explicit --no-cover-letter defeats implied --cover-letter" ' + test_when_finished "rm -f v2-000?-*" && + test_must_fail git format-patch --no-cover-letter \ + -v2 --range-diff=topic main..unmodified && + test_must_fail git -c format.coverLetter=no format-patch \ + -v2 --range-diff=topic main..unmodified +' + test_expect_success 'format-patch --range-diff as commentary' ' git format-patch --range-diff=HEAD~1 HEAD~1 >actual && test_when_finished "rm 0001-*" && diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 5fb5250df4..de9e8455b3 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -2445,6 +2445,21 @@ test_expect_success 'interdiff: solo-patch' ' test_cmp expect actual ' +test_expect_success 'interdiff: multi-patch, implicit --cover-letter' ' + test_when_finished "rm -f v23-0*.patch" && + git format-patch --interdiff=boop~2 -2 -v23 && + test_grep "^Interdiff against v22:$" v23-0000-cover-letter.patch && + test_cmp expect actual +' + +test_expect_success 'interdiff: explicit --no-cover-letter defeats implied --cover-letter' ' + test_when_finished "rm -f v23-0*.patch" && + test_must_fail git format-patch --no-cover-letter \ + --interdiff=boop~2 -2 -v23 && + test_must_fail git -c format.coverLetter=no format-patch \ + --interdiff=boop~2 -2 -v23 +' + test_expect_success 'format-patch does not respect diff.noprefix' ' git -c diff.noprefix format-patch -1 --stdout >actual && grep "^--- a/blorp" actual