Skip to content

Commit 100a4bc

Browse files
committed
Get non branch push working and improve debug logging
1 parent 8e07c21 commit 100a4bc

File tree

4 files changed

+339
-166
lines changed

4 files changed

+339
-166
lines changed

builtin/remote-svn--helper.c

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
static struct index_state svn_index;
1010
static int svn_eol = EOL_UNSET;
11+
static int verbose;
1112

1213
static void trypause(void) {
1314
static int env = -1;
@@ -60,6 +61,8 @@ static int config(const char *key, const char *value, void *dummy) {
6061
return git_default_config(key, value, dummy);
6162
}
6263

64+
static struct strbuf indbg = STRBUF_INIT;
65+
6366
static void read_atom(struct strbuf* buf) {
6467
strbuf_reset(buf);
6568
for (;;) {
@@ -70,6 +73,11 @@ static void read_atom(struct strbuf* buf) {
7073
strbuf_addch(buf, ch);
7174
}
7275
}
76+
77+
if (verbose) {
78+
strbuf_addch(&indbg, ' ');
79+
strbuf_addstr(&indbg, buf->buf);
80+
}
7381
}
7482

7583
static int read_number(void) {
@@ -89,14 +97,39 @@ static int read_number(void) {
8997
}
9098
}
9199

100+
if (verbose)
101+
strbuf_addf(&indbg, " %d", num);
102+
92103
return num;
93104
}
94105

95-
static void read_string(struct strbuf *buf) {
106+
static void read_string(struct strbuf *s) {
96107
int len = read_number();
97-
strbuf_reset(buf);
98-
if (strbuf_fread(buf, len, stdin) != len)
108+
strbuf_reset(s);
109+
if (strbuf_fread(s, len, stdin) != len)
99110
die_errno("read");
111+
112+
if (verbose) {
113+
static struct strbuf qbuf = STRBUF_INIT;
114+
strbuf_addch(&indbg, ':');
115+
strbuf_reset(&qbuf);
116+
117+
if (s->len > 20) {
118+
quote_c_style_counted(s->buf, 20, &qbuf, NULL, 1);
119+
strbuf_add(&indbg, qbuf.buf, qbuf.len);
120+
strbuf_addstr(&indbg, "...");
121+
} else {
122+
quote_c_style_counted(s->buf, s->len, &qbuf, NULL, 1);
123+
strbuf_add(&indbg, qbuf.buf, qbuf.len);
124+
}
125+
}
126+
}
127+
128+
static void read_command(void) {
129+
if (verbose) {
130+
fprintf(stderr, "H-%s\n", indbg.buf);
131+
}
132+
strbuf_reset(&indbg);
100133
}
101134

102135
static void add_dir(const char *name) {
@@ -254,18 +287,24 @@ static void report(const char *ref, const char *gitref) {
254287

255288
struct commit *svn = lookup_commit_reference_by_name(ref);
256289
struct commit *git = svn_commit(svn);
290+
const char *hex;
257291

258292
if (!prefixcmp(gitref, "refs/tags/")) {
259293
strbuf_reset(&buf);
260294
strbuf_addf(&buf, "%s.tag", ref);
261295
if (read_ref(buf.buf, sha1)) {
262296
hashcpy(sha1, git->object.sha1);
263297
}
264-
265-
printf("fetched %s %s\n", sha1_to_hex(sha1), gitref);
298+
hex = sha1_to_hex(sha1);
266299
} else {
267-
printf("fetched %s %s\n", cmt_to_hex(git), gitref);
300+
hex = cmt_to_hex(git);
268301
}
302+
303+
if (verbose) {
304+
fprintf(stderr, "r+ fetched %s %s\n", hex, gitref);
305+
}
306+
307+
printf("fetched %s %s\n", hex, gitref);
269308
}
270309

271310
static void havelog(const char *ref, int rev, const char *logrev) {
@@ -440,27 +479,37 @@ int cmd_remote_svn__helper(int argc, const char **argv, const char *prefix) {
440479
if (!strcmp(cmd.buf, "")) {
441480
break;
442481

482+
} else if (!strcmp(cmd.buf, "verbose")) {
483+
read_command();
484+
verbose = 1;
485+
443486
} else if (!strcmp(cmd.buf, "checkout")) {
444487
int rev;
445488
read_string(&ref);
446489
rev = read_number();
490+
read_command();
491+
447492
checkout(ref.buf, rev);
448493

449494
} else if (!strcmp(cmd.buf, "reset")) {
495+
read_command();
450496
reset();
451497

452498
} else if (!strcmp(cmd.buf, "report")) {
453499
read_string(&ref);
454500
read_string(&gitref);
501+
read_command();
502+
455503
report(ref.buf, gitref.buf);
456504

457505
} else if (!strcmp(cmd.buf, "havelog")) {
458506
int rev;
459507
read_string(&ref);
460508
rev = read_number();
461509
read_atom(&logrev);
462-
strbuf_complete_line(&logrev);
510+
read_command();
463511

512+
strbuf_complete_line(&logrev);
464513
havelog(ref.buf, rev, logrev.buf);
465514

466515
} else if (!strcmp(cmd.buf, "branch")) {
@@ -473,6 +522,7 @@ int cmd_remote_svn__helper(int argc, const char **argv, const char *prefix) {
473522
read_string(&path);
474523
read_string(&ident);
475524
read_string(&msg);
525+
read_command();
476526

477527
branch(copyref.buf, copyrev, ref.buf, rev, path.buf, ident.buf, msg.buf);
478528

@@ -485,16 +535,19 @@ int cmd_remote_svn__helper(int argc, const char **argv, const char *prefix) {
485535
read_string(&path);
486536
read_string(&ident);
487537
read_string(&msg);
538+
read_command();
488539

489540
commit(ref.buf, baserev, rev, path.buf, ident.buf, msg.buf);
490541

491542
} else if (!strcmp(cmd.buf, "add-dir")) {
492543
read_string(&path);
544+
read_command();
493545

494546
add_dir(path.buf);
495547

496548
} else if (!strcmp(cmd.buf, "delete-entry")) {
497549
read_string(&path);
550+
read_command();
498551

499552
remove_path_from_index(&svn_index, path.buf);
500553
remove_path_from_index(&the_index, path.buf);
@@ -504,16 +557,19 @@ int cmd_remote_svn__helper(int argc, const char **argv, const char *prefix) {
504557
read_string(&before);
505558
read_string(&after);
506559
read_string(&diff);
560+
read_command();
507561

508562
change_file(cmd.buf[0] == 'a', path.buf, &diff, before.buf, after.buf);
509563

510564
} else if (!strcmp(cmd.buf, "set-mergeinfo")) {
511565
read_string(&buf);
566+
read_command();
512567

513568
free_svn_mergeinfo(svn_mergeinfo);
514569
svn_mergeinfo = parse_svn_mergeinfo(buf.buf);
515570

516571
} else if (!strcmp(cmd.buf, "test")) {
572+
read_command();
517573
test_svn_mergeinfo();
518574
}
519575

0 commit comments

Comments
 (0)