-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Typedef git_pkt_type and clarify recv_pkt return type #4514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitly much more readable, so I'm very happy with your change overall. Thanks! Just some comments to make it even more readable, even though your changes already go most of the way
if (out != NULL) | ||
*out = pkt; | ||
else | ||
git__free(pkt); | ||
|
||
return pkt_type; | ||
return error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This is our preferred style and definitly easier to handle than the previous interface
src/transports/smart_protocol.c
Outdated
@@ -209,11 +209,11 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec | |||
return 0; | |||
} | |||
|
|||
static int recv_pkt(git_pkt **out, gitno_buffer *buf) | |||
static int recv_pkt(git_pkt **out, git_pkt_type *pkt_type, gitno_buffer *buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name it out_type
instead? Just to make the parameter's intention a bit more clear
src/transports/smart_protocol.c
Outdated
if (pkt_type == GIT_PKT_ACK) { | ||
error = recv_pkt(NULL, &pkt_type, buf); | ||
if (error < 0) { | ||
goto on_error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd propose to make it if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0) goto on_error;
. This would further disentangle handling of errors and the packet type.
src/transports/smart_protocol.c
Outdated
if (pkt_type < 0) { | ||
return pkt_type; | ||
if (error < 0) { | ||
return error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
35c2ce8
to
eb2d9b9
Compare
Rebased against master, and fixed review comments. I stumbled on a (small) memory leak when checking uses of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some places where you're accidentally using spaces instead of tabs. Otherwise it looks fine, I think
src/transports/smart_protocol.c
Outdated
goto on_error; | ||
} else if (pkt_type == GIT_PKT_ACK) { | ||
|
||
if (pkt_type == GIT_PKT_ACK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using spaces instead of tabs here
src/transports/smart_protocol.c
Outdated
return error; | ||
} else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) { | ||
|
||
if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here as well, spaces instead of tab
src/transports/smart_protocol.c
Outdated
if (git_vector_insert(&t->common, pkt) < 0) { | ||
git__free(pkt); | ||
return -1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here ;)
eb2d9b9
to
a2124a2
Compare
a2124a2
to
13a7727
Compare
Fixup-ed spaces into tabs ! |
I like this cleanup, thanks for doing it (and thanks for your patience in getting it merged). |
This is extracted from my WIP shallow/smart-transport branch (a.k.a. shallow clones).
I was very confused by the "error handling" around that function, so hopefully this makes it clearer.