From patchwork Thu May 6 16:50:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 614B6C433B4 for ; Thu, 6 May 2021 16:52:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 277A161177 for ; Thu, 6 May 2021 16:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236105AbhEFQxl (ORCPT ); Thu, 6 May 2021 12:53:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236072AbhEFQxl (ORCPT ); Thu, 6 May 2021 12:53:41 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D76C061574 for ; Thu, 6 May 2021 09:52:42 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id v12so6345317wrq.6 for ; Thu, 06 May 2021 09:52:42 -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=bKLz9YgU+E+1QH0x93PER+OPkHX2Qopkv+2Q71QSacI=; b=g794zA9/D2nHzKnNqPTrC2d21G3vmY/mWeqIHvrtB3k+33Z9CSEqgdZCRl5YTuD3cO 6ufZb4ns36LQxm37E/9aC7Yvbjd1UMYRwTviEv72PyvbsIZrK8dXO4OSKt7XfMIwXIye r5+9P5iuknlTuAEBskI1ZMDE9pYSg04ZG0MDpsJYPPPh1bAMKq/tEY2MVxCcLJByA3ix 66r713G5GKup9XS1UH/s3If1Bj2DnpU/62wzbdCeZeOhrZojQy8PssWkTOnTOqJZmRgy dll2QyKi1cV3sUW8AFWHnxwciyeIkN17ZL/CyD+BhG3LyBhaRypD7CFQ9FWSd3Oxr+jV 5wQw== 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=bKLz9YgU+E+1QH0x93PER+OPkHX2Qopkv+2Q71QSacI=; b=hLTk+ymHIe5OFMag9IQeb8DeHehqcLN76oc15l6Vt8VdqZjoVjekuJ0frQAwWL62x2 PS9KyKbdIOIusQiHbw2qNGPun6eHUznstIf29hWfG2yzGjYJR5aZNmJZg2zkl/XrAb0J BonPBAbbV7VY+MacIK8VSHRE+rRWjaSGnh5yJJ4IbmaoCNupaCq1f69HzziPbOh+7D1e bqYXG/vUZmevobH9DL6o9sUVuIifGX20zHhXSMNmAq0yH10B4pgxGWn3b8Aw3pg4RhMu oVfqmOktloMhYKCShVLs+a+/ncvtP8o010bjGvTV4fogpRZ35ST/0l4LuXWTDCCxlMn2 CyGA== X-Gm-Message-State: AOAM531DlC1G6a7N1ViOfrHLTTCWwLhICsviNrF42WPD0IzubR2IpX8B utOP0Z6Vu3PubugbEluJVIQ= X-Google-Smtp-Source: ABdhPJxhpI3eKzzN3W9nxYRAgwlcc5/7AhfIiJfk6eO4vkKJT0BE4WOKajTh2+yIHeNwjmb4QZBj+g== X-Received: by 2002:adf:ed07:: with SMTP id a7mr6735342wro.113.1620319961757; Thu, 06 May 2021 09:52:41 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:41 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 1/8] compat/terminal: let prompt accept input from pipe Date: Thu, 6 May 2021 18:50:55 +0200 Message-Id: <20210506165102.123739-2-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, git_prompt ignores input coming from anywhere other than terminal (pipe, redirection etc.) meaning that standard prompt auto-answering methods would have no effect: echo 'Y' | git ... yes 'Y' | git ... git ... --- compat/terminal.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/compat/terminal.c b/compat/terminal.c index 43b73ddc75..c12e0b9ab9 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -202,41 +202,50 @@ static int mingw_getchar(void) char *git_terminal_prompt(const char *prompt, int echo) { static struct strbuf buf = STRBUF_INIT; - int r; - FILE *input_fh, *output_fh; + int r, input_not_from_tty = !isatty(STDIN_FILENO); + FILE *input_fh = NULL, *output_fh = NULL; + char* ret = NULL; + + if (input_not_from_tty) + input_fh = stdin; + else + input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT); - input_fh = fopen(INPUT_PATH, "r" FORCE_TEXT); if (!input_fh) - return NULL; + goto done; output_fh = fopen(OUTPUT_PATH, "w" FORCE_TEXT); - if (!output_fh) { - fclose(input_fh); - return NULL; - } - if (!echo && disable_echo()) { - fclose(input_fh); - fclose(output_fh); - return NULL; - } + if (!output_fh) + goto done; + + if (!echo && disable_echo()) + goto done; fputs(prompt, output_fh); fflush(output_fh); r = strbuf_getline_lf(&buf, input_fh); - if (!echo) { + + if (input_not_from_tty) + fputs(buf.buf, output_fh); + + if (!echo || input_not_from_tty) { putc('\n', output_fh); fflush(output_fh); } restore_term(); - fclose(input_fh); - fclose(output_fh); - if (r == EOF) - return NULL; - return buf.buf; + if (r != EOF) + ret = buf.buf; +done: + if (input_fh && input_fh != stdin) + fclose(input_fh); + if (output_fh) + fclose(output_fh); + + return ret; } /* From patchwork Thu May 6 16:50:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43D67C433ED for ; Thu, 6 May 2021 16:52:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 173E9613B5 for ; Thu, 6 May 2021 16:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236108AbhEFQxm (ORCPT ); Thu, 6 May 2021 12:53:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235881AbhEFQxm (ORCPT ); Thu, 6 May 2021 12:53:42 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8176C061574 for ; Thu, 6 May 2021 09:52:43 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t18so6358856wry.1 for ; Thu, 06 May 2021 09:52:43 -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=/QqPvbntNNm0mzRCQZCg49nN1oygxHKwZAuEutsaIqc=; b=q1Q3+k50MYieelGDgW77va4LR+qhJmcFCx2GmpQTwKO7FqtCTBMCNI/b9x2Yui8+wQ bBtbzEyHPwjyj2px14sLkldmV3POfHsHirgwa8l21CWIRnpDVoXTV3RxAl2wh4ZO9hAw E/NsiqIXPWbm1uNF42cCKH0jlXLfPPQczwvk2DeR+1cm+tGV2/GpbZPUweoSib7rpAG7 8Riv2TW6V64HL7LoyqAB3ozwT2x5LcksQTD1pcRqnAiHX6iN/Xs5SIeMqCIRDzmOeGKS y7sQRxakl0xf4Fyg+mkcXUmvdJ4QadNh8Pa7MvCnGxg5Zlpf5niNJxYvzURlYidt8Y7p rGeg== 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=/QqPvbntNNm0mzRCQZCg49nN1oygxHKwZAuEutsaIqc=; b=hihhWvpaG1IRHqfCV+4MWz4Zu9YNdmIkXAW+rRLwLHEce/qjQEIQ/XUvadoMvEiER/ F8pECLioHEhABM3e2+HJnIisD/PceXh3+JZ1t3SLb85L5m6npzDl8NubX8+YplLR54Mv sJlnXt5IEJ0d1X1gLnNkzDSLxkkpAYe/YawbNSuEH5HGIsDV0vVExR+WYjfVuUeRrzPX CHtbEeqxwaCnOi7L/KepO76HQRe27vwRfKJpJcu406zDPYBJ7rugWNpdSu6MqMD+WgBX Hf7M95lge7F7DRowazdu1qfw3+ouVDMwsTYacNl0VO4DKr+0wE1CylIkNm/zA2uQEPzP PKrQ== X-Gm-Message-State: AOAM532t1eJiSTX9D1Md+4ZP1/SoRKgaUMMxujtGIH7FCYFx/8n3vaqi yU77UbgFhGQ8PMYG9J0yB64= X-Google-Smtp-Source: ABdhPJzwBuV/lNCxVCgyFUGa4p0hmG0/vYG9fzp1t7IIrdBpLOb8LoFhKEaHpnXxUpS4HScaqb8xng== X-Received: by 2002:adf:e40f:: with SMTP id g15mr6457732wrm.392.1620319962388; Thu, 06 May 2021 09:52:42 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:42 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 2/8] format-patch: confirmation whenever patches exist Date: Thu, 6 May 2021 18:50:56 +0200 Message-Id: <20210506165102.123739-3-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, git-format-patch, along with the option --cover-letter, unconditionaly overwrites a cover letter with the same name (if present). Although this is a desired behaviour for patches which are auto-generated from Git commits log, it might not be the case for a cover letter whose the content is meticulously written manually. Particulary, this behaviour could be awkward in the following hypothetical situations: * The user can easily erase a cover letter coming from prior versions or another patch series by reusing an old command line (e.g. autocompleted from the shell history). * Assuming that the user is writing a cover letter and realizes that small changes should be made. They make the change, amend and format-patch again to regenerate patches. If it happens that they use the same command again (e.g. with --cover-letter), the cover letter being written is gone. This patch addresses this issue by asking confirmation from the user whenever a cover letter or a patch with the same name already exists. Signed-off-by: Firmin Martin --- builtin/log.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 6102893fcc..bada3db9eb 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -35,6 +35,7 @@ #include "repository.h" #include "commit-reach.h" #include "range-diff.h" +#include "prompt.h" #define MAIL_DEFAULT_WRAP 72 #define COVER_FROM_AUTO_MAX_SUBJECT_LEN 100 @@ -959,6 +960,10 @@ static int open_next_file(struct commit *commit, const char *subject, struct rev_info *rev, int quiet) { struct strbuf filename = STRBUF_INIT; + struct strbuf file_exists_prompt = STRBUF_INIT; + const char *yesno; + static int not_prompted = 1; + int res = 0; if (output_directory) { strbuf_addstr(&filename, output_directory); @@ -972,17 +977,35 @@ static int open_next_file(struct commit *commit, const char *subject, else fmt_output_subject(&filename, subject, rev); - if (!quiet) - printf("%s\n", filename.buf + outdir_offset); + if (not_prompted && !access(filename.buf, F_OK)) { + + /* + * TRANSLATORS: Make sure to include [Y] and [n] in your + * translation. The program will only accept English input + * at this point. + */ + strbuf_addf(&file_exists_prompt, _("The file '%s' already exists.\n" + "Would you overwrite this file and subsequent ones [Y/n]? "), filename.buf); + yesno = git_prompt(file_exists_prompt.buf, PROMPT_ECHO); + not_prompted = 0; + if (tolower(*yesno) == 'n') { + res = -1; + goto done; + } + } if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) { error_errno(_("cannot open patch file %s"), filename.buf); - strbuf_release(&filename); - return -1; + res = -1; + goto done; } + if (!quiet) + printf("%s\n", filename.buf + outdir_offset); +done: strbuf_release(&filename); - return 0; + strbuf_release(&file_exists_prompt); + return res; } static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) From patchwork Thu May 6 16:50:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E884C433B4 for ; Thu, 6 May 2021 16:52:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC405611AE for ; Thu, 6 May 2021 16:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236115AbhEFQxn (ORCPT ); Thu, 6 May 2021 12:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235881AbhEFQxm (ORCPT ); Thu, 6 May 2021 12:53:42 -0400 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 60827C061574 for ; Thu, 6 May 2021 09:52:44 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id m9so6369716wrx.3 for ; Thu, 06 May 2021 09:52:44 -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=hsOLhCThGciT8IlLf93ZVtFXDGUr0WzgXEOka7x1W7c=; b=ClN+a0jKSYrd18EkWfY/QynoEflcLxeRFfEGp7gGRxPN/UC60jsqu/Jkn3Fv/KK9VK hsaovMd4Od6ztsC5NkHykHy4XINGtAsbQR4Sqvqqg+1GJr1AdgKZAtN+FqhwH0uWyMdo XZXugj4BWO+8P/ciFiLvPmJaqytW9GpVuVIR5ou2RIKe8j3RmeLUXhoMsqRKXZti5pLd 6bIlIzx8jTzGyIThc1Tuo/hciCHpM13HuyTbJC8E+SLSv9sPmgpbqrJEUQTXgOAg8+IP mVXl8f/mPvEh1ZmjNESwebOk/dxHNvbJ2VahzyvGmFtAxXHCu7pMPKIyTgWvM9y+CXjJ UCgw== 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=hsOLhCThGciT8IlLf93ZVtFXDGUr0WzgXEOka7x1W7c=; b=QQuo4zZuu6ly2xYWlV2iAhLUMCqX+dMurrC/H2PRC66Xb6V1tYF0mA4iH5zQ6IWLFH AWwUQgMOg6NucfD2CBnZHD/GTSSVk/Y+24KXsTYg2+5ET43s+gRV7wY92SoS/eI/fQl3 dOO1eGSR01fFdzGacIY3HAq7tsoOfikqoKNIfOri1rKCRADdX67n0RGQhy3xUqYV8zud 0ay/6eWF5vdy0X3pSrFsLhP6aPtsfL108r3uAai2iWP0yGKPczMjJDm2Z/hNW50BGtBn v+pFP9oIvftnZy/cZXRgvlE0RP8GDB0HEr7rI45DA5lacE09bxyNia4aSFQ43xiYfQxb 4AMw== X-Gm-Message-State: AOAM533a3pv/mg1BxpwSrhOhhdKBPXmm2l0o928KL7hsXX85355FO53w xe/ZVO0HuRq5esdSeyk5FYFaxYGpWSDobykR X-Google-Smtp-Source: ABdhPJw+gyycWJRq20OplB3IH9zP/MILTYZaDz9B4uvGJ4eHX6UOvg4igPu6Qx6uBSrMCheJJzoRnQ== X-Received: by 2002:adf:82e1:: with SMTP id 88mr6438571wrc.186.1620319963123; Thu, 06 May 2021 09:52:43 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:42 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 3/8] format-patch: add config option confirmOverwrite Date: Thu, 6 May 2021 18:50:57 +0200 Message-Id: <20210506165102.123739-4-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Provide the configuration option format.confirmOverwrite. This option will decide whether a confirmation is required to overwrite cover letter or patches issued by git-format-patch. It accepts three values. * "never"/"always": never/always ask confirmation whenever cover letter or patches are subject to be overwritten. * "cover": ask confirmation only if a cover letter is subject to be overwritten. format.confirmOverwrite defaults to "cover" to avoid cover letter being written be overwritten mistakenly. Signed-off-by: Firmin Martin --- builtin/log.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/builtin/log.c b/builtin/log.c index bada3db9eb..ec9848da70 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -816,6 +816,12 @@ enum auto_base_setting { AUTO_BASE_WHEN_ABLE }; +enum confirm_overwrite_setting { + CONFIRM_OVERWRITE_NEVER, + CONFIRM_OVERWRITE_ALWAYS, + CONFIRM_OVERWRITE_COVER +}; + static enum thread_level thread; static int do_signoff; static enum auto_base_setting auto_base; @@ -827,6 +833,7 @@ static const char *config_output_directory; static enum cover_from_description cover_from_description_mode = COVER_FROM_MESSAGE; static int show_notes; static struct display_notes_opt notes_opt; +static enum confirm_overwrite_setting confirm_overwrite = CONFIRM_OVERWRITE_COVER; static enum cover_from_description parse_cover_from_description(const char *arg) { @@ -844,6 +851,18 @@ static enum cover_from_description parse_cover_from_description(const char *arg) die(_("%s: invalid cover from description mode"), arg); } +static enum confirm_overwrite_setting parse_confirm_overwrite(const char *arg) +{ + if (!arg || !strcasecmp(arg, "cover")) + return CONFIRM_OVERWRITE_COVER; + else if (!strcasecmp(arg, "always")) + return CONFIRM_OVERWRITE_ALWAYS; + else if (!strcasecmp(arg, "never")) + return CONFIRM_OVERWRITE_NEVER; + else + die(_("%s: invalid file overwrite setting"), arg); +} + static int git_format_config(const char *var, const char *value, void *cb) { if (!strcmp(var, "format.headers")) { @@ -949,6 +968,10 @@ static int git_format_config(const char *var, const char *value, void *cb) cover_from_description_mode = parse_cover_from_description(value); return 0; } + if (!strcmp(var, "format.confirmoverwrite")) { + confirm_overwrite = parse_confirm_overwrite(value); + return 0; + } return git_log_config(var, value, cb); } @@ -977,7 +1000,10 @@ static int open_next_file(struct commit *commit, const char *subject, else fmt_output_subject(&filename, subject, rev); - if (not_prompted && !access(filename.buf, F_OK)) { + if (not_prompted && + ((rev->nr == 0 && confirm_overwrite == CONFIRM_OVERWRITE_COVER) || + confirm_overwrite == CONFIRM_OVERWRITE_ALWAYS) && + !access(filename.buf, F_OK)) { /* * TRANSLATORS: Make sure to include [Y] and [n] in your From patchwork Thu May 6 16:50:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F203FC43460 for ; Thu, 6 May 2021 16:52:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BAB9461090 for ; Thu, 6 May 2021 16:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236114AbhEFQxp (ORCPT ); Thu, 6 May 2021 12:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236113AbhEFQxn (ORCPT ); Thu, 6 May 2021 12:53:43 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B07C061574 for ; Thu, 6 May 2021 09:52:45 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id l13so6337630wru.11 for ; Thu, 06 May 2021 09:52:44 -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=Se6om0d9PxlobWGzikWjFivknQIZP8jT5Pqjb7aF+sY=; b=tgL0T1SB03WeHnPg03Vi4jVuWwhLSSEByjq+TXT9pWOr8tpb6tlNeUmvss5UlxL1l2 jfhVtHKDbgPFKotBnBg88ktBk/VnUmo9T7YGRwISR0SWy9NVcIqDl7PfdZrqL8stWbPe FOdW9QQxElvb++oJxTIcmzmOR/ds9eOwA/c9qI1H5dpmm7KhzUup7L/pWe+CRH1CBGY2 zOkxx9TzaozbjNzp9XezzJURXcFQfHp/b5yD9/8OhCAL96Fz+eymm5CrKlxPy5gUONtE k+Lz7u7CehzGQZjB216OdzCQZLA6LqvcRPj1OOWKG+bwsu5T6XeomuP1zuSsc9uxa6P1 KH+Q== 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=Se6om0d9PxlobWGzikWjFivknQIZP8jT5Pqjb7aF+sY=; b=gY4fgevTgb7OAnxZ2XneLUkzF6FpoJoYU/uRmferz2xwQoSWq6ow1wv3ZQO8mmmU9s pDEX7qWEnCUIfpcHnBuHjq2bjo7jSdwZHFfg5gkbvA/plnEeOK2Upk403+mGtb5IYY6I hPsNyL9Nsn+TiHJTHmk9uVShAJLlunzhIEdN8Ok9VyRxrvnD3x9jYaM6wa9YbUOA9g6R 5QB+rxDxWQciHLQMq3Sk5IcRAfsElns1wf0zSasTscvhEiqyvhxtZX+DxboEik8pM/F8 TEpqAnxWeOB/n0H2OsXDn6CtPJDEs7od7A5crM2BNJTyZxtLK6hK04cIWo8GT1BSAl21 ObCg== X-Gm-Message-State: AOAM530B/D45h8vlSu7R/4vwQersixG3/7F/suJLMhK7PV1Afb9HtMXe 840mqOpSTb7ymv1PdqBwU7c= X-Google-Smtp-Source: ABdhPJzxN9Cbm9PoO/7SWomD5oNYKQ2uoDGp+r9BBKI4RJyjP1E3lEB/3rppbyVfMn3+ASz+VROXKQ== X-Received: by 2002:adf:ed4b:: with SMTP id u11mr6502910wro.293.1620319963815; Thu, 06 May 2021 09:52:43 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:43 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 4/8] format-patch: add the option --confirm-overwrite Date: Thu, 6 May 2021 18:50:58 +0200 Message-Id: <20210506165102.123739-5-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This command line option acts in the same way as the configuration option format.confirmOverwrite. Signed-off-by: Firmin Martin --- builtin/log.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builtin/log.c b/builtin/log.c index ec9848da70..0ce8778338 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1776,6 +1776,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) int quiet = 0; const char *reroll_count = NULL; char *cover_from_description_arg = NULL; + char *confirm_overwrite_arg = NULL; char *branch_name = NULL; char *base_commit = NULL; struct base_tree_info bases; @@ -1818,6 +1819,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) OPT_STRING(0, "cover-from-description", &cover_from_description_arg, N_("cover-from-description-mode"), N_("generate parts of a cover letter based on a branch's description")), + OPT_STRING(0, "confirm-overwrite", &confirm_overwrite_arg, N_("when"), + N_("overwrite cover letter/patches with or without confirmation")), OPT_CALLBACK_F(0, "subject-prefix", &rev, N_("prefix"), N_("use [] instead of [PATCH]"), PARSE_OPT_NONEG, subject_prefix_callback), @@ -1919,6 +1922,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (cover_from_description_arg) cover_from_description_mode = parse_cover_from_description(cover_from_description_arg); + if (confirm_overwrite_arg) + confirm_overwrite = parse_confirm_overwrite(confirm_overwrite_arg); + if (reroll_count) { struct strbuf sprefix = STRBUF_INIT; From patchwork Thu May 6 16:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79839C433ED for ; Thu, 6 May 2021 16:52:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55225613C2 for ; Thu, 6 May 2021 16:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236138AbhEFQxp (ORCPT ); Thu, 6 May 2021 12:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235881AbhEFQxo (ORCPT ); Thu, 6 May 2021 12:53:44 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAFBEC061761 for ; Thu, 6 May 2021 09:52:45 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 82-20020a1c01550000b0290142562ff7c9so3404050wmb.3 for ; Thu, 06 May 2021 09:52:45 -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=DC0BC5oYnVj1FKJXiYqZE7eHen0OEzX70j/8Mne4u+4=; b=LA1BBcxbBHnjcDNWc/bDkEBzrfexuKFwjuAvNxWyFJnKW+F857LLVRhS96pkaURFli sOwINYFhGdCTZWDlk72wI8c1AnIWNMylsOCVj7wDOjuUdDkLptn46AQECzxp9+f9ZgF8 s/4v/UY68MAYGLPh+P2Xl7Xw+1tHlFiZX2ShgyhQMxSXjMq9kuuCK5w4KMzPyddvV0gR DSzG1RuXGLEdXgqUb+DL9J8E/1w7JRsch9Ijn6t1HlMMTKEj6eihuK5ohv2MG27MlLuz k7n90D8ubVYvlGeesHIIiU2wWnnrWnP3Lwmn5OIqdAm9w6zpU4Myup37sMFf11nOSYB4 ibcA== 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=DC0BC5oYnVj1FKJXiYqZE7eHen0OEzX70j/8Mne4u+4=; b=DK04IC67dvvXAfAvtJ9BB8f1iQCRPQxndUGKGXmgkFUQ33jApu6wAwGweeZYd71P/o YcB4vt1Ad+JDYRSj1m3PCj+Ag7sDPqpDEeLHMIeeb1GAu2fM4xP2MeBrx1829f049Mnf tNrL90hCMAfFn7UcWZIvQZEnDcCVFBE7IKtlbac0IhTm9aCC60/aQEUB2DCnKlMttyYR y5Hg1ltFiC5ZW0XysVuLDzPzgn6no9blUc6cF6T9hnazn7insTkLmTc+5WXpQqQZUulL 2JeCvMtYZZALiKER+U0q6ifBH9zVlZ6F3AWin3L001FF08XCdIs0K5qFchpv1qOKXDho YqHA== X-Gm-Message-State: AOAM532R6Uu9dblIY+wK522VSoPRnZ+QX6b6JMm6IrXicXEn/ZUco53P LvTNS0hdOku4gR6k4NefR2w= X-Google-Smtp-Source: ABdhPJy4Q5IdPtXzPAR70Lzxh7SEN1lRaBMCt71xNXgxX7oTL16cJ/T22Nre9uUD3NHkOkjLuaTrlQ== X-Received: by 2002:a1c:a949:: with SMTP id s70mr16561302wme.84.1620319964444; Thu, 06 May 2021 09:52:44 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:44 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 5/8] t4014: test patches overwrite confirmation Date: Thu, 6 May 2021 18:50:59 +0200 Message-Id: <20210506165102.123739-6-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Firmin Martin --- t/t4014-format-patch.sh | 123 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 712d4b5ddf..cf7e48f4de 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -2256,6 +2256,129 @@ test_expect_success 'format-patch --pretty=mboxrd' ' test_cmp expect actual ' +# $1 = git format-patch extra arguments +confirm_overwrite_setup () { + test_when_finished "rm -rf confirm-overwrite" && + git format-patch $1 -o confirm-overwrite main..side && + for patch in confirm-overwrite/*; do echo 'APPENDUM' >>$patch; done +} + +# $1 = format.confirmOverwrite value +# $2 = git format-patch extra arguments +# $3 = git format-patch with prompt (Y/N) or without it +confirm_overwrite_test_body () { + if test ! -z $1; + then + test_config format.confirmOverwrite $1 + fi && + case "$3" in + Y) + echo Y | git format-patch $2 -o confirm-overwrite main..side + ;; + N) + echo N | test_must_fail git format-patch $2 -o confirm-overwrite main..side + ;; + *) + git format-patch $2 -o confirm-overwrite main..side + ;; + esac +} + +# true if all patches are overwritten, false otherwise +confirm_overwrite_all_overwritten () { + for patch in confirm-overwrite/*; do test_i18ngrep ! "^APPENDUM$" $patch; done +} + +test_expect_success 'format-patch overwrite unconditionally patch series without cover letter' ' + confirm_overwrite_setup && + confirm_overwrite_test_body && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch overwrites present cover letter (prompt/Y)' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "" "--cover-letter" "Y" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch does not overwrite present cover letter (prompt/N)' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "" "--cover-letter" "N" && + ! confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --numbered-files overwrites existing cover letter (prompt/Y)' ' + confirm_overwrite_setup "--cover-letter --numbered-files" && + confirm_overwrite_test_body "" "--cover-letter --numbered-files" "Y" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --numbered-files does not overwrite existing cover letter (prompt/N)' ' + confirm_overwrite_setup "--cover-letter --numbered-files" && + confirm_overwrite_test_body "" "--cover-letter --numbered-files" "N" && + ! confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch overwrites existing cover letter (format.confirmOverwrite = never)' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "never" "--cover-letter" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch: the user disagrees to overwrite existing cover letter (format.confirmOverwrite = always)' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "always" "--cover-letter" "N" && + ! confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch: the user agrees to overwrite existing cover letter (format.confirmOverwrite = always)' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "always" "--cover-letter" "Y" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite has higher priority than format.confirmOverwrite' ' + confirm_overwrite_setup && + confirm_overwrite_test_body "always" "--confirm-overwrite never" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite cover: the user agrees to overwrite existing cover letter' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "never" "--cover-letter --confirm-overwrite cover" "Y" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite cover: the user disagrees to overwrite existing cover letter' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "never" "--cover-letter --confirm-overwrite cover" "N" && + ! confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite always: the user agrees to overwrite existing patches' ' + confirm_overwrite_setup && + confirm_overwrite_test_body "never" "--confirm-overwrite always" "Y" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite always: the user disagrees to overwrite existing patches' ' + confirm_overwrite_setup && + confirm_overwrite_test_body "never" "--confirm-overwrite always" "N" && + ! confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite never: overwrite cover letter unconditionally' ' + confirm_overwrite_setup "--cover-letter" && + confirm_overwrite_test_body "always" "--cover-letter --confirm-overwrite never" && + confirm_overwrite_all_overwritten +' + +test_expect_success 'format-patch --confirm-overwrite never: overwrite patches unconditionally' ' + confirm_overwrite_setup && + confirm_overwrite_test_body "always" "--confirm-overwrite never" && + confirm_overwrite_all_overwritten +' + test_expect_success 'interdiff: setup' ' git checkout -b boop main && test_commit fnorp blorp && From patchwork Thu May 6 16:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E2DFC433B4 for ; Thu, 6 May 2021 16:52:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF4F46121F for ; Thu, 6 May 2021 16:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236153AbhEFQxq (ORCPT ); Thu, 6 May 2021 12:53:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236122AbhEFQxo (ORCPT ); Thu, 6 May 2021 12:53:44 -0400 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 636C9C06138B for ; Thu, 6 May 2021 09:52:46 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id s5-20020a7bc0c50000b0290147d0c21c51so3403661wmh.4 for ; Thu, 06 May 2021 09:52:46 -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=x6GvtC21N81eSxYX9fXQ4E4xIU4uGASvgWOykQevpXU=; b=V4oveJgjNMyB/wiPlPX4OMR3Yw9OSsh4uJTH9beDoWwrKLZddjTE5e9MfG2sj9DoRC ftAlN5Mcr9maPwHV1ilTXDPijoZwzfmDGdVkbDKEh5l8v9nj6YtrvGZI7mH5gkyDz2wS 2tMfx9sYDVGGOO2cVYwdF1SeuISom2MO/IY8XF77TDLxJUHi2o92qjgjCCVY65U7l+eH LkcMB9Zp9/ldld1rzE6VxYApOCxdJEwxCdJaupE8xSlPokgduXiE0yn3sWtDDgB4fw54 he7TSXrob0FHSshSc/qjwp34LV4nPzTjQE3PLJaSsCPWxcrYRnPiJg0gOcilMQ/2d35r B68w== 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=x6GvtC21N81eSxYX9fXQ4E4xIU4uGASvgWOykQevpXU=; b=f2/PmVbjF3E4aJ5P+QfwxXMnMJfjRcnRXRrtPn8iBQWGnPR5ilhoS60eRS21UwNERp 0Z9H3yTRB1TCh1J5/WtfgMK3Hse0+MkphcuS1fi3/JzzZY1/U9qea8YGJN/Eo9i0T0y3 nfSLTGdQunw9AZTC6Kl4mEsP8CrFnzpgcW9yvNlCZEQiEsbyT8c+/7Kln3rApHfdBOo/ 8OOdzaUpdAzajGuIO6ylBR9wNE8qU8vyNAE6sU/0Ns8pgouIGwKHmHnzfR3j69Z6ssF3 Sy4jw7/XmvNWVm66nfkhPG2FAyD/FBA4IZLdPH+Qj33tgG2mZTnmr9vu6L7DYcZpw0+I hCsg== X-Gm-Message-State: AOAM530vufpj5dU+6BDyQs/jPIdCwRK4MXrQJAOm9muBdp7JKZJXjcLe WzAvygtOfRBAsQ7ghkocIL0= X-Google-Smtp-Source: ABdhPJxDOxuFfyiPb5JIpThfKZIeBnvb4oIH2d3yiZL/SouSFST9j8U+T9Rfjm/SK/D4iqt/Icagrg== X-Received: by 2002:a1c:ed05:: with SMTP id l5mr16417261wmh.154.1620319965141; Thu, 06 May 2021 09:52:45 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:44 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 6/8] t4014: fix tests overwriting cover letter in silent Date: Thu, 6 May 2021 18:51:00 +0200 Message-Id: <20210506165102.123739-7-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org These tests are broken due to the new configuration option format.confirmOvewrite whose the default value requires confirmation from user whenever an existing cover letter is subject to be overwritten. Also change some pairs of git config and git config --unset to a single test_config. Signed-off-by: Firmin Martin --- t/t4014-format-patch.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index cf7e48f4de..a34598beca 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -669,11 +669,13 @@ test_expect_success 'failure to write cover-letter aborts gracefully' ' ' test_expect_success 'cover-letter inherits diff options' ' + test_when_finished "rm 0000-cover-letter.patch" && git mv file foo && git commit -m foo && git format-patch --no-renames --cover-letter -1 && check_patch 0000-cover-letter.patch && ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch && + rm 0000-cover-letter.patch && git format-patch --cover-letter -1 -M && grep "file => foo .* 0 *\$" 0000-cover-letter.patch ' @@ -1917,10 +1919,9 @@ test_expect_success 'cover letter with nothing' ' test_expect_success 'cover letter auto' ' mkdir -p tmp && - test_when_finished "rm -rf tmp; - git config --unset format.coverletter" && + test_when_finished "rm -rf tmp" && - git config format.coverletter auto && + test_config format.coverletter auto && git format-patch -o tmp -1 >list && test_line_count = 1 list && git format-patch -o tmp -2 >list && @@ -1929,10 +1930,10 @@ test_expect_success 'cover letter auto' ' test_expect_success 'cover letter auto user override' ' mkdir -p tmp && - test_when_finished "rm -rf tmp; - git config --unset format.coverletter" && + test_when_finished "rm -rf tmp" && - git config format.coverletter auto && + test_config format.confirmOverwrite never && + test_config format.coverletter auto && git format-patch -o tmp --cover-letter -1 >list && test_line_count = 2 list && git format-patch -o tmp --cover-letter -2 >list && @@ -2386,6 +2387,7 @@ test_expect_success 'interdiff: setup' ' ' test_expect_success 'interdiff: cover-letter' ' + test_when_finished "rm 0000-cover-letter.patch" && sed "y/q/ /" >expect <<-\EOF && +fleep --q @@ -2398,16 +2400,19 @@ test_expect_success 'interdiff: cover-letter' ' ' test_expect_success 'interdiff: reroll-count' ' + test_when_finished "rm v2-0000-cover-letter.patch" && git format-patch --cover-letter --interdiff=boop~2 -v2 -1 boop && test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch ' test_expect_success 'interdiff: reroll-count with a non-integer' ' + test_when_finished "rm v2.2-0000-cover-letter.patch" && git format-patch --cover-letter --interdiff=boop~2 -v2.2 -1 boop && test_i18ngrep "^Interdiff:$" v2.2-0000-cover-letter.patch ' test_expect_success 'interdiff: reroll-count with a integer' ' + test_when_finished "rm v2-0000-cover-letter.patch" && git format-patch --cover-letter --interdiff=boop~2 -v2 -1 boop && test_i18ngrep "^Interdiff ..* v1:$" v2-0000-cover-letter.patch ' From patchwork Thu May 6 16:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 495EBC433ED for ; Thu, 6 May 2021 16:52:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 173EC61090 for ; Thu, 6 May 2021 16:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236151AbhEFQxr (ORCPT ); Thu, 6 May 2021 12:53:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236120AbhEFQxp (ORCPT ); Thu, 6 May 2021 12:53:45 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 296AEC061761 for ; Thu, 6 May 2021 09:52:47 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso5660250wmh.4 for ; Thu, 06 May 2021 09:52:47 -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=7Zi+hq8aiYbnsFSQijylzQu3r5I5OBBYzjBOxosnP4s=; b=qknpvUV02w3jat7KPJxAdu2TmTxho011hGVLJ3tBbCE8TB4wFPz3pXDFeyL719m4rp pDCdnGFRWWSBLC0z1ihWcbA/Q6yB13OgmVYjnYBOhtO/keF9WlPe5qNqDZOUVtVF/oOm rJDiLbFgCRGnYSFKd4Fqo7qAxVlX4h0IbzjWl8roPPTFGGjmhQSZs1t2drXd6xMWPeoz 0Pbl+0dETzQ+uNwlg/UjCrLvETwoo9IcZJEKea5Ncpn0sdJZKUZaRy7t9KYmeg7Ewwt9 b0omtCibAEpi/zLNr4KOvpqSZ0wFDmqWyRXJybEcH/MVFFeZG+xyGqqSKAlvt3QUCEFB 2+kw== 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=7Zi+hq8aiYbnsFSQijylzQu3r5I5OBBYzjBOxosnP4s=; b=O3GUT+CVc2bNSTzokkAMqSgtgWngi+xDVcbGm2PfBA9KpK2Uub1dvo+tOn5Ze5uXP0 z0JJm1/NXBR3BeiC88Gjej8KLm3RdJajNFX3KlWhKq70hFK7+tCU4Wfd6kEUpea1L2sB XddLFctXKdaifX/oVaCB8Lfbdu71Uv0uOVVYoe+TBf1AJ+KqvcEGjYGD0J1xWAwFFkLa unAmVMMv3tZMHl8jaMDwzjxk+WznftHMq8GlPc3sk5mQk8+ozdotUaOv5nuLXV59bw4q Tu5fOrWFhR/boMBB08blJlcvBV+py42QPYBddEL0J2ZN6p2uev05ITOyrhaSavLKM7Qx AmvQ== X-Gm-Message-State: AOAM531f4bN8TpNmDK9+PEpO24O/46xkxDhe0cG8wVcILVdZ/1q3NA8K PAao0UzD5BRHdaOkuOy71KA= X-Google-Smtp-Source: ABdhPJwNXBkFeZCCgTQif0PnUb9XsnL7vV6EM06d/Nm51R6H+ERQ2zmtfSMeJ3KAiMA3LgPccb45yg== X-Received: by 2002:a05:600c:4998:: with SMTP id h24mr16218682wmp.10.1620319965831; Thu, 06 May 2021 09:52:45 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:45 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 7/8] doc/format-patch: describe --confirm-overwrite Date: Thu, 6 May 2021 18:51:01 +0200 Message-Id: <20210506165102.123739-8-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Firmin Martin --- Documentation/git-format-patch.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 911da181a1..49f08b5e51 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -20,6 +20,7 @@ SYNOPSIS [--in-reply-to=] [--suffix=.] [--ignore-if-in-upstream] [--cover-from-description=] + [--confirm-overwrite=] [--rfc] [--subject-prefix=] [(--reroll-count|-v) ] [--to=] [--cc=] @@ -195,6 +196,7 @@ will want to ensure that threading is disabled for `git send-email`. --cover-from-description=:: Controls which parts of the cover letter will be automatically populated using the branch's description. + + If `` is `message` or `default`, the cover letter subject will be populated with placeholder text. The body of the cover letter will be @@ -212,6 +214,23 @@ is greater than 100 bytes, then the mode will be `message`, otherwise If `` is `none`, both the cover letter subject and body will be populated with placeholder text. +`--confirm-overwrite`=:: + Specifies when Git must ask the user to confirm whether existing + patches or cover letter of the same name should be overwritten. + possible values are: ++ +-- +always;; +never;; + Always/never prompt for confirmation whenever patches or a cover letter + are subject to be overwritten. +cover;; + Ask confirmation whenever a cover letter is subject to be overwritten. +-- ++ +Defaults to the value of the `format.confirmOverwrite` variable, or +"cover" if unconfigured. + --subject-prefix=:: Instead of the standard '[PATCH]' prefix in the subject line, instead use '[]'. This @@ -409,6 +428,7 @@ with configuration variables. outputDirectory = coverLetter = auto coverFromDescription = auto + confirmOverwrite = onlyCover ------------ From patchwork Thu May 6 16:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Firmin Martin X-Patchwork-Id: 12242773 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BDE3C433B4 for ; Thu, 6 May 2021 16:52:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FCC661090 for ; Thu, 6 May 2021 16:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236120AbhEFQxv (ORCPT ); Thu, 6 May 2021 12:53:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236161AbhEFQxr (ORCPT ); Thu, 6 May 2021 12:53:47 -0400 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 B4435C061574 for ; Thu, 6 May 2021 09:52:47 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id b19-20020a05600c06d3b029014258a636e8so3413444wmn.2 for ; Thu, 06 May 2021 09:52:47 -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=Co0d1CBaNMlWOAx/tnA6iPj7GRwGq4paSIRmxwG10ec=; b=Xyr7Y83JLcXZiH5Oh4nRXfi2SDbdfbrs+Wp4okJcU01iuI0Db7CBd99VxkHxMbXeTS biztFksxtKz7vdQDaDNbqCJUOdX/pGgJuGHWmZuH2JR61hkKR7PMj8+dXfqhGS49W/GR Uycn1U/7hou0BHe0rk5K2tvk0in4em2MmZ5rPD+0WBqE3RKRWx4b3bJDmuti2EAO9c1Q mjeRn/6u3IK3NcPN9pv5LBcsVvx9GQeryG5kXxYno+3/Xj8ED47dAm3L65zS+R6flzHU e1ZGbB9bFzYrt+pv+KKrPuO3SDMbJRFAdF9xGA9jKTwEZ/8Ax43A9tEbRd4NDXmWlfJ1 a8Xw== 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=Co0d1CBaNMlWOAx/tnA6iPj7GRwGq4paSIRmxwG10ec=; b=YL4Op9ZCYQIOO/wyfOAR5PEnPTwE7l0nvHa3s8bfjH1+dW5n/kgvu0ozUjTiqwHl8f j1nhNcTzuee3nlwn3Hdm8EPyuPcT/i5GMx6o5DS+0TEAgd6xFArOXqNa96EnV1otfGDe N2hdsv3BdKUuLkKPzSIme4f6/C/Qrz5ibX1X6tsLK0n/MCJEIo5h/Oy3+MiyrpsP5FkY hcBQHTNGpKOCZA01+FOe9Dqr+tT9IRKLWHwni+p+toG6Vuzvgb8CB/9aGSypT2c4ILbd d7nO05t1b1T2m4Ab8mfLuN0XfoXS/47jJAk9KR7jLHzusA+qVH4vXNEonqjxhLQfkySi 6Y1A== X-Gm-Message-State: AOAM531AXhBbM4wdQ2gsiUIZkSOQAsTlpY/5a5MUBXYZZXzTViAwg7WT yU5E9/DM6uO4xQG970DoxII= X-Google-Smtp-Source: ABdhPJwKqwqh+gxqN98t61QoC6WsxEagsEV9jqpyq+zpkRUvLVvKouzj7Eh3LwgaO3cjN98tW+lsCw== X-Received: by 2002:a05:600c:4f49:: with SMTP id m9mr11487619wmq.78.1620319966533; Thu, 06 May 2021 09:52:46 -0700 (PDT) Received: from Inspiron.home (2a01cb04010c42006d71140a7638f172.ipv6.abo.wanadoo.fr. [2a01:cb04:10c:4200:6d71:140a:7638:f172]) by smtp.gmail.com with ESMTPSA id y14sm5354482wrr.82.2021.05.06.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 09:52:46 -0700 (PDT) From: Firmin Martin To: Firmin Martin , git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Erik Faye-Lund , Denton Liu Subject: [PATCH v1 8/8] config/format: describe format.confirmOverwrite Date: Thu, 6 May 2021 18:51:02 +0200 Message-Id: <20210506165102.123739-9-firminmartin24@gmail.com> X-Mailer: git-send-email 2.31.1.450.g14fbf8793d In-Reply-To: <20210506165102.123739-1-firminmartin24@gmail.com> References: <20210506165102.123739-1-firminmartin24@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Firmin Martin --- Documentation/config/format.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt index fdbc06a4d2..bc189e3ec8 100644 --- a/Documentation/config/format.txt +++ b/Documentation/config/format.txt @@ -42,6 +42,11 @@ format.coverFromDescription:: description. See the `--cover-from-description` option in linkgit:git-format-patch[1]. +format.confirmOverwrite:: + Determines when the user must be prompted for confirmation whenever a + cover letter or a patch is subject to be overwritten. See the + `--confirm-overwrite` option in linkgit:git-format-patch[1]. + format.signature:: The default for format-patch is to output a signature containing the Git version number. Use this variable to change that default.