Skip to content

Commit 81c634e

Browse files
larsxschneidergitster
authored andcommitted
pkt-line: rename packet_write() to packet_write_fmt()
packet_write() should be called packet_write_fmt() because it is a printf-like function that takes a format string as first parameter. packet_write_fmt() should be used for text strings only. Arbitrary binary data should use a new packet_write() function that is introduced in a subsequent patch. Suggested-by: Junio C Hamano <[email protected]> Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ac2fbaa commit 81c634e

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

builtin/archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ static int run_remote_archiver(int argc, const char **argv,
4747
if (name_hint) {
4848
const char *format = archive_format_from_filename(name_hint);
4949
if (format)
50-
packet_write(fd[1], "argument --format=%s\n", format);
50+
packet_write_fmt(fd[1], "argument --format=%s\n", format);
5151
}
5252
for (i = 1; i < argc; i++)
53-
packet_write(fd[1], "argument %s\n", argv[i]);
53+
packet_write_fmt(fd[1], "argument %s\n", argv[i]);
5454
packet_flush(fd[1]);
5555

5656
buf = packet_read_line(fd[0], NULL);

builtin/receive-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
224224
static void show_ref(const char *path, const unsigned char *sha1)
225225
{
226226
if (sent_capabilities) {
227-
packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
227+
packet_write_fmt(1, "%s %s\n", sha1_to_hex(sha1), path);
228228
} else {
229229
struct strbuf cap = STRBUF_INIT;
230230

@@ -239,7 +239,7 @@ static void show_ref(const char *path, const unsigned char *sha1)
239239
if (advertise_push_options)
240240
strbuf_addstr(&cap, " push-options");
241241
strbuf_addf(&cap, " agent=%s", git_user_agent_sanitized());
242-
packet_write(1, "%s %s%c%s\n",
242+
packet_write_fmt(1, "%s %s%c%s\n",
243243
sha1_to_hex(sha1), path, 0, cap.buf);
244244
strbuf_release(&cap);
245245
sent_capabilities = 1;

builtin/remote-ext.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ static void send_git_request(int stdin_fd, const char *serv, const char *repo,
128128
const char *vhost)
129129
{
130130
if (!vhost)
131-
packet_write(stdin_fd, "%s %s%c", serv, repo, 0);
131+
packet_write_fmt(stdin_fd, "%s %s%c", serv, repo, 0);
132132
else
133-
packet_write(stdin_fd, "%s %s%chost=%s%c", serv, repo, 0,
133+
packet_write_fmt(stdin_fd, "%s %s%chost=%s%c", serv, repo, 0,
134134
vhost, 0);
135135
}
136136

builtin/upload-archive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)
8888
writer.git_cmd = 1;
8989
if (start_command(&writer)) {
9090
int err = errno;
91-
packet_write(1, "NACK unable to spawn subprocess\n");
91+
packet_write_fmt(1, "NACK unable to spawn subprocess\n");
9292
die("upload-archive: %s", strerror(err));
9393
}
9494

95-
packet_write(1, "ACK\n");
95+
packet_write_fmt(1, "ACK\n");
9696
packet_flush(1);
9797

9898
while (1) {

connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ struct child_process *git_connect(int fd[2], const char *url,
730730
* Note: Do not add any other headers here! Doing so
731731
* will cause older git-daemon servers to crash.
732732
*/
733-
packet_write(fd[1],
733+
packet_write_fmt(fd[1],
734734
"%s %s%chost=%s%c",
735735
prog, path, 0,
736736
target_host, 0);

daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int daemon_error(const char *dir, const char *msg)
281281
{
282282
if (!informative_errors)
283283
msg = "access denied or repository not exported";
284-
packet_write(1, "ERR %s: %s", msg, dir);
284+
packet_write_fmt(1, "ERR %s: %s", msg, dir);
285285
return -1;
286286
}
287287

http-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static void get_info_refs(struct strbuf *hdr, char *arg)
464464
hdr_str(hdr, content_type, buf.buf);
465465
end_headers(hdr);
466466

467-
packet_write(1, "# service=git-%s\n", svc->name);
467+
packet_write_fmt(1, "# service=git-%s\n", svc->name);
468468
packet_flush(1);
469469

470470
argv[0] = svc->name;

pkt-line.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void format_packet(struct strbuf *out, const char *fmt, va_list args)
118118
packet_trace(out->buf + orig_len + 4, n - 4, 1);
119119
}
120120

121-
void packet_write(int fd, const char *fmt, ...)
121+
void packet_write_fmt(int fd, const char *fmt, ...)
122122
{
123123
static struct strbuf buf = STRBUF_INIT;
124124
va_list args;

pkt-line.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* side can't, we stay with pure read/write interfaces.
2121
*/
2222
void packet_flush(int fd);
23-
void packet_write(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
23+
void packet_write_fmt(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
2424
void packet_buf_flush(struct strbuf *buf);
2525
void packet_buf_write(struct strbuf *buf, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
2626

shallow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *c
260260
{
261261
int fd = *(int *)cb;
262262
if (graft->nr_parent == -1)
263-
packet_write(fd, "shallow %s\n", oid_to_hex(&graft->oid));
263+
packet_write_fmt(fd, "shallow %s\n", oid_to_hex(&graft->oid));
264264
return 0;
265265
}
266266

0 commit comments

Comments
 (0)