Skip to contentSkip to conversation

Corrected return values in post-receive-email.prep_for_email

PATCH In review Alan Raison 4 participants 9 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Corrected return values in post-receive-email.prep_for_email

---
 contrib/hooks/post-receive-email |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/contrib/hooks/post-receive-email
index 85724bf..020536d 100755

contrib/hooks/post-receive-email +0 -0
@@ -150,7 +150,7 @@ prep_for_email()
 			# Anything else (is there anything else?)
 			echo >&2 "*** Unknown type of update to $refname

($rev_type)"
echo >&2 "*** - no email generated"
- return 0
+ return 1
;;
esac

@@ -166,10 +166,10 @@ prep_for_email()
esac
echo >&2 "*** $config_name is not set so no email will be
sent"
echo >&2 "*** for $refname update $oldrev->$newrev"
- return 0
+ return 1
fi

- return 1
+ return 0
}

#

Signature · 1 line
1.7.3.1.msysgit.0
#1 lore raw

Care to explain in the change log message why the return value should be 1 instead of 0?

Quoted 41 lines · Alan Raison

---
 contrib/hooks/post-receive-email |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
contrib/hooks/post-receive-email +0 -0
index 85724bf..020536d 100755
@@ -150,7 +150,7 @@ prep_for_email()
                        # Anything else (is there anything else?)

                       echo >&2 "*** Unknown type of update to $refname ($rev_type)"
                       echo >&2 "***  - no email generated"
-                       return 0
+                       return 1
                       ;;
       esac

contrib/hooks/post-receive-email +0 -0
@@ -166,10 +166,10 @@ prep_for_email()

               esac
               echo >&2 "*** $config_name is not set so no email will be sent"
               echo >&2 "*** for $refname update $oldrev->$newrev"
-               return 0
+               return 1
       fi

-       return 1
+       return 0
 }

 #
--
1.7.3.1.msysgit.0

--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw

In the main loop (lines 734 and 738 in the current master) the && and || operations assume true==0 and false==1; in line with shell defaults.

I tested it on a sourceforge shell (I think using Bash); error conditions reported an error to standard error, then proceeded to generate the email; if prep_for_email succeeded then no mail was sent.

HTH

Alan

-----Original Message-----
From: Thiago Farina [mailto:[email protected]]
Sent: 07 December 2010 16:50
To: Alan Raison
Cc: [email protected]
Subject: Re: [PATCH] Corrected return values in post-receive-email.prep_for_email

Care to explain in the change log message why the return value should be 1 instead of 0?

Quoted 41 lines · Alan Raison
---
 contrib/hooks/post-receive-email |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
contrib/hooks/post-receive-email +0 -0
index 85724bf..020536d 100755
@@ -150,7 +150,7 @@ prep_for_email()
                       # Anything else (is there anything else?)
                       echo >&2 "*** Unknown type of update to $refname

($rev_type)"
echo >&2 "*** - no email generated"

contrib/hooks/post-receive-email +1 -1
-                       return 0
+                       return 1
                       ;;
       esac
@@ -166,10 +166,10 @@ prep_for_email()
               esac
               echo >&2 "*** $config_name is not set so no email will be

sent"

               echo >&2 "*** for $refname update $oldrev->$newrev"
contrib/hooks/post-receive-email +2 -3
-               return 0
+               return 1
       fi
 
-       return 1
+       return 0
 }
 
 #
--

1.7.3.1.msysgit.0

--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Alan Raison
Quoted 3 lines · Alan Raison
---
 contrib/hooks/post-receive-email |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

No sign-off, no description.

This is a regression introduced by 53cad69 (post-receive-email: ensure sent messages are not empty, 2010-09-10), I think.

contrib/hooks/post-receive-email

Quoted 12 lines
contrib/hooks/post-receive-email +0 -0
index 85724bf..020536d 100755
@@ -150,7 +150,7 @@ prep_for_email()
 			# Anything else (is there anything else?)
 			echo >&2 "*** Unknown type of update to $refname

($rev_type)"

contrib/hooks/post-receive-email +1 -1
 			echo >&2 "***  - no email generated"
-			return 0
+			return 1

This used to "exit 1" before 53cad69 and I agree with the patch that signalling error with "return 1" is the right thing to do here.

contrib/hooks/post-receive-email

Quoted 10 lines
contrib/hooks/post-receive-email +0 -0
 			;;
 	esac
@@ -166,10 +166,10 @@ prep_for_email()
 		esac
 		echo >&2 "*** $config_name is not set so no email will be

sent"

contrib/hooks/post-receive-email +1 -1
 		echo >&2 "*** for $refname update $oldrev->$newrev"
-		return 0
+		return 1

This used to "exit 0" before 53cad69 to cause the program stop before sending mails. Again, I agree with the patch that signalling error is the right thing to do here.

contrib/hooks/post-receive-email

Quoted 4 lines
contrib/hooks/post-receive-email +1 -1
 	fi
 
-	return 1
+	return 0

And this obviously is correct.

Kevin, care to review and Ack? Alan, care to add a few lines of patch description and sign-off?

Thanks.

#4 lore raw
Quoted 44 lines · Junio C Hamano
Quoted 3 lines · Alan Raison
---
  contrib/hooks/post-receive-email |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

No sign-off, no description.

This is a regression introduced by 53cad69 (post-receive-email: ensure sent messages are not empty, 2010-09-10), I think.

contrib/hooks/post-receive-email

Quoted 12 lines
contrib/hooks/post-receive-email +0 -0
index 85724bf..020536d 100755
@@ -150,7 +150,7 @@ prep_for_email()
  			# Anything else (is there anything else?)
  			echo>&2 "*** Unknown type of update to $refname

($rev_type)"
echo>&2 "*** - no email generated"

contrib/hooks/post-receive-email +1 -1
-			return 0
+			return 1

This used to "exit 1" before 53cad69 and I agree with the patch that signalling error with "return 1" is the right thing to do here.

contrib/hooks/post-receive-email

Quoted 10 lines

;;
esac

contrib/hooks/post-receive-email +0 -0
@@ -166,10 +166,10 @@ prep_for_email()
  		esac
  		echo>&2 "*** $config_name is not set so no email will be

sent"
echo>&2 "*** for $refname update $oldrev->$newrev"

contrib/hooks/post-receive-email +1 -1
-		return 0
+		return 1

This used to "exit 0" before 53cad69 to cause the program stop before sending mails. Again, I agree with the patch that signalling error is the right thing to do here.

Quoted 2 lines

fi

Quoted 7 lines

contrib/hooks/post-receive-email

Quoted 2 lines
contrib/hooks/post-receive-email +1 -1
-	return 1
+	return 0

And this obviously is correct.

Kevin, care to review and Ack? Alan, care to add a few lines of patch description and sign-off?

Yeah, this is clearly my breakage; our internal version of this script is so different that it has become hard to backport fixes to the upstream version... or I just did a terrible job of it.

Alan, while you are in there fixing this, there is a remaining 'exit 0' in prep_for_email (at line 147) that should be 'return 1' instead.

Signature · 5 lines
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: [email protected]
Check us out at www.digium.com & www.asterisk.org
#5 lore raw

PATCH 1/1 Corrected return values in prep_for_email;

Quoted 1 line

From ebe98d1c682f268b39a7eaf3ef529accbf0ac61c Mon Sep 17 00:00:00 2001

From: Alan Raison <[email protected]>
Date: Mon, 6 Dec 2010 15:49:21 +0000
Subject: [PATCH] Corrected return values in prep_for_email;

Function was returning 0 for failure and 1 for success which was breaking the logic in the main loop.

Corrected to return 0 for success, 1 for failure. Function now also returns in all cases, rather than exiting.

---
 contrib/hooks/post-receive-email |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/contrib/hooks/post-receive-email
index 85724bf..f99ea95 100755

contrib/hooks/post-receive-email +0 -0
@@ -144,13 +144,13 @@ prep_for_email()
 			short_refname=${refname##refs/remotes/}
 			echo >&2 "*** Push-update of tracking branch,

$refname"
echo >&2 "*** - no email generated."
- exit 0
+ return 1
;;
*)
# Anything else (is there anything else?) echo >&2 "*** Unknown type of update to $refname
($rev_type)"
echo >&2 "*** - no email generated"
- return 0
+ return 1
;;
esac

@@ -166,10 +166,10 @@ prep_for_email()
esac
echo >&2 "*** $config_name is not set so no email will be
sent"
echo >&2 "*** for $refname update $oldrev->$newrev"
- return 0
+ return 1
fi

- return 1
+ return 0
}

#

Signature · 1 line
1.7.3.1.msysgit.0
Acked-by on v1 1/1
#6 lore raw

Re: [PATCH] Corrected return values in prep_for_email;

Quoted 10 lines · Alan Raison

From ebe98d1c682f268b39a7eaf3ef529accbf0ac61c Mon Sep 17 00:00:00 2001
From: Alan Raison<[email protected]>
Date: Mon, 6 Dec 2010 15:49:21 +0000
Subject: [PATCH] Corrected return values in prep_for_email;

Function was returning 0 for failure and 1 for success which was breaking the logic in the main loop.

Corrected to return 0 for success, 1 for failure. Function now also returns in all cases, rather than exiting.

Your commit message will need a Signed-Off-By line, but...

Quoted 41 lines
---
  contrib/hooks/post-receive-email |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
contrib/hooks/post-receive-email +0 -0
index 85724bf..f99ea95 100755
@@ -144,13 +144,13 @@ prep_for_email()
  			short_refname=${refname##refs/remotes/}
  			echo>&2 "*** Push-update of tracking branch,

$refname"
echo>&2 "*** - no email generated."

contrib/hooks/post-receive-email +1 -1
-			exit 0
+			return 1
  			;;
  		*)
  			# Anything else (is there anything else?)
  			echo>&2 "*** Unknown type of update to $refname

($rev_type)"
echo>&2 "*** - no email generated"

contrib/hooks/post-receive-email +1 -1
-			return 0
+			return 1
  			;;
  	esac
@@ -166,10 +166,10 @@ prep_for_email()
  		esac
  		echo>&2 "*** $config_name is not set so no email will be

sent"
echo>&2 "*** for $refname update $oldrev->$newrev"

contrib/hooks/post-receive-email +2 -2
-		return 0
+		return 1
  	fi
 
-	return 1
+	return 0
  }
 
  #
Signature · 5 lines
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: [email protected]
Check us out at www.digium.com & www.asterisk.org
#7 lore raw

PATCH 1/1 Corrected return values in prep_for_email;

In reply to Kevin P. Fleming

Function was returning 0 for failure and 1 for success which was breaking the logic in the main loop.

Corrected to return 0 for success, 1 for failure. Function now also returns in all cases, rather than exiting.

---
 contrib/hooks/post-receive-email |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/contrib/hooks/post-receive-email
index 85724bf..f99ea95 100755

contrib/hooks/post-receive-email +0 -0
@@ -144,13 +144,13 @@ prep_for_email()
 			short_refname=${refname##refs/remotes/}
 			echo >&2 "*** Push-update of tracking branch,

$refname"
echo >&2 "*** - no email generated."
- exit 0
+ return 1
;;
*)
# Anything else (is there anything else?) echo >&2 "*** Unknown type of update to $refname
($rev_type)"
echo >&2 "*** - no email generated"
- return 0
+ return 1
;;
esac

@@ -166,10 +166,10 @@ prep_for_email()
esac
echo >&2 "*** $config_name is not set so no email will be
sent"
echo >&2 "*** for $refname update $oldrev->$newrev"
- return 0
+ return 1
fi

- return 1
+ return 0
}

#

Signature · 1 line
1.7.3.1.msysgit.0
#8 lore raw

Re: [PATCH] Corrected return values in prep_for_email;

Quoted 5 lines · Alan Raison

Function was returning 0 for failure and 1 for success which was breaking the logic in the main loop.

Corrected to return 0 for success, 1 for failure. Function now also returns in all cases, rather than exiting.

Thanks, will apply.

Quoted 2 lines

Just for reference---the order of events is that you signed-off first and then Kevin acked the result, so the above is backwards.

Also your patch was linewrapped, but I can fix it up---no need to resend, but please tell your MUA not to corrupt patches next time.