From: Lucas Seiki Oshiro Date: Fri, 15 Aug 2025 13:55:16 GMT Subject: [GSoC PATCH v10 0/5] repo: declare the repo command Message-ID: <20250815135521.44044-1-lucasseikioshiro@gmail.com> In-Reply-To: <20250610152117.14826-1-lucasseikioshiro@gmail.com> Hi! The only major change in this v10 is that git-repo-info now returns the values following the same order as they were requested instead of sorting the keys. In past versions, the sorting existed for dropping duplicated keys, but after the discussion with Eric, Phillip and Junio, we agreed that returning the values following the keys order was more important than removing the duplications, which weren't exactly a bad thing. Consequently, the duplication checks were also removed. Other minor issues pointed by Eric were also addressed. Thanks! Here's the range-diff versus v9: 1: 3c2ede66be = 1: 6767028da3 repo: declare the repo command 2: b18e74763d ! 2: c44e2d1619 repo: add the field references.format @@ Documentation/git-repo.adoc: COMMANDS the requested data will be returned based on their keys (see "INFO KEYS" section below). ++ -+The returned data is lexicographically sorted by the keys. ++The values are returned in the same order in which their respective keys were ++requested. ++ +The output format consists of key-value pairs one per line using the `=` +character as the delimiter between the key and the value. Values containing +"unusual" characters are quoted as explained for the configuration variable -+`core.quotePath` (see linkgit:git-config[1]). This is the default. ++`core.quotePath` (see linkgit:git-config[1]). + +INFO KEYS +--------- @@ builtin/repo.c return 0; } -+/* repo_info_fields keys should be in lexicographical order */ ++/* repo_info_fields keys must be in lexicographical order */ +static const struct field repo_info_fields[] = { + { "references.format", get_references_format }, +}; @@ builtin/repo.c + return found ? found->get_value : NULL; +} + -+static int qsort_strcmp(const void *va, const void *vb) -+{ -+ const char *a = *(const char **)va; -+ const char *b = *(const char **)vb; -+ -+ return strcmp(a, b); -+} -+ +static int print_fields(int argc, const char **argv, struct repository *repo) +{ + int ret = 0; -+ const char *last = ""; + struct strbuf valbuf = STRBUF_INIT; + struct strbuf quotbuf = STRBUF_INIT; + -+ QSORT(argv, argc, qsort_strcmp); -+ + for (int i = 0; i < argc; i++) { + get_value_fn *get_value; + const char *key = argv[i]; + -+ strbuf_reset(&valbuf); -+ strbuf_reset("buf); -+ -+ if (!strcmp(key, last)) -+ continue; -+ -+ last = key; + get_value = get_value_fn_for_key(key); + + if (!get_value) { @@ builtin/repo.c + continue; + } + ++ strbuf_reset(&valbuf); ++ strbuf_reset("buf); ++ + get_value(repo, &valbuf); + quote_c_style(valbuf.buf, "buf, NULL, 0); + printf("%s=%s\n", key, quotbuf.buf); @@ t/t1900-repo.sh (new) + +# Test whether a key-value pair is correctly returned +# -+# Usage: test_repo_info