summaryrefslogtreecommitdiff
path: root/contrib
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'sg/retire-unused-cocci'Junio C Hamano2023-05-153-170/+0
|\ | | | | | | | | | | | | Retire a rather expensive-to-run Coccinelle check patch. * sg/retire-unused-cocci: cocci: remove 'unused.cocci'
| * cocci: remove 'unused.cocci'SZEDER Gábor2023-04-203-170/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When 'unused.cocci' was added in 4f40f6cb73 (cocci: add and apply a rule to find "unused" strbufs, 2022-07-05) it found three unused strbufs, and when it was generalized in the next commit it managed to find an unused string_list as well. That's four unused variables in over 17 years, so apparently we rarely make this mistake. Unfortunately, applying 'unused.cocci' is quite expensive, e.g. it increases the from-scratch runtime of 'make coccicheck' by over 5:30 minutes or over 160%: $ make -s cocciclean $ time make -s coccicheck * new spatch flags real 8m56.201s user 0m0.420s sys 0m0.406s $ rm contrib/coccinelle/unused.cocci contrib/coccinelle/tests/unused.* $ make -s cocciclean $ time make -s coccicheck * new spatch flags real 3m23.893s user 0m0.228s sys 0m0.247s That's a lot of runtime spent for not much in return, and arguably an unused struct instance sneaking in is not that big of a deal to justify the significantly increased runtime. Remove 'unused.cocci', because we are not getting our CPU cycles' worth. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'js/subtree-fully-spelt-quiet-and-debug-options'Junio C Hamano2023-05-151-2/+2
|\ \ | | | | | | | | | | | | | | | | | | "git subtree" (in contrib/) update. * js/subtree-fully-spelt-quiet-and-debug-options: subtree: support long global flags
| * | subtree: support long global flagsJosh Soref2023-05-081-2/+2
| | | | | | | | | | | | | | | | | | | | | The documentation at e75d1da38a claimed support, but it was never present Signed-off-by: Josh Soref <jsoref@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'mh/credential-password-expiry-wincred'Junio C Hamano2023-05-111-2/+23
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach the recently invented "password expiry time" trait to the wincred credential helper. * mh/credential-password-expiry-wincred: credential/wincred: store password_expiry_utc
| * | | credential/wincred: store password_expiry_utcM Hickford2023-04-031-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This attribute is important when storing OAuth credentials which may expire after as little as one hour. d208bfdf (credential: new attribute password_expiry_utc, 2023-02-18) added support for this attribute in general so that individual credential backend like wincred can use it. Signed-off-by: M Hickford <mirth.hickford@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'mh/use-wincred-from-system'Junio C Hamano2023-05-111-60/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code clean-up. * mh/use-wincred-from-system: credential/wincred: include wincred.h
| * | | | credential/wincred: include wincred.hM Hickford2023-03-271-60/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Delete redundant definitions. Mingw-w64 has wincred.h since 2007 [1]. [1] https://github.com/mingw-w64/mingw-w64/blob/9d937a7f4f766f903c9433044f77bfa97a0bc1d8/mingw-w64-headers/include/wincred.h Signed-off-by: M Hickford <mirth.hickford@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Merge branch 'tb/credential-long-lines'Junio C Hamano2023-05-107-511/+32
|\ \ \ \ | |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation of credential helpers used fgets() over fixed size buffers to read protocol messages, causing the remainder of the folded long line to trigger unexpected behaviour, which has been corrected. * tb/credential-long-lines: contrib/credential: embiggen fixed-size buffer in wincred contrib/credential: avoid fixed-size buffer in libsecret contrib/credential: .gitignore libsecret build artifacts contrib/credential: remove 'gnome-keyring' credential helper contrib/credential: avoid fixed-size buffer in osxkeychain t/lib-credential.sh: ensure credential helpers handle long headers credential.c: store "wwwauth[]" values in `credential_read()`
| * | | contrib/credential: embiggen fixed-size buffer in wincredTaylor Blau2023-05-011-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As in previous commits, harden the wincred credential helper against the aforementioned protocol injection attack. Unlike the approached used for osxkeychain and libsecret, where a fixed-size buffer was replaced with `getline()`, we must take a different approach here. There is no `getline()` equivalent in Windows, and the function is not available to us with ordinary compiler settings. Instead, allocate a larger (still fixed-size) buffer in which to process each line. The value of 100 KiB is chosen to match the maximum-length header that curl will allow, CURL_MAX_HTTP_HEADER. To ensure that we are reading complete lines at a time, and that we aren't susceptible to a similar injection attack (albeit with more padding), ensure that each read terminates at a newline (i.e., that no line is more than 100 KiB long). Note that it isn't sufficient to turn the old loop into something like: while (len && strchr("\r\n", buf[len - 1])) { buf[--len] = 0; ends_in_newline = 1; } because if an attacker sends something like: [aaaaa.....]\r host=example.com\r\n the credential helper would fill its buffer after reading up through the first '\r', call fgets() again, and then see "host=example.com\r\n" on its line. Note that the original code was written in a way that would trim an arbitrary number of "\r" and "\n" from the end of the string. We should get only a single "\n" (since the point of `fgets()` is to return the buffer to us when it sees one), and likewise would not expect to see more than one associated "\r". The new code trims a single "\r\n", which matches the original intent. [1]: https://curl.se/libcurl/c/CURLOPT_HEADERFUNCTION.html Tested-by: Matthew John Cheetham <mjcheetham@outlook.com> Helped-by: Matthew John Cheetham <mjcheetham@outlook.com> Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | contrib/credential: avoid fixed-size buffer in libsecretTaylor Blau2023-05-011-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The libsecret credential helper reads the newline-delimited protocol stream one line at a time by repeatedly calling fgets() into a fixed-size buffer, and is thus affected by the vulnerability described in the previous commit. To mitigate this attack, avoid using a fixed-size buffer, and instead rely on getline() to allocate a buffer as large as necessary to fit the entire content of the line, preventing any protocol injection. In most parts of Git we don't assume that every platform has getline(). But libsecret is primarily used on Linux, where we do already assume it (using a knob in config.mak.uname). POSIX also added getline() in 2008, so we'd expect other recent Unix-like operating systems to have it (e.g., FreeBSD also does). Note that the buffer was already allocated on the heap in this case, but we'll swap `g_free()` for `free()`, since it will now be allocated by the system `getline()`, rather than glib's `g_malloc()`. Tested-by: Jeff King <peff@peff.net> Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | contrib/credential: .gitignore libsecret build artifactsTaylor Blau2023-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The libsecret credential helper does not mark its build artifact as ignored, so running "make" results in a dirty working tree. Mark the "git-credential-libsecret" binary as ignored to avoid the above. Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | contrib/credential: remove 'gnome-keyring' credential helperTaylor Blau2023-05-013-496/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libgnome-keyring was deprecated in 2014 (in favor of libsecret), more than nine years ago [1]. The credential helper implemented using libgnome-keyring has had a small handful of commits since 2013, none of which implemented or changed any functionality. The last commit to do substantial work in this area was 15f7221686 (contrib/git-credential-gnome-keyring.c: support really ancient gnome-keyring, 2013-09-23), just shy of nine years ago. This credential helper suffers from the same `fgets()`-related injection attack (using the new "wwwauth[]" feature) as in the previous commit. Instead of patching it, let's remove this helper as deprecated. [1]: https://mail.gnome.org/archives/commits-list/2014-January/msg01585.html Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | contrib/credential: avoid fixed-size buffer in osxkeychainTaylor Blau2023-05-011-3/+7
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macOS Keychain-based credential helper reads the newline-delimited protocol stream one line at a time by repeatedly calling fgets() into a fixed-size buffer, and is thus affected by the vulnerability described in the previous commit. To mitigate this attack, avoid using a fixed-size buffer, and instead rely on getline() to allocate a buffer as large as necessary to fit the entire content of the line, preventing any protocol injection. We solved a similar problem in a5bb10fd5e (config: avoid fixed-sized buffer when renaming/deleting a section, 2023-04-06) by switching to strbuf_getline(). We can't do that here because the contrib helpers do not link with the rest of Git, and so can't use a strbuf. But we can use the system getline() directly, which works similarly. In most parts of Git we don't assume that every platform has getline(). But this helper is run only on OS X, and that platform added support in 10.7 ("Lion") which was released in 2011. Tested-by: Taylor Blau <me@ttaylorr.com> Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'ek/completion-use-read-r-to-read-literally'Junio C Hamano2023-05-021-1/+1
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | The completion script used to use bare "read" without the "-r" option to read the contents of various state files, which risked getting confused with backslashes in them. This has been corrected. * ek/completion-use-read-r-to-read-literally: completion: suppress unwanted unescaping of `read`
| * | completion: suppress unwanted unescaping of `read`Edwin Kofler2023-04-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `__git_eread`, which reads the first line from the file, calls the `read` builtin without passing the flag option `-r`. When the `read` builtin is called without the flag `-r`, it processes the backslash escaping in the text that it reads. For this reason, it is generally considered the best practice to always use the `read` builtin with flag `-r` unless one intensionally processes the backslash escaping. For the present case in git-prompt.sh, in fact, all the occurrences of the calls of `__git_eread` intend to read the literal content of the first lines. To make it read the first line literally, pass the flag `-r` to the `read` builtin in the function `__git_eread`. Signed-off-by: Edwin Kofler <edwin@kofler.dev> Signed-off-by: Koichi Murase <myoga.murase@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'ab/remove-implicit-use-of-the-repository'Junio C Hamano2023-04-062-128/+123
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code clean-up around the use of the_repository. * ab/remove-implicit-use-of-the-repository: libs: use "struct repository *" argument, not "the_repository" post-cocci: adjust comments for recent repo_* migration cocci: apply the "revision.h" part of "the_repository.pending" cocci: apply the "rerere.h" part of "the_repository.pending" cocci: apply the "refs.h" part of "the_repository.pending" cocci: apply the "promisor-remote.h" part of "the_repository.pending" cocci: apply the "packfile.h" part of "the_repository.pending" cocci: apply the "pretty.h" part of "the_repository.pending" cocci: apply the "object-store.h" part of "the_repository.pending" cocci: apply the "diff.h" part of "the_repository.pending" cocci: apply the "commit.h" part of "the_repository.pending" cocci: apply the "commit-reach.h" part of "the_repository.pending" cocci: apply the "cache.h" part of "the_repository.pending" cocci: add missing "the_repository" macros to "pending" cocci: sort "the_repository" rules by header cocci: fix incorrect & verbose "the_repository" rules cocci: remove dead rule from "the_repository.pending.cocci"
| * | | cocci: apply the "revision.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-14/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "revision.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "rerere.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "rerere.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "refs.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "refs.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "promisor-remote.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "promisor-remote.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "packfile.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "packfile.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "pretty.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "pretty.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "object-store.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "object-store.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "diff.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "diff.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "commit.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "commit.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "commit-reach.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "commit-reach.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: apply the "cache.h" part of "the_repository.pending"Ævar Arnfjörð Bjarmason2023-03-282-37/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apply the part of "the_repository.pending.cocci" pertaining to "cache.h". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: add missing "the_repository" macros to "pending"Ævar Arnfjörð Bjarmason2023-03-281-0/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case of diff.h, rerere.h and revision.h the macros were added in [1], [2] and [3] when "the_repository.pending.cocci" didn't exist. None of the subsequently added migration rules covered them. Let's add those missing rules. In the case of macros in "cache.h", "commit.h", "packfile.h", "promisor-remote.h" and "refs.h" those aren't guarded by "NO_THE_REPOSITORY_COMPATIBILITY_MACROS", but they're also macros that add "the_repository" as the first argument, so we should migrate away from them. 1. 2abf3503854 (revision.c: remove implicit dependency on the_index, 2018-09-21) 2. e6757652350 (diff.c: remove implicit dependency on the_index, 2018-09-21) 3. 35843b1123e (rerere.c: remove implicit dependency on the_index, 2018-09-21) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: sort "the_repository" rules by headerÆvar Arnfjörð Bjarmason2023-03-281-15/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sort the "the_repository.pending.cocci" file by which header the macros are in, and add a comment to that effect in front of the rules. This will make subsequent commits easier to follow, as we'll be applying these rules on a header-by-header basis. Once we've fully applied "the_repository.pending.cocci" we'll keep this rules around for a while in "the_repository.cocci", to help any outstanding topics and out-of-tree code to resolve textual or semantic conflicts with these changes, but eventually we'll remove the "the_repository.cocci" as a follow-up. So even if some of these functions are subsequently moved and/or split into other or new headers there's no risk of this becoming stale, if and when that happens the we should be removing these rules anyway. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: fix incorrect & verbose "the_repository" rulesÆvar Arnfjörð Bjarmason2023-03-281-114/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When these rules started being added in [1] they didn't use a ";" after the ")", and would thus catch uses of these macros within expressions. But as of [2] the new additions were broken in that they'd only match a subset of the users of these macros. Rather than narrowly fixing that, let's have these use the much less verbose pattern introduced in my recent [3]: There's no need to exhaustively enumerate arguments if we use the "..." syntax. This means that we can fold all of these different rules into one. 1. afd69dcc219 (object-store: prepare read_object_file to deal with any repo, 2018-11-13) 2. 21a9651ba3f (commit-reach: prepare get_merge_bases to handle any repo, 2018-11-13) 3. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | cocci: remove dead rule from "the_repository.pending.cocci"Ævar Arnfjörð Bjarmason2023-03-281-8/+0
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "parse_commit_gently" macro went away in [1], so we don't need to carry this for its migration. 1. ea3f7e598c8 (revision: use repository from rev_info when parsing commits, 2020-06-23) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'fc/completion-colors-do-not-need-prompt-command'Junio C Hamano2023-03-281-12/+7
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | | | | Lift the limitation that colored prompts can only be used with PROMPT_COMMAND mode. * fc/completion-colors-do-not-need-prompt-command: completion: prompt: use generic colors
| * | completion: prompt: use generic colorsFelipe Contreras2023-03-161-12/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the prompt command mode was introduced in 1bfc51ac81 (Allow __git_ps1 to be used in PROMPT_COMMAND, 2012-10-10), the assumption was that it was necessary in order to properly add colors to PS1 in bash, but this wasn't true. It's true that the \[ \] markers add the information needed to properly calculate the width of the prompt, and they have to be added directly to PS1, a function returning them doesn't work. But that is because bash coverts the \[ \] markers in PS1 to \001 \002, which is what readline ultimately needs in order to calculate the width. We don't need bash to do this conversion, we can use \001 \002 ourselves, and then the prompt command mode is not necessary to display colors. This is what functions returning colors are supposed to do [1]. [1] http://mywiki.wooledge.org/BashFAQ/053 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Tested-by: Joakim Petersen <joak-pet@online.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | test: don't print aggregate-results commandFelipe Contreras2023-03-091-1/+1
| | | | | | | | | | | | | | There's no value in it. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | test: simplify counts aggregationFelipe Contreras2023-03-091-3/+1
|/ | | | | | | | | | | When the list of files as input was implemented in 6508eedf67 (t/aggregate-results: accomodate systems with small max argument list length, 2010-06-01), a much simpler solution wasn't considered. Let's just pass the directory as an argument. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cocci & cache.h: remove "USE_THE_INDEX_COMPATIBILITY_MACROS"Ævar Arnfjörð Bjarmason2023-02-102-21/+6
| | | | | | | | | | | | | | | | | | | Have the last users of "USE_THE_INDEX_COMPATIBILITY_MACROS" use the underlying *_index() variants instead. Now all previous users of "USE_THE_INDEX_COMPATIBILITY_MACROS" have been migrated away from the wrapper macros, and if applicable to use the "USE_THE_INDEX_VARIABLE" added in [1]. Let's leave the "index-compatibility.cocci" in place, even though it won't be doing anything on "master". It will benefit any out-of-tree code that need to use these compatibility macros. We can eventually remove it. 1. bdafeae0b9c (cache.h & test-tool.h: add & use "USE_THE_INDEX_VARIABLE", 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cache-tree API: remove redundant update_main_cache_tree()Ævar Arnfjörð Bjarmason2023-02-101-0/+3
| | | | | | | | | | | | | | | | | Remove the redundant update_main_cache_tree() function, and make its users use cache_tree_update() instead. The behavior of populating the "the_index.cache_tree" if it wasn't present already was needed when this function was introduced in [1], but it hasn't been needed since [2]; The "cache_tree_update()" will now lazy-allocate, so there's no need for the wrapper. 1. 996277c5206 (Refactor cache_tree_update idiom from commit, 2011-12-06) 2. fb0882648e0 (cache-tree: clean up cache_tree_update(), 2021-01-23) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cocci & cache-tree.h: migrate "write_cache_as_tree" to "*_index_*"Ævar Arnfjörð Bjarmason2023-02-101-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a trivial rule for "write_cache_as_tree" to "index-compatibility.cocci", and apply it. This was left out of the rules added in 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) because this compatibility wrapper lived in "cache-tree.h", not "cache.h" But it's like the other "USE_THE_INDEX_COMPATIBILITY_MACROS", so let's migrate it too. The replacement of "USE_THE_INDEX_COMPATIBILITY_MACROS" here with "USE_THE_INDEX_VARIABLE" is a manual change on top, now that these files only use "&the_index", and don't need any compatibility macros (or functions). The wrapping of some argument lists is likewise manual, as coccinelle would otherwise give us overly long argument lists. The reason for putting the "O" in the cocci rule on the "-" and "+" lines is because I couldn't get correct whitespacing otherwise, i.e. I'd end up with "oid,&the_index", not "oid, &the_index". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cocci & cache.h: apply pending "index_cache_pos" ruleÆvar Arnfjörð Bjarmason2023-02-102-3/+3
| | | | | | | | | | | | | | | | | Apply the rule added in [1] to change "cache_name_pos" to "index_name_pos", which allows us to get rid of another "USE_THE_INDEX_COMPATIBILITY_MACROS" macro. The replacement of "USE_THE_INDEX_COMPATIBILITY_MACROS" here with "USE_THE_INDEX_VARIABLE" is a manual change on top, now that these files only use "&the_index", and don't need any compatibility macros (or functions). 1. 0e6550a2c63 (cocci: add a index-compatibility.pending.cocci, 2022-11-19) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* cocci & cache.h: fully apply "active_nr" part of index-compatibilityÆvar Arnfjörð Bjarmason2023-02-101-9/+4
| | | | | | | | | | | | | | Apply the "active_nr" part of "index-compatibility.pending.cocci", which was left out in [1] due to an in-flight conflict. As of [2] the topic we conflicted with has been merged to "master", so we can fully apply this rule. 1. dc594180d9e (cocci & cache.h: apply variable section of "pending" index-compatibility, 2022-11-19) 2. 9ea1378d046 (Merge branch 'ab/various-leak-fixes', 2022-12-14) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* use DUP_ARRAYRené Scharfe2023-01-091-0/+7
| | | | | | | | Add a semantic patch for replace ALLOC_ARRAY+COPY_ARRAY with DUP_ARRAY to reduce code duplication and apply its results. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'aw/complete-case-insensitive'Junio C Hamano2022-12-191-3/+23
|\ | | | | | | | | | | | | | | Introduce a case insensitive mode to the Bash completion helpers. * aw/complete-case-insensitive: completion: add case-insensitive match of pseudorefs completion: add optional ignore-case when matching refs
| * completion: add case-insensitive match of pseudorefsAlison Winters2022-11-301-3/+11
| | | | | | | | | | | | | | | | When GIT_COMPLETION_IGNORE_CASE is set, also allow lowercase completion text like "head" to match uppercase HEAD and other pseudorefs. Signed-off-by: Alison Winters <alisonatwork@outlook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * completion: add optional ignore-case when matching refsAlison Winters2022-11-301-0/+12
| | | | | | | | | | | | | | | | | | If GIT_COMPLETION_IGNORE_CASE is set, --ignore-case will be added to git for-each-ref calls so that refs can be matched case insensitively, even when running on case sensitive filesystems. Signed-off-by: Alison Winters <alisonatwork@outlook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'yn/git-jump-emacs'Junio C Hamano2022-12-142-4/+51
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "git jump" (in contrib/) learned to present the "quickfix list" to its standard output (instead of letting it consumed by the editor it invokes), and learned to also drive emacs/emacsclient. * yn/git-jump-emacs: git-jump: invoke emacs/emacsclient git-jump: move valid-mode check earlier git-jump: add an optional argument '--stdout'
| * | git-jump: invoke emacs/emacsclientYoichi Nakayama2022-11-271-1/+16
| | | | | | | | | | | | | | | | | | | | | It works with GIT_EDITOR="emacs", "emacsclient" or "emacsclient -t" Signed-off-by: Yoichi Nakayama <yoichi.nakayama@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | git-jump: move valid-mode check earlierJeff King2022-11-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We check if the "mode" argument supplied by the user is valid by seeing if we have a mode_$mode function defined. But we don't do that until after creating the tempfile. This is wasteful (we create a tempfile but never use it), and makes it harder to add new options (the recent stdout option exits before creating the tempfile, so it misses the check and "git jump --stdout foo" will produce "git-jump: 92: mode_foo: not found" rather than the regular usage message). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | git-jump: add an optional argument '--stdout'Yoichi Nakayama2022-11-272-2/+33
| | | | | | | | | | | | | | | | | | | | | It can be used with M-x grep on Emacs. Signed-off-by: Yoichi Nakayama <yoichi.nakayama@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'ab/fewer-the-index-macros'Junio C Hamano2022-12-011-4/+8
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | Squelch warnings from Coccinelle * ab/fewer-the-index-macros: cocci: avoid "should ... be a metavariable" warnings