diff mbox

[maintainer-tools,1/2] dim: use quotes when testing for empty string

Message ID 1449171651-30872-1-git-send-email-paulo.r.zanoni@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zanoni, Paulo R Dec. 3, 2015, 7:40 p.m. UTC
Today I applied/pushed patches for the first time, and noticed that
all my commits had exactly this:
    Link: http://patchwork.freedesktop.org/patch/msgid/
without the actual ID there. I assumed the ID would be set by some
commit hook since our hooks seem to be able to talk to patchwork.
Looks like I was wrong. It seems that I was supposed to apply a patch
email, not the original patch file that I sent with git send-email.

The problem happened due to missing quotes around $message_id:

    pzanoni@panetone:~/nfs/teste$ cat test.sh
    #!/bin/bash
    A=""
    if [ -n $A ]; then
        echo "No quotes: true"
    else
        echo "No quotes: false"
    fi
    if [ -n "$A" ]; then
        echo "With quotes: true"
    else
        echo "With quotes: false"
    fi
    pzanoni@panetone:~/nfs/teste$ bash test.sh
    No quotes: true
    With quotes: false

In addition, print a little message telling us that the message-ids
are missing. This may help by reminding us that we should apply the
mail file, not the original patch. I'm not enforcing it since I don't
know all our use cases.

Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 dim | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jani Nikula Dec. 4, 2015, 8:35 a.m. UTC | #1
On Thu, 03 Dec 2015, Paulo Zanoni <paulo.r.zanoni@intel.com> wrote:
> Today I applied/pushed patches for the first time, and noticed that
> all my commits had exactly this:
>     Link: http://patchwork.freedesktop.org/patch/msgid/
> without the actual ID there. I assumed the ID would be set by some
> commit hook since our hooks seem to be able to talk to patchwork.
> Looks like I was wrong. It seems that I was supposed to apply a patch
> email, not the original patch file that I sent with git send-email.

Yes, the whole idea of the Link: tag was to increase transparency about
people only applying patches that went throught the list.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


> The problem happened due to missing quotes around $message_id:
>
>     pzanoni@panetone:~/nfs/teste$ cat test.sh
>     #!/bin/bash
>     A=""
>     if [ -n $A ]; then
>         echo "No quotes: true"
>     else
>         echo "No quotes: false"
>     fi
>     if [ -n "$A" ]; then
>         echo "With quotes: true"
>     else
>         echo "With quotes: false"
>     fi
>     pzanoni@panetone:~/nfs/teste$ bash test.sh
>     No quotes: true
>     With quotes: false
>
> In addition, print a little message telling us that the message-ids
> are missing. This may help by reminding us that we should apply the
> mail file, not the original patch. I'm not enforcing it since I don't
> know all our use cases.
>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
> ---
>  dim | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/dim b/dim
> index 78b3f30..5f2f686 100755
> --- a/dim
> +++ b/dim
> @@ -382,8 +382,10 @@ function dim_apply
>  
>  	cat $file | git am -3 "$@"
>  
> -	if [ -n $message_id ]; then
> +	if [ -n "$message_id" ]; then
>  		commit_add_tag "Link" "http://patchwork.freedesktop.org/patch/msgid/$message_id"
> +	else
> +		echo "No message-id found in the patch file."
>  	fi
>  
>  	eval $DRY $DIM_POST_APPLY_ACTION
diff mbox

Patch

diff --git a/dim b/dim
index 78b3f30..5f2f686 100755
--- a/dim
+++ b/dim
@@ -382,8 +382,10 @@  function dim_apply
 
 	cat $file | git am -3 "$@"
 
-	if [ -n $message_id ]; then
+	if [ -n "$message_id" ]; then
 		commit_add_tag "Link" "http://patchwork.freedesktop.org/patch/msgid/$message_id"
+	else
+		echo "No message-id found in the patch file."
 	fi
 
 	eval $DRY $DIM_POST_APPLY_ACTION