Пример #1
0
Файл: add.c Проект: AlmirUa/git
/*
 * Checks the index to see whether any path in pathspec refers to
 * something inside a submodule.  If so, dies with an error message.
 */
static void treat_gitlinks(const char **pathspec)
{
	int i;

	if (!pathspec || !*pathspec)
		return;

	for (i = 0; pathspec[i]; i++)
		pathspec[i] = check_path_for_gitlink(pathspec[i]);
}
Пример #2
0
static int check_ignore(const char *prefix, const char **pathspec)
{
	struct dir_struct dir;
	const char *path, *full_path;
	char *seen;
	int num_ignored = 0, dtype = DT_UNKNOWN, i;
	struct exclude *exclude;

	/* read_cache() is only necessary so we can watch out for submodules. */
	if (read_cache() < 0)
		die(_("index file corrupt"));

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

	if (!pathspec || !*pathspec) {
		if (!quiet)
			fprintf(stderr, "no pathspec given.\n");
		return 0;
	}

	/*
	 * look for pathspecs matching entries in the index, since these
	 * should not be ignored, in order to be consistent with
	 * 'git status', 'git add' etc.
	 */
	seen = find_pathspecs_matching_against_index(pathspec);
	for (i = 0; pathspec[i]; i++) {
		path = pathspec[i];
		full_path = prefix_path(prefix, prefix
					? strlen(prefix) : 0, path);
		full_path = check_path_for_gitlink(full_path);
		die_if_path_beyond_symlink(full_path, prefix);
		if (!seen[i]) {
			exclude = last_exclude_matching(&dir, full_path, &dtype);
			if (exclude) {
				if (!quiet)
					output_exclude(path, exclude);
				num_ignored++;
			}
		}
	}
	free(seen);
	clear_directory(&dir);

	return num_ignored;
}