Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSOC] trailer: add new .cmd config option #913

Closed

Commits on Apr 12, 2021

  1. [GSOC] docs: correct descript of trailer.<token>.command

    In the original documentation of `trailer.<token>.command`,
    some descriptions are easily misunderstood. So let's modify
    it to increase its readability.
    
    In addition, clarify that `$ARG` in command can only be
    replaced once.
    
    Signed-off-by: ZheNing Hu <adlternative@gmail.com>
    adlternative committed Apr 12, 2021
    Configuration menu
    Copy the full SHA
    8129ef6 View commit details
    Browse the repository at this point in the history

Commits on May 3, 2021

  1. [GSOC] trailer: add new .cmd config option

    The `trailer.<token>.command` configuration variable
    specifies a command (run via the shell, so it does not have
    to be a single name or path to the command, but can be a
    shell script), and the first occurrence of substring $ARG is
    replaced with the value given to the `interpret-trailer`
    command for the token in a '--trailer <token>=<value>' argument.
    
    This has three downsides:
    
    * The use of $ARG in the mechanism misleads the users that
    the value is passed in the shell variable, and tempt them
    to use $ARG more than once, but that would not work, as
    the second and subsequent $ARG are not replaced.
    
    * Because $ARG is textually replaced without regard to the
    shell language syntax, even '$ARG' (inside a single-quote
    pair), which a user would expect to stay intact, would be
    replaced, and worse, if the value had an unmatched single
    quote (imagine a name like "O'Connor", substituted into
    NAME='$ARG' to make it NAME='O'Connor'), it would result in
    a broken command that is not syntactically correct (or
    worse).
    
    * The first occurrence of substring `$ARG` will be replaced
    with the empty string, in the command when the command is
    first called to add a trailer with the specified <token>.
    This is a bad design, the nature of automatic execution
    causes it to add a trailer that we don't expect.
    
    Introduce a new `trailer.<token>.cmd` configuration that
    takes higher precedence to deprecate and eventually remove
    `trailer.<token>.command`, which passes the value as an
    argument to the command.  Instead of "$ARG", users can
    refer to the value as positional argument, $1, in their
    scripts. At the same time, in order to allow
    `git interpret-trailers` to better simulate the behavior
    of `git command -s`, 'trailer.<token>.cmd' will not
    automatically execute.
    
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Helped-by: Christian Couder <christian.couder@gmail.com>
    Signed-off-by: ZheNing Hu <adlternative@gmail.com>
    adlternative committed May 3, 2021
    Configuration menu
    Copy the full SHA
    edb7f19 View commit details
    Browse the repository at this point in the history