Re: [PATCH] git-mergetool: print filename when it contains %

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Asheesh Laroia <asheesh@xxxxxxxxxxx> writes:

> Before this change, if git-mergetool was invoked with regard to

Drop "before this change,"; it is clear (and it is a recommended
practice) you are first describing what problem you are addressing.

> files with a percent sign (%) in their names, it would print an
> error. For example, if you were calling mergetool on a file called
> "%2F":
>
>     printf: %2F: invalid directive
>
> This changes the behavior to pass "%s" to printf as its first argument
> to avoid processing the filename as a format string.
>
> Signed-off-by: Asheesh Laroia <asheesh@xxxxxxxxxxx>
> ---

Thanks.

As a follow-up to this patch, we may want to perform a systematic
audit of

    $ git grep -e 'printf "[^"]*\$[^"]*"'

There is one in git-difftool-helper.sh

    printf "\nViewing: '$MERGED'\n"

and mergetools/p4merge:

    printf "$empty_file"

>  git-mergetool.sh |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index c50e18a..d2b9289 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -440,7 +440,7 @@ then
>  fi
>  
>  printf "Merging:\n"
> -printf "$files\n"
> +printf "%s" "$files\n"

I think

	printf "%s\n" "$files"

would be clearer.

>  
>  IFS='
>  '
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]