forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sideband: reverse its dependency on pkt-line
A subsequent patch will teach struct packet_reader a new field that, if set, instructs it to interpret read data as multiplexed. This will create a dependency from pkt-line to sideband. To avoid a circular dependency, split recv_sideband() into 2 parts: the reading loop (left in recv_sideband()) and the processing of the contents (in demultiplex_sideband()), and move the former into pkt-line. This reverses the direction of dependency: sideband no longer depends on pkt-line, and pkt-line now depends on sideband. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
1 parent
bc2e795
commit fbd76cd
Showing
4 changed files
with
141 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
#ifndef SIDEBAND_H | ||
#define SIDEBAND_H | ||
|
||
#define SIDEBAND_PROTOCOL_ERROR -2 | ||
#define SIDEBAND_REMOTE_ERROR -1 | ||
enum sideband_type { | ||
SIDEBAND_PROTOCOL_ERROR = -2, | ||
SIDEBAND_REMOTE_ERROR = -1, | ||
SIDEBAND_FLUSH = 0, | ||
SIDEBAND_PRIMARY = 1 | ||
}; | ||
|
||
/* | ||
* Inspects a multiplexed packet read from the remote. If this packet is a | ||
* progress packet and thus should not be processed by the caller, returns 0. | ||
* Otherwise, returns 1, releases scratch, and sets sideband_type. | ||
* | ||
* If this packet is SIDEBAND_PROTOCOL_ERROR, SIDEBAND_REMOTE_ERROR, or a | ||
* progress packet, also prints a message to stderr. | ||
* | ||
* scratch must be a struct strbuf allocated by the caller. It is used to store | ||
* progress messages split across multiple packets. | ||
*/ | ||
int demultiplex_sideband(const char *me, char *buf, int len, | ||
struct strbuf *scratch, | ||
enum sideband_type *sideband_type); | ||
|
||
int recv_sideband(const char *me, int in_stream, int out); | ||
void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max); | ||
|
||
#endif |