From patchwork Thu Sep 7 22:20:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver X-Patchwork-Id: 13376894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE9DFEC875E for ; Thu, 7 Sep 2023 22:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241366AbjIGWUm (ORCPT ); Thu, 7 Sep 2023 18:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238877AbjIGWUc (ORCPT ); Thu, 7 Sep 2023 18:20:32 -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 EAF2A1BF3 for ; Thu, 7 Sep 2023 15:20:22 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31c65820134so1293132f8f.1 for ; Thu, 07 Sep 2023 15:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694125221; x=1694730021; 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=fY09o0eIjQAOX4i11ObRwSPzY+XFP7GgwXI2YvGZ6Jg=; b=pozJR5Ine5Lbd8yl5objvS/D+id5rfEoL4x0E8iVKUjEauAmQQ3KcC50qYXN0kzRTx hTJfztMvu1f5ezLXQU19julK7CXOKKNTbUhuRhhR2IEBjwu83lEFIDRa8GU3ojVPHmFI M5rSx5ik3a06oBSQVS41Ddy9E5HVx8qAjrWi0U9HVXwQnHlB0u5xo04HZisk+oPuCmJF ks9o+hF5d3Pg8PVZq7aEKCUjCgBzhNCtPshw7RlCDklEp58NF2q5cDE4MYing61WLaKM +Cb6f+buJXs1kwxYzP/VyU7kajRMAiYsUKGUIjOAqfuAnYJt7Kl7+wQBI8yte2MIu/zI k2UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694125221; x=1694730021; 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=fY09o0eIjQAOX4i11ObRwSPzY+XFP7GgwXI2YvGZ6Jg=; b=GOoLBb7LhwCCWc9XR76+BKRmnj/+9x5HDtje23ih1tIi/IcHhxqQzn/pX2fRBo+SCs /ZjUzU1axeejWK2LOzpXstTYgvkaxSYqOYAcLgpkDnm2DwGj6Zw5FezvtlDoe/T0EFMt dtn4oL63T68dO2C2vxvI4IvSHHWUokBDHzli04w0Btk/B6nPP5pkcWQ0Dc9c4Pll07T7 99xtUGjLhcdC4XDqjObVQWbdvp++rfWEF93RVEPec2IFhD7H6RQ8ShdVYjByusnkGRn8 A9sM/i6ktLo4tFMEBgSsbaFF0H5zjtBQp15Bn2SnWkPrdz1ZtuCevBXLdS6S2R5mR0aQ guQA== X-Gm-Message-State: AOJu0Yy82sZ+zeO6xmYvD2B1k9CUZB5BiR2hQOxbyGyaIiVc4+n04tFY T2PRxPLllxTjYFgig3SRdYEdTmK0oOs= X-Google-Smtp-Source: AGHT+IHOwANvMGNV7qX0BhQTooBc4kNolddZb0+BAFBh9EVDhbuubagGMhPiqXbn6J5l8ZMoLjIkig== X-Received: by 2002:adf:e6cc:0:b0:31a:d6cb:7f9d with SMTP id y12-20020adfe6cc000000b0031ad6cb7f9dmr453886wrm.24.1694125220902; Thu, 07 Sep 2023 15:20:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r3-20020a5d4983000000b00317ab75748bsm433268wrq.49.2023.09.07.15.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 15:20:20 -0700 (PDT) Message-ID: <0b9525db5a0787fdc71834abad9151aa03acc497.1694125210.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 07 Sep 2023 22:20:09 +0000 Subject: [PATCH v3 13/13] trailer doc: is a or , not both Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Christian Couder , Linus Arver , Linus Arver Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Linus Arver From: Linus Arver The `--trailer` option takes a "=" argument, for example --trailer "Acked-by=Bob" And in this exampple it is understood that "Acked-by" is the . However, the user can use a shorter "ack" string by defining configuration like git config trailer.ack.key "Acked-by" However, in the docs we define the above configuration as trailer..key so the can mean either the longer "Acked-by" or the shorter "ack". Separate the two meanings of into and , and update the configuration syntax to say "trailer..key". Signed-off-by: Linus Arver --- Documentation/git-interpret-trailers.txt | 136 +++++++++++++---------- builtin/interpret-trailers.c | 2 +- 2 files changed, 77 insertions(+), 61 deletions(-) diff --git a/Documentation/git-interpret-trailers.txt b/Documentation/git-interpret-trailers.txt index 25433e1a1ff..418265f044d 100644 --- a/Documentation/git-interpret-trailers.txt +++ b/Documentation/git-interpret-trailers.txt @@ -9,7 +9,7 @@ SYNOPSIS -------- [verse] 'git interpret-trailers' [--in-place] [--trim-empty] - [(--trailer [(=|:)])...] + [(--trailer (|)[(=|:)])...] [--parse] [...] DESCRIPTION @@ -53,22 +53,32 @@ are applied to each input and the way any existing trailer in the input is changed. They also make it possible to automatically add some trailers. -By default, a '=' or ':' argument given +By default, a '=' or ':' argument given using `--trailer` will be appended after the existing trailers only if -the last trailer has a different (, ) pair (or if there -is no existing trailer). The and parts will be trimmed +the last trailer has a different (, ) pair (or if there +is no existing trailer). The and parts will be trimmed to remove starting and trailing whitespace, and the resulting trimmed - and will appear in the output like this: + and will appear in the output like this: ------------------------------------------------ -token: value +key: value ------------------------------------------------ -This means that the trimmed and will be separated by -`': '` (one colon followed by one space). For convenience, the can be a -shortened string key (e.g., "sign") instead of the full string which should -appear before the separator on the output (e.g., "Signed-off-by"). This can be -configured using the 'trailer..key' configuration variable. +This means that the trimmed and will be separated by +`': '` (one colon followed by one space). + +For convenience, a can be configured to make using `--trailer` +shorter to type on the command line. This can be configured using the +'trailer..key' configuration variable. The must be a prefix +of the full string, although case sensitivity does not matter. For +example, if you have + +------------------------------------------------ +trailer.sign.key "Signed-off-by: " +------------------------------------------------ + +in your configuration, you only need to specify `--trailer="sign: foo"` +on the command line instead of `--trailer="Signed-off-by: foo"`. By default the new trailer will appear at the end of all the existing trailers. If there is no existing trailer, the new trailer will appear @@ -85,14 +95,14 @@ non-whitespace lines before a line that starts with '---' (followed by a space or the end of the line). When reading trailers, there can be no whitespace before or inside the -, but any number of regular space and tab characters are allowed -between the and the separator. There can be whitespaces before, +, but any number of regular space and tab characters are allowed +between the and the separator. There can be whitespaces before, inside or after the . The may be split over multiple lines with each subsequent line starting with at least one whitespace, like the "folding" in RFC 822. Example: ------------------------------------------------ -token: This is a very long value, with spaces and +key: This is a very long value, with spaces and newlines in it. ------------------------------------------------ @@ -109,8 +119,8 @@ OPTIONS the whole trailer will be removed from the output. This applies to existing trailers as well as new trailers. ---trailer [(=|:)]:: - Specify a (, ) pair that should be applied as a +--trailer [(=|:)]:: + Specify a (, ) pair that should be applied as a trailer to the inputs. See the description of this command. @@ -118,7 +128,7 @@ OPTIONS --no-where:: Specify where all new trailers will be added. A setting provided with '--where' overrides the `trailer.where` and any - applicable `trailer..where` configuration variables + applicable `trailer..where` configuration variables and applies to all '--trailer' options until the next occurrence of '--where' or '--no-where'. Upon encountering '--no-where', clear the effect of any previous use of '--where', such that the relevant configuration @@ -128,9 +138,9 @@ OPTIONS --if-exists :: --no-if-exists:: Specify what action will be performed when there is already at - least one trailer with the same in the input. A setting + least one trailer with the same in the input. A setting provided with '--if-exists' overrides the `trailer.ifExists` and any - applicable `trailer..ifExists` configuration variables + applicable `trailer..ifExists` configuration variables and applies to all '--trailer' options until the next occurrence of '--if-exists' or '--no-if-exists'. Upon encountering '--no-if-exists, clear the effect of any previous use of '--if-exists, such that the relevant configuration @@ -140,9 +150,9 @@ OPTIONS --if-missing :: --no-if-missing:: Specify what action will be performed when there is no other - trailer with the same in the input. A setting + trailer with the same in the input. A setting provided with '--if-missing' overrides the `trailer.ifMissing` and any - applicable `trailer..ifMissing` configuration variables + applicable `trailer..ifMissing` configuration variables and applies to all '--trailer' options until the next occurrence of '--if-missing' or '--no-if-missing'. Upon encountering '--no-if-missing, clear the effect of any previous use of '--if-missing, such that the relevant @@ -187,11 +197,11 @@ used when another separator is not specified in the config for this trailer. + For example, if the value for this option is "%=$", then only lines -using the format '' with containing '%', '=' +using the format '' with containing '%', '=' or '$' and then spaces will be considered trailers. And '%' will be the default separator used, so by default trailers will appear like: -'% ' (one percent sign and one space will appear between -the token and the value). +'% ' (one percent sign and one space will appear between +the key and the value). trailer.where:: This option tells where a new trailer will be added. @@ -205,41 +215,41 @@ If it is `start`, then each new trailer will appear at the start, instead of the end, of the existing trailers. + If it is `after`, then each new trailer will appear just after the -last trailer with the same . +last trailer with the same . + If it is `before`, then each new trailer will appear just before the -first trailer with the same . +first trailer with the same . trailer.ifexists:: This option makes it possible to choose what action will be performed when there is already at least one trailer with the - same in the input. + same in the input. + The valid values for this option are: `addIfDifferentNeighbor` (this is the default), `addIfDifferent`, `add`, `replace` or `doNothing`. + With `addIfDifferentNeighbor`, a new trailer will be added only if no -trailer with the same (, ) pair is above or below the line +trailer with the same (, ) pair is above or below the line where the new trailer will be added. + With `addIfDifferent`, a new trailer will be added only if no trailer -with the same (, ) pair is already in the input. +with the same (, ) pair is already in the input. + With `add`, a new trailer will be added, even if some trailers with -the same (, ) pair are already in the input. +the same (, ) pair are already in the input. + -With `replace`, an existing trailer with the same will be +With `replace`, an existing trailer with the same will be deleted and the new trailer will be added. The deleted trailer will be -the closest one (with the same ) to the place where the new one +the closest one (with the same ) to the place where the new one will be added. + With `doNothing`, nothing will be done; that is no new trailer will be -added if there is already one with the same in the input. +added if there is already one with the same in the input. trailer.ifmissing:: This option makes it possible to choose what action will be performed when there is not yet any trailer with the same - in the input. + in the input. + The valid values for this option are: `add` (this is the default) and `doNothing`. @@ -248,34 +258,40 @@ With `add`, a new trailer will be added. + With `doNothing`, nothing will be done. -trailer..key:: - This `key` will be used instead of in the trailer. At - the end of this key, a separator can appear and then some - space characters. By default the only valid separator is ':', - but this can be changed using the `trailer.separators` config - variable. +trailer..key:: + Defines a for the . The must be a + prefix (case does not matter) of the . For example, in `git + config trailer.ack.key "Acked-by"` the "Acked-by" is the and + the "ack" is the . This configuration allows the shorter + `--trailer "ack:..."` invocation on the command line using the "ack" + instead of the longer `--trailer "Acked-by:..."`. ++ +At the end of the , a separator can appear and then some +space characters. By default the only valid separator is ':', +but this can be changed using the `trailer.separators` config +variable. + If there is a separator in the key, then it overrides the default separator when adding the trailer. -trailer..where:: +trailer..where:: This option takes the same values as the 'trailer.where' configuration variable and it overrides what is specified by - that option for trailers with the specified . + that option for trailers with the specified . -trailer..ifexists:: +trailer..ifexists:: This option takes the same values as the 'trailer.ifexists' configuration variable and it overrides what is specified by - that option for trailers with the specified . + that option for trailers with the specified . -trailer..ifmissing:: +trailer..ifmissing:: This option takes the same values as the 'trailer.ifmissing' configuration variable and it overrides what is specified by - that option for trailers with the specified . + that option for trailers with the specified . -trailer..command:: - Deprecated in favor of 'trailer..cmd'. - This option behaves in the same way as 'trailer..cmd', except +trailer..command:: + Deprecated in favor of 'trailer..cmd'. + This option behaves in the same way as 'trailer..cmd', except that it doesn't pass anything as argument to the specified command. Instead the first occurrence of substring $ARG is replaced by the that would be passed as argument. @@ -283,29 +299,29 @@ trailer..command:: Note that $ARG in the user's command is only replaced once and that the original way of replacing $ARG is not safe. + -When both 'trailer..cmd' and 'trailer..command' are given -for the same , 'trailer..cmd' is used and -'trailer..command' is ignored. +When both 'trailer..cmd' and 'trailer..command' are given +for the same , 'trailer..cmd' is used and +'trailer..command' is ignored. -trailer..cmd:: +trailer..cmd:: This option can be used to specify a shell command that will be called - once to automatically add a trailer with the specified , and then - called each time a '--trailer =' argument is specified to + once to automatically add a trailer with the specified , and then + called each time a '--trailer =' argument is specified to modify the of the trailer that this option would produce. + When the specified command is first called to add a trailer -with the specified , the behavior is as if a special -'--trailer =' argument was added at the beginning +with the specified , the behavior is as if a special +'--trailer =' argument was added at the beginning of the "git interpret-trailers" command, where is taken to be the standard output of the command with any leading and trailing whitespace trimmed off. + -If some '--trailer =' arguments are also passed +If some '--trailer =' arguments are also passed on the command line, the command is called again once for each -of these arguments with the same . And the part +of these arguments with the same . And the part of these arguments, if any, will be passed to the command as its first argument. This way the command can produce a computed -from the passed in the '--trailer =' argument. +from the passed in the '--trailer =' argument. EXAMPLES -------- diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c index 832f86a770a..d2d78fd961f 100644 --- a/builtin/interpret-trailers.c +++ b/builtin/interpret-trailers.c @@ -14,7 +14,7 @@ static const char * const git_interpret_trailers_usage[] = { N_("git interpret-trailers [--in-place] [--trim-empty]\n" - " [(--trailer [(=|:)])...]\n" + " [(--trailer (|)[(=|:)])...]\n" " [--parse] [...]"), NULL };