* [PATCH] git-credential-netrc: fix uninitialized warning
@ 2013-10-08 14:34 Ted Zlatanov
2013-10-08 19:41 ` Jonathan Nieder
0 siblings, 1 reply; 7+ messages in thread
From: Ted Zlatanov @ 2013-10-08 14:34 UTC (permalink / raw)
To: git
Simple patch to avoid unitialized warning and log what we'll do.
---
contrib/credential/netrc/git-credential-netrc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc
index 6c51c43..13e537b 100755
--- a/contrib/credential/netrc/git-credential-netrc
+++ b/contrib/credential/netrc/git-credential-netrc
@@ -369,7 +369,10 @@ sub find_netrc_entry {
{
my $entry_text = join ', ', map { "$_=$entry->{$_}" } keys %$entry;
foreach my $check (sort keys %$query) {
- if (defined $query->{$check}) {
+ if (!defined $entry->{$check}) {
+ log_debug("OK: entry has no $check token, so any value satisfies check $check");
+ }
+ elsif (defined $query->{$check}) {
log_debug("compare %s [%s] to [%s] (entry: %s)",
$check,
$entry->{$check},
--
1.8.1.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 14:34 [PATCH] git-credential-netrc: fix uninitialized warning Ted Zlatanov
@ 2013-10-08 19:41 ` Jonathan Nieder
2013-10-08 19:55 ` Ted Zlatanov
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2013-10-08 19:41 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: git
Hi,
Ted Zlatanov wrote:
> Simple patch to avoid unitialized warning and log what we'll do.
Sign-off?
[...]
> --- a/contrib/credential/netrc/git-credential-netrc
> +++ b/contrib/credential/netrc/git-credential-netrc
> @@ -369,7 +369,10 @@ sub find_netrc_entry {
> {
> my $entry_text = join ', ', map { "$_=$entry->{$_}" } keys %$entry;
> foreach my $check (sort keys %$query) {
> - if (defined $query->{$check}) {
> + if (!defined $entry->{$check}) {
> + log_debug("OK: entry has no $check token, so any value satisfies check $check");
> + }
> + elsif (defined $query->{$check}) {
Style: elsewhere this file seems to use cuddled elses:
} elsif (...) {
Or more simply, would it make sense to wrap both 'defined' checks into
a single "if", like so?
if (defined $entry->{$check} && defined $query->{$check}) {
...
} else {
log_debug(...);
}
Thanks and hope that helps,
Jonathan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 19:41 ` Jonathan Nieder
@ 2013-10-08 19:55 ` Ted Zlatanov
2013-10-08 19:58 ` Stefan Beller
2013-10-08 20:02 ` Jonathan Nieder
0 siblings, 2 replies; 7+ messages in thread
From: Ted Zlatanov @ 2013-10-08 19:55 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
On Tue, 8 Oct 2013 12:41:47 -0700 Jonathan Nieder <jrnieder@gmail.com> wrote:
JN> Ted Zlatanov wrote:
>> Simple patch to avoid unitialized warning and log what we'll do.
JN> Sign-off?
I didn't realize it was a requirement, must I?
JN> [...]
>> --- a/contrib/credential/netrc/git-credential-netrc
>> +++ b/contrib/credential/netrc/git-credential-netrc
>> @@ -369,7 +369,10 @@ sub find_netrc_entry {
>> {
>> my $entry_text = join ', ', map { "$_=$entry->{$_}" } keys %$entry;
>> foreach my $check (sort keys %$query) {
>> - if (defined $query->{$check}) {
>> + if (!defined $entry->{$check}) {
>> + log_debug("OK: entry has no $check token, so any value satisfies check $check");
>> + }
>> + elsif (defined $query->{$check}) {
JN> Style: elsewhere this file seems to use cuddled elses:
JN> } elsif (...) {
Ah, thanks, I missed that.
JN> Or more simply, would it make sense to wrap both 'defined' checks into
JN> a single "if", like so?
JN> if (defined $entry->{$check} && defined $query->{$check}) {
JN> ...
JN> } else {
JN> log_debug(...);
JN> }
I prefer the explicit version because we can issue a more precise
log_debug message.
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 19:55 ` Ted Zlatanov
@ 2013-10-08 19:58 ` Stefan Beller
2013-10-08 20:04 ` Ted Zlatanov
2013-10-08 20:02 ` Jonathan Nieder
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Beller @ 2013-10-08 19:58 UTC (permalink / raw)
To: Ted Zlatanov, Jonathan Nieder; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 242 bytes --]
On 10/08/2013 09:55 PM, Ted Zlatanov wrote:
> JN> Sign-off?
>
> I didn't realize it was a requirement, must I?
Yes, this is a requirement. See Documentation/SubmittingPatches
to read what signing off actually means here.
Stefan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 19:55 ` Ted Zlatanov
2013-10-08 19:58 ` Stefan Beller
@ 2013-10-08 20:02 ` Jonathan Nieder
2013-10-08 20:12 ` Ted Zlatanov
1 sibling, 1 reply; 7+ messages in thread
From: Jonathan Nieder @ 2013-10-08 20:02 UTC (permalink / raw)
To: Ted Zlatanov; +Cc: git
Ted Zlatanov wrote:
> On Tue, 8 Oct 2013 12:41:47 -0700 Jonathan Nieder <jrnieder@gmail.com> wrote:
> JN> Ted Zlatanov wrote:
>>> Simple patch to avoid unitialized warning and log what we'll do.
> JN> Sign-off?
>
> I didn't realize it was a requirement, must I?
See Documentation/SubmittingPatches, section '(5) Sign your work'
for what this means.
If you just forgot to sign off, that's fine and I can forge it or go
without. If you are unable to sign off because you don't have the
right to submit the change under an open source license, I'd be a bit
worried going forward.
[...]
> JN> Or more simply, would it make sense to wrap both 'defined' checks into
> JN> a single "if", like so?
>
> JN> if (defined $entry->{$check} && defined $query->{$check}) {
> JN> ...
> JN> } else {
> JN> log_debug(...);
> JN> }
>
> I prefer the explicit version because we can issue a more precise
> log_debug message.
That's fine with me.
After this patch, the code looks like
if (!defined $entry->{$check}) {
log_debug(...);
} elsif (defined $query->{$check}) {
...
} else {
log_debug(...);
}
As a small nit, wouldn't it be more readable with the two !defined()
cases together?
if (!defined $entry->{$check}) {
...
} elsif (!defined $query->{$check}) {
...
} else {
...
}
Thanks again.
Jonathan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 19:58 ` Stefan Beller
@ 2013-10-08 20:04 ` Ted Zlatanov
0 siblings, 0 replies; 7+ messages in thread
From: Ted Zlatanov @ 2013-10-08 20:04 UTC (permalink / raw)
To: Stefan Beller; +Cc: Jonathan Nieder, git
On Tue, 08 Oct 2013 21:58:41 +0200 Stefan Beller <stefanbeller@googlemail.com> wrote:
SB> On 10/08/2013 09:55 PM, Ted Zlatanov wrote:
JN> Sign-off?
>>
>> I didn't realize it was a requirement, must I?
SB> Yes, this is a requirement. See Documentation/SubmittingPatches
SB> to read what signing off actually means here.
OK, I didn't realize it was. Thanks for explaining.
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] git-credential-netrc: fix uninitialized warning
2013-10-08 20:02 ` Jonathan Nieder
@ 2013-10-08 20:12 ` Ted Zlatanov
0 siblings, 0 replies; 7+ messages in thread
From: Ted Zlatanov @ 2013-10-08 20:12 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
On Tue, 8 Oct 2013 13:02:35 -0700 Jonathan Nieder <jrnieder@gmail.com> wrote:
JN> Ted Zlatanov wrote:
>> On Tue, 8 Oct 2013 12:41:47 -0700 Jonathan Nieder <jrnieder@gmail.com> wrote:
JN> Ted Zlatanov wrote:
>>>> Simple patch to avoid unitialized warning and log what we'll do.
JN> Sign-off?
>>
>> I didn't realize it was a requirement, must I?
JN> See Documentation/SubmittingPatches, section '(5) Sign your work'
JN> for what this means.
JN> If you just forgot to sign off, that's fine and I can forge it or go
JN> without. If you are unable to sign off because you don't have the
JN> right to submit the change under an open source license, I'd be a bit
JN> worried going forward.
Right, I got it. Sorry, I didn't know that applied to trivial patches.
JN> After this patch, the code looks like
JN> if (!defined $entry->{$check}) {
JN> log_debug(...);
JN> } elsif (defined $query->{$check}) {
JN> ...
JN> } else {
JN> log_debug(...);
JN> }
JN> As a small nit, wouldn't it be more readable with the two !defined()
JN> cases together?
JN> if (!defined $entry->{$check}) {
JN> ...
JN> } elsif (!defined $query->{$check}) {
JN> ...
JN> } else {
JN> ...
JN> }
Because of way the "next ENTRY" line comes out, I like my way slightly
better, but honestly it's fine either way :) If you like, go ahead and
commit the rewrite the way it works for you, I have no objections at all.
Ted
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-08 20:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-08 14:34 [PATCH] git-credential-netrc: fix uninitialized warning Ted Zlatanov
2013-10-08 19:41 ` Jonathan Nieder
2013-10-08 19:55 ` Ted Zlatanov
2013-10-08 19:58 ` Stefan Beller
2013-10-08 20:04 ` Ted Zlatanov
2013-10-08 20:02 ` Jonathan Nieder
2013-10-08 20:12 ` Ted Zlatanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).