Beispiel #1
0
static void wt_status_collect_untracked(struct wt_status *s)
{
	int i;
	struct dir_struct dir;
	struct timeval t_begin;

	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 |=
			DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
	setup_standard_excludes(&dir);

	fill_directory(&dir, s->pathspec);
	for (i = 0; i < dir.nr; i++) {
		struct dir_entry *ent = dir.entries[i];
		if (cache_name_is_other(ent->name, ent->len) &&
		    match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
			string_list_insert(&s->untracked, ent->name);
		free(ent);
	}

	if (s->show_ignored_files) {
		dir.nr = 0;
		dir.flags = DIR_SHOW_IGNORED;
		if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
			dir.flags |= DIR_SHOW_OTHER_DIRECTORIES;
		fill_directory(&dir, s->pathspec);
		for (i = 0; i < dir.nr; i++) {
			struct dir_entry *ent = dir.entries[i];
			if (cache_name_is_other(ent->name, ent->len) &&
			    match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
				string_list_insert(&s->ignored, ent->name);
			free(ent);
		}
	}

	free(dir.entries);

	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);
	}
}
Beispiel #2
0
static void wt_status_print_untracked(struct wt_status *s)
{
    struct dir_struct dir;
    int i;
    int shown_header = 0;
    struct strbuf buf = STRBUF_INIT;

    memset(&dir, 0, sizeof(dir));

    if (!s->untracked) {
        dir.show_other_directories = 1;
        dir.hide_empty_directories = 1;
    }
    setup_standard_excludes(&dir);

    read_directory(&dir, ".", "", 0, NULL);
    for(i = 0; i < dir.nr; i++) {
        struct dir_entry *ent = dir.entries[i];
        if (!cache_name_is_other(ent->name, ent->len))
            continue;
        if (!shown_header) {
            s->workdir_untracked = 1;
            wt_status_print_untracked_header(s);
            shown_header = 1;
        }
        color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
        color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s",
                         quote_path(ent->name, ent->len,
                                    &buf, s->prefix));
    }
    strbuf_release(&buf);
}
Beispiel #3
0
struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
{
	if (!cache_name_is_other(pathname, len))
		return NULL;

	ALLOC_GROW(dir->ignored, dir->ignored_nr+1, dir->ignored_alloc);
	return dir->ignored[dir->ignored_nr++] = dir_entry_new(pathname, len);
}
Beispiel #4
0
static void wt_status_collect_untracked(struct wt_status *s)
{
	int i;
	struct dir_struct dir;
	uint64_t t_begin = getnanotime();

	if (!s->show_untracked_files)
		return;

	memset(&dir, 0, sizeof(dir));
	if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
		dir.flags |=
			DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
	if (s->show_ignored_files)
		dir.flags |= DIR_SHOW_IGNORED_TOO;
	else
		dir.untracked = the_index.untracked;
	setup_standard_excludes(&dir);

	fill_directory(&dir, &s->pathspec);

	for (i = 0; i < dir.nr; i++) {
		struct dir_entry *ent = dir.entries[i];
		if (cache_name_is_other(ent->name, ent->len) &&
		    dir_path_match(ent, &s->pathspec, 0, NULL))
			string_list_insert(&s->untracked, ent->name);
		free(ent);
	}

	for (i = 0; i < dir.ignored_nr; i++) {
		struct dir_entry *ent = dir.ignored[i];
		if (cache_name_is_other(ent->name, ent->len) &&
		    dir_path_match(ent, &s->pathspec, 0, NULL))
			string_list_insert(&s->ignored, ent->name);
		free(ent);
	}

	free(dir.entries);
	free(dir.ignored);
	clear_directory(&dir);

	if (advice_status_u_option)
		s->untracked_in_ms = (getnanotime() - t_begin) / 1000000;
}
Beispiel #5
0
static void show_other_files(struct dir_struct *dir)
{
	int i;

	for (i = 0; i < dir->nr; i++) {
		struct dir_entry *ent = dir->entries[i];
		if (!cache_name_is_other(ent->name, ent->len))
			continue;
		show_dir_entry(tag_other, ent);
	}
}
Beispiel #6
0
static void wt_status_collect_untracked(struct wt_status *s)
{
	int i;
	struct dir_struct dir;

	if (!s->show_untracked_files)
		return;
	memset(&dir, 0, sizeof(dir));
	if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
		dir.flags |=
			DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
	setup_standard_excludes(&dir);

	fill_directory(&dir, s->pathspec);
	for (i = 0; i < dir.nr; i++) {
		struct dir_entry *ent = dir.entries[i];
		if (!cache_name_is_other(ent->name, ent->len))
			continue;
		if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
			continue;
		string_list_insert(&s->untracked, ent->name);
		free(ent);
	}

	if (s->show_ignored_files) {
		dir.nr = 0;
		dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES;
		fill_directory(&dir, s->pathspec);
		for (i = 0; i < dir.nr; i++) {
			struct dir_entry *ent = dir.entries[i];
			if (!cache_name_is_other(ent->name, ent->len))
				continue;
			if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
				continue;
			string_list_insert(&s->ignored, ent->name);
			free(ent);
		}
	}

	free(dir.entries);
}