From patchwork Sun Feb 18 07:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson X-Patchwork-Id: 13561714 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 217A5CA78 for ; Sun, 18 Feb 2024 07:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241618; cv=none; b=GE95Syp+CTLrEBjWE39JGvqMbmPtES16wRrqjJ8os9eMqV3Au+oU2lmY/POdcgfgIWRPNBmq7pnloFyZVx3UVicJGTsx5IwqtUumKWSGDu7XPFCBHikfQkHDmwggRE6TuQnA6oz0KgTaaHV7xFL2tmz3EFMu8m4L8/aECPMaFMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241618; c=relaxed/simple; bh=WmRXm0pyTve36e6rjfLfHzYUICBZ2BLp7os0+yR3V/M=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=eBJLWk86DlK4U2mRfkK9Qotv7PkvrYjPO1I2JGdhL0Z7kn9RgrW/YHc5o1fhL853bPiYMDEHR6yIV4AYNR55AyVcfqHFfjXNCNdz5iALIIWjhJw1oHqJC0Ybn/DJbYhLzA2gadSQl3PfuuKPPmKqhF99dRnxHNUbOgfipk03BFA= 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=BZXwRi8/; arc=none smtp.client-ip=209.85.128.50 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="BZXwRi8/" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4125df90568so5642765e9.3 for ; Sat, 17 Feb 2024 23:33:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708241614; x=1708846414; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=W2NJS1iYua1VoPGj2sUOPIRhK5uD2Oq+lB71D0E+IZg=; b=BZXwRi8/PuihmVrkoFMyNhvGrA8h4/taZWUsoqoyjJLicPuGpTPiHdD2FZgZx33sw+ nysqk2aSqWk/cMwWd3sXE5xh3IU36O5TPpj3MpEN7kjhUtsvTSphJXKBN39jyD4vw3bt BNmCPwaY8uoBriJkuezewzYwd1DVZsSuQOgEafFTOnrl2u7W9HkYWNDNDhcuurzOnirN FEl9oaztsyZ8lUY1jX+HndOA8adbk9MG9JcktVgiBzYBl/AR6xiphHbVYcDmNojXhhjG a2bVI9wifIvIW8uJZRnrjA2l3f6fxdm0/vSdCK8qBVNmicHrawbCaIb7ZjXYdEI1WjgI arjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708241614; x=1708846414; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2NJS1iYua1VoPGj2sUOPIRhK5uD2Oq+lB71D0E+IZg=; b=aTJxbiEvGJbV2S/pMBh9zQxs3zaCGFNU5SzqLcpCq2s+fi8iorm/FawPSXyy9hXp7l gb9EWi0ZIh66v0a6Ze+NtlcMLmbyPXAyI812PMZJTsP8GdTgyUozsLu+scM6OEck+lnE ev+EIehdHZVXPYzeDbjyzICMdD8i56Hkh54Y91Hdw23U+M0bGwNdgNyM2c2xaBo6/Miq 3qLftu/4VG1r+kqwF2NAVnBmImRL9g+y1hecWJzHzS7SQwZRAGHfZAcqH69UXKh5qhvw IEPIwr+m+LzfKw5asV7p/ICagMMZDOGOEZriAXxtu4oL1sd197qXz3GqqokvxuAApHKP pxTA== X-Gm-Message-State: AOJu0Yy++/mT8mvNuCpp+nxnnCNOJPU88c0bdnfWQOsCw2p1POxVB5yr pQN28yOzZwWvY1eU+G1jeVbCWlsH9ptDN8pY3c/u5/oT9jpfkyC0YncV9FQ8 X-Google-Smtp-Source: AGHT+IFiwzg89qEFTqGGarvnsTXZYhvY+A4DS0i4BMeXWT9tp2aGRSb90i2Fs+W4AiGtbdtIHNafmA== X-Received: by 2002:a5d:49cc:0:b0:33d:827:145d with SMTP id t12-20020a5d49cc000000b0033d0827145dmr5346009wrs.42.1708241614530; Sat, 17 Feb 2024 23:33:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b7-20020adfe647000000b0033b406bc689sm6789072wrn.75.2024.02.17.23.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:33:34 -0800 (PST) Message-ID: In-Reply-To: References: Date: Sun, 18 Feb 2024 07:33:28 +0000 Subject: [PATCH 1/5] promise: add promise pattern to track success/error from operations Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Emily Shaffer , Philip Peterson , Philip Peterson From: Philip Peterson From: Philip Peterson Introduce a promise paradigm. A promise starts off in the pending state, and represents an asynchronous (or synchronous) action that will eventually end in either a successful result or a failure result. If a failure result, an error message may be provided. This allows us to represent tasks which may fail, while deferring any control flow actions or error printing that may occur in relation to said task. Signed-off-by: Philip Peterson --- Makefile | 1 + promise.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ promise.h | 71 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 promise.c create mode 100644 promise.h diff --git a/Makefile b/Makefile index 78e874099d9..4851eb2d822 100644 --- a/Makefile +++ b/Makefile @@ -1109,6 +1109,7 @@ LIB_OBJS += preload-index.o LIB_OBJS += pretty.o LIB_OBJS += prio-queue.o LIB_OBJS += progress.o +LIB_OBJS += promise.o LIB_OBJS += promisor-remote.o LIB_OBJS += prompt.o LIB_OBJS += protocol.o diff --git a/promise.c b/promise.c new file mode 100644 index 00000000000..58ed8b67880 --- /dev/null +++ b/promise.c @@ -0,0 +1,89 @@ +/* + * Generic implementation of callbacks with await checking. + */ +#include "promise.h" + +void promise_assert_finished(struct promise_t *p) { + if (p->state == PROMISE_UNRESOLVED) { + BUG("expected promise to have been resolved/rejected"); + } +} + +void promise_assert_failure(struct promise_t *p) { + if (p->state != PROMISE_FAILURE) { + BUG("expected promise to have been rejected"); + } +} + +void promise_resolve(struct promise_t *p, int status) { + if (p->state != PROMISE_UNRESOLVED) { + BUG("promise was already resolved/rejected"); + return; + } + p->result.success_result = status; + p->state = PROMISE_SUCCESS; +} + +void promise_reject(struct promise_t *p, int status, const char* fmt, ...) { + va_list args; + if (p->state != PROMISE_UNRESOLVED) { + BUG("promise was already resolved/rejected"); + return; + } + p->result.failure_result.status = status; + + strbuf_init(&p->result.failure_result.message, 0); + + va_start(args, fmt); + strbuf_vaddf(&p->result.failure_result.message, fmt, args); + va_end(args); + + p->state = PROMISE_FAILURE; +} + +struct promise_t *promise_init(void) { + // Promises are allocated on the heap, because they represent potentially long-running tasks, + // and a stack-allocated value might not live long enough. + struct promise_t *new_promise = xmalloc(sizeof(struct promise_t)); + struct failure_result_t failure_result; + + new_promise->state = PROMISE_UNRESOLVED; + failure_result.status = 0; + new_promise->result.failure_result = failure_result; + + return new_promise; +} + +/** + * Outputs an error message and size from a failed promise. The error message must be + * free()'ed by the caller. Calling this function is not allowed if the promise is not + * failed. + * + * Argument `size` may be omitted by passing in NULL. + * + * Note that although *error_message is null-terminated, its size may be larger + * than the terminated string, and its actual size is indicated by *size. + */ +void promise_copy_error(struct promise_t *p, char **error_message, size_t *size) { + size_t local_size; + promise_assert_failure(p); + + *error_message = strbuf_detach(&p->result.failure_result.message, &local_size); + if (size) { + *size = local_size; + } + + // We are only doing a copy, not a consume, so we need to put the error message back + // the way we found it. + strbuf_add(&p->result.failure_result.message, *error_message, strlen(*error_message)); +} + +/** + * Fully deallocates the promise as well as the error message, if any. + */ +void promise_release(struct promise_t *p) { + if (p->state == PROMISE_FAILURE) { + strbuf_release(&p->result.failure_result.message); + } + free(p); +} diff --git a/promise.h b/promise.h new file mode 100644 index 00000000000..c5500eba986 --- /dev/null +++ b/promise.h @@ -0,0 +1,71 @@ +#ifndef PROMISE_H +#define PROMISE_H + +#include "git-compat-util.h" +#include "strbuf.h" + +enum promise_state { + PROMISE_UNRESOLVED = 0, + PROMISE_SUCCESS = 1, + PROMISE_FAILURE = 2, +}; + +typedef int success_result_t; + +struct failure_result_t { + int status; + struct strbuf message; +}; + +struct promise_t { + enum promise_state state; + union { + success_result_t success_result; + struct failure_result_t failure_result; + } result; +}; + +// Function to assert that a promise has been resolved +void promise_assert_finished(struct promise_t *p); + +// Function to assert that a promise has been rejected +void promise_assert_failure(struct promise_t *p); + +// Function to resolve a promise with a success result +void promise_resolve(struct promise_t *p, int status); + +// Function to reject a promise with a failure result and an optional formatted error message +void promise_reject(struct promise_t *p, int status, const char* fmt, ...); + +// Function to create a new promise +struct promise_t *promise_init(void); + +// Copies the error out of a failed promise +void promise_copy_error(struct promise_t *promise, char **error_message, size_t *size); + +// Fully deallocates the promise +void promise_release(struct promise_t *promise); + +#define PROMISE_SUCCEED(p, errcode) do { \ + promise_resolve(p, errcode); \ + return; \ +} while (0) + +#define PROMISE_THROW(p, errcode, ...) do { \ + promise_reject(p, errcode, __VA_ARGS__); \ + return; \ +} while (0) + +#define PROMISE_BUBBLE_UP(dst, src, ...) do { \ + if (strlen(src->result.failure_result.message.buf) != 0) { \ + strbuf_insertf(&src->result.failure_result.message, 0, "\n\t"); \ + strbuf_insertf(&src->result.failure_result.message, 0, _("caused by:")); \ + strbuf_insertf(&src->result.failure_result.message, 0, "\n"); \ + strbuf_insertf(&src->result.failure_result.message, 0, __VA_ARGS__); \ + } \ + promise_reject(dst, src->result.failure_result.status, "%s", src->result.failure_result.message.buf); \ + promise_release(src); \ + return; \ +} while (0) + +#endif From patchwork Sun Feb 18 07:33:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson X-Patchwork-Id: 13561716 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 45E27E572 for ; Sun, 18 Feb 2024 07:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; cv=none; b=snVWSBgEOJsp5OgXezC7Z3Csz3VvjvSQFx5cO1SZenDuZTxRBSdkn9rfBsWSQEbZ/264LeCJTud2p5yTGMNFvyjEEP2cyPyeTmdOJBIYKu5ixNXDkhcBMM8oiz+Rp3iSXv/kwP+Db6l1Zk7qzxf0IrzaS07iwesxgcoi2lfIw18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; c=relaxed/simple; bh=nGX6vLPfqqm0vBIu2q8/Js0XqrRFaQ/OGBKm9bc2DOE=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=Yszou2DqPBpcjmXdAsRbtoqtXatNtX8EENLZ8w4xHowf9jhjA6uF8VrgBWYfpdRbP479GuPkYg8DNRPrLGMMh3xw18DZ9dVXBTo8fim/sO8P7pnSeryqDyEQrVkb41e6QTWq5pLj2i5lxo6TJbhF54H488AFhL67j/ZDFltBpXA= 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=lJR00Zr3; arc=none smtp.client-ip=209.85.208.182 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="lJR00Zr3" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d0a4e1789cso39164091fa.3 for ; Sat, 17 Feb 2024 23:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708241617; x=1708846417; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=yEEz+vKVRLG46q9uHuS4oE7thy/XFbz/wG1i3jVoL6s=; b=lJR00Zr3Xs3Vhm6NEPiMiZIHtrIsyTGMrLU1MAngdnScCpEVODDq/pognRk+vktT3U XJEOZ0Rlu/7lMKxCCNpN3zsVBfl1/OoPD3OiNi9YV8bYMl6sygaoQQLH47WUEJlol/Q2 f29RdHj2UNidiWUYBMW7BecWoineKooSEOOZ0L1hgOsPJHKci4kujopvenEv1GiUTRnd RoYU4dzVVttNSE4ADlWJTIdUJ+ynDPqRRR4XS9CQtvy6AzXLS0gjCBrbZ77vx7fgiW0r dcHqQjjnXd5Z6EpaQoxIqXeNXPwlR/hsAzCq6hVJk/9vIX6gr1JdkLJkTq3yqc0SJrze yW0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708241617; x=1708846417; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yEEz+vKVRLG46q9uHuS4oE7thy/XFbz/wG1i3jVoL6s=; b=gtAbW2GSUvQLehniRuoXFsN0AzEySRdFeqSjXWE2yMdUZkwV89XEsnfcPjMpPZJBUs curtgEcn4jgApgWcgGBDgM2tRxQGClynCd3qwBelkHyMmOpOInN7+sLRJ7NsZa/1m/gS ynmz4RxokhwakEozJeSwt8MIgirlf9o9ogM7OIq3i58T4IoxPGJbyY2RhpUJIhHXK91Z 4sJ0g6ELqd3wWabLOiW2pUoDSs0h9i+yPKiu/CJWmWiXBcajiCzLEzki/b+KsTea6MyZ 0hwyGm+1JLkiiG7MFw16Dk2CkxmT/8Dz08v2l4zU59Q/ndISbKWQ5rGrzb8Ii9RiebIs riXg== X-Gm-Message-State: AOJu0YwVgPF694fv27hLOf5s4Y6WdZpcKBO3wPb3l+rmxPcD6Rt6ph4a XYzOIIw1R/kbu7YbbW9WW6wpgzk6sLYjnOGZ9ffKlALUgdgnHnDklfgRvncr X-Google-Smtp-Source: AGHT+IEDtYlwQzaSxdVN0hd5iHL7/jhSpI/c109/bKbr6Cun+KCIMmPDv/7mVekn4lCF3J7arNGKVg== X-Received: by 2002:a2e:9b51:0:b0:2d0:ab90:adbc with SMTP id o17-20020a2e9b51000000b002d0ab90adbcmr5887657ljj.28.1708241616483; Sat, 17 Feb 2024 23:33:36 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id jj9-20020a05600c6a0900b0040fb44a9288sm7220834wmb.48.2024.02.17.23.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:33:34 -0800 (PST) Message-ID: <677da78652c58f6d0e147638b7b2313dffb0d858.1708241613.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 18 Feb 2024 07:33:29 +0000 Subject: [PATCH 2/5] apply: use new promise structures in git-apply logic as a proving ground Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Emily Shaffer , Philip Peterson , Philip Peterson From: Philip Peterson From: Philip Peterson Uses the new promise paradigm in a simple example with git apply and git am. Several operations that may produce errors are encapsulated in a promise, so that any errors may be captured and handled according to how the caller wants to do so. As an added bonus, we can see more context in error messages now, for example: % git apply -3 garbage.patch error: could not find header caused by: no lines to read Signed-off-by: Philip Peterson --- apply.c | 133 +++++++++++++++++++++++++++++++++------------------ apply.h | 9 +++- range-diff.c | 14 ++++-- 3 files changed, 103 insertions(+), 53 deletions(-) diff --git a/apply.c b/apply.c index 7608e3301ca..fb6b7074c19 100644 --- a/apply.c +++ b/apply.c @@ -26,6 +26,7 @@ #include "object-file.h" #include "parse-options.h" #include "path.h" +#include "promise.h" #include "quote.h" #include "read-cache.h" #include "rerere.h" @@ -1316,13 +1317,14 @@ static int check_header_line(int linenr, struct patch *patch) return 0; } -int parse_git_diff_header(struct strbuf *root, +void parse_git_diff_header(struct strbuf *root, int *linenr, int p_value, const char *line, int len, unsigned int size, - struct patch *patch) + struct patch *patch, + struct promise_t* return_promise) { unsigned long offset; struct gitdiff_data parse_hdr_state; @@ -1386,10 +1388,12 @@ int parse_git_diff_header(struct strbuf *root, if (len < oplen || memcmp(p->str, line, oplen)) continue; res = p->fn(&parse_hdr_state, line + oplen, patch); - if (res < 0) - return -1; - if (check_header_line(*linenr, patch)) - return -1; + if (res < 0) { + PROMISE_THROW(return_promise, APPLY_ERR_GENERIC, "operation for \"%s\" failed with code: %d", p->str, res); + } + if (check_header_line(*linenr, patch)) { + PROMISE_THROW(return_promise, APPLY_ERR_GENERIC, "invalid header lines"); + } if (res > 0) goto done; break; @@ -1399,25 +1403,25 @@ int parse_git_diff_header(struct strbuf *root, done: if (!patch->old_name && !patch->new_name) { if (!patch->def_name) { - error(Q_("git diff header lacks filename information when removing " - "%d leading pathname component (line %d)", - "git diff header lacks filename information when removing " - "%d leading pathname components (line %d)", - parse_hdr_state.p_value), - parse_hdr_state.p_value, *linenr); - return -128; + PROMISE_THROW(return_promise, -128, + Q_("git diff header lacks filename information when removing " + "%d leading pathname component (line %d)", + "git diff header lacks filename information when removing " + "%d leading pathname components (line %d)", + parse_hdr_state.p_value), + parse_hdr_state.p_value, *linenr + ); } patch->old_name = xstrdup(patch->def_name); patch->new_name = xstrdup(patch->def_name); } if ((!patch->new_name && !patch->is_delete) || (!patch->old_name && !patch->is_new)) { - error(_("git diff header lacks filename information " + PROMISE_THROW(return_promise, -128, _("git diff header lacks filename information " "(line %d)"), *linenr); - return -128; } patch->is_toplevel_relative = 1; - return offset; + PROMISE_SUCCEED(return_promise, offset); } static int parse_num(const char *line, unsigned long *p) @@ -1539,16 +1543,17 @@ static int parse_fragment_header(const char *line, int len, struct fragment *fra /* * Find file diff header * - * Returns: + * Resolves promise with: * -1 if no header was found * -128 in case of error * the size of the header in bytes (called "offset") otherwise */ -static int find_header(struct apply_state *state, +static void find_header(struct apply_state *state, const char *line, unsigned long size, int *hdrsize, - struct patch *patch) + struct patch *patch, + struct promise_t* return_promise) { unsigned long offset, len; @@ -1577,9 +1582,8 @@ static int find_header(struct apply_state *state, struct fragment dummy; if (parse_fragment_header(line, len, &dummy) < 0) continue; - error(_("patch fragment without header at line %d: %.*s"), + PROMISE_THROW(return_promise, -128, _("patch fragment without header at line %d: %.*s"), state->linenr, (int)len-1, line); - return -128; } if (size < len + 6) @@ -1590,15 +1594,25 @@ static int find_header(struct apply_state *state, * or mode change, so we handle that specially */ if (!memcmp("diff --git ", line, 11)) { - int git_hdr_len = parse_git_diff_header(&state->root, &state->linenr, + int git_hdr_len; + struct promise_t *parse_git_diff_header_promise = promise_init(); + parse_git_diff_header(&state->root, &state->linenr, state->p_value, line, len, - size, patch); - if (git_hdr_len < 0) - return -128; + size, patch, parse_git_diff_header_promise); + promise_assert_finished(parse_git_diff_header_promise); + + if (parse_git_diff_header_promise->state == PROMISE_FAILURE) { + PROMISE_BUBBLE_UP(return_promise, parse_git_diff_header_promise, + _("could not find file diff header")); + } + + git_hdr_len = parse_git_diff_header_promise->result.success_result; + promise_release(parse_git_diff_header_promise); if (git_hdr_len <= len) continue; *hdrsize = git_hdr_len; - return offset; + PROMISE_SUCCEED(return_promise, offset); + return; } /* --- followed by +++ ? */ @@ -1615,13 +1629,14 @@ static int find_header(struct apply_state *state, continue; /* Ok, we'll consider it a patch */ - if (parse_traditional_patch(state, line, line+len, patch)) - return -128; + if (parse_traditional_patch(state, line, line+len, patch)) { + PROMISE_THROW(return_promise, -128, "could not parse traditional patch"); + } *hdrsize = len + nextlen; state->linenr += 2; - return offset; + PROMISE_SUCCEED(return_promise, offset); } - return -1; + PROMISE_THROW(return_promise, APPLY_ERR_GENERIC, "no lines to read"); } static void record_ws_error(struct apply_state *state, @@ -2129,19 +2144,29 @@ static int use_patch(struct apply_state *state, struct patch *p) * reading after seeing a single patch (i.e. changes to a single file). * Create fragments (i.e. patch hunks) and hang them to the given patch. * - * Returns: + * Resolves promise with: * -1 if no header was found or parse_binary() failed, * -128 on another error, * the number of bytes consumed otherwise, * so that the caller can call us again for the next patch. */ -static int parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch) +static void parse_chunk(struct apply_state *state, char *buffer, unsigned long size, struct patch *patch, struct promise_t* return_promise) { - int hdrsize, patchsize; - int offset = find_header(state, buffer, size, &hdrsize, patch); + int hdrsize = -1, patchsize, offset; + struct promise_t *find_header_promise = promise_init(); + find_header(state, buffer, size, &hdrsize, patch, find_header_promise); + promise_assert_finished(find_header_promise); - if (offset < 0) - return offset; + if (find_header_promise->state == PROMISE_FAILURE) { + PROMISE_BUBBLE_UP(return_promise, find_header_promise, _("could not find header")); + } + + offset = find_header_promise->result.success_result; + promise_release(find_header_promise); + + if (offset < 0) { + PROMISE_SUCCEED(return_promise, offset); + } prefix_patch(state, patch); @@ -2159,8 +2184,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si size - offset - hdrsize, patch); - if (patchsize < 0) - return -128; + if (patchsize < 0) { + PROMISE_THROW(return_promise, -128, _("could not parse patch")); + } if (!patchsize) { static const char git_binary[] = "GIT binary patch\n"; @@ -2173,8 +2199,9 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si state->linenr++; used = parse_binary(state, buffer + hd + llen, size - hd - llen, patch); - if (used < 0) - return -1; + if (used < 0) { + PROMISE_THROW(return_promise, -1, _("could not parse binary patch")); + } if (used) patchsize = used + llen; else @@ -2205,12 +2232,11 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si */ if ((state->apply || state->check) && (!patch->is_binary && !metadata_changes(patch))) { - error(_("patch with only garbage at line %d"), state->linenr); - return -128; + PROMISE_THROW(return_promise, -128, _("patch with only garbage at line %d"), state->linenr); } } - return offset + hdrsize + patchsize; + PROMISE_SUCCEED(return_promise, offset + hdrsize + patchsize); } static void reverse_patches(struct patch *p) @@ -4755,21 +4781,36 @@ static int apply_patch(struct apply_state *state, return -128; offset = 0; while (offset < buf.len) { - struct patch *patch; int nr; + struct patch *patch; + struct promise_t *parse_chunk_promise; CALLOC_ARRAY(patch, 1); patch->inaccurate_eof = !!(options & APPLY_OPT_INACCURATE_EOF); patch->recount = !!(options & APPLY_OPT_RECOUNT); - nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch); - if (nr < 0) { + + parse_chunk_promise = promise_init(); + parse_chunk(state, buf.buf + offset, buf.len - offset, patch, parse_chunk_promise); + + promise_assert_finished(parse_chunk_promise); + + if (parse_chunk_promise->state == PROMISE_FAILURE) { + int nr; + nr = parse_chunk_promise->result.failure_result.status; free_patch(patch); if (nr == -128) { + error("\n\t%s", parse_chunk_promise->result.failure_result.message.buf); + promise_release(parse_chunk_promise); res = -128; goto end; } + promise_release(parse_chunk_promise); break; } + + nr = parse_chunk_promise->result.success_result; + promise_release(parse_chunk_promise); + if (state->apply_in_reverse) reverse_patches(patch); if (use_patch(state, patch)) { diff --git a/apply.h b/apply.h index 7cd38b1443c..44af75883c5 100644 --- a/apply.h +++ b/apply.h @@ -5,6 +5,10 @@ #include "lockfile.h" #include "string-list.h" #include "strmap.h" +#include "promise.h" + +/* Error codes (must be less than 0) */ +#define APPLY_ERR_GENERIC -1 struct repository; @@ -165,13 +169,14 @@ int check_apply_state(struct apply_state *state, int force_apply); * * Returns -1 on failure, the length of the parsed header otherwise. */ -int parse_git_diff_header(struct strbuf *root, +void parse_git_diff_header(struct strbuf *root, int *linenr, int p_value, const char *line, int len, unsigned int size, - struct patch *patch); + struct patch *patch, + struct promise_t *promise); void release_patch(struct patch *patch); diff --git a/range-diff.c b/range-diff.c index c45b6d849cb..3ef8b976a0c 100644 --- a/range-diff.c +++ b/range-diff.c @@ -121,8 +121,8 @@ static int read_patches(const char *range, struct string_list *list, if (starts_with(line, "diff --git")) { struct patch patch = { 0 }; struct strbuf root = STRBUF_INIT; + struct promise_t *parse_git_diff_header_promise = promise_init(); int linenr = 0; - int orig_len; in_header = 0; strbuf_addch(&buf, '\n'); @@ -130,16 +130,20 @@ static int read_patches(const char *range, struct string_list *list, util->diff_offset = buf.len; if (eol) *eol = '\n'; - orig_len = len; - len = parse_git_diff_header(&root, &linenr, 0, line, - len, size, &patch); - if (len < 0) { + parse_git_diff_header(&root, &linenr, 0, line, + len, size, &patch, parse_git_diff_header_promise); + promise_assert_finished(parse_git_diff_header_promise); + if (parse_git_diff_header_promise->state == PROMISE_FAILURE) { + int orig_len = len; error(_("could not parse git header '%.*s'"), orig_len, line); FREE_AND_NULL(util); string_list_clear(list, 1); + promise_release(parse_git_diff_header_promise); goto cleanup; } + len = parse_git_diff_header_promise->result.success_result; + promise_release(parse_git_diff_header_promise); strbuf_addstr(&buf, " ## "); if (patch.is_new > 0) strbuf_addf(&buf, "%s (new)", patch.new_name); From patchwork Sun Feb 18 07:33:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson X-Patchwork-Id: 13561715 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 914B9EAD5 for ; Sun, 18 Feb 2024 07:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; cv=none; b=XGZpmNBWvfgHls5OEzy+oer+6Xd5SMrNjdloXklxNwqNQQmcSpw4RbRXon/Bfp756lkh+yGosYsDE7hQkj6sabFge6B9by8I7MKH4ZT3/wj6yQHvsmzIvqPsNh87gAUtGQAMJgvtxztZQlYKMDKML2ua+Llvdh+Ev1gPdLXvKlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; c=relaxed/simple; bh=8ujX+kVsm9jjU572xg5y5/pxb+955Wd1weWAEMPR984=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=AISvvCcnrE3Td9CRgJ0vV6Yg+5pP0YErfqCdMQzFP8tems2+W8IW/dg/w16dc/dm8Mz8GSvmvHeoHNyk8WuqwRyyS1rNTKezILtaZS2J94Pf7JUeK0OKIhcM0EThGfVzKl9RzWpbHXNvb1jQoOlDJqRlEP2lYQWN0jTT7ijCoWM= 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=afuaSwck; arc=none smtp.client-ip=209.85.128.48 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="afuaSwck" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4126126f4f4so2389035e9.0 for ; Sat, 17 Feb 2024 23:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708241617; x=1708846417; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=RxjQAef9+qAUjBcvJJcDUwD4MHxGTp3gRvgdxO0dKLE=; b=afuaSwck8URc0ANSWb34/J/EjxRz1C78YY8B0B2mwJc9ooWpMIG52Bxw7EAfqmnFRL 69A+Stvd74607cFHlWSbOVMcxKy36TIulOZwiz/pT3CvygyQLJCQ28SgZK+KLAtw0oT0 2X+HfKi4TXCz+eGr9WqkO3kG8Uu37J1P5qZOkrom2RsJn87hn8wsG64uQcF9l7zWgCq2 HNZ6QLby2GYs1lznmhP06ThyTRfv92IZLpv6lR4ooOvR7ih9hCHHA1wHzmVoGKAeTkel vtLLtjqUs3GewFdQvbaih9w+dvMq6RU7NX1tfwxN0eTPNEqkTtQeLrh+sYuVkLvW0aci oo6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708241617; x=1708846417; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RxjQAef9+qAUjBcvJJcDUwD4MHxGTp3gRvgdxO0dKLE=; b=ETw9iGVjiG4hSvDBVv1XJ/XAPFPQQ7P5Ysql8B/RLIgShkdYiu1464hBnqAmGEMIe5 hah1ZGLyBK28nAqktUMSpnf7SblRIlUaUO393SLk07Lbu1W0RyhJX0fHZYOzTVkvH4W8 xTEpNnFfubYswq8gudW1oszqcxMRSGkXIYVWaKRViG2fL2cAh2TpmHXJs4Qs1jnrBNE3 6jWLamGlp3t2BliX2HrhMNebFwf0r3avb9bhiQH/HB17oX8FzB5AsMYKnCeOl82EajbM MYBOXk4UOKMLZL1Jdv19/jZPMmFH3Vgsg/ANO9lXo5uvajRQXXxIJ/p0RPcWMaggzkLC ZCSg== X-Gm-Message-State: AOJu0YwfLGmEhWcgi31c95/FJBi5GZiBht8p3jMTqCkYky3UKoNShcQB 34HE2hJ4BHKQ3RFFPdwpytIvuMzIrodN1IyyCufzN7krZV36OxRli6sYCH6+ X-Google-Smtp-Source: AGHT+IEVqtpyXPQA16YpKhVmz2caIDacOLPZ/bmFHm70I5XNJqibFOifvo9T6mAsXDp5+LrLFqjU1w== X-Received: by 2002:a05:600c:4fc3:b0:411:a70e:3d20 with SMTP id o3-20020a05600c4fc300b00411a70e3d20mr6832592wmq.1.1708241617074; Sat, 17 Feb 2024 23:33:37 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j18-20020a5d6192000000b0033b6e26f0f9sm6702727wru.42.2024.02.17.23.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:33:36 -0800 (PST) Message-ID: <2da1b6509d810c76e5ea753a91b6a3a46a73fa6c.1708241613.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 18 Feb 2024 07:33:30 +0000 Subject: [PATCH 3/5] apply: update t4012 test suite Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Emily Shaffer , Philip Peterson , Philip Peterson From: Philip Peterson From: Philip Peterson The test suite matched against a regex that expected the entire errored output to end before the additional context added to `git apply`. Signed-off-by: Philip Peterson --- t/t4012-diff-binary.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index c64d9d2f405..59defaa37b8 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -68,7 +68,7 @@ test_expect_success 'apply detecting corrupt patch correctly' ' git diff >output && sed -e "s/-CIT/xCIT/" broken && test_must_fail git apply --stat --summary broken 2>detected && - detected=$(cat detected) && + detected=$(head -n 1 detected) && detected=$(expr "$detected" : "error.*at line \\([0-9]*\\)\$") && detected=$(sed -ne "${detected}p" broken) && test "$detected" = xCIT @@ -77,7 +77,7 @@ test_expect_success 'apply detecting corrupt patch correctly' ' test_expect_success 'apply detecting corrupt patch correctly' ' git diff --binary | sed -e "s/-CIT/xCIT/" >broken && test_must_fail git apply --stat --summary broken 2>detected && - detected=$(cat detected) && + detected=$(head -n 1 detected) && detected=$(expr "$detected" : "error.*at line \\([0-9]*\\)\$") && detected=$(sed -ne "${detected}p" broken) && test "$detected" = xCIT From patchwork Sun Feb 18 07:33:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson X-Patchwork-Id: 13561717 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 4505CEAFC for ; Sun, 18 Feb 2024 07:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; cv=none; b=hRJLoBqmQ6zuebsAKkWMdP5eWUPPHDGWWDbCLnxnZsfmvBg0oVmFqw1+Pj/HrxMBrBBNSMd053kQ1jMpiJHUjzgw/tTysE16O+Wjj8EvaYNDVtbEnAp2pxshJ5ng81CTmbv2eip+I32k95+T5dV3MHciVRSpo7F5z6UsEsIy95I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241621; c=relaxed/simple; bh=e30FGQSHiNwkp4qApRH3y3xnTx2Zi8WMb/R1wLFE/gE=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=eBbm02uO4YqCN6uNHxYZ1LSUfOeqYvRfAYboPhbYZ7VyA/226Oxq5Zt6gQ5gQa17CN3kNZmEEkGC4qrzG8oxbYl6xUsctht8Yt7+pJlfux6N5PJc2OF0Sk8T8n8ldaCjPgIrRzNehjMnOrztPL74Wg54f2f32tO0IvWc8EUliAI= 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=Hxt1CyY3; arc=none smtp.client-ip=209.85.128.41 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="Hxt1CyY3" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-41260adfea7so2935715e9.2 for ; Sat, 17 Feb 2024 23:33:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708241618; x=1708846418; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=VwvzsxQ8/Vw/1NrwghNPJcVfjwJf80Rjwp40GXIfL20=; b=Hxt1CyY3pXUubngoDWyaNf3/zBB1VOwLSPd0VYz+NAZR4Zx8FCFD8CXu3FUE0BY1ML ZIdYx5Qb8IS4usSsDi9WRXiLwkiFgsDf76n1eUwcF8bbJxF6Ra2VXxYBbGo8d62leHZ3 qMyD4QTOsZhZ13bE9tXnKOOREO6qJinEfAG72pyxIVL2bHF7QQo2RIbUk+grH1psP2tD qxwJzm7SydrGFUzj4g9m2thD+77mc2T7YH0IwxoX0j/PdwNo9xG5Cl8gFLPQTpLC7t5v 0ciX/LrMi/OGjvapN2vEUD+rFOk6s43MI9yajNdNqNTSXwNOcUEscuBEsjmnWd7mdE4X WMuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708241618; x=1708846418; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VwvzsxQ8/Vw/1NrwghNPJcVfjwJf80Rjwp40GXIfL20=; b=XbfXxq0MUhmMdgsRMgISDcNPKYmXSpZfy4G9VpK8XWofavTHxxpm9JEZVypojNs4Mi qWOQQ2qjMhyXQ0GrxGB2gsUTWkfTd3+sS2pGR0WRoFC8A0+T0hoVtFjukFQymI358i2i 4JYLiaQyv2gY1xjtFtFH2tbJ/dem/IxKnoPItcI8jnbw4zCniVNNSB57iZ5vscoPzIvs Lwjy2Axk7uLogxJFDNY/zPnPlv3bPCgEB+08v9bfLTAv0b1CnePs6vhrbvLeJDt4V6Ct vfXNMUrGJ+DJXHxqJDIZki9NefBUcn+Z80NXZyXN8hltohPvE6Z+glokrEQnsn4bnZAM SIsg== X-Gm-Message-State: AOJu0YxhCUR9468RUJr04rsnTZuXNYIhbYRlatjjxiA5X/BA12BO9iJ1 noiQfmQ4AFPPVyIBBXvST7mgxkT9Iea2F8/sOS5f+jB9zWantviUzN1Xp8+G X-Google-Smtp-Source: AGHT+IH5d+7jHqAYB3kjmKf8CUh3ScXJa4IcPq4WsgjTWULQx6idhb7u5V7jqt9xZ1Kd3vbsM5Bs7A== X-Received: by 2002:a05:600c:5486:b0:411:eb73:243b with SMTP id iv6-20020a05600c548600b00411eb73243bmr7417163wmb.5.1708241618529; Sat, 17 Feb 2024 23:33:38 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c139600b004122aba0008sm7505327wmf.11.2024.02.17.23.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:33:37 -0800 (PST) Message-ID: In-Reply-To: References: Date: Sun, 18 Feb 2024 07:33:31 +0000 Subject: [PATCH 4/5] apply: pass through quiet flag to fix t4150 Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Emily Shaffer , Philip Peterson , Philip Peterson From: Philip Peterson From: Philip Peterson This test was failing because it expects the invocation of `git apply` to be silent. Because previous patches introduce verbosity where previously there was a silent error (in the form of a return code), this adds an opportunity for a bug to become visible. The bug is in the way `git am` invokes `git apply`, not passing through --quiet when it is specified. Signed-off-by: Philip Peterson --- builtin/am.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/am.c b/builtin/am.c index d1990d7edcb..799cb8128a3 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -36,6 +36,7 @@ #include "mailinfo.h" #include "apply.h" #include "string-list.h" +#include "packfile.h" #include "pager.h" #include "path.h" #include "repository.h" @@ -2412,6 +2413,10 @@ int cmd_am(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, usage, 0); + if (state.quiet) { + strvec_push(&state.git_apply_opts, "--quiet"); + } + if (binary >= 0) fprintf_ln(stderr, _("The -b/--binary option has been a no-op for long time, and\n" "it will be removed. Please do not use it anymore.")); From patchwork Sun Feb 18 07:33:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson X-Patchwork-Id: 13561718 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 7AC54F4FC for ; Sun, 18 Feb 2024 07:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241623; cv=none; b=Sweu74NO+Xba7ROEUeE2yJEf+Ugr/AoQUXAoWrpBdC8T7TiwUxUGO5CQrkw9ziNBqDQ7o1Dlxl1SLIh3SDXwoRZI+Xzydu3td8vG/JKYuLTDh2G76zYsf4shOKy9Udss3drA8ro7dR7nmLZnn+PBvPE/oHMizFHDsP4sNC+plic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708241623; c=relaxed/simple; bh=6aE2xtTX7MCYi8osIR5IG8bWfOk0xPylK1Yham/3J/4=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=LnHbyT18qq5X0GUN+F5Eusqw5Hf4Tyw6tpN2E6mXFJ4HuzoR/xsSwMZEexq1+LqFCqFl9xWznSOyflZFtgN/366BqhleF7s8ukGGjCtDBjMuSpZk+h73xkYmtp8c3lXomgi65Ru0pDxkEbnL/5q1sWWzamNpVK/lTGf2MXRQ6mU= 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=W3pFqzTz; arc=none smtp.client-ip=209.85.128.49 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="W3pFqzTz" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4125ea5d913so4687825e9.2 for ; Sat, 17 Feb 2024 23:33:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708241619; x=1708846419; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=smv2uvExotzcskWd364Z/h/YcZbOyVk197y3lT1L1lY=; b=W3pFqzTz92dorp7VCJVwFO+z48SsKDAx0sDN2R2r3vEI5R1R5h8kzIhSmjfOeAIOnE ZLFKWTiUqMaagckoUEBhdqSa0dJ+EnKHjs4Ry/aRUn63jgPCWYHvtQVrnWCTHcz68uE4 kT7If5mLtcp0pYTr9HflEiiYp+Cz8Wvtlg1CWHrzFHYGg6wOKhhIMxIyxldLEZAP5i5e w7jkpnGpmSUCulrRHQbcBjozaBtywWn3FeWMblrfybr1Z3w5ijRJZYXdJhOBXZuxm5TL 8o00Hayrepd8sLUG5mehnORw3s7nYHsAjMP3c/q4A4jOVpec1urs+IuisrUCDW09MW0i EPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708241619; x=1708846419; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=smv2uvExotzcskWd364Z/h/YcZbOyVk197y3lT1L1lY=; b=uL605r9v60dzXwKyVOP6z0HauK5LV2kGeoEd9x31qOJZVr4ZQUUBrD4TvuRfnWQiCF 2cNgVuM5NJPAVWIs5N87OgICcdkX34L7JbsorZ3x2rX5dF9A9R7NgE0ttuvKF4QkQMa/ a8f2A27pSxhANvhMdvNXH6F0lQE2cyconAh45SezSFuTgolrTNvQnFXdqOrrMwhEVN14 AmYAa1lhAr0KrR3JRZYANNgNRFGLwiA2zZU1DZG7pwqnm5p/u6PdHUqHYwtX4DRPQAX1 ui3lxqVqEs6456bFCcAmOgfzq2kZ3ubB70G9xVutfGzfTqt8qr3fHo4tlrZvxNFCWzJ6 MUAg== X-Gm-Message-State: AOJu0YywtZ2/MRdmFSDRBIObeVXc5tptSzVDx0wghV/RaAU2Q8awHRpl BGVG21voQmN3krNZJkTvPxHosPRCe4XPw9Ga+6mSh92ojGuJ1PuDMcH+ruyV X-Google-Smtp-Source: AGHT+IE1jjcFtK843ntOvd59aL4Nr7PgsQblTt1HByXEyjuWFskpzODlslxfkaa75HBlW95so/OuRA== X-Received: by 2002:a05:600c:46ce:b0:40e:f693:94f6 with SMTP id q14-20020a05600c46ce00b0040ef69394f6mr6739990wmo.35.1708241619242; Sat, 17 Feb 2024 23:33:39 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l11-20020a1c790b000000b00411d3a414c6sm7261721wme.47.2024.02.17.23.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 23:33:38 -0800 (PST) Message-ID: In-Reply-To: References: Date: Sun, 18 Feb 2024 07:33:32 +0000 Subject: [PATCH 5/5] am: update test t4254 by adding the new error text Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Emily Shaffer , Philip Peterson , Philip Peterson From: Philip Peterson From: Philip Peterson The old error text was shorter than the new, so this just adds the new context message to the expected text. Signed-off-by: Philip Peterson --- t/t4254-am-corrupt.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh index 45f1d4f95e5..265bcc41bbd 100755 --- a/t/t4254-am-corrupt.sh +++ b/t/t4254-am-corrupt.sh @@ -60,7 +60,14 @@ test_expect_success setup ' test_expect_success 'try to apply corrupted patch' ' test_when_finished "git am --abort" && test_must_fail git -c advice.amWorkDir=false am bad-patch.diff 2>actual && - echo "error: git diff header lacks filename information (line 4)" >expected && + space=" " && + echo \ +"error:$space + could not find header +caused by: + could not find file diff header +caused by: + git diff header lacks filename information (line 4)" >expected && test_path_is_file f && test_cmp expected actual '