Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] all: new command used for multi-repo operations

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:51

Lars Hjemli [off-list ref] writes:
+static struct option builtin_all_options[] = {
+	OPT_BOOLEAN('c', "clean", &only_clean, N_("only show clean repositories")),
+	OPT_BOOLEAN('d', "dirty", &only_dirty, N_("only show dirty repositories")),
+	OPT_END(),
+};
If you were to go in the OPT_SET_INT route, that would give users
the usual "last one wins" semantics, e.g.

	$ git for-each-repo --clean --dirty

will look for only dirty repositories.  For completeness, we would
probably want "all" to defeat either of them, i.e.

	$ git for-each-repo --clean --all
+static int walk(struct strbuf *path, int argc, const char **argv)
+{
+	DIR *dir;
+	struct dirent *ent;
+	size_t len;
+
+	dir = opendir(path->buf);
+	if (!dir)
+		return errno;
+	strbuf_addstr(path, "/");
+	len = path->len;
+	while ((ent = readdir(dir))) {
+		if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
+			continue;
+		if (!strcmp(ent->d_name, ".git")) {
This only looks for the top of working tree.  Have you considered if
this "iterate over directories and list git repositories in them"
may be useful for collection of bare repositories, and if it is, how
to go about implementing the discovery process?
+		if (ent->d_type != DT_DIR)
+			continue;
I think this is wrong.

On platforms that need a NO_D_TYPE_IN_DIRENT build, your compilation
may fail here (you would need to lstat() it yourself).  See how
dir.c does this without ugly #ifdef's in the code, especially around
the use of get_dtype() and DTYPE() macro.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help