Post 2.3 cycle (batch #3)
[gitweb.git] / wt-status.c
index 882cfe9fb050efe84e2330b9aea76685c6a7f891..29666d0dbaa5af768aca86f3ca0b644ac9720648 100644 (file)
@@ -128,7 +128,7 @@ void wt_status_prepare(struct wt_status *s)
        s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
        s->use_color = -1;
        s->relative_paths = 1;
-       s->branch = resolve_refdup("HEAD", sha1, 0, NULL);
+       s->branch = resolve_refdup("HEAD", 0, sha1, NULL);
        s->reference = "HEAD";
        s->fp = stdout;
        s->index_file = get_index_file();
@@ -574,14 +574,11 @@ static void wt_status_collect_untracked(struct wt_status *s)
 {
        int i;
        struct dir_struct dir;
-       struct timeval t_begin;
+       uint64_t t_begin = getnanotime();
 
        if (!s->show_untracked_files)
                return;
 
-       if (advice_status_u_option)
-               gettimeofday(&t_begin, NULL);
-
        memset(&dir, 0, sizeof(dir));
        if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
                dir.flags |=
@@ -612,13 +609,8 @@ static void wt_status_collect_untracked(struct wt_status *s)
        free(dir.ignored);
        clear_directory(&dir);
 
-       if (advice_status_u_option) {
-               struct timeval t_end;
-               gettimeofday(&t_end, NULL);
-               s->untracked_in_ms =
-                       (uint64_t)t_end.tv_sec * 1000 + t_end.tv_usec / 1000 -
-                       ((uint64_t)t_begin.tv_sec * 1000 + t_begin.tv_usec / 1000);
-       }
+       if (advice_status_u_option)
+               s->untracked_in_ms = (getnanotime() - t_begin) / 1000000;
 }
 
 void wt_status_collect(struct wt_status *s)
@@ -733,36 +725,30 @@ static void wt_status_print_changed(struct wt_status *s)
 
 static void wt_status_print_submodule_summary(struct wt_status *s, int uncommitted)
 {
-       struct child_process sm_summary;
-       struct argv_array env = ARGV_ARRAY_INIT;
-       struct argv_array argv = ARGV_ARRAY_INIT;
+       struct child_process sm_summary = CHILD_PROCESS_INIT;
        struct strbuf cmd_stdout = STRBUF_INIT;
        struct strbuf summary = STRBUF_INIT;
        char *summary_content;
        size_t len;
 
-       argv_array_pushf(&env, "GIT_INDEX_FILE=%s", s->index_file);
+       argv_array_pushf(&sm_summary.env_array, "GIT_INDEX_FILE=%s",
+                        s->index_file);
 
-       argv_array_push(&argv, "submodule");
-       argv_array_push(&argv, "summary");
-       argv_array_push(&argv, uncommitted ? "--files" : "--cached");
-       argv_array_push(&argv, "--for-status");
-       argv_array_push(&argv, "--summary-limit");
-       argv_array_pushf(&argv, "%d", s->submodule_summary);
+       argv_array_push(&sm_summary.args, "submodule");
+       argv_array_push(&sm_summary.args, "summary");
+       argv_array_push(&sm_summary.args, uncommitted ? "--files" : "--cached");
+       argv_array_push(&sm_summary.args, "--for-status");
+       argv_array_push(&sm_summary.args, "--summary-limit");
+       argv_array_pushf(&sm_summary.args, "%d", s->submodule_summary);
        if (!uncommitted)
-               argv_array_push(&argv, s->amend ? "HEAD^" : "HEAD");
+               argv_array_push(&sm_summary.args, s->amend ? "HEAD^" : "HEAD");
 
-       memset(&sm_summary, 0, sizeof(sm_summary));
-       sm_summary.argv = argv.argv;
-       sm_summary.env = env.argv;
        sm_summary.git_cmd = 1;
        sm_summary.no_stdin = 1;
        fflush(s->fp);
        sm_summary.out = -1;
 
        run_command(&sm_summary);
-       argv_array_clear(&env);
-       argv_array_clear(&argv);
 
        len = strbuf_read(&cmd_stdout, sm_summary.out, 1024);
 
@@ -1154,7 +1140,7 @@ static char *read_and_strip_branch(const char *path)
        if (strbuf_read_file(&sb, git_path("%s", path), 0) <= 0)
                goto got_nothing;
 
-       while (&sb.len && sb.buf[sb.len - 1] == '\n')
+       while (sb.len && sb.buf[sb.len - 1] == '\n')
                strbuf_setlen(&sb, sb.len - 1);
        if (!sb.len)
                goto got_nothing;