From patchwork Fri Jan 24 03:34:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349577 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 304A117EA for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0915124125 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KH4fRWrx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729423AbgAXDfO (ORCPT ); Thu, 23 Jan 2020 22:35:14 -0500 Received: from mail-yb1-f202.google.com ([209.85.219.202]:41112 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfO (ORCPT ); Thu, 23 Jan 2020 22:35:14 -0500 Received: by mail-yb1-f202.google.com with SMTP id 132so401471yba.8 for ; Thu, 23 Jan 2020 19:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=wYfggJxm8K+elrxHnLYhO6b+r8FA8AILm0Ssp9FfPHY=; b=KH4fRWrx+8eX4cEpFbi6dg1I3CJrWVTFBc9ZwnimCFV8fngwuzBneS/0st8MjV5nO/ IFKNmri8qkuIvrUmIxNknthtI43eUEfe8/WnNcKzaItqT7QbjD93tsZNXakE+s9dyJsu l02Mdw3RN7x7424+l3e3fYyhrs3O3gAfzKC8vRDZyneKpzstArBJNIBQyScY1/XNDCVK DEmKA9Egz4E2Kyyv8Wy+sgjwkLiLbeFkKjHPpREuBWwMVT20t26EXTk9IRl/0bP6GuyU Qba65hDnCc9lYNA5BLxMfZzCiLwiypqFxJ91DYLjdRUyWe6ja6iAlQWssj6rGq+qnt3q ZXHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wYfggJxm8K+elrxHnLYhO6b+r8FA8AILm0Ssp9FfPHY=; b=IT+06E0imqVpKeV5uvMAJ/1154aQ0E56+UzESfj9rztMxU0fGuKrINqDxHgJkYY2mF R4m4GHiPE6Ftw2A7sTF7t4Y/RfTyvDKk83w9xCxRCX8sUhl179s9xkhkF+iMySPpAjVA 93Vre9eu9xPUxdCQLrKLVocO+yyezUxZn55+XwRglR1/YlFQmPjZbsnQM6PLnIHCdExv 0CQ+dD6fODd9PtIHr4XLz9TQ2SHrKBBq4gFeBgepPH6CJDzSrdjn+qpgRSDEKxFEZDmq 6RvxLH305H/BttTMCZhrUOwflXFc+itZ2rdfp3VxPCORWvY2d+u5J32CmwBZsUoMZz9P c9tw== X-Gm-Message-State: APjAAAWY0UnQF6HMURuqHfcqNZnixYWKotZrUk3uHLOq7K41eIyDFF7i Xu1ZrD8vBR4YcH+tNRP1uZoopuJdExCzc5T7NHbHreu5Ck9Vtvs1JEK6aqSeSoYbh1J1AQFqDpT HKApCU68BMgMLbF5CQttk/szlT4vKTWlh9/2biXKhp0rvbgbzHeshFBs1VdTdUTrGbBYtxK1GFA == X-Google-Smtp-Source: APXvYqxclEJY+8IeN8proqH5RpT+mzgKYpKj3YGVaSY7LLco9Ue0hRS8wuTHfcpZOcWw/bby/GKyo4Ax09KZXZbvma8= X-Received: by 2002:a81:2781:: with SMTP id n123mr756721ywn.70.1579836912312; Thu, 23 Jan 2020 19:35:12 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:22 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-2-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 01/15] bugreport: add tool to generate debugging info From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Teach Git how to prompt the user for a good bug report: reproduction steps, expected behavior, and actual behavior. Later, Git can learn how to collect some diagnostic information from the repository. If users can send us a well-written bug report which contains diagnostic information we would otherwise need to ask the user for, we can reduce the number of question-and-answer round trips between the reporter and the Git contributor. Users may also wish to send a report like this to their local "Git expert" if they have put their repository into a state they are confused by. Signed-off-by: Emily Shaffer --- .gitignore | 1 + Documentation/git-bugreport.txt | 43 ++++++++++++++++++++ Makefile | 5 +++ bugreport.c | 69 +++++++++++++++++++++++++++++++++ t/t0091-bugreport.sh | 41 ++++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 Documentation/git-bugreport.txt create mode 100644 bugreport.c create mode 100755 t/t0091-bugreport.sh diff --git a/.gitignore b/.gitignore index aebe7c0908..ca301bc890 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ /git-bisect--helper /git-blame /git-branch +/git-bugreport /git-bundle /git-cat-file /git-check-attr diff --git a/Documentation/git-bugreport.txt b/Documentation/git-bugreport.txt new file mode 100644 index 0000000000..75f0c80acf --- /dev/null +++ b/Documentation/git-bugreport.txt @@ -0,0 +1,43 @@ +git-bugreport(1) +================ + +NAME +---- +git-bugreport - Collect information for user to file a bug report + +SYNOPSIS +-------- +[verse] +'git bugreport' [-o | --output ] + +DESCRIPTION +----------- +Captures information about the user's machine, Git client, and repository state, +as well as a form requesting information about the behavior the user observed, +into a single text file which the user can then share, for example to the Git +mailing list, in order to report an observed bug. + +The following information is requested from the user: + + - Reproduction steps + - Expected behavior + - Actual behavior + +The following information is captured automatically: + + - Git version (`git version --build-options`) + - Machine information (`uname -a`) + - Versions of various dependencies + - Git config contents (`git config --show-origin --list`) + - The names of all configured git-hooks in `.git/hooks/` + +OPTIONS +------- +-o []:: +--output []:: + Place the resulting bug report file in instead of the root of the + Git repository. + +GIT +--- +Part of the linkgit:git[1] suite diff --git a/Makefile b/Makefile index 09f98b777c..f271619371 100644 --- a/Makefile +++ b/Makefile @@ -681,6 +681,7 @@ EXTRA_PROGRAMS = # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS += $(EXTRA_PROGRAMS) +PROGRAM_OBJS += bugreport.o PROGRAM_OBJS += credential-store.o PROGRAM_OBJS += daemon.o PROGRAM_OBJS += fast-import.o @@ -2450,6 +2451,10 @@ endif git-%$X: %.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) +git-bugreport$X: bugreport.o GIT-LDFLAGS $(GITLIBS) + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(LIBS) + git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(IMAP_SEND_LDFLAGS) $(LIBS) diff --git a/bugreport.c b/bugreport.c new file mode 100644 index 0000000000..5495b31674 --- /dev/null +++ b/bugreport.c @@ -0,0 +1,69 @@ +#include "builtin.h" +#include "parse-options.h" +#include "stdio.h" +#include "strbuf.h" +#include "time.h" + +static const char * const bugreport_usage[] = { + N_("git bugreport [-o|--output ]"), + NULL +}; + +static int get_bug_template(struct strbuf *template) +{ + const char template_text[] = N_( +"Thank you for filling out a Git bug report!\n" +"Please answer the following questions to help us understand your issue.\n" +"\n" +"What did you do before the bug happened? (Steps to reproduce your issue)\n" +"\n" +"What did you expect to happen? (Expected behavior)\n" +"\n" +"What happened instead? (Actual behavior)\n" +"\n" +"What's different between what you expected and what actually happened?\n" +"\n" +"Anything else you want to add:\n" +"\n" +"Please review the rest of the bug report below.\n" +"You can delete any lines you don't wish to send.\n"); + + strbuf_addstr(template, template_text); + return 0; +} + +int cmd_main(int argc, const char **argv) +{ + struct strbuf buffer = STRBUF_INIT; + struct strbuf report_path = STRBUF_INIT; + FILE *report; + time_t now = time(NULL); + char *option_output = NULL; + + const struct option bugreport_options[] = { + OPT_STRING('o', "output", &option_output, N_("path"), + N_("specify a destination for the bugreport file")), + OPT_END() + }; + argc = parse_options(argc, argv, "", bugreport_options, + bugreport_usage, 0); + + if (option_output) { + strbuf_addstr(&report_path, option_output); + strbuf_complete(&report_path, '/'); + } + + strbuf_addstr(&report_path, "git-bugreport-"); + strbuf_addftime(&report_path, "%F", gmtime(&now), 0, 0); + strbuf_addstr(&report_path, ".txt"); + + + get_bug_template(&buffer); + + report = fopen_for_writing(report_path.buf); + strbuf_write(&buffer, report); + fclose(report); + + launch_editor(report_path.buf, NULL, NULL); + return 0; +} diff --git a/t/t0091-bugreport.sh b/t/t0091-bugreport.sh new file mode 100755 index 0000000000..6eb2ee4f66 --- /dev/null +++ b/t/t0091-bugreport.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +test_description='git bugreport' + +. ./test-lib.sh + +# Headers "[System Info]" will be followed by a non-empty line if we put some +# information there; we can make sure all our headers were followed by some +# information to check if the command was successful. +HEADER_PATTERN="^\[.*\]$" +check_all_headers_populated() { + while read -r line; do + if [$(grep $HEADER_PATTERN $line)]; then + read -r nextline + if [-z $nextline]; then + return 1; + fi + fi + done +} + +test_expect_success 'creates a report with content in the right places' ' + git bugreport && + check_all_headers_populated output && + grep usage output && + test ! -f git-bugreport-* +' + +test_done From patchwork Fri Jan 24 03:34:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349579 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60DCF18B6 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B96D22522 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oIg33ogu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729464AbgAXDfQ (ORCPT ); Thu, 23 Jan 2020 22:35:16 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:40151 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfP (ORCPT ); Thu, 23 Jan 2020 22:35:15 -0500 Received: by mail-pf1-f201.google.com with SMTP id d127so528033pfa.7 for ; Thu, 23 Jan 2020 19:35:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lNQXz1R+/WtdfSs9/w1SNQHyB67Mr0ApRGK0e7S5RlI=; b=oIg33oguDTCMm3BEQTAZGJeRTObg5GxmMA7VDy1td6IYUkECGQ/ax4jPp4/12i8k4u xX9ZpMrITg7gvh+694yoFs+kfDOcP7XCyo1xgCJX97dp2C9Mo1KwJ1wmjbo/hIoI37el tS5n5y0vZ+X0tP/hTg8UNEGVVCFCcq3OZZMME/EE0pwBqX7SzHRRLiYpMh5M6bgCh/RS SYNklqYUiY2Xxgu/6cCzj1EbkGKoyTAovZIPiHA6ah4gzd8xq7XAldpVCME+j4iLr93F L6ICj3M5ZRux5yaTj3I28UgDGFviSfjZ8x+sqOHMIafPnuxdyRbKHEDKr0kza3A1tZoE k+TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lNQXz1R+/WtdfSs9/w1SNQHyB67Mr0ApRGK0e7S5RlI=; b=ReO5ov90oyLClU5MjUvHudjDu0B9scWeJ0YExDagTdvRQ9St8W9oW60dEi5g5rCXcP T8coVcGiPQV5g7Jp3Q2sHTxjP65Exs7yd0ZL+BiYz/ISgHnKoR4bw8dSnZGQlqglUcAc VibzHO+VTYSC9X+l9rtUzZIqbPDJqvfqihI5dH2jS1GMiKRrMjr3H2Ot32c2RfCNql/H TPbxdxt4UAD1UjOBqoOC9o0Fhu3WwHErZaPD3WZ0v7pRUtJT2aG/eb+6pnqR9DF/SVRz T11NTTDPsfQvIkniNs/9wwXa1FqG3jCXJf9278F6IMHraoXxLS2Dg6Bi0clLq0WJ+Q04 gbCA== X-Gm-Message-State: APjAAAVOpT1/CwieOXx4FXc2Za00XTwwpQMS4aTX281szn1TPHVd+Kf2 KCnk+6YY9pngzo9S+oUzhMKLd21B/n4kcP00InDcYpQpqplkrqlsfNriCZYttnq+azk43kylWER T8C3WcuipA31isjKynG1KcjALwbbLpR9FWXhv9WjVZoOtkK5hVmnFKOAdglpVCXXwbCpWL8KGFA == X-Google-Smtp-Source: APXvYqzQY4YnwjeVpP9ExhttkDtZtRtobJcKTgac18Tp25X7Lw4M3fUzYxMVzHCA3xNDIPih1qCH2M+8M/n8GL+y3QU= X-Received: by 2002:a63:3191:: with SMTP id x139mr1760277pgx.368.1579836914547; Thu, 23 Jan 2020 19:35:14 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:23 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-3-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 02/15] help: move list_config_help to builtin/help From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Starting in 3ac68a93fd2, help.o began to depend on builtin/branch.o, builtin/clean.o, and builtin/config.o. This meant that help.o was unusable outside of the context of the main Git executable. To make help.o usable by other commands again, move list_config_help() into builtin/help.c (where it makes sense to assume other builtin libraries are present). When command-list.h is included but a member is not used, we start to hear a compiler warning. Since the config list is generated in a fairly different way than the command list, and since commands and config options are semantically different, move the config list into its own header and move the generator into its own script and build rule. Signed-off-by: Emily Shaffer --- .gitignore | 1 + Makefile | 13 +++++-- builtin/help.c | 86 ++++++++++++++++++++++++++++++++++++++++++ generate-cmdlist.sh | 19 ---------- generate-configlist.sh | 24 ++++++++++++ help.c | 85 ----------------------------------------- help.h | 1 - 7 files changed, 121 insertions(+), 108 deletions(-) create mode 100755 generate-configlist.sh diff --git a/.gitignore b/.gitignore index ca301bc890..d89bf9e11e 100644 --- a/.gitignore +++ b/.gitignore @@ -190,6 +190,7 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/config-list.h /command-list.h *.tar.gz *.dsc diff --git a/Makefile b/Makefile index f271619371..a01a050aa3 100644 --- a/Makefile +++ b/Makefile @@ -815,6 +815,7 @@ LIB_FILE = libgit.a XDIFF_LIB = xdiff/lib.a VCSSVN_LIB = vcs-svn/lib.a +GENERATED_H += config-list.h GENERATED_H += command-list.h LIB_H := $(sort $(patsubst ./%,%,$(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \ @@ -2129,7 +2130,7 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) help.sp help.s help.o: command-list.h -builtin/help.sp builtin/help.s builtin/help.o: command-list.h GIT-PREFIX +builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \ @@ -2149,6 +2150,12 @@ $(BUILT_INS): git$X ln -s $< $@ 2>/dev/null || \ cp $< $@ +config-list.h: generate-configlist.sh + +config-list.h: + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ + >$@+ && mv $@+ $@ + command-list.h: generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt @@ -2786,7 +2793,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -EXCEPT_HDRS := command-list.h unicode-width.h compat/% xdiff/% +EXCEPT_HDRS := command-list.h config-list.h unicode-width.h compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h endif @@ -2808,7 +2815,7 @@ hdr-check: $(HCO) style: git clang-format --style file --diff --extensions c,h -check: command-list.h +check: config-list.h command-list.h @if sparse; \ then \ echo >&2 "Use 'make sparse' instead"; \ diff --git a/builtin/help.c b/builtin/help.c index e5590d7787..1c5f2b9255 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -8,6 +8,7 @@ #include "parse-options.h" #include "run-command.h" #include "column.h" +#include "config-list.h" #include "help.h" #include "alias.h" @@ -62,6 +63,91 @@ static const char * const builtin_help_usage[] = { NULL }; +struct slot_expansion { + const char *prefix; + const char *placeholder; + void (*fn)(struct string_list *list, const char *prefix); + int found; +}; + +static void list_config_help(int for_human) +{ + struct slot_expansion slot_expansions[] = { + { "advice", "*", list_config_advices }, + { "color.branch", "", list_config_color_branch_slots }, + { "color.decorate", "", list_config_color_decorate_slots }, + { "color.diff", "", list_config_color_diff_slots }, + { "color.grep", "", list_config_color_grep_slots }, + { "color.interactive", "", list_config_color_interactive_slots }, + { "color.remote", "", list_config_color_sideband_slots }, + { "color.status", "", list_config_color_status_slots }, + { "fsck", "", list_config_fsck_msg_ids }, + { "receive.fsck", "", list_config_fsck_msg_ids }, + { NULL, NULL, NULL } + }; + const char **p; + struct slot_expansion *e; + struct string_list keys = STRING_LIST_INIT_DUP; + int i; + + for (p = config_name_list; *p; p++) { + const char *var = *p; + struct strbuf sb = STRBUF_INIT; + + for (e = slot_expansions; e->prefix; e++) { + + strbuf_reset(&sb); + strbuf_addf(&sb, "%s.%s", e->prefix, e->placeholder); + if (!strcasecmp(var, sb.buf)) { + e->fn(&keys, e->prefix); + e->found++; + break; + } + } + strbuf_release(&sb); + if (!e->prefix) + string_list_append(&keys, var); + } + + for (e = slot_expansions; e->prefix; e++) + if (!e->found) + BUG("slot_expansion %s.%s is not used", + e->prefix, e->placeholder); + + string_list_sort(&keys); + for (i = 0; i < keys.nr; i++) { + const char *var = keys.items[i].string; + const char *wildcard, *tag, *cut; + + if (for_human) { + puts(var); + continue; + } + + wildcard = strchr(var, '*'); + tag = strchr(var, '<'); + + if (!wildcard && !tag) { + puts(var); + continue; + } + + if (wildcard && !tag) + cut = wildcard; + else if (!wildcard && tag) + cut = tag; + else + cut = wildcard < tag ? wildcard : tag; + + /* + * We may produce duplicates, but that's up to + * git-completion.bash to handle + */ + printf("%.*s\n", (int)(cut - var), var); + } + string_list_clear(&keys, 0); +} + static enum help_format parse_help_format(const char *format) { if (!strcmp(format, "man")) diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh index 71158f7d8b..45fecf8bdf 100755 --- a/generate-cmdlist.sh +++ b/generate-cmdlist.sh @@ -76,23 +76,6 @@ print_command_list () { echo "};" } -print_config_list () { - cat <", list_config_color_branch_slots }, - { "color.decorate", "", list_config_color_decorate_slots }, - { "color.diff", "", list_config_color_diff_slots }, - { "color.grep", "", list_config_color_grep_slots }, - { "color.interactive", "", list_config_color_interactive_slots }, - { "color.remote", "", list_config_color_sideband_slots }, - { "color.status", "", list_config_color_status_slots }, - { "fsck", "", list_config_fsck_msg_ids }, - { "receive.fsck", "", list_config_fsck_msg_ids }, - { NULL, NULL, NULL } - }; - const char **p; - struct slot_expansion *e; - struct string_list keys = STRING_LIST_INIT_DUP; - int i; - - for (p = config_name_list; *p; p++) { - const char *var = *p; - struct strbuf sb = STRBUF_INIT; - - for (e = slot_expansions; e->prefix; e++) { - - strbuf_reset(&sb); - strbuf_addf(&sb, "%s.%s", e->prefix, e->placeholder); - if (!strcasecmp(var, sb.buf)) { - e->fn(&keys, e->prefix); - e->found++; - break; - } - } - strbuf_release(&sb); - if (!e->prefix) - string_list_append(&keys, var); - } - - for (e = slot_expansions; e->prefix; e++) - if (!e->found) - BUG("slot_expansion %s.%s is not used", - e->prefix, e->placeholder); - - string_list_sort(&keys); - for (i = 0; i < keys.nr; i++) { - const char *var = keys.items[i].string; - const char *wildcard, *tag, *cut; - - if (for_human) { - puts(var); - continue; - } - - wildcard = strchr(var, '*'); - tag = strchr(var, '<'); - - if (!wildcard && !tag) { - puts(var); - continue; - } - - if (wildcard && !tag) - cut = wildcard; - else if (!wildcard && tag) - cut = tag; - else - cut = wildcard < tag ? wildcard : tag; - - /* - * We may produce duplicates, but that's up to - * git-completion.bash to handle - */ - printf("%.*s\n", (int)(cut - var), var); - } - string_list_clear(&keys, 0); -} - static int get_alias(const char *var, const char *value, void *data) { struct string_list *list = data; diff --git a/help.h b/help.h index 7a455beeb7..9071894e8c 100644 --- a/help.h +++ b/help.h @@ -22,7 +22,6 @@ static inline void mput_char(char c, unsigned int num) void list_common_cmds_help(void); void list_all_cmds_help(void); void list_common_guides_help(void); -void list_config_help(int for_human); void list_all_main_cmds(struct string_list *list); void list_all_other_cmds(struct string_list *list); From patchwork Fri Jan 24 03:34:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91641921 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C54322522 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oHdOIjMd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729624AbgAXDfS (ORCPT ); Thu, 23 Jan 2020 22:35:18 -0500 Received: from mail-vs1-f74.google.com ([209.85.217.74]:54682 "EHLO mail-vs1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfS (ORCPT ); Thu, 23 Jan 2020 22:35:18 -0500 Received: by mail-vs1-f74.google.com with SMTP id l1so45966vsr.21 for ; Thu, 23 Jan 2020 19:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7hnJFTXG0VTuFPNr3IRwCWsuYdQmVj8ZgovBHCF4rWw=; b=oHdOIjMdmJ1D70WV72FOLxsQ4NSyjxVrhyfLJC6iVA9UN5sZofYPf5eU2h7wm1U+8S AuiDILosKMMP/y+GdA9+zrCg3i9LK40VBfhNPHVUH08tSuxz0ypWc8csZ335kAeT0Ggk de0Cw+nbuGZ8zFXwzvlzx2QLNIKJdLqByZCAqXJ+v0duWHAoFyM8e/WxpvMNRLYmbvpW w9c20HqIvsq4Wb1lkmiS9MmhlrHI8hS7btKf/RL6PXMCCSpxTnEvgfi7ysd16b+Snejk CkRPgJNHz+IYgg+2oQG1Bf7895ymymLACgbJG0O7/KzzwEp1QRjAAbVRj3AsiR0uW+NR dcEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7hnJFTXG0VTuFPNr3IRwCWsuYdQmVj8ZgovBHCF4rWw=; b=fKI0YVUAGJb1C7AjsuP46azZIwwEP4c+ma7JrcND0epbc4tZkeAgFPCVx8CP/d3767 tj3MOBNYtMbXmH64VkIkCWf1Ky5bm2rcvHoVrfRypVRECQl6ft/k2OENP2VFWpAYPAiF Mn6uOCFK73kLKcIZPh9OklToQL+arPMqoRIIKdhoK874hmVlZq5FCWjCNMb6EioCGe/r MiIqNEh71DRoXguqTTRTxyDB4ER7mkq1peWJqyHwzT851FuKlB9JLvgk3/TNdyoqXmJr +WnW5mat0RZon7nWD+/J2ncKzMZJokUMRMqcoSyVcoKNOSA3+QZYzkkAlL3/BCJv7A0G kVlg== X-Gm-Message-State: APjAAAVz0ZqBO4EB4i/bzMrAOB8GJhj11/KzyKvEXCd6y6WnA7P/nesJ Cy22aCXqYgtfs/9xAHYjh3LwFWDmq/7EJ2Mr9AZoUP0FCfEKy/kQ3rpYEZJYBroOPD0012mXmmg j02RjbA+AP08vMYf49ufgdriZP567CEJKKRnBcM5u90N73DDLP00q8UDr7XkVwrcvBscJeF67vQ == X-Google-Smtp-Source: APXvYqxPOH3S00jwL4w6c1BVRg1aH8i9UOrt1ftZUbiqApde8BakTbHKEfrfbG56+Vd8oG7lE01SS1u803nRvtvx+XA= X-Received: by 2002:a67:fa51:: with SMTP id j17mr982156vsq.59.1579836916944; Thu, 23 Jan 2020 19:35:16 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:24 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-4-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 03/15] bugreport: gather git version and build info From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Knowing which version of Git a user has and how it was built allows us to more precisely pin down the circumstances when a certain issue occurs, so teach bugreport how to tell us the same output as 'git version --build-options'. It's not ideal to directly call 'git version --build-options' because that output goes to stdout. Instead, wrap the version string in a helper within help.[ch] library, and call that helper from within the bugreport library. Signed-off-by: Emily Shaffer --- bugreport.c | 22 +++++++++++++++++++++- help.c | 47 +++++++++++++++++++++++++++++------------------ help.h | 1 + 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/bugreport.c b/bugreport.c index 5495b31674..b1a5a279ac 100644 --- a/bugreport.c +++ b/bugreport.c @@ -1,8 +1,20 @@ -#include "builtin.h" +#include "cache.h" #include "parse-options.h" #include "stdio.h" #include "strbuf.h" #include "time.h" +#include "help.h" + +static void get_system_info(struct strbuf *sys_info) +{ + struct strbuf version_info = STRBUF_INIT; + + /* get git version from native cmd */ + strbuf_addstr(sys_info, "git version:\n"); + get_version_info(&version_info, 1); + strbuf_addbuf(sys_info, &version_info); + strbuf_complete_line(sys_info); +} static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), @@ -32,6 +44,11 @@ static int get_bug_template(struct strbuf *template) return 0; } +static void get_header(struct strbuf *buf, const char *title) +{ + strbuf_addf(buf, "\n\n[%s]\n", title); +} + int cmd_main(int argc, const char **argv) { struct strbuf buffer = STRBUF_INIT; @@ -60,6 +77,9 @@ int cmd_main(int argc, const char **argv) get_bug_template(&buffer); + get_header(&buffer, "System Info"); + get_system_info(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); diff --git a/help.c b/help.c index a21487db77..156a6cdea3 100644 --- a/help.c +++ b/help.c @@ -622,8 +622,33 @@ const char *help_unknown_cmd(const char *cmd) exit(1); } +void get_version_info(struct strbuf *buf, int show_build_options) +{ + strbuf_reset(buf); + /* + * The format of this string should be kept stable for compatibility + * with external projects that rely on the output of "git version". + * + * Always show the version, even if other options are given. + */ + strbuf_addf(buf, "git version %s\n", git_version_string); + + if (show_build_options) { + strbuf_addf(buf, "cpu: %s\n", GIT_HOST_CPU); + if (git_built_from_commit_string[0]) + strbuf_addf(buf, "built from commit: %s\n", + git_built_from_commit_string); + else + strbuf_addstr(buf, "no commit associated with this build\n"); + strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long)); + strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t)); + /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ + } +} + int cmd_version(int argc, const char **argv, const char *prefix) { + struct strbuf buf = STRBUF_INIT; int build_options = 0; const char * const usage[] = { N_("git version []"), @@ -637,25 +662,11 @@ int cmd_version(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, usage, 0); - /* - * The format of this string should be kept stable for compatibility - * with external projects that rely on the output of "git version". - * - * Always show the version, even if other options are given. - */ - printf("git version %s\n", git_version_string); + get_version_info(&buf, build_options); + printf("%s", buf.buf); + + strbuf_release(&buf); - if (build_options) { - printf("cpu: %s\n", GIT_HOST_CPU); - if (git_built_from_commit_string[0]) - printf("built from commit: %s\n", - git_built_from_commit_string); - else - printf("no commit associated with this build\n"); - printf("sizeof-long: %d\n", (int)sizeof(long)); - printf("sizeof-size_t: %d\n", (int)sizeof(size_t)); - /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ - } return 0; } diff --git a/help.h b/help.h index 9071894e8c..500521b908 100644 --- a/help.h +++ b/help.h @@ -37,6 +37,7 @@ void add_cmdname(struct cmdnames *cmds, const char *name, int len); void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); int is_in_cmdlist(struct cmdnames *cmds, const char *name); void list_commands(unsigned int colopts, struct cmdnames *main_cmds, struct cmdnames *other_cmds); +void get_version_info(struct strbuf *buf, int show_build_options); /* * call this to die(), when it is suspected that the user mistyped a From patchwork Fri Jan 24 03:34:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C251D184C for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9CFC022522 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ebn5IyPN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729793AbgAXDfU (ORCPT ); Thu, 23 Jan 2020 22:35:20 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:42296 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfT (ORCPT ); Thu, 23 Jan 2020 22:35:19 -0500 Received: by mail-pg1-f202.google.com with SMTP id 193so578720pgh.9 for ; Thu, 23 Jan 2020 19:35:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cm9Ej2IpaMY/kksamirIQxVIpZbyhSncLIDt6Y94kwM=; b=ebn5IyPNao5YfU/pX9lgLVA7pIwbn83+ZmsiBa3mI5CfrLBoUG13Qmn2NvPRRWdNJ5 vD3jvJXflRQs4OqNnx7JBkLq2bnN9SLVzuETAgvG7p5pTI4pfFzHdd0skbAT8c1wBHvn 0lUHIXX2wbb3/PR59Ke32jnkxgA/3licm+WbXE3Iky1NDA/7oPrQvRaPR9135dxZk6Wi 7MmblE4fdUraVJmWtcNTbNWN2q7+xjA2NBih3z+tUlYF7E8TlLh/14QpolOD5j995ZvP qD+PbZtRjDuWk8vj3urZzguPQlaLtbkPYy6HjryzXswySZVoi14iK81b3VEWlyEAyIrd ftqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cm9Ej2IpaMY/kksamirIQxVIpZbyhSncLIDt6Y94kwM=; b=b4oYG/nu/KD7Qe05fiVuM3WMU04t9K1mqmdw/UyT9/w40M7RgbP51iGGZNpb0jNepS ggsBikjKXnJmRclomEgO5ILc/ZsmJGU8Ub4o2jiWxmevjuoZw80WMJMfU9iyX7ucQczA ASOkMr5mSzyKpv/pzvpjw8eCJamA89qw3qmd9770XZLLtD3+Vc340AJ4YjQXBr9arLIr pNGpPpOwS/1w87BtOvJlRqUt/vZYGXIlfmULQoZukWSXdR82Z8I9CM5zaQ7kp1PHvTts Wur+qRQPLh93ETqlmISyqut2CZxGjEdzQrLBVbzkJhU7VTCv+IjObng0I1C2q69wv4cp yzLQ== X-Gm-Message-State: APjAAAU2mv7uIVsanLuZznJ7BgjSQMU/It3xXV+Gi939JAy5vL7QiTHl Ac0kCiclRnMgv7bD+dJfNtsIuBwKvg0mZeLDRzNv/GHJt0wYKjwmlt14prYArkiAP5UAkHMAdw/ ovSYMp3S5nhIT4Z7fbr6TVQGwHOywpjz8H3WYLAFNlW/5vxUM4b4RZ9xLOis0D0sNtOdem9MXTQ == X-Google-Smtp-Source: APXvYqxGZT8od+swx6/oFC+Ts8TL2VdKywKujp6/NYMC8xNASy/t1xTjrrm26kjwep3eSSmQyxiNi3pYdKfB/Ingkd4= X-Received: by 2002:a63:cb47:: with SMTP id m7mr1762445pgi.309.1579836919114; Thu, 23 Jan 2020 19:35:19 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:25 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-5-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 04/15] help: add shell-path to --build-options From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer It may be useful to know which shell Git was built to try to point to, in the event that shell-based Git commands are failing. $SHELL_PATH is set during the build and used to launch the manpage viewer, as well as by git-compat-util.h, and it's used during tests. 'git version --build-options' is encouraged for use in bug reports, so it makes sense to include this information there. Signed-off-by: Emily Shaffer --- help.c | 1 + 1 file changed, 1 insertion(+) diff --git a/help.c b/help.c index 156a6cdea3..d3f941824f 100644 --- a/help.c +++ b/help.c @@ -642,6 +642,7 @@ void get_version_info(struct strbuf *buf, int show_build_options) strbuf_addstr(buf, "no commit associated with this build\n"); strbuf_addf(buf, "sizeof-long: %d\n", (int)sizeof(long)); strbuf_addf(buf, "sizeof-size_t: %d\n", (int)sizeof(size_t)); + strbuf_addf(buf, "shell-path: %s\n", SHELL_PATH); /* NEEDSWORK: also save and output GIT-BUILD_OPTIONS? */ } } From patchwork Fri Jan 24 03:34:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349585 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F38EC1902 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDBFC22522 for ; Fri, 24 Jan 2020 03:35:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AmPv22p6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729826AbgAXDfX (ORCPT ); Thu, 23 Jan 2020 22:35:23 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:52453 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfW (ORCPT ); Thu, 23 Jan 2020 22:35:22 -0500 Received: by mail-pg1-f202.google.com with SMTP id w21so564655pgf.19 for ; Thu, 23 Jan 2020 19:35:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FwPvDDx5s/e0Cs6fgauUA9tC1FV9pA2MPKvMDI8L53o=; b=AmPv22p6xNfLITPTNBXNHrPDLISxCDqnqoRn+ovJ2xszURWQBSWSiOquu1394YrYNO qsxCXzQWsebszgtC25w/KMynk8OCVMCgqcnYkSCJAK6jdpXrHUFhN0b1opRGzcqZHDgI wthCqL5ymfBMvyXQzwIBCk449WZ60+rXnQfduHKxIv4Jgm5n01ln6+b4Cenloa2ia+8T qOxN9URjE7wpfqOzXiPB6+x8BcBWVtLAv2fjjwkwUJy3YatMGGCaL2uyNrsJ4dMxtPJ8 Qm3VRHeDo2Qa52QQoB5LH9SRf9zNdA2fYipcIqHn9HP3Xf0zHAxWVDLSbcqqoaoTafTP +NXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FwPvDDx5s/e0Cs6fgauUA9tC1FV9pA2MPKvMDI8L53o=; b=k0icHq3/tyQq4w7lDz/AFa25eZ5sjoU2E260Qtb4ziYmGSr0gX9hO76Jnu5q3hxLO6 Kb8jrtmfi7QCZvV2PDKDnFG7FHFK5jSo1h07e47xYlojEG5rngifbKgUhZ4RSiRwTV6P 2IJDB97tDnv8eQbHn6YDrm7ya1hTio2nysvqTlzJQPI59aLX9D/ErCG9Qq1xcQtPpQRh RLFx7/ITpnf+PXpF13QJCdF0wjdgBLacWALLBaeNk1Oe4G5TpUszbWgCdYgqUu6yeizH h9xqSeHCKVdEujmldJWxkDp+gEJyui72yKiNrFrTpFOQEoJRk+40L6FOn3+jXjmcyRp+ yE0g== X-Gm-Message-State: APjAAAXr2ElJAbEI7NwuPfGRhJWyjfkLKRQEQdtY5CSKDW3gpfTpBFcU 9Bc9q6yH/A39Rv+rY+Qqy4MT8UGDJjH5wdtWWeLFePtsLche33ROhTmT3LTYCZ1YOnjGLNvOYoo XbUXyJBV9iG3MpB4jiRv75hsUPBl1pv9lsXPZsoCWConcuRAlNoPdjRwoeHnNlFXnoVNVeVANXg == X-Google-Smtp-Source: APXvYqycRo8TblfCyWT84Szi6oI6TkmWjvVIKNu4n5r0QFloDEbw2T0d4JJIeEIRfoPUSUFMWDHRBaJm3WqcntlZo08= X-Received: by 2002:a63:149:: with SMTP id 70mr97968pgb.206.1579836921709; Thu, 23 Jan 2020 19:35:21 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:26 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-6-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 05/15] bugreport: add uname info From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer The contents of uname() can give us some insight into what sort of system the user is running on, and help us replicate their setup if need be. The domainname field is not guaranteed to be available, so don't collect it. Signed-off-by: Emily Shaffer --- bugreport.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bugreport.c b/bugreport.c index b1a5a279ac..720c91e1bd 100644 --- a/bugreport.c +++ b/bugreport.c @@ -8,12 +8,24 @@ static void get_system_info(struct strbuf *sys_info) { struct strbuf version_info = STRBUF_INIT; + struct utsname uname_info; /* get git version from native cmd */ strbuf_addstr(sys_info, "git version:\n"); get_version_info(&version_info, 1); strbuf_addbuf(sys_info, &version_info); strbuf_complete_line(sys_info); + + /* system call for other version info */ + strbuf_addstr(sys_info, "uname -a: "); + if (uname(&uname_info)) + strbuf_addf(sys_info, "uname() failed with code %d\n", errno); + else + strbuf_addf(sys_info, "%s %s %s %s\n", + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine); } static const char * const bugreport_usage[] = { From patchwork Fri Jan 24 03:34:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349587 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3080118B6 for ; Fri, 24 Jan 2020 03:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AFEE22522 for ; Fri, 24 Jan 2020 03:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="psBGsHBR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729856AbgAXDfZ (ORCPT ); Thu, 23 Jan 2020 22:35:25 -0500 Received: from mail-vk1-f201.google.com ([209.85.221.201]:51459 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDfZ (ORCPT ); Thu, 23 Jan 2020 22:35:25 -0500 Received: by mail-vk1-f201.google.com with SMTP id c127so249057vkh.18 for ; Thu, 23 Jan 2020 19:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4ePX9MdGkN/ZfSUGxE9QIoCX83dvdMKlkminVB6jc8s=; b=psBGsHBRkmYcIaTwC1RaMDjqaUhiBN+7ueOGoLLpsSw/FsyulMlBNYLLfxrSMSvxaT dKCOBmiA2qoaHs+3cqLF/OrvbgGKrGRAmENH2IPCNPq8bvOuELsNS4cfokqiv/RuIP3e b7pix/lHiRkx1h98K8Kv+peTsctUcAxcRAAAueKPCb/G01FKyqXG7meFRL+MxcvkPCHi 8s1xvBO/mndIWg1YJExw0FOVCSt0a+rPigP0ZVjJdHuvRcnhZs/O+5aZhuR0XrV7ix/m JrqgAHTzmPh0Y8UJmYIplu1yfcMag7vSV60JhR23Ul9ALic38G/Mc7aLPqdf9qmaUnbn wI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4ePX9MdGkN/ZfSUGxE9QIoCX83dvdMKlkminVB6jc8s=; b=YiUy2+QjbCp0zWhJvsXIyBGxuZlWgNy8khLC2mxgmAmy6qM6Y6xVMzWFg4WL7Klqkb iBsdUkE+2dzJuo3jAguJnuSm2Efl/2NkgefSwZ3eey5lNENcQELs9A86/k59XOOerJbo IqGphQUHHnOgBR6o9wZCvsfN9APDev7pN9rEKqqlaX4h0OGLp2vYLDxiczKK3E7P/fdr G6QyEle039tOvRHhMkor2eOQ10ba+gTcRkxAmA/n31rdgl/biHPrTBhdco7SUtQmRS6z bEofkqLWpU/Offr5c21Xotf8QVNLCDyw4wud3d38eZrgPlx17zaF6M379lKRKnHfQgi5 c/ew== X-Gm-Message-State: APjAAAX5u1RPpG8h+9xptpcmkFvJ86WhsiHHThEAzLrzuXtan8iZW1Hf 3+1IoeMCnjcAa2clbDwnZBgghb8rm6klweoePeU6p2IiEnv1ks25NtBduAbym9BFW3lGfozp2bO TV8fijvKtFc0dB853SYnZ71RazbcWDNFZUEOh5vgEAl8lzFSBCAOAABopLDiG3s5u5fm8MM1uzQ == X-Google-Smtp-Source: APXvYqwqZiP+wzDCYE8sW7K4P2iyupGlweQ2vw/G1wrsuuUFPAZzLmdom5DIiziz5fmhQ67YgUcjYeWohdcQi2m8J+E= X-Received: by 2002:a67:f81a:: with SMTP id l26mr985744vso.194.1579836924089; Thu, 23 Jan 2020 19:35:24 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:27 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-7-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 06/15] bugreport: add compiler info From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer To help pinpoint the source of a regression, it is useful to know some info about the compiler which the user's Git client was built with. By adding a generic get_compiler_info() in 'compat/' we can choose which relevant information to share per compiler; to get started, let's demonstrate the version of glibc if the user built with 'gcc'. Signed-off-by: Emily Shaffer --- bugreport.c | 5 +++++ compat/compiler.h | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 compat/compiler.h diff --git a/bugreport.c b/bugreport.c index 720c91e1bd..818ccb385c 100644 --- a/bugreport.c +++ b/bugreport.c @@ -4,6 +4,7 @@ #include "strbuf.h" #include "time.h" #include "help.h" +#include "compat/compiler.h" static void get_system_info(struct strbuf *sys_info) { @@ -26,6 +27,10 @@ static void get_system_info(struct strbuf *sys_info) uname_info.release, uname_info.version, uname_info.machine); + + strbuf_addstr(sys_info, "compiler info: "); + get_compiler_info(sys_info); + strbuf_complete_line(sys_info); } static const char * const bugreport_usage[] = { diff --git a/compat/compiler.h b/compat/compiler.h new file mode 100644 index 0000000000..bda5098e1b --- /dev/null +++ b/compat/compiler.h @@ -0,0 +1,24 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#include "git-compat-util.h" +#include "strbuf.h" + +#ifdef __GLIBC__ +#include + +static inline void get_compiler_info(struct strbuf *info) +{ + strbuf_addf(info, "glibc: %s", gnu_get_libc_version()); +} + +#else + +static inline void get_compiler_info(struct strbuf *info) +{ + strbuf_addstr(info, "get_compiler_info() not implemented"); +} + +#endif + +#endif /* COMPILER_H */ From patchwork Fri Jan 24 03:34:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349589 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60E4317EA for ; Fri, 24 Jan 2020 03:35:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BE4622522 for ; Fri, 24 Jan 2020 03:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="l84pa+qX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729875AbgAXDf1 (ORCPT ); Thu, 23 Jan 2020 22:35:27 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:34777 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgAXDf1 (ORCPT ); Thu, 23 Jan 2020 22:35:27 -0500 Received: by mail-pj1-f73.google.com with SMTP id c67so2121377pje.1 for ; Thu, 23 Jan 2020 19:35:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=8qKWsQsM+MgWbCv7TZB90oKew/yDE6OgybJU0YT4zA0=; b=l84pa+qXrjZ3m+MCGKf1orAb2HYkWPYiE8NQKKPI2nBWKu7P5hXqb5nwRuDHdTZ8RD w7bEjavPqN86H4jN6Vr4KqlFngCyyJ8pp64ezR0ijderM9iJZV37DhIuEGVfNFc7Zs7Y /O/uqa7ZTSkiXDWKGe+H2m0wNzQstSprNqpwzAhgZX8f46EAMeL6a266OV6O3EEHknWv Caa1P/kfCAjezKR4whepQLuClB5Pt2G1K3qQ6V026I9IwzsY4OwR+QlEnWfkfuWpHAbh 9XgHD/OutSnOybutWbJD2jroqLaOx3ueFVK+usAZU5/1w5a7IgtmgIruV9bteiQn9+AF +Jmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=8qKWsQsM+MgWbCv7TZB90oKew/yDE6OgybJU0YT4zA0=; b=Oo8EXQR/mPR9U8/vJ9CG89W+i1sKSaIxpfiJS7g+Gxykd+6RJEKemD7zI0y08hSRVm VSLUthjmE6ujZmtgs+bv2Nxnq7HcSrOoEJWtzFbRlFrrOxvw6XAKfTnLOHUHgfWrmj57 2nZJxQYhn6yFxRerwWjSthYVIVUfkr7n+Dn5NGZobjDmuYfRNdoD4mxOnrc3SukwEnPt dmoggrq8GcYtov5naskvDOjMkZMmZJwhtSR1g968/SFMsmGiqJyilb1F8u2z2zcMnrh0 Txkwajps5DWe2BK3UqkJ15Hba1odwUDhHFYdo8aQjIGODrpTZg+rRPRsY2/7IZSvJyGA lZUA== X-Gm-Message-State: APjAAAWsMey1uTW65CS4KPcnG8ekiDLeSBpv0pTpghInUlQJ54seCxOo 3SeVZrjm3ZH1DRRgg6gWy1m5VKKG4fdXB0f4R1bV9tp9RAx3+/vVjiVz0kJrwfqmS/DupRJ6c7j 9ebHCL2C2C2jtuM3jHg36qRJLTzShccRvfYBmTAt9bnQevk7ekmfYmdvuTvu+3eYpIvVJ3ftYSg == X-Google-Smtp-Source: APXvYqyCADK9jdLG+1FqU0S2ZokYXtbcO7T/J9Ak1lVCwcHftMQWeuhK1VtqutpAS76AxRBRI3PVl/t+IxFXqFhr7i4= X-Received: by 2002:a63:2808:: with SMTP id o8mr1788141pgo.39.1579836926505; Thu, 23 Jan 2020 19:35:26 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:28 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-8-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 07/15] bugreport: add curl version From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer It's possible for git-remote-curl to be built separately from git; in that case we want to know what version of cURL is used by git-remote-curl, not necessarily which version was present at git-bugreport's build time. So instead, ask git-remote-curl for the version information it knows about. For longevity purposes, invoke the alias "git-remote-https" instead of "git-remote-http". Since it could have been built at a different time, also report the version and built-from commit of git-remote-curl alongside the cURL info. Signed-off-by: Emily Shaffer --- bugreport.c | 16 ++++++++++++++++ remote-curl.c | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/bugreport.c b/bugreport.c index 818ccb385c..73f6d39517 100644 --- a/bugreport.c +++ b/bugreport.c @@ -5,6 +5,18 @@ #include "time.h" #include "help.h" #include "compat/compiler.h" +#include "run-command.h" + +static void get_curl_version_info(struct strbuf *curl_info) +{ + struct child_process cp = CHILD_PROCESS_INIT; + + argv_array_push(&cp.args, "git"); + argv_array_push(&cp.args, "remote-https"); + argv_array_push(&cp.args, "--build-info"); + if (capture_command(&cp, curl_info, 0)) + strbuf_addstr(curl_info, "'git-remote-https --build-info' not supported\n"); +} static void get_system_info(struct strbuf *sys_info) { @@ -31,6 +43,10 @@ static void get_system_info(struct strbuf *sys_info) strbuf_addstr(sys_info, "compiler info: "); get_compiler_info(sys_info); strbuf_complete_line(sys_info); + + strbuf_addstr(sys_info, "git-remote-https --build-info:\n"); + get_curl_version_info(sys_info); + strbuf_complete_line(sys_info); } static const char * const bugreport_usage[] = { diff --git a/remote-curl.c b/remote-curl.c index 350d92a074..c590fbfae3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -17,6 +17,7 @@ #include "protocol.h" #include "quote.h" #include "transport.h" +#include "version.h" static struct remote *remote; /* always ends with a trailing slash */ @@ -1374,6 +1375,13 @@ int cmd_main(int argc, const char **argv) string_list_init(&options.deepen_not, 1); string_list_init(&options.push_options, 1); + if (!strcmp("--build-info", argv[1])) { + printf("git-http-fetch version: %s\n", git_version_string); + printf("built from commit: %s\n", git_built_from_commit_string); + printf("curl version: %s\n", curl_version()); + return 0; + } + /* * Just report "remote-curl" here (folding all the various aliases * ("git-remote-http", "git-remote-https", and etc.) here since they From patchwork Fri Jan 24 03:34:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14CB7921 for ; Fri, 24 Jan 2020 03:35:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E346124125 for ; Fri, 24 Jan 2020 03:35:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z8/qpD0J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729898AbgAXDfb (ORCPT ); Thu, 23 Jan 2020 22:35:31 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:33646 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgAXDfa (ORCPT ); Thu, 23 Jan 2020 22:35:30 -0500 Received: by mail-yw1-f74.google.com with SMTP id e66so539802ywf.0 for ; Thu, 23 Jan 2020 19:35:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cyO149RfctL+SLMlcgnvh4ZsUVUgUM/UYJB6OSgVkmo=; b=Z8/qpD0J8GUwjdDZuii7wni8NTGy94wH/4XLLMtiN40WE5s8nAOvO2WcheJhYDilYj hXQCU+O69qgunO0/MCyUA+jxUgJ2Gytxfb5ZK8cWS7AoLDrkjwNFh4h+EGxpBKQTzDtV wzWOmcuV1m0S91pq2D/Avy94IQcgJPLjY7/+xwOjtZvLAeFHWM6XYfktsPrkfrhf3mV5 POJ/1NwvvcMjQTGf0klLixnxRuCpT35cYo0Tn3DOoL81v6SHH15SBzEC3rIbyrRUxx1h RUF2fHGWUapixDO3/RVK7WkGpuVZdfObrl2GRIxRSVs6NJD1LXnF77C8IYuorSv8KYW4 3Ncw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cyO149RfctL+SLMlcgnvh4ZsUVUgUM/UYJB6OSgVkmo=; b=OgnzlfgB8DLuKiYeT8loI/7NIlD5j23gxLpcQpW0M6TaXwm51oGGoSi0XfUOS8XYAo 3Zs84gfB+It70GYRxj1YD8Q+5R7AlLdHqE6uHUzEWurCRsCmYV/zvkf5CaGXjn9gn2iw C09bQI1AfdiIWKL9LJa9/qM8oybQa8UM/5JBcg8ERGT0JpIdplFtGMqMkELd5tZz9/s5 6opxLOt7PVueipbfkuFUZDHL1qN3XN1J/Jud5MudbKYTC9KQbo3cYeQksDnTCKo84Ndk ohjTXSnBtAYrA77i4mnCKybQc2kbCt/z22lv6RzC33Jobf37DMjqVJFxhpm8A9/cnfvt rE7Q== X-Gm-Message-State: APjAAAWqVdemYkSif06/EWDVH6dplNZUvds5i+QgE3YKoHkOETnkWaX9 D3yvCmDjFtcyvEXU+aT/5lqMzKdSTFXu+bV6AK+vAkC91nbknbUvtfbn02heaMjY41GMjHJYGlZ 1tqaHePH79IIeY4xhxE/gL5mfGrcY5gfxL42Kp++25Qi42VuHo1heNe/QcAIFreEx278FfSNlpg == X-Google-Smtp-Source: APXvYqzJ73HMj1XWuQYlV5bVAOd1wjPNKqNSVQK2X6FLsNlzanIpaWg07OASuFC8yVoMCMIf/UvjQ+SPpSMW+g2NTkc= X-Received: by 2002:a0d:c6c1:: with SMTP id i184mr616553ywd.389.1579836929284; Thu, 23 Jan 2020 19:35:29 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:29 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-9-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 08/15] bugreport: include user interactive shell From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer It's possible a user may complain about the way that Git interacts with their interactive shell, e.g. autocompletion or shell prompt. In that case, it's useful for us to know which shell they're using interactively. Signed-off-by: Emily Shaffer --- bugreport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bugreport.c b/bugreport.c index 73f6d39517..07b84b9c94 100644 --- a/bugreport.c +++ b/bugreport.c @@ -22,6 +22,7 @@ static void get_system_info(struct strbuf *sys_info) { struct strbuf version_info = STRBUF_INIT; struct utsname uname_info; + char *shell = NULL; /* get git version from native cmd */ strbuf_addstr(sys_info, "git version:\n"); @@ -44,6 +45,10 @@ static void get_system_info(struct strbuf *sys_info) get_compiler_info(sys_info); strbuf_complete_line(sys_info); + shell = getenv("SHELL"); + strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n", + shell ? shell : "(NULL)"); + strbuf_addstr(sys_info, "git-remote-https --build-info:\n"); get_curl_version_info(sys_info); strbuf_complete_line(sys_info); From patchwork Fri Jan 24 03:34:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B9F9921 for ; Fri, 24 Jan 2020 03:35:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E29224125 for ; Fri, 24 Jan 2020 03:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ufj1LBnO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729927AbgAXDfd (ORCPT ); Thu, 23 Jan 2020 22:35:33 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:33421 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgAXDfc (ORCPT ); Thu, 23 Jan 2020 22:35:32 -0500 Received: by mail-pg1-f201.google.com with SMTP id s23so592297pgg.0 for ; Thu, 23 Jan 2020 19:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=w0zOxSADVL7WmpZIfCipAStf9CMvWfwy2JdFqBYJ0XM=; b=Ufj1LBnOXACvK9V+04fnAh2cPeG8Ah1u7nRBs7vCZ8zEM7b+wYww5DPJQpvltC+i3l nU+rSpgbF6uxH+yRBI5s8fp5rr7gluKRKI2mgQ0xGvhqYd87vsEUQhYPzt7liXUoCxHg eYFZbZFr2HiH5R0YK/rBiQjR0OcVfFZkbyrly0Kq5eb87Fej60sJZCZEJrXS/Ds9zSBS 4qSX3mbo7pCU1TbuLnEDkt+dP4+HKunuT0i90E09ILdXIJEnDWBaODoncqwJbbrAhY1R EyF/4hLSmDnfcZm2Yw38OhrWDEbjEU2rgemx3MppvvITdq5eZPAyzj368IbpSCyT18LT 3xCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=w0zOxSADVL7WmpZIfCipAStf9CMvWfwy2JdFqBYJ0XM=; b=R46mLc+6L27Cg9Ohb76o2qO9kh/nAYOnI6TsNjjaFHVM/tw7vpX5UDYrxPdFEblh5R BaWiYQ5am33mcuxUBzgukxPbVbUhvslFUy+8Sw1KvHnfNvCWHoqz3C/Pew2LWWUwY9jT Iq9XbhWsR09dpLBoPNhmYjYkk2Phn57YTDGF91I5BjqhVKEVptRW5gw9xENBlh+mHle+ V2azUxARwukuk9X2nQPWkt+ZYL17gi8fA7StA8MHtODq834lXqEuvah+esUxi0Z4z8WH uZOBYnVIlDXZgnmIGWIU+i6koebyGQqZapL2n4lqwyLDwOWORd+oaejRrthT4R3+PTQl 9z4w== X-Gm-Message-State: APjAAAVVV34oxzHXVMEnZN7APRxAXdhq+4+ShREn6dYIouUJw796l8f2 uqc7P7nCZ/QMu18V8vW9nu+mX20zQZ1ym0+fBs6w+HsA4pdZ9lCfy92rnOIsQyx7qGMpurij+lM CxPCxEtUHw3jJ2EaYfMnNrwV+OAKKfkl5JjhKRtAZHQuTd/gJ/iVVTEyvxwkLRdlyjgETy+ktzg == X-Google-Smtp-Source: APXvYqyvg6WSdkZ+Gjqi4bCgS5gr50tjg4f1yhjSiTT1/F1PkKZ5chkMYwux3CkkDFNaSFUYRJQH/Q8epsI+44vvc4Q= X-Received: by 2002:a63:4723:: with SMTP id u35mr1733480pga.194.1579836931676; Thu, 23 Jan 2020 19:35:31 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:30 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-10-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 09/15] bugreport: generate config safelist based on docs From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer , " =?utf-8?q?Martin_=C3=85gren?= " , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Add a new step to the build to generate a safelist of git-config variables which are appropriate to include in the output of git-bugreport. New variables can be added to the safelist by annotating their documentation in Documentation/config with the "bugreport" macro, which is recognized by AsciiDoc and AsciiDoctor. Some configs are private in nature, and can contain remote URLs, passwords, or other sensitive information. In the event that a user doesn't notice their information while reviewing a bugreport, that user may leak their credentials to other individuals, mailing lists, or bug tracking tools inadvertently. Heuristic blocklisting of configuration keys is imperfect and prone to false negatives; given the nature of the information which can be leaked, a safelist is more reliable. In order to prevent staleness of the safelist, add a mechanism to generate the safelist from annotations in the config documentation, where contributors are already used to documenting their new config keys. Implement a new no-op "bugreport" macro for use as "bugreport:include[x]" to annotate the config keys that should be included in the automatically generated safelist. Use "exclude" for the others. With Asciidoctor, it's ok to say "bugreport:include[]", but AsciiDoc seems to want something between the brackets. A bit unfortunate, but not a huge problem -- we'll just provide an "x". "doc-diff" reports that this macro doesn't render at all. That is, these are both empty after this commit: cd Documentation ./doc-diff --asciidoctor :/"bugreport: add tool" HEAD ./doc-diff --asciidoc :/"bugreport: add tool" HEAD Diffing the rendered HTML shows that there is some small amount of whitespace and comments added. That shouldn't be a problem. We could perhaps let the implementation verify that the "action" is one of "include" and "exclude". For the Asciidoctor implementation that should be straightforward, but for AsciiDoc I don't immediately know how to do it. Anyway, if someone stumbles on the keyboard and writes "bugreport:icndule", they'll "only" miss out on the config key being included in the safelist. If this were a blocklist, the consequences of a misspelled target could be a lot more severe. Additionally, add annotations to the sendemail config documentation in order to demonstrate a proof of concept. Helped-by: Martin Ă…gren Helped-by: Johannes Schindelin Signed-off-by: Emily Shaffer --- .gitignore | 1 + Documentation/asciidoc.conf | 8 +++ Documentation/asciidoctor-extensions.rb | 7 +++ Documentation/config/sendemail.txt | 68 ++++++++++++------------- Makefile | 7 +++ generate-bugreport-config-safelist.sh | 17 +++++++ 6 files changed, 74 insertions(+), 34 deletions(-) create mode 100755 generate-bugreport-config-safelist.sh diff --git a/.gitignore b/.gitignore index d89bf9e11e..bd2f49b996 100644 --- a/.gitignore +++ b/.gitignore @@ -192,6 +192,7 @@ /gitweb/static/gitweb.min.* /config-list.h /command-list.h +/bugreport-config-safelist.h *.tar.gz *.dsc *.deb diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf index 8fc4b67081..5d5359fcf9 100644 --- a/Documentation/asciidoc.conf +++ b/Documentation/asciidoc.conf @@ -6,9 +6,13 @@ # # Show Git link as: (
); if section is defined, else just show # the command. +# +# The bugreport macro does nothing as far as rendering is +# concerned -- we just grep for it in the sources. [macros] (?su)[\\]?(?Plinkgit):(?P\S*?)\[(?P.*?)\]= +(?su)[\\]?(?Pbugreport):(?P\S*?)\[(?P.*?)\]= [attributes] asterisk=* @@ -28,6 +32,8 @@ ifdef::backend-docbook[] {0#} {0#{target}{0}} {0#} +[bugreport-inlinemacro] +{0#} endif::backend-docbook[] ifdef::backend-docbook[] @@ -94,4 +100,6 @@ ifdef::backend-xhtml11[] git-relative-html-prefix= [linkgit-inlinemacro] {target}{0?({0})} +[bugreport-inlinemacro] + endif::backend-xhtml11[] diff --git a/Documentation/asciidoctor-extensions.rb b/Documentation/asciidoctor-extensions.rb index d906a00803..750bdff9af 100644 --- a/Documentation/asciidoctor-extensions.rb +++ b/Documentation/asciidoctor-extensions.rb @@ -37,6 +37,10 @@ module Git output = output.sub(/<\/refmeta>/, new_tags + "") end output + + class BugReportProcessor < Asciidoctor::Extensions::InlineMacroProcessor + def process(parent, action, attrs) + "" end end end @@ -45,4 +49,7 @@ end Asciidoctor::Extensions.register do inline_macro Git::Documentation::LinkGitProcessor, :linkgit postprocessor Git::Documentation::DocumentPostProcessor + # The bugreport macro does nothing as far as rendering is + # concerned -- we just grep for it in the sources. + inline_macro Git::Documentation::BugReportProcessor, :bugreport end diff --git a/Documentation/config/sendemail.txt b/Documentation/config/sendemail.txt index 0006faf800..92f5082013 100644 --- a/Documentation/config/sendemail.txt +++ b/Documentation/config/sendemail.txt @@ -1,63 +1,63 @@ -sendemail.identity:: +sendemail.identity bugreport:exclude[x] :: A configuration identity. When given, causes values in the 'sendemail.' subsection to take precedence over values in the 'sendemail' section. The default identity is the value of `sendemail.identity`. -sendemail.smtpEncryption:: +sendemail.smtpEncryption bugreport:include[x] :: See linkgit:git-send-email[1] for description. Note that this setting is not subject to the 'identity' mechanism. -sendemail.smtpssl (deprecated):: +sendemail.smtpssl (deprecated) bugreport:exclude[x] :: Deprecated alias for 'sendemail.smtpEncryption = ssl'. -sendemail.smtpsslcertpath:: +sendemail.smtpsslcertpath bugreport:exclude[x] :: Path to ca-certificates (either a directory or a single file). Set it to an empty string to disable certificate verification. -sendemail..*:: +sendemail..* bugreport:exclude[x] :: Identity-specific versions of the 'sendemail.*' parameters found below, taking precedence over those when this identity is selected, through either the command-line or `sendemail.identity`. -sendemail.aliasesFile:: -sendemail.aliasFileType:: -sendemail.annotate:: -sendemail.bcc:: -sendemail.cc:: -sendemail.ccCmd:: -sendemail.chainReplyTo:: -sendemail.confirm:: -sendemail.envelopeSender:: -sendemail.from:: -sendemail.multiEdit:: -sendemail.signedoffbycc:: -sendemail.smtpPass:: -sendemail.suppresscc:: -sendemail.suppressFrom:: -sendemail.to:: -sendemail.tocmd:: -sendemail.smtpDomain:: -sendemail.smtpServer:: -sendemail.smtpServerPort:: -sendemail.smtpServerOption:: -sendemail.smtpUser:: -sendemail.thread:: -sendemail.transferEncoding:: -sendemail.validate:: -sendemail.xmailer:: +sendemail.aliasesFile bugreport:exclude[x] :: +sendemail.aliasFileType bugreport:exclude[x] :: +sendemail.annotate bugreport:include[x] :: +sendemail.bcc bugreport:include[x] :: +sendemail.cc bugreport:include[x] :: +sendemail.ccCmd bugreport:include[x] :: +sendemail.chainReplyTo bugreport:include[x] :: +sendemail.confirm bugreport:include[x] :: +sendemail.envelopeSender bugreport:include[x] :: +sendemail.from bugreport:include[x] :: +sendemail.multiEdit bugreport:include[x] :: +sendemail.signedoffbycc bugreport:include[x] :: +sendemail.smtpPass bugreport:exclude[x] :: +sendemail.suppresscc bugreport:include[x] :: +sendemail.suppressFrom bugreport:include[x] :: +sendemail.to bugreport:include[x] :: +sendemail.tocmd bugreport:include[x] :: +sendemail.smtpDomain bugreport:include[x] :: +sendemail.smtpServer bugreport:include[x] :: +sendemail.smtpServerPort bugreport:include[x] :: +sendemail.smtpServerOption bugreport:include[x] :: +sendemail.smtpUser bugreport:exclude[x] :: +sendemail.thread bugreport:include[x] :: +sendemail.transferEncoding bugreport:include[x] :: +sendemail.validate bugreport:include[x] :: +sendemail.xmailer bugreport:include[x] :: See linkgit:git-send-email[1] for description. -sendemail.signedoffcc (deprecated):: +sendemail.signedoffcc (deprecated) bugreport:exclude[x] :: Deprecated alias for `sendemail.signedoffbycc`. -sendemail.smtpBatchSize:: +sendemail.smtpBatchSize bugreport:include[x] :: Number of messages to be sent per connection, after that a relogin will happen. If the value is 0 or undefined, send all messages in one connection. See also the `--batch-size` option of linkgit:git-send-email[1]. -sendemail.smtpReloginDelay:: +sendemail.smtpReloginDelay bugreport:include[x] :: Seconds wait before reconnecting to smtp server. See also the `--relogin-delay` option of linkgit:git-send-email[1]. diff --git a/Makefile b/Makefile index a01a050aa3..2bc9f112ea 100644 --- a/Makefile +++ b/Makefile @@ -817,6 +817,7 @@ VCSSVN_LIB = vcs-svn/lib.a GENERATED_H += config-list.h GENERATED_H += command-list.h +GENERATED_H += bugreport-config-safelist.h LIB_H := $(sort $(patsubst ./%,%,$(shell git ls-files '*.h' ':!t/' ':!Documentation/' 2>/dev/null || \ $(FIND) . \ @@ -2163,6 +2164,12 @@ command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Doc $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@ +bugreport-config-safelist.h: generate-bugreport-config-safelist.sh + +bugreport-config-safelist.h: Documentation/config/*.txt + $(QUIET_GEN)$(SHELL_PATH) ./generate-bugreport-config-safelist.sh \ + >$@+ && mv $@+ $@ + SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\ $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ $(gitwebdir_SQ):$(PERL_PATH_SQ):$(SANE_TEXT_GREP):$(PAGER_ENV):\ diff --git a/generate-bugreport-config-safelist.sh b/generate-bugreport-config-safelist.sh new file mode 100755 index 0000000000..44612d5538 --- /dev/null +++ b/generate-bugreport-config-safelist.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +cat < X-Patchwork-Id: 11349597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C54AC17EA for ; Fri, 24 Jan 2020 03:35:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9465B24655 for ; Fri, 24 Jan 2020 03:35:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IWdO1fYJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729949AbgAXDfg (ORCPT ); Thu, 23 Jan 2020 22:35:36 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:33422 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgAXDfe (ORCPT ); Thu, 23 Jan 2020 22:35:34 -0500 Received: by mail-pg1-f202.google.com with SMTP id s23so592326pgg.0 for ; Thu, 23 Jan 2020 19:35:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=k9JufkulLGwySzhRbUjAmjY2tNQfo+MMSJLRQyRBhdc=; b=IWdO1fYJw2P+uX6h/ubLxp7roml7YLw9o0+Pef6bTsq8vh++oW52HKq1fGj26Y4WJD chRp1OCLk/hHJLVQiLrd5qiZyL805eEftiPnIIh7QKUeyPj9JcsiiK2zNNRcdqFF0uDN jdLRhvGje2Qg55J6htqaEkcZ5pqOn542Z6b/x/yvp/OAPsxZRM9lZclMo2Yd4ssmBQKe N3HEAohsXP61L5m3Gawyt6+7dCOKTkuTsDFsp20ScoaD+nU8rUZvgsjuQnsPcxKC4c5P SFm6qWOeYafM4oERQfkh0+AiJR970g5r+eSkUVjOxovk6FdkLsarENMk+gsjETQkLSXo no8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=k9JufkulLGwySzhRbUjAmjY2tNQfo+MMSJLRQyRBhdc=; b=bu9YHemKngD1GbMWBhzwthDJ2WRS7H7B9RFNd6Fxqv2B5RITAcRwag8a45t7FGwe2B Be0gmRpS60JJN0Nby1s0+8kRyEs05HkXnm3okN61Ij6pmvWq5jEKuZpxRC5sfEMuvBwm HGXywTVrckxXBbD+b9MY9gOePo9qIUrmz0mGrA79wmuTHSnf6TIgnrDsfxY99CJ9khc+ vhcKVHhBOr+tjuwcogTG1kCnDdHaKykC0JVyeul+LpW1wFyurMJS7Vors8Rd1uNoluBL UYpQ0oq2gOujdOmtSRehasP/9pygurKxy5pKdDuOsMPKOtx38ztWptsqXS4twWeSdEFO PJug== X-Gm-Message-State: APjAAAWjTvJqsHxW+oBdDemV46gWFgytu1M7V1Yt4KmbzqlMPNjsprKu ussRsGLuZmaJiNL8vZanD8h7u88rj4QzajknBgFTiYbUCEup1Hvvcl75tbDDcHUbzbcwSistpzB Bpf57msYIXtEeL8THRr5AssWFbIhKctiExV67pzU/FhWxN2MmBlt6E3Wu8jaQbNQ0JzqUX92RDg == X-Google-Smtp-Source: APXvYqwAq3SGG44fJtscuCb0hOhYrbEFYp1LYamFUk5KB29qhPBvq7KkyVMemlRwrzA+kK+e4xNG6MAK/AQ2UiFdxU8= X-Received: by 2002:a63:3104:: with SMTP id x4mr1722009pgx.369.1579836934077; Thu, 23 Jan 2020 19:35:34 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:31 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-11-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 10/15] bugreport: add config values from safelist From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Teach bugreport to gather the values of config options which are present in 'bugreport-config-safelist.h'. Many config options are sensitive, and many Git add-ons use config options which git-core does not know about; it is better only to gather config options which we know to be safe, rather than excluding options which we know to be unsafe. Taking the build-time generated array and putting it into a set saves us time - since git_config_bugreport() is called for every option the user has configured, performing option lookup in constant time is a useful optimization. Signed-off-by: Emily Shaffer --- Makefile | 2 +- bugreport.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2bc9f112ea..eb17ece120 100644 --- a/Makefile +++ b/Makefile @@ -2465,7 +2465,7 @@ endif git-%$X: %.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) -git-bugreport$X: bugreport.o GIT-LDFLAGS $(GITLIBS) +git-bugreport$X: bugreport-config-safelist.h bugreport.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) diff --git a/bugreport.c b/bugreport.c index 07b84b9c94..7a9fd36b60 100644 --- a/bugreport.c +++ b/bugreport.c @@ -6,6 +6,9 @@ #include "help.h" #include "compat/compiler.h" #include "run-command.h" +#include "config.h" +#include "bugreport-config-safelist.h" +#include "khash.h" static void get_curl_version_info(struct strbuf *curl_info) { @@ -18,6 +21,40 @@ static void get_curl_version_info(struct strbuf *curl_info) strbuf_addstr(curl_info, "'git-remote-https --build-info' not supported\n"); } +KHASH_INIT(cfg_set, const char*, int, 0, kh_str_hash_func, kh_str_hash_equal); + +struct cfgset { + kh_cfg_set_t set; +}; + +struct cfgset safelist; + +static void cfgset_init(struct cfgset *set, size_t initial_size) +{ + memset(&set->set, 0, sizeof(set->set)); + if (initial_size) + kh_resize_cfg_set(&set->set, initial_size); +} + +static int cfgset_insert(struct cfgset *set, const char *cfg_key) +{ + int added; + kh_put_cfg_set(&set->set, cfg_key, &added); + return !added; +} + +static int cfgset_contains(struct cfgset *set, const char *cfg_key) +{ + khiter_t pos = kh_get_cfg_set(&set->set, cfg_key); + return pos != kh_end(&set->set); +} + +static void cfgset_clear(struct cfgset *set) +{ + kh_release_cfg_set(&set->set); + cfgset_init(set, 0); +} + static void get_system_info(struct strbuf *sys_info) { struct strbuf version_info = STRBUF_INIT; @@ -54,6 +91,36 @@ static void get_system_info(struct strbuf *sys_info) strbuf_complete_line(sys_info); } +static void gather_safelist(void) +{ + int index; + int safelist_len = sizeof(bugreport_config_safelist) / sizeof(const char *); + cfgset_init(&safelist, safelist_len); + for (index = 0; index < safelist_len; index++) + cfgset_insert(&safelist, bugreport_config_safelist[index]); + +} + +static int git_config_bugreport(const char *var, const char *value, void *cb) +{ + struct strbuf *config_info = (struct strbuf *)cb; + + if (cfgset_contains(&safelist, var)) + strbuf_addf(config_info, + "%s (%s) : %s\n", + var, config_scope_to_string(current_config_scope()), + value); + + return 0; +} + +static void get_safelisted_config(struct strbuf *config_info) +{ + gather_safelist(); + git_config(git_config_bugreport, config_info); + cfgset_clear(&safelist); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -94,12 +161,17 @@ int cmd_main(int argc, const char **argv) FILE *report; time_t now = time(NULL); char *option_output = NULL; + int nongit_ok = 0; const struct option bugreport_options[] = { OPT_STRING('o', "output", &option_output, N_("path"), N_("specify a destination for the bugreport file")), OPT_END() }; + + /* Prerequisite for hooks and config checks */ + setup_git_directory_gently(&nongit_ok); + argc = parse_options(argc, argv, "", bugreport_options, bugreport_usage, 0); @@ -118,6 +190,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "System Info"); get_system_info(&buffer); + get_header(&buffer, "Safelisted Config Info"); + get_safelisted_config(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Jan 24 03:34:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349599 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3A871580 for ; Fri, 24 Jan 2020 03:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E72A22522 for ; Fri, 24 Jan 2020 03:35:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sUqPMLnM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729970AbgAXDfi (ORCPT ); Thu, 23 Jan 2020 22:35:38 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:38833 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgAXDfh (ORCPT ); Thu, 23 Jan 2020 22:35:37 -0500 Received: by mail-pl1-f201.google.com with SMTP id t17so447056ply.5 for ; Thu, 23 Jan 2020 19:35:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=oFR7nJWhTF5N+cLtzN0uc/ITeUuxrT/RCmci3iWfKyE=; b=sUqPMLnM77ZRAjC0Kja3tg6/WzAiR/bx7Pu+TWDSzxbj3GFfQfY53eJLIea5Qy27K9 WfaGk219AqiZ05CkJ0KZ20ZvRROp4Mvi8EWlHebVyJtY8So9Q8LYKhW8iSVGTnwuvxkd induRO0v0HlRVcqh03hVLF6KfwdpKoavmxk/8D9jPSo6WXi1tBN45YCLMCb7IvNrsazY wkXqqbfjeKi6lmpOC705LK4Q52CSAlLFsc2T5sgYmHw7r8pia98n6fBiYpkfmoWozH6F gKN/FYR6y526AgBZyXgxejcfph1j6lm0Q9CvW0ymgyka1lbQ7K4OrOwvEXVuw2VsSHq2 8W3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=oFR7nJWhTF5N+cLtzN0uc/ITeUuxrT/RCmci3iWfKyE=; b=d+l8DhaYucdIGQt1KSuvURvaZLNzKuZ989UphVisvBGW7GRQRRFtRUUk7yfjaK/FQv 9QdUYAsTE9/5NbYAXUZY6SYEwMwNTwxryr/byjE4KT1LDM4NXeZl4DwnQvGkFo6sOEKt qLOBH4EdLWNWz1cPDaoi/9oTAKW1fkd+HNE+K+jyIeXPGlHJImjySKpuQVTy5oFbCGfV GGoIhtBejgsa3vgFlRIvsYND2dK+vCczJQPPFRJ4jD10DFL6moFE9VCH8tQluLpoVRkL uj6K/QUYD2YWh9h9nVwbjerHII2KliLRugfH7d3rL7QBEJQ3h2V/qPxqG6sSFJTlPUjb xOgA== X-Gm-Message-State: APjAAAUVYGVgXnWDJ2TZuo5CEXx4Kig/VDZBA84JUBUWGOUuMQN7/PWu /a/LidYx2MXQsNQ63J6bC2qqpfim9tWytezIkhwxpsqQ+xi0edfvT/Gi07se7V6GX1lkBTRQ9kA OK828h/kYUaX+Ot1uB4naHYGZB631Dv/Xl7t5rb68vUgjHdwoj1nMpDsvmFBrxi8mfUI2tZJiqw == X-Google-Smtp-Source: APXvYqw3zZECaFEYMbX+HfsENPEX6hBIKGK17awcgyGWe0qpzRr4UHfjH9OTvjFN3PYnKzUk/21CO58bfd5cl3Erd/E= X-Received: by 2002:a63:1853:: with SMTP id 19mr1764801pgy.170.1579836936318; Thu, 23 Jan 2020 19:35:36 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:32 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-12-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 11/15] bugreport: collect list of populated hooks From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Occasionally a failure a user is seeing may be related to a specific hook which is being run, perhaps without the user realizing. While the contents of hooks can be sensitive - containing user data or process information specific to the user's organization - simply knowing that a hook is being run at a certain stage can help us to understand whether something is going wrong. Without a definitive list of hook names within the code, we compile our own list from the documentation. This is likely prone to bitrot. To reduce the amount of code humans need to read, we turn the list into a string_list and iterate over it (as we are calling the same find_hook operation on each string). However, since bugreport should primarily be called by the user, the performance loss from massaging the string seems acceptable. Signed-off-by: Emily Shaffer --- bugreport.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/bugreport.c b/bugreport.c index 7a9fd36b60..4c77009f1b 100644 --- a/bugreport.c +++ b/bugreport.c @@ -9,6 +9,7 @@ #include "config.h" #include "bugreport-config-safelist.h" #include "khash.h" +#include "run-command.h" static void get_curl_version_info(struct strbuf *curl_info) { @@ -121,6 +122,55 @@ static void get_safelisted_config(struct strbuf *config_info) cfgset_clear(&safelist); } +static void get_populated_hooks(struct strbuf *hook_info, int nongit) +{ + /* + * Doesn't look like there is a list of all possible hooks; so below is + * a transcription of `git help hook`. + */ + const char *hooks = "applypatch-msg," + "pre-applypatch," + "post-applypatch," + "pre-commit," + "pre-merge-commit," + "prepare-commit-msg," + "commit-msg," + "post-commit," + "pre-rebase," + "post-checkout," + "post-merge," + "pre-push," + "pre-receive," + "update," + "post-receive," + "post-update," + "push-to-checkout," + "pre-auto-gc," + "post-rewrite," + "sendemail-validate," + "fsmonitor-watchman," + "p4-pre-submit," + "post-index-changex"; + struct string_list hooks_list = STRING_LIST_INIT_DUP; + struct string_list_item *iter = NULL; + + + if (nongit) { + strbuf_addstr(hook_info, + "not run from a git repository - no hooks to show\n"); + return; + } + + string_list_split(&hooks_list, hooks, ',', -1); + + for_each_string_list_item(iter, &hooks_list) { + if (find_hook(iter->string)) { + strbuf_addstr(hook_info, iter->string); + strbuf_complete_line(hook_info); + } + } +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -193,6 +243,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Safelisted Config Info"); get_safelisted_config(&buffer); + get_header(&buffer, "Configured Hooks"); + get_populated_hooks(&buffer, nongit_ok); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Jan 24 03:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349603 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E16FD1580 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB8E024655 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LOXWf8wZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730020AbgAXDfm (ORCPT ); Thu, 23 Jan 2020 22:35:42 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:47499 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729880AbgAXDfj (ORCPT ); Thu, 23 Jan 2020 22:35:39 -0500 Received: by mail-pl1-f202.google.com with SMTP id h3so435068plt.14 for ; Thu, 23 Jan 2020 19:35:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KokYk1QYEDbftX+PB6HNSmTNk7153BXKySC1YaTHrRQ=; b=LOXWf8wZ/i7i2CstOUj3i0rgdQdqMcPuR0788TXS0klJ7zTy2ocPd1IJE0d4fmpbHX fJzoU//71rEwB7MDIXOvYIibVGYVn4kotGS0K004ybhYP2xlYYdmDs+18EYUeTe1pzJJ OQWVCFvwbKq3/lvG0iMz1HxxGe7lOKs3dunMKWcCSgWbd3EMSnU3GlFogkCLe8pJzg24 q7gVgbTXcqD7LUEGAlR4BEZKBFs8CDTeiVFXLYxZ6jXlsutzSJVtes615hgBq3cYt9p4 LOWG0N8euY2u4HGCZobnt2mDvbl0BDvDTwv7xCtoz7rpBRu9cEr9Ir77BnRId53jiGQe QZxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KokYk1QYEDbftX+PB6HNSmTNk7153BXKySC1YaTHrRQ=; b=EECLCb2e5bJcRTEkpBj7FFlYCJiCXrR7MZd46L8g+olgP9i13HvZhohdHfAkk7Ud7V BhF7SlP1hVxCksrAOWj/UcL8dGL28C3bcXqyc4GDha7Ju39W0wCFh/ciyHVdvQEsi+mo CoLHH0BjsZQZHzDMoAHn/OcMIVDuR63TlmLvBv3cZmX2xg4boAm66X2LvGgYHcG1QtUZ 4tlyfhGoJNozKlgwFeNz9Oo55sVzqMHKAb5Uh4ncazEGsWWmmeIduSVf0ATGUAyfeCa+ /RjDuIoMbZmQtPR1+fBuXTYU3yTZf+XurTDGKDKkjF6MHZXNJQrLjIeqdegcSc4UpHvX 7DZQ== X-Gm-Message-State: APjAAAUfi7m2EHC+ICBkuD+959lIp74gaeA/gUrfDJ2OLRJqpdIUUQWf iZvBYm+v/qARwyJ2J/wcMNRDYxG3Jv62daUe/koIrrM0r5ClGNa9Uj0R1elmzNdJzKGC8i31NO6 ZamU1WrHAhKhqAD7FJZhh2hnhjihcC5ohHvg53If3WK0n3DZvwJGRUHciHWhjexNlWC8dnGRYNA == X-Google-Smtp-Source: APXvYqzgl0omCiXT63yLHEjc+/H6GUTOQ8PU7PqoafvvRIwoVZqsy6Dt2LH02kDWmpIcie2xotk1u6CHa52ZJQl4uaU= X-Received: by 2002:a63:2ac2:: with SMTP id q185mr1773993pgq.417.1579836938756; Thu, 23 Jan 2020 19:35:38 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:33 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-13-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 12/15] bugreport: count loose objects From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer The number of unpacked objects in a user's repository may help us understand the root of the problem they're seeing, especially if a command is running unusually slowly. Helped-by: Johannes Schindelin Signed-off-by: Emily Shaffer --- The refactor removed much of the code Dscho suggested; and yet it remains true that he helped me while developing this commit (although his suggestions didn't survive). Shall I leave the Helped-by line or remove it? - Emily bugreport.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/bugreport.c b/bugreport.c index 4c77009f1b..bf10857183 100644 --- a/bugreport.c +++ b/bugreport.c @@ -10,6 +10,7 @@ #include "bugreport-config-safelist.h" #include "khash.h" #include "run-command.h" +#include "object-store.h" static void get_curl_version_info(struct strbuf *curl_info) { @@ -171,6 +172,48 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit) } } +static int loose_object_cb(const struct object_id *oid, const char *path, + void *data) { + int *loose_object_count = data; + + if (loose_object_count) { + (*loose_object_count)++; + return 0; + } + + return 1; +} + +static void get_loose_object_summary(struct strbuf *obj_info) { + + int local_loose_object_count = 0, total_loose_object_count = 0; + int local_count_questionable = 0, total_count_questionable = 0; + + local_count_questionable = for_each_loose_object( + loose_object_cb, + &local_loose_object_count, + FOR_EACH_OBJECT_LOCAL_ONLY); + + total_count_questionable = for_each_loose_object( + loose_object_cb, + &total_loose_object_count, + 0); + + strbuf_addf(obj_info, "%d local loose objects%s\n", + local_loose_object_count, + local_count_questionable ? " (problem during count)" : ""); + + strbuf_addf(obj_info, "%d alternate loose objects%s\n", + total_loose_object_count - local_loose_object_count, + (local_count_questionable || total_count_questionable) + ? " (problem during count)" + : ""); + + strbuf_addf(obj_info, "%d total loose objects%s\n", + total_loose_object_count, + total_count_questionable ? " (problem during count)" : ""); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -246,6 +289,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Configured Hooks"); get_populated_hooks(&buffer, nongit_ok); + get_header(&buffer, "Loose Object Counts"); + get_loose_object_summary(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Jan 24 03:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EAB5921 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35BC324125 for ; Fri, 24 Jan 2020 03:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GLL5khmF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730040AbgAXDfm (ORCPT ); Thu, 23 Jan 2020 22:35:42 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:48328 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgAXDfl (ORCPT ); Thu, 23 Jan 2020 22:35:41 -0500 Received: by mail-pg1-f202.google.com with SMTP id c8so570168pgl.15 for ; Thu, 23 Jan 2020 19:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WvPVNv9YPSMDwsZTnnax5OM3yhXCWMqhegtg+6rIqyk=; b=GLL5khmFkHOPmi8XMuUXvxjIrVk+OXNLZm1bGZy1ET8XAScgkvlsP+IGB1p31nRyS6 qJHxpMsKJoHIuqD/BPwlwuxYae7Y34FttthLssSljyxFzclCfCy50U/q+9LxgvQxaBet zBpJgbrylbbShAmhqUT1mFzooQJQcNPxVSXUKTWY2KED7/4lvC1Z4jbZfW93RORpDpBl /2lYqt7timKa+ApTM9ImKdUgqItCT+mm4PzRCo4LBFko/18IvWuOaB4dofQ1PqRW0yS5 8riJcBS4O2BVxlE5pWnsdycZFJcYrBQisUdUWtsGhZwEB2eElC4dR6yjmk7mcgDqiXaL GhDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WvPVNv9YPSMDwsZTnnax5OM3yhXCWMqhegtg+6rIqyk=; b=pJubx2KrqEw9iWEdpH0Mo2X4BkW3cpG7FnFNQstcxFYQ7xsmWeP95ch1cmTKBYkBhK N5NUA2e5yQZqjUazr38QMq1Aup1OJWQYpi2yWaJW1aH7YMwXgeHSvwK42Pf4YOUyJ/eI VTuTT4ePmE7kAkevlfm3JttbfCBfyu3BiKKM/4XFrXLFvYgBGHvsmhwBOkBD5YsSWaoV 9rTlCATy38H7ry9OqeoQClZXaAf9qupJUIV1uCs0dpeb1XFi2FG2tjRW14o9O6sxJY6q mJOjxISZJKvj6hqsmojeHNZIz37BYm3+z/BscdjeY1VYbObNDXJLxFQRE7In2yKK6UMF IoCw== X-Gm-Message-State: APjAAAV3o3rDg4/bPvVW0IpQ1/Y2blHMHSEag1xLguaUZJtDKI3fQGaT 7uqlKLAPSpXr/qpIRAbw3fO91Hwzlr5rQjUCrWRoh4Dyu8f2/F+aKJvbB19ej2bS4KfrRZDBzzj Xd1DVAFUdEJ39pL8UmbUQR4McXjQx7yBKbdfU0fJz2d61eKfS2RJhuMsyeZRU71DL4ajqfcqiDQ == X-Google-Smtp-Source: APXvYqwsNUgc24Fl3LiOnezxMeoosIzmKCYYduEsohimAL/+ie4cEljT3J6zksTOfecIPSt6pCEZc019ZHZ2BWG5ztk= X-Received: by 2002:a65:4d0b:: with SMTP id i11mr1876227pgt.340.1579836941150; Thu, 23 Jan 2020 19:35:41 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:34 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-14-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 13/15] bugreport: add packed object summary From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Alongside the loose object counts, it can be useful to show the number of packs and packed objects. This way we can check whether the repo has an appropriate ratio of packed to loose objects to help determine whether it's behaving correctly. Signed-off-by: Emily Shaffer --- bugreport.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bugreport.c b/bugreport.c index bf10857183..45cc1764e0 100644 --- a/bugreport.c +++ b/bugreport.c @@ -214,6 +214,41 @@ static void get_loose_object_summary(struct strbuf *obj_info) { total_count_questionable ? " (problem during count)" : ""); } +struct packed_object_cb_data { + struct packed_git *last_pack; + int pack_count; + int object_count; +}; + +static int packed_object_cb(const struct object_id *oid, + struct packed_git *pack, + uint32_t pos, + void *data) { + struct packed_object_cb_data *cb_data = data; + + if (!cb_data) + return 1; + + if (pack && pack != cb_data->last_pack) { + cb_data->last_pack = pack; + cb_data->pack_count++; + } + + cb_data->object_count++; + + return 0; +} + +static void get_packed_object_summary(struct strbuf *obj_info) +{ + struct packed_object_cb_data cb_data = {NULL, 0, 0}; + + for_each_packed_object(packed_object_cb, &cb_data, 0); + + strbuf_addf(obj_info, "%d total packs (%d objects)\n", + cb_data.pack_count, cb_data.object_count); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -292,6 +327,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Loose Object Counts"); get_loose_object_summary(&buffer); + get_header(&buffer, "Packed Object Summary"); + get_packed_object_summary(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Jan 24 03:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349605 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7C70921 for ; Fri, 24 Jan 2020 03:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EFD724125 for ; Fri, 24 Jan 2020 03:35:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r4VqcqBO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730090AbgAXDfp (ORCPT ); Thu, 23 Jan 2020 22:35:45 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:40585 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgAXDfo (ORCPT ); Thu, 23 Jan 2020 22:35:44 -0500 Received: by mail-pj1-f73.google.com with SMTP id g12so545857pje.5 for ; Thu, 23 Jan 2020 19:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7UBci21ScjkBeEf9VgxewN7XfaxUl4B2fpgA6V29wVk=; b=r4VqcqBO0rSOT1SgNDcHrq0npB1hwS5jIfSN6qHu3HZjRePggeBZ+Rn2d+V8RWGorr Xu+9UpsR4ziGwklnzXB+YzgFDG8qfvViYO6pLjZV4FUxl2svZxGfAx84xrRmUiQnIgoo 90Kn5eP81jFjF4Jkb7A3oBpQ4E+T3agvlbxCRo2u9lUPjMw1vmRmsxGui/qtrak/qQcX AQskFCLKZUrISZUVOIJt6uUbyCav/qUNfp+EusJCJ09mGz6LNVbNfKMg8EJZoXbfsNLe 8ohOnonhE94LxBUgfAzJTvuY3cZdkVrvSF/5Vw0a6FT718ggmHgtGx6WnCiUeGMWMBEg e0pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7UBci21ScjkBeEf9VgxewN7XfaxUl4B2fpgA6V29wVk=; b=HSmwJf5k78KBSdoGwBONSRqJzNRGeqsUy6syk4NXHxWe/X28fSXQEB02exRJJA/vWZ /tZ3rZFfHx+3h1DS75Sa9Z61fDSalry1GcAr23GUAV8WFx2TKzPjVYBXtnFxI94bpWSy HKG6dFbgtRLM75eKtT1hRI4PF0+5oPfokY2a36t23CAe+88jqrsgLWXk8zexF885AhCa SZ0fdgA826nCPMHxdmx+8mqU+zl2fL+8/Xsm6QsCPFKcGQGmjYPsJajoL805EE8iAKwX 0GgcRmvANWcWJ66MEOWdMRfFoOhHuEOZUVH/f3W0i8/7YqLWw/tNlkhKGwWZkdLc4E+o yDuA== X-Gm-Message-State: APjAAAWvPDd6OHeCdz/tEzYlTN2ba6Fjp4MBsNQ9tdju49GkeD3uKfFM uL09RI9wKZ3jWiEMexztoC9UfIDE9LCVLvSW0BrL2CZd4Pp/rrvPmoRqPnwq8dl55dH5+vzmNs6 AOw45NBIvbSXbFswt8Y22ek5EAL4LkjdruXqnoti5E1IoYG27Px246w+Xp3iVFDVn0daVvducZg == X-Google-Smtp-Source: APXvYqwX1Vh8gRuAqJFLxdO1FbIEzGCw9TKHtMHw89QWMkg6JC0LztB99mnNtnO31pF7Yv2vCv011b4VsBhQJalLctQ= X-Received: by 2002:a63:ce4b:: with SMTP id r11mr1823909pgi.419.1579836943635; Thu, 23 Jan 2020 19:35:43 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:35 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-15-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 14/15] bugreport: list contents of $OBJDIR/info From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer Miscellaneous information used about the object store can end up in .git/objects/info; this can help us understand what may be going on with the object store when the user is reporting a bug. Otherwise, it could be difficult to track down what is going wrong with an object which isn't kept locally to .git/objects/ or .git/objects/pack. Having some understanding of where the user's objects may be kept can save us some hops during the bug reporting process. Signed-off-by: Emily Shaffer --- bugreport.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/bugreport.c b/bugreport.c index 45cc1764e0..12463ffdc7 100644 --- a/bugreport.c +++ b/bugreport.c @@ -249,6 +249,51 @@ static void get_packed_object_summary(struct strbuf *obj_info) cb_data.pack_count, cb_data.object_count); } +static void list_contents_of_dir_recursively(struct strbuf *contents, + struct strbuf *dirpath) +{ + struct dirent *d; + DIR *dir; + size_t path_len; + + dir = opendir(dirpath->buf); + if (!dir) + return; + + strbuf_complete(dirpath, '/'); + path_len = dirpath->len; + + while ((d = readdir(dir))) { + if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) + continue; + + strbuf_addbuf(contents, dirpath); + strbuf_addstr(contents, d->d_name); + strbuf_complete_line(contents); + + if (d->d_type == DT_DIR) { + strbuf_addstr(dirpath, d->d_name); + list_contents_of_dir_recursively(contents, dirpath); + } + strbuf_setlen(dirpath, path_len); + } + + closedir(dir); +} + +static void get_object_info_summary(struct strbuf *obj_info) +{ + struct strbuf dirpath = STRBUF_INIT; + + strbuf_addstr(&dirpath, get_object_directory()); + strbuf_complete(&dirpath, '/'); + strbuf_addstr(&dirpath, "info/"); + + list_contents_of_dir_recursively(obj_info, &dirpath); + + strbuf_release(&dirpath); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -330,6 +375,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Packed Object Summary"); get_packed_object_summary(&buffer); + get_header(&buffer, "Object Info Summary"); + get_object_info_summary(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Jan 24 03:34:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11349607 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3A94921 for ; Fri, 24 Jan 2020 03:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE1A422522 for ; Fri, 24 Jan 2020 03:35:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dHYR7+KH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730107AbgAXDfs (ORCPT ); Thu, 23 Jan 2020 22:35:48 -0500 Received: from mail-pl1-f202.google.com ([209.85.214.202]:56162 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgAXDfq (ORCPT ); Thu, 23 Jan 2020 22:35:46 -0500 Received: by mail-pl1-f202.google.com with SMTP id c12so426854pls.22 for ; Thu, 23 Jan 2020 19:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VzoZ4FKhaorUGWAXnLUFgwc7FU1UKXLmaUOcwxG/PjU=; b=dHYR7+KHKv6w8p6ByZ34JG7/0gwW8AUtoJCa4djaRokQDgxJ6S9XyhDEU1QsbILuCe XGzMhh9mE0a1F/zr3g/NTZ0fBLhW/L/7oBaNx8HLPMh++O759WDD3RKBCXgcJgwNw97p dtSJePlYDMpEoWt5zccof9QYcrzLpSfJLQkXQpo7cIO6nwOZG3um+U63a08hfrLfTfYH rAbJwtqK0ZqzNudAFWlaGXIXBJR4ZFWWHikqAN6MLBcXew3Qsf+wfZXrL4ju1lmxZHMn ZlIMb04zc/KyJqmr1LvjwspRYJHVjXH5mvWaWYvHs93HRzTVBsG0em2Me0/wzomNhgm9 XPeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VzoZ4FKhaorUGWAXnLUFgwc7FU1UKXLmaUOcwxG/PjU=; b=KgG1rg+IQBctgKZR+qW5A3UKdxNSnP5khp7GCaOrYtprCFJLv3+fbRuvOPeEiHd4Ba TMTfEx0piduh9uccHjOtLc4VSx6B9UeSSf8Lqp8Hpk25uno5GwIU4RcnR1LyLPK6vLzu K5RkhabDRkwokngLi530eaoEmABjVaA8wCiUOVDZ5v5Qh0OfFS5vqzW8jbG/4rtbaRzX HLn3IY4OaKqX1OM1e2coxswpN7U9bpDPj6TSRsE/EYJ8MqNKxH3feaDSbbwbMwGaY3TS b1lqRWXdm7aQnO7ZMsp2a2Vp1bFmloxC17DMt1BsJovCGPTfyu1JTj+TgHAchOZTyGrT oiqg== X-Gm-Message-State: APjAAAU358BBvGGqm8vtcgfaXdwQQ5nFwDhdj6fjPgI7jimQI7rxPdWv 8B9izBCfKmGMEMNPNYDOjw1pDYuPPnhO2RqweVmqZRPNy+ReC91t2tf0pCv6JtTD67FUPby5cFI lAMN4GQugPP61c6QEeH6C9WflaA28S+R8Z5RkJ+gh4uKuyIXEsUO6sNNDcBYBYg4trOAcfXcNHg == X-Google-Smtp-Source: APXvYqwPUwcIb8F5W6r1tpOV6yEePdNkAvCQxdR4yBBvN4ZedFZldw55s3Hxu1yhYMW8ufjNXNTxOkUiGyjVP5YqTnw= X-Received: by 2002:a65:4c8b:: with SMTP id m11mr1868236pgt.208.1579836945908; Thu, 23 Jan 2020 19:35:45 -0800 (PST) Date: Thu, 23 Jan 2020 19:34:36 -0800 In-Reply-To: <20200124033436.81097-1-emilyshaffer@google.com> Message-Id: <20200124033436.81097-16-emilyshaffer@google.com> Mime-Version: 1.0 References: <20200124033436.81097-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH v5 15/15] bugreport: summarize contents of alternates file From: emilyshaffer@google.com To: git@vger.kernel.org Cc: Emily Shaffer Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Emily Shaffer In some cases, it could be that the user is having a problem with an object which isn't present in their normal object directory. We can get a hint that that might be the case by examining the list of alternates where their object may be stored instead. Since paths to alternates may be sensitive, we'll instead count how many alternates have been specified and note how many of them exist or are broken. While object-cache.h describes a function "foreach_alt_odb()", this function does not provide information on broken alternates, which are skipped over in "link_alt_odb_entry()". Since the goal is to identify missing alternates, we can gather the contents of .git/objects/info/alternates manually. Signed-off-by: Emily Shaffer --- bugreport.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/bugreport.c b/bugreport.c index 12463ffdc7..2c540182dd 100644 --- a/bugreport.c +++ b/bugreport.c @@ -294,6 +294,42 @@ static void get_object_info_summary(struct strbuf *obj_info) strbuf_release(&dirpath); } +static void get_alternates_summary(struct strbuf *alternates_info) +{ + struct strbuf alternates_path = STRBUF_INIT; + struct strbuf alternate = STRBUF_INIT; + FILE *file; + size_t exists = 0, broken = 0; + + strbuf_addstr(&alternates_path, get_object_directory()); + strbuf_complete(&alternates_path, '/'); + strbuf_addstr(&alternates_path, "info/alternates"); + + file = fopen(alternates_path.buf, "r"); + if (!file) { + strbuf_addstr(alternates_info, "No alternates file found.\n"); + strbuf_release(&alternates_path); + return; + } + + while (strbuf_getline(&alternate, file) != EOF) { + if (!access(alternate.buf, F_OK)) + exists++; + else + broken++; + } + + strbuf_addf(alternates_info, + "%zd alternates found (%zd working, %zd broken)\n", + exists + broken, + exists, + broken); + + fclose(file); + strbuf_release(&alternate); + strbuf_release(&alternates_path); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -378,6 +414,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Object Info Summary"); get_object_info_summary(&buffer); + get_header(&buffer, "Alternates"); + get_alternates_summary(&buffer); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report);