Skip to content

Commit 534dbe1

Browse files
Merge pull request #100 from jeffhostetler/gvfs-trace2-v3
Trace2 V3 (squash/fixup of V1+V2)
2 parents ab10b47 + f4e9264 commit 534dbe1

45 files changed

Lines changed: 1852 additions & 88 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ TEST_BUILTINS_OBJS += test-string-list.o
756756
TEST_BUILTINS_OBJS += test-submodule-config.o
757757
TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
758758
TEST_BUILTINS_OBJS += test-subprocess.o
759+
TEST_BUILTINS_OBJS += test-trace2.o
759760
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
760761
TEST_BUILTINS_OBJS += test-wildmatch.o
761762
TEST_BUILTINS_OBJS += test-windows-named-pipe.o
@@ -1009,6 +1010,7 @@ LIB_OBJS += trace2/tr2_tgt_event.o
10091010
LIB_OBJS += trace2/tr2_tgt_normal.o
10101011
LIB_OBJS += trace2/tr2_tgt_perf.o
10111012
LIB_OBJS += trace2/tr2_tls.o
1013+
LIB_OBJS += trace2/tr2_verb.o
10121014
LIB_OBJS += trailer.o
10131015
LIB_OBJS += transport.o
10141016
LIB_OBJS += transport-helper.o

builtin/am.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ static int run_post_rewrite_hook(const struct am_state *state)
468468

469469
cp.in = xopen(am_path(state, "rewritten"), O_RDONLY);
470470
cp.stdout_to_stderr = 1;
471+
cp.trace2_hook_name = "post-rewrite";
471472

472473
ret = run_command(&cp);
473474

builtin/checkout.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ static int checkout_paths(const struct checkout_opts *opts,
258258
int errs = 0;
259259
struct lock_file lock_file = LOCK_INIT;
260260

261+
trace2_cmd_subverb(opts->patch_mode ? "patch" : "path");
262+
261263
if (opts->track != BRANCH_TRACK_UNSPECIFIED)
262264
die(_("'%s' cannot be used with updating paths"), "--track");
263265

@@ -930,6 +932,9 @@ static int switch_branches(const struct checkout_opts *opts,
930932
void *path_to_free;
931933
struct object_id rev;
932934
int flag, writeout_error = 0;
935+
936+
trace2_cmd_subverb("branch");
937+
933938
memset(&old_branch_info, 0, sizeof(old_branch_info));
934939
old_branch_info.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
935940
if (old_branch_info.path)
@@ -1159,6 +1164,8 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
11591164
int status;
11601165
struct strbuf branch_ref = STRBUF_INIT;
11611166

1167+
trace2_cmd_subverb("unborn");
1168+
11621169
if (!opts->new_branch)
11631170
die(_("You are on a branch yet to be born"));
11641171
strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);

builtin/commit.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static int opt_parse_porcelain(const struct option *opt, const char *arg, int un
145145
static int do_serialize = 0;
146146
static char *serialize_path = NULL;
147147

148+
static int reject_implicit = 0;
148149
static int do_implicit_deserialize = 0;
149150
static int do_explicit_deserialize = 0;
150151
static char *deserialize_path = NULL;
@@ -202,7 +203,7 @@ static int opt_parse_deserialize(const struct option *opt, const char *arg, int
202203
if (arg) /* override config or stdin */
203204
deserialize_path = xstrdup(arg);
204205
if (deserialize_path && *deserialize_path
205-
&& (access(deserialize_path, R_OK) != 0))
206+
&& (wt_status_deserialize_access(deserialize_path, R_OK) != 0))
206207
die("cannot find serialization file '%s'",
207208
deserialize_path);
208209

@@ -1396,6 +1397,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
13961397
if (v && *v && access(v, R_OK) == 0) {
13971398
do_implicit_deserialize = 1;
13981399
deserialize_path = xstrdup(v);
1400+
} else {
1401+
reject_implicit = 1;
13991402
}
14001403
return 0;
14011404
}
@@ -1552,6 +1555,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15521555
(do_implicit_deserialize || do_explicit_deserialize));
15531556
if (try_deserialize)
15541557
goto skip_init;
1558+
/*
1559+
* If we implicitly received a status cache pathname from the config
1560+
* and the file does not exist, we silently reject it and do the normal
1561+
* status "collect". Fake up some trace2 messages to reflect this and
1562+
* assist post-processors know this case is different.
1563+
*/
1564+
if (!do_serialize && reject_implicit) {
1565+
trace2_cmd_subverb("implicit-deserialize");
1566+
trace2_data_string("status", the_repository, "deserialize/reject",
1567+
"status-cache/access");
1568+
}
15551569

15561570
enable_fscache(0);
15571571
if (status_format != STATUS_FORMAT_PORCELAIN &&
@@ -1595,6 +1609,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
15951609
if (s.relative_paths)
15961610
s.prefix = prefix;
15971611

1612+
trace2_cmd_subverb("deserialize");
15981613
result = wt_status_deserialize(&s, deserialize_path, dw);
15991614
if (result == DESERIALIZE_OK)
16001615
return 0;
@@ -1612,6 +1627,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16121627
fd = -1;
16131628
}
16141629

1630+
trace2_cmd_subverb("collect");
16151631
wt_status_collect(&s);
16161632

16171633
if (0 <= fd)
@@ -1626,6 +1642,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16261642
if (fd_serialize < 0)
16271643
die_errno(_("could not serialize to '%s'"),
16281644
serialize_path);
1645+
trace2_cmd_subverb("serialize");
16291646
wt_status_serialize_v1(fd_serialize, &s);
16301647
close(fd_serialize);
16311648
}

builtin/rebase.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,16 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
10091009
ACTION_EDIT_TODO,
10101010
ACTION_SHOW_CURRENT_PATCH,
10111011
} action = NO_ACTION;
1012+
static const char *action_names[] = {
1013+
N_("undefined"),
1014+
N_("continue"),
1015+
N_("skip"),
1016+
N_("abort"),
1017+
N_("quit"),
1018+
N_("edit_todo"),
1019+
N_("show_current_patch"),
1020+
NULL
1021+
};
10121022
const char *gpg_sign = NULL;
10131023
struct string_list exec = STRING_LIST_INIT_NODUP;
10141024
const char *rebase_merges = NULL;
@@ -1195,6 +1205,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11951205
die(_("The --edit-todo action can only be used during "
11961206
"interactive rebase."));
11971207

1208+
if (trace2_is_enabled()) {
1209+
if (is_interactive(&options))
1210+
trace2_cmd_subverb("interactive");
1211+
else if (exec.nr)
1212+
trace2_cmd_subverb("interactive-exec");
1213+
else
1214+
trace2_cmd_subverb(action_names[action]);
1215+
}
1216+
11981217
switch (action) {
11991218
case ACTION_CONTINUE: {
12001219
struct object_id head;

builtin/receive-pack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed,
694694
proc.argv = argv;
695695
proc.in = -1;
696696
proc.stdout_to_stderr = 1;
697+
proc.trace2_hook_name = hook_name;
698+
697699
if (feed_state->push_options) {
698700
int i;
699701
for (i = 0; i < feed_state->push_options->nr; i++)
@@ -807,6 +809,7 @@ static int run_update_hook(struct command *cmd)
807809
proc.stdout_to_stderr = 1;
808810
proc.err = use_sideband ? -1 : 0;
809811
proc.argv = argv;
812+
proc.trace2_hook_name = "update";
810813

811814
code = start_command(&proc);
812815
if (code)
@@ -1190,6 +1193,7 @@ static void run_update_post_hook(struct command *commands)
11901193
proc.no_stdin = 1;
11911194
proc.stdout_to_stderr = 1;
11921195
proc.err = use_sideband ? -1 : 0;
1196+
proc.trace2_hook_name = "post-update";
11931197

11941198
if (!start_command(&proc)) {
11951199
if (use_sideband)

builtin/reset.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
419419
if (patch_mode) {
420420
if (reset_type != NONE)
421421
die(_("--patch is incompatible with --{hard,mixed,soft}"));
422+
trace2_cmd_subverb("patch-interactive");
422423
return run_add_interactive(rev, "--patch=reset", &pathspec);
423424
}
424425

@@ -435,6 +436,13 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
435436
if (reset_type == NONE)
436437
reset_type = MIXED; /* by default */
437438

439+
if (read_from_stdin)
440+
trace2_cmd_subverb("path-stdin");
441+
else if (pathspec.nr)
442+
trace2_cmd_subverb("path");
443+
else
444+
trace2_cmd_subverb(reset_type_names[reset_type]);
445+
438446
if (reset_type != SOFT && (reset_type != MIXED || get_git_work_tree()))
439447
setup_work_tree();
440448

builtin/worktree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ static int add_worktree(const char *path, const char *refname,
401401
cp.dir = path;
402402
cp.env = env;
403403
cp.argv = NULL;
404+
cp.trace2_hook_name = "post-checkout";
404405
argv_array_pushl(&cp.args, absolute_path(hook),
405406
oid_to_hex(&null_oid),
406407
oid_to_hex(&commit->object.oid),

common-main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ static void restore_sigpipe_to_default(void)
2525

2626
int main(int argc, const char **argv)
2727
{
28+
int result;
29+
2830
/*
2931
* Always open file descriptors 0/1/2 to avoid clobbering files
3032
* in die(). It also avoids messing up when the pipes are dup'ed
@@ -33,7 +35,9 @@ int main(int argc, const char **argv)
3335
sanitize_stdfds();
3436
restore_sigpipe_to_default();
3537

36-
trace2_initialize(argv);
38+
trace2_initialize();
39+
trace2_cmd_start(argv);
40+
trace2_collect_process_info();
3741

3842
git_resolve_executable_dir(argv[0]);
3943

@@ -43,5 +47,9 @@ int main(int argc, const char **argv)
4347

4448
attr_start();
4549

46-
return cmd_main(argc, argv);
50+
result = cmd_main(argc, argv);
51+
52+
trace2_cmd_exit(result);
53+
54+
return result;
4755
}

compat/mingw.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,6 +1945,7 @@ static int try_shell_exec(const char *cmd, char *const *argv)
19451945
return 0;
19461946
prog = path_lookup(interpr, 1);
19471947
if (prog) {
1948+
int exec_id;
19481949
int argc = 0;
19491950
#ifndef _MSC_VER
19501951
const
@@ -1954,14 +1955,16 @@ static int try_shell_exec(const char *cmd, char *const *argv)
19541955
ALLOC_ARRAY(argv2, argc + 1);
19551956
argv2[0] = (char *)cmd; /* full path to the script file */
19561957
memcpy(&argv2[1], &argv[1], sizeof(*argv) * argc);
1958+
exec_id = trace2_exec(prog, argv2);
19571959
pid = mingw_spawnv(prog, argv2, interpr);
19581960
if (pid >= 0) {
19591961
int status;
19601962
if (waitpid(pid, &status, 0) < 0)
19611963
status = 255;
1962-
trace2_exec_result(status);
1964+
trace2_exec_result(exec_id, status);
19631965
exit(status);
19641966
}
1967+
trace2_exec_result(exec_id, -1);
19651968
pid = 1; /* indicate that we tried but failed */
19661969
free(prog);
19671970
free(argv2);
@@ -1974,13 +1977,17 @@ int mingw_execv(const char *cmd, char *const *argv)
19741977
/* check if git_command is a shell script */
19751978
if (!try_shell_exec(cmd, argv)) {
19761979
int pid, status;
1980+
int exec_id;
19771981

1982+
exec_id = trace2_exec(cmd, (const char **)argv);
19781983
pid = mingw_spawnv(cmd, (const char **)argv, NULL);
1979-
if (pid < 0)
1984+
if (pid < 0) {
1985+
trace2_exec_result(exec_id, -1);
19801986
return -1;
1987+
}
19811988
if (waitpid(pid, &status, 0) < 0)
19821989
status = 255;
1983-
trace2_exec_result(status);
1990+
trace2_exec_result(exec_id, status);
19841991
exit(status);
19851992
}
19861993
return -1;

0 commit comments

Comments
 (0)