{"thread":{"id":"32854","subject":"[PATCH] git-mergetool: print filename when it contains %","startedAt":"2013-02-08T01:16:24Z","lastAt":"2013-02-08T21:09:56Z","messageCount":4,"participants":["Asheesh Laroia","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"208961","messageId":"1360286184-14278-1-git-send-email-asheesh@asheesh.org","threadId":"32854","inReplyTo":null,"subject":"[PATCH] git-mergetool: print filename when it contains %","fromName":"Asheesh Laroia","fromEmail":"asheesh@asheesh.org","sentAt":"2013-02-08T01:16:24Z","receivedAt":"2013-02-08T01:16:24Z","isPatch":true,"sender":{"key":"asheesh@asheesh.org","avatar":"https://avatars.githubusercontent.com/u/25457?v=4"},"body":"Before this change, if git-mergetool was invoked with regard to\nfiles with a percent sign (%) in their names, it would print an\nerror. For example, if you were calling mergetool on a file called\n\"%2F\":\n\n    printf: %2F: invalid directive\n\nThis changes the behavior to pass \"%s\" to printf as its first argument\nto avoid processing the filename as a format string.\n\nSigned-off-by: Asheesh Laroia <asheesh@asheesh.org>\n---\n git-mergetool.sh |    2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex c50e18a..d2b9289 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -440,7 +440,7 @@ then\n fi\n \n printf \"Merging:\\n\"\n-printf \"$files\\n\"\n+printf \"%s\" \"$files\\n\"\n \n IFS='\n '\n-- \n1.7.10.4\n"},{"id":"209006","messageId":"7vhalm3e54.fsf@alter.siamese.dyndns.org","threadId":"32854","inReplyTo":"1360286184-14278-1-git-send-email-asheesh@asheesh.org","subject":"Re: [PATCH] git-mergetool: print filename when it contains %","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-08T17:32:23Z","receivedAt":"2013-02-08T17:32:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Asheesh Laroia <asheesh@asheesh.org> writes:\n\n> Before this change, if git-mergetool was invoked with regard to\n\nDrop \"before this change,\"; it is clear (and it is a recommended\npractice) you are first describing what problem you are addressing.\n\n> files with a percent sign (%) in their names, it would print an\n> error. For example, if you were calling mergetool on a file called\n> \"%2F\":\n>\n>     printf: %2F: invalid directive\n>\n> This changes the behavior to pass \"%s\" to printf as its first argument\n> to avoid processing the filename as a format string.\n>\n> Signed-off-by: Asheesh Laroia <asheesh@asheesh.org>\n> ---\n\nThanks.\n\nAs a follow-up to this patch, we may want to perform a systematic\naudit of\n\n    $ git grep -e 'printf \"[^\"]*\\$[^\"]*\"'\n\nThere is one in git-difftool-helper.sh\n\n    printf \"\\nViewing: '$MERGED'\\n\"\n\nand mergetools/p4merge:\n\n    printf \"$empty_file\"\n\n>  git-mergetool.sh |    2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-mergetool.sh b/git-mergetool.sh\n> index c50e18a..d2b9289 100755\n> --- a/git-mergetool.sh\n> +++ b/git-mergetool.sh\n> @@ -440,7 +440,7 @@ then\n>  fi\n>  \n>  printf \"Merging:\\n\"\n> -printf \"$files\\n\"\n> +printf \"%s\" \"$files\\n\"\n\nI think\n\n\tprintf \"%s\\n\" \"$files\"\n\nwould be clearer.\n\n>  \n>  IFS='\n>  '\n"},{"id":"209038","messageId":"alpine.DEB.2.02.1302081558130.23245@rose.makesad.us","threadId":"32854","inReplyTo":"7vhalm3e54.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-mergetool: print filename when it contains %","fromName":"Asheesh Laroia","fromEmail":"asheesh@asheesh.org","sentAt":"2013-02-08T20:58:54Z","receivedAt":"2013-02-08T20:58:54Z","isPatch":true,"sender":{"key":"asheesh@asheesh.org","avatar":"https://avatars.githubusercontent.com/u/25457?v=4"},"body":"On Fri, 8 Feb 2013, Junio C Hamano wrote:\n\n> Asheesh Laroia <asheesh@asheesh.org> writes:\n>\n>> Before this change, if git-mergetool was invoked with regard to\n>\n> Drop \"before this change,\"; it is clear (and it is a recommended\n> practice) you are first describing what problem you are addressing.\n>\n\nJunio, thanks for the quick reply! I agree with your suggestions, and will \ntake a look at addressing them, hopefully by Tuesday or so.\n\n-- Asheesh.\n"},{"id":"209039","messageId":"7vliayzf4r.fsf@alter.siamese.dyndns.org","threadId":"32854","inReplyTo":"alpine.DEB.2.02.1302081558130.23245@rose.makesad.us","subject":"Re: [PATCH] git-mergetool: print filename when it contains %","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-02-08T21:09:56Z","receivedAt":"2013-02-08T21:09:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Asheesh Laroia <asheesh@asheesh.org> writes:\n\n> Junio, thanks for the quick reply! I agree with your suggestions, and\n> will take a look at addressing them, hopefully by Tuesday or so.\n\nFYI, here is what I queued for now.\n\n-- >8 --\nFrom: Asheesh Laroia <asheesh@asheesh.org>\nDate: Thu, 7 Feb 2013 17:16:24 -0800\nSubject: [PATCH] git-mergetool: print filename when it contains %\n\nIf git-mergetool was invoked with files with a percent sign (%) in\ntheir names, it would print an error.  For example, if you were\ncalling mergetool on a file called \"%2F\":\n\n    printf: %2F: invalid directive\n\nDo not pass random string to printf as if it were a valid format.\nUse format string \"%s\" and pass the string as a data to be formatted\ninstead.\n\nSigned-off-by: Asheesh Laroia <asheesh@asheesh.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-mergetool.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-mergetool.sh b/git-mergetool.sh\nindex c50e18a..012afa5 100755\n--- a/git-mergetool.sh\n+++ b/git-mergetool.sh\n@@ -440,7 +440,7 @@ then\n fi\n \n printf \"Merging:\\n\"\n-printf \"$files\\n\"\n+printf \"%s\\n\" \"$files\"\n \n IFS='\n '\n-- \n1.8.1.3.617.gb5c8e72\n"}]}