From patchwork Fri Dec 13 00:42:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289619 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 6A88C139A for ; Fri, 13 Dec 2019 00:43:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BD2E227BF for ; Fri, 13 Dec 2019 00:43:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NU0VoiKy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731692AbfLMAna (ORCPT ); Thu, 12 Dec 2019 19:43:30 -0500 Received: from mail-pj1-f74.google.com ([209.85.216.74]:41603 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731591AbfLMAn2 (ORCPT ); Thu, 12 Dec 2019 19:43:28 -0500 Received: by mail-pj1-f74.google.com with SMTP id ie20so416460pjb.8 for ; Thu, 12 Dec 2019 16:43:28 -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=K6Ks5A+bdUKeqOTIznyPV9G4BxhJ0Il65kR6FoJbgq8=; b=NU0VoiKy+VtveadbBtWj/1AFF9ebpWCO6bpz9yGxiA/PWLTeXXDL7b7/sBiYCsP4Ei U1wv3BGa8Kn2f+wYgkwseI+z5/y/C37VgBI0Wjh3i12kPtL35+7ng3joNOo8UYfEg/GS ASwO7y7X6tY1P11H5IZ/9JlUWE806YLhGHz9sGADxs+qsXzAMEtNwskMws96TscykP7X XOJy7JNpmcGtdSzqG7NQvwvxIPix+OJzIoxjTAruuTgSLIQK2+dLrVjETKGJtSrsiyfO vPsKnk70iJr9tdXNJrJks2/ZX+Tv1EvkSBEHUtcWJD0aFZvDwQw4Ud0EgYtDZWS4GSoB 8PTw== 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=K6Ks5A+bdUKeqOTIznyPV9G4BxhJ0Il65kR6FoJbgq8=; b=YENMX5lr8+biii1v+UjcmLCotr3LQ2PfdpACVSLo2Z8RiSES0NOsXsGa+nWHQKB8CH VIfPKOo7LD11IqGR6lYSS+gmO2Dm757y3uOAevD8qH9Ofn+TLmViOQfVPQeJfNiMRHt2 H/C8ZSclAhKBuuewk8V/kYATe9Pdc0chtxJsIf9P5JvZaZJS4he857B7CklzWBqW1I8R btHB/gZeU47GMpN8xCBFPJn4NAMxC3OlmDuUhS12AViP78MSCuAYFwj6JzW4nq9t/oMR t/PK/z1beuObRSwIbCfp4dd6nPpAkgzhgfDZTEpQYcYEgS7ubMSkt1B/DqUVzxXnyuBt zuvQ== X-Gm-Message-State: APjAAAVDZzzmWnQUPK7KW6zJ+Vszob/Rt67wXs4PKiPL0Uvc8oHzwv/H 0zHo2KlqppOb4uGhXYcQiHdS2wU0RlDNxB7CbhADqsGaCdpRHTDS68YlsEMwLhqfoIhkb88ZCr9 A2j3xDhXaA7CW4LL+R93lQ6XKxbRf70AK6MOnHE6Ew0qv+zCsWU6fj9QesRFI7QZiCuJn3Fj4Dw == X-Google-Smtp-Source: APXvYqx8hrPzjZFM9gpY454ZypzB30NT9NkU2eQbHP7DNgd6WftTBcijgUL/RfMUU/1u5EByVWvLswf1yzS1tpbQEaQ= X-Received: by 2002:a63:5818:: with SMTP id m24mr13884993pgb.358.1576197807384; Thu, 12 Dec 2019 16:43:27 -0800 (PST) Date: Thu, 12 Dec 2019 16:42:58 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-2-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 01/15] bugreport: add tool to generate debugging info From: Emily Shaffer 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 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 89b3b79c1a..055a84c4a8 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 b7d7374dac..9dff91436e 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 @@ -2448,6 +2449,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 Dec 13 00:42:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289617 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 7BAE6930 for ; Fri, 13 Dec 2019 00:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45C7B21655 for ; Fri, 13 Dec 2019 00:43:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sMlMPb6K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731707AbfLMAnc (ORCPT ); Thu, 12 Dec 2019 19:43:32 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:39185 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731679AbfLMAnb (ORCPT ); Thu, 12 Dec 2019 19:43:31 -0500 Received: by mail-pg1-f201.google.com with SMTP id v2so348941pgv.6 for ; Thu, 12 Dec 2019 16:43: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=HaNUWIlAAhTM6vP3+OuIJM4fmFoY7pz91q9iMIy3d/8=; b=sMlMPb6KgmwlqurX5S+6GryjhFmw2XlUJXzQNy1fvUUXb24AEvmy/SEZ99mxRB0ihp IY1tmU76wYUd05YN4PYAuCUdwpMk7nJ+LbF3S8cwX/gtElGbO3KmzV5/OqkEh/B7omx7 GnjZmLr5U26BYsMamZtuKI7e+fiOSaM9gJnUOrebFTYUP5J+3rf/LlU9WVdgzgCvAiBP OEjhyCDDROcyd5tEYad8FD0bwBBfcBKQLPFRXmXyhnw+X1oKLNPlcI1mTBx+2ljsSKVE guFTawLH0sYR//ow6HG9oWcSWUkSQyCvufE363C7+RbBEXF0Bmg+ByhQ/mb9ZpJ4haZp HTXQ== 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=HaNUWIlAAhTM6vP3+OuIJM4fmFoY7pz91q9iMIy3d/8=; b=jl0h4xLYx1iTatPrhDFugrpn1e8F7Jm73NILjS6p7MYomdpALqVq/7zpoZDXQn0xdY 8Okfu/XkyuiI4Yi7cnzVgAwNZ12GQPL5AS2DCbxdiG9o2ZjAoUwUOa269kOyyHT9sX16 nWjMHJRswryNniiAjVHQ0bU8gHMhWFNWM4L8lg1ivgf7xeqZaOiQrDA+fPDbofHRPrHt vuBfrAdwER+LECJcJT6OQYjz3vPXcI/wLsJnOFVMdo4J3ZMXsLwAbzBto0LQ7bPlHZzS YEqx8apQXoIqfiF44d/F3bbdkQFjC5dSrksrxfCr6Bubsk5n5UiirySuNULGP/CzB7xh MoHA== X-Gm-Message-State: APjAAAWHdcrIxJgHXiGptuwtERUKMsCsttMFz5hYRFYviqHWzDqQjxxw ZDM4xIyIaHIPR+tO5ZjXuAY0/zFBZEeYeQSV817TwzFz0ViOEAodUu1FU6CTntXFOn7whMbGGQs Yx4cxqMMrKzqQJMw9EViQqTGhNphIqlSyX+Ge7O2sFK9Q8dhkPhDoV6WNVdYk07trOwV0Rns1KQ == X-Google-Smtp-Source: APXvYqxeN0s6w93VcbgVWqdz1GY/Q/5XEZH2Tndg7Cegy0M4z7ZBIbcqlruSk5667P5QXS5f1nrzURin5DDzGc5YJp4= X-Received: by 2002:a63:1106:: with SMTP id g6mr13704486pgl.13.1576197809860; Thu, 12 Dec 2019 16:43:29 -0800 (PST) Date: Thu, 12 Dec 2019 16:42:59 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-3-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 02/15] help: move list_config_help to builtin/help From: Emily Shaffer 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 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 | 16 ++++++-- builtin/help.c | 86 ++++++++++++++++++++++++++++++++++++++++++ generate-cmdlist.sh | 19 ---------- generate-configlist.sh | 24 ++++++++++++ help.c | 85 ----------------------------------------- help.h | 1 - 7 files changed, 123 insertions(+), 109 deletions(-) create mode 100755 generate-configlist.sh diff --git a/.gitignore b/.gitignore index 055a84c4a8..5dde2cc4c8 100644 --- a/.gitignore +++ b/.gitignore @@ -189,6 +189,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 9dff91436e..c49f55a521 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 || \ @@ -2127,7 +2128,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)"' \ @@ -2147,6 +2148,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 @@ -2784,7 +2791,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -GEN_HDRS := command-list.h unicode-width.h +GEN_HDRS := config-list.h command-list.h unicode-width.h EXCEPT_HDRS := $(GEN_HDRS) compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h @@ -2807,7 +2814,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"; \ @@ -3110,7 +3117,8 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(HCC) $(RM) -r bin-wrappers $(dep_dirs) $(RM) -r po/build/ - $(RM) *.pyc *.pyo */*.pyc */*.pyo command-list.h $(ETAGS_TARGET) tags cscope* + $(RM) *.pyc *.pyo */*.pyc */*.pyo config-list.h command-list.h + $(RM) $(ETAGS_TARGET) tags cscope* $(RM) -r $(GIT_TARNAME) .doc-tmp-dir $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz $(RM) $(htmldocs).tar.gz $(manpages).tar.gz 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 Dec 13 00:43:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289621 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 1D70E1593 for ; Fri, 13 Dec 2019 00:43:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0786227BF for ; Fri, 13 Dec 2019 00:43:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Rcpqoku/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731712AbfLMAnf (ORCPT ); Thu, 12 Dec 2019 19:43:35 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:38821 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731709AbfLMAnd (ORCPT ); Thu, 12 Dec 2019 19:43:33 -0500 Received: by mail-pg1-f201.google.com with SMTP id l13so350983pgt.5 for ; Thu, 12 Dec 2019 16:43: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; bh=tVVUHAlz5t2lfZHs7UHZfMcr2HaAk25GW3+M1vTrBPg=; b=Rcpqoku/ttoPoEV0+OoM1M0rOIyhV4ytkwNlZBgpJD8ruU2kdJEdscBJs4GwFp21Jy gtu5xL1dhi0dM4GCYYHbS49rqmPIqfptLNIurLxhH5P0xVMDxOREnk+4t1x7lKrXdnGq gW93Jh7clH2HYSE1G2xdUQeccgnVlzwn42bJS5xuQRX2Vegj6wg2yC+iu1QDUCjpCLGF Rygv8KjdIdv43isYwUW07B/l0KX808mkENEhRKa2RFa9Whshz8sRIrFPJQQy0Yj/4PWA pbevcYSzkzw9WCiWnS3QRqg4/8VWtfzJOeDHnLHwyjuUtYBg3kF+TXK6z0T3A2uKkJr7 XCmQ== 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=tVVUHAlz5t2lfZHs7UHZfMcr2HaAk25GW3+M1vTrBPg=; b=QDHP2It3I3NYhxB0UwN8k+zhhfUN/QSK+VffaxazphqkRM6OLfDJEGYDostX5D/mqF o4w2rjhHa5CG1JFgdAQliqm5naKIH88KVB7cyFYSzYuiN2P4gzRowil0ScXz0HvBip6d qRPfE/8TIE854sJ1EPRhvHCRpuJG8kG5F+nH1ZvHt3i5mICqPZ0PRC9UzZ9tN0PZ31xz zfz6EvqsUUXqhREXk/mnDSzvBIrWXLuBe6mMkTWBU+vwdYYE2tASLEckbinB0pZ3lYlt KCWwWVK3JIGitWBJU5Q255t7J5UJCgvqzbzCkmOnshde09PeWcZk2/X+7az4FuKKDv9p FAsg== X-Gm-Message-State: APjAAAUNOwIMPAfRjRXPTL3EgpjX0Mp3P2jC+0ULG70YqEnAAgvPjaP8 h/ES3ifI5SCJVc/OdsMS/SaXIcMrUzNNZDS9o5GxhtiBKbMMKszrFn9v+GSiT65gzBFfw5oHJBu ZGgcpWSfdbWvCOHZAv9izPl65JnNk8UckULLuQW40nGJ0Onu6sOX7wlVr/Z8AIZTMS2ecTgTpYg == X-Google-Smtp-Source: APXvYqybGLa5zJ8tdwDp3krrCworTtvJl0cIg7WdNVawBudoEKtE08wNzo7H16qq5V62Swo0xVLRfLHkXnVSiGXWtVY= X-Received: by 2002:a63:2063:: with SMTP id r35mr14289420pgm.120.1576197812389; Thu, 12 Dec 2019 16:43:32 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:00 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-4-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 03/15] bugreport: gather git version and build info From: Emily Shaffer 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 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 | 23 ++++++++++++++++++++++- help.c | 45 +++++++++++++++++++++++++++------------------ help.h | 1 + 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/bugreport.c b/bugreport.c index 5495b31674..59d8b5a3af 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"); + list_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,10 @@ int cmd_main(int argc, const char **argv) get_bug_template(&buffer); + // add other contents + 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..a43693fca5 100644 --- a/help.c +++ b/help.c @@ -622,8 +622,33 @@ const char *help_unknown_cmd(const char *cmd) exit(1); } +void list_version_info(struct strbuf *buf, int 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 (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_addf(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,9 @@ 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); + list_version_info(&buf, build_options); + printf("%s", buf.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..54f6b5f793 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 list_version_info(struct strbuf *buf, int build_options); /* * call this to die(), when it is suspected that the user mistyped a From patchwork Fri Dec 13 00:43:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289623 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 1550C139A for ; Fri, 13 Dec 2019 00:43:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6F6F21655 for ; Fri, 13 Dec 2019 00:43:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="unbL+J68" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731718AbfLMAnh (ORCPT ); Thu, 12 Dec 2019 19:43:37 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:41779 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731709AbfLMAnf (ORCPT ); Thu, 12 Dec 2019 19:43:35 -0500 Received: by mail-pg1-f202.google.com with SMTP id r30so346120pgm.8 for ; Thu, 12 Dec 2019 16:43:35 -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=GHPS1RzDUOQ6QbXrCNkCqbcKszw+nDn47/gRPb+DnK8=; b=unbL+J68nBUTkDKU3j6dwQOZ6esKEXRRojZFIonSbGfVEr+vxrch+hSGBxMvYC8+FJ L1eEQSFfAi/lRAcqCuRZJnsmIyP8gfyszfxpBDwwZMlu5CV/rBb7j1bUCIZpYLvImmiC VPyTW0xLdMl2o0cFwQmtlZh+IMefX3SWuzBp2yT0SAX03xy4bfik8nRvfbCOpa16ttrQ a68Ss4wiz/CIgDAxwRWRvDNfYAJz5knCMiRZAl+cPjN6mMy63dxIkhqL9D1IeNllsMdb 4gSs8ArwjbjGcQShFp5/0L3l5D9/t2La9RIO0FTD2gQ6miTjMXoLZLx2qWNav0byI5ue LkWw== 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=GHPS1RzDUOQ6QbXrCNkCqbcKszw+nDn47/gRPb+DnK8=; b=AexhevW126zD8MsSY9nqoDJNtAZX4KYVg7VOCxmwro+y1II/a58zlqQVtCtIN7f6sE S69u/YijEsV4ExfGgYfmmdd8rIuDj6aM9UZrkj/R9nV/WxAikcuUmq4BKdwtB3Iij0eI 8jJJehyl7cH+NpEftpEL/AoDl+3Qx3pYwYM2Fr9bJUbeDVlZFA7CKpmhLnXotjw5LQS3 sQsoP6+DU71rixCPJ1czg/hdKobq3nJN21a6WxmMX8F2TiZb+SMDRpdFLZBxTJh2OOuo dD1RqRmR2BHgvpxnbmYgsZOvX9q6b+rxuWRZrnJvLhzMh2tyN6QV1/HcSMUKPDNxqAWS MVcQ== X-Gm-Message-State: APjAAAX7iKDNgNUXYeNAtT3FmdjAYz3g+g3kg5fvFHuWwmAaNVbh2kzJ GfmkFGhD9viS38JxW2cMj3YtM0l+QYET6xFDCa+aKW+GY1PmacgjtN7AUewsZxr5i+Ydr6pxPHb YLgtKHkZnqlWFtWmdGv2LeO+3ak4PySq9otmyJydAkOutsTSTEizRV2WD8f3Dbc0468wHpNl3sQ == X-Google-Smtp-Source: APXvYqzEYHwK0IDXcPe20pSMpyxoQNIXUEyEoPWmb6WuUDXbO7Ur4k/xXha+Vq3bTlkYmTTfIZpWsnpF6F4HBW2zMjY= X-Received: by 2002:a65:68d4:: with SMTP id k20mr14010540pgt.142.1576197814764; Thu, 12 Dec 2019 16:43:34 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:01 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-5-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 04/15] help: add shell-path to --build-options From: Emily Shaffer 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 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 a43693fca5..6d1bd17971 100644 --- a/help.c +++ b/help.c @@ -642,6 +642,7 @@ void list_version_info(struct strbuf *buf, int build_options) strbuf_addf(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 Dec 13 00:43:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289625 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 C5941139A for ; Fri, 13 Dec 2019 00:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A338A21655 for ; Fri, 13 Dec 2019 00:43:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y6U+A+eb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731726AbfLMAnl (ORCPT ); Thu, 12 Dec 2019 19:43:41 -0500 Received: from mail-pg1-f201.google.com ([209.85.215.201]:38822 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731722AbfLMAnj (ORCPT ); Thu, 12 Dec 2019 19:43:39 -0500 Received: by mail-pg1-f201.google.com with SMTP id l13so351142pgt.5 for ; Thu, 12 Dec 2019 16:43:38 -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=qBQm09bh4S6bFa+KGMXaVCUH33mTauwB38+9NuRoiiY=; b=Y6U+A+eb+7ML3hjQ4SomyKU8ngswbSEpbba+D+cBFFGzFtjg9C7taH55kYMlSNXDGb l0KqwDKYY7okkoXLkpbEn+Q+fLQS3a+PL3Rt3kHOWAuA/kVsE7R1KxAiyCwmg6e5Auce xLmESxrDYNzEnDyrYaV3hU8tEUCCw9dMk6zBsGyM1NN7OH7lQ0zHfRdMJTjRrmfHvYfY Rgpy6g7a+13kwnF/2G/+RkNhVk9w+Ji0LivdXvIVZB30OQle3jirb1gSYySrTDEOF6SB EZkNb5Wq8O9mMOpwdFMQhXM3KLdlfooHtewHseOTwObixhp5u4pMA+VlKVWZP+2uzAat 38ZQ== 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=qBQm09bh4S6bFa+KGMXaVCUH33mTauwB38+9NuRoiiY=; b=LCmHtUsvs8pFdiAuDva7BkJ43ulkhnXfgQTISY+9Wcz5m1HFUZCzZtQsaWkPX0pP5W sE0mzWncP+OZooNcocTfkSY3pdvtPr8MFREllGS6GHIMAaZfj/unl2YGz7QhQcdP2D1O GDkGNLw7YI4pLAQ0cJ5rHwxi25hIq0T4VnLWlbBiAleDzVB7diKynYLxPnDueNVtXVNz RFd8AvOgl1zUCjxs4ogxxqJxDh5OZMjXRu/EdNx5CD8ZxOyneOKmUEbg3NDlqB2E5TSf CXHDgjhyxnd2Lh0v3XYqixXpxrbwbhEjUQptkv+CfgkpMD+VrQyQ0whbdYk7XlQfYr9u wjeQ== X-Gm-Message-State: APjAAAUEo9V9K8u7zgsObY/nl5YzSKevZyLA88dQ1T3dASD4RgFNCuQ0 tNqBEjcl+00UTMTLznNW44D0TxWeFizAUGWjOkLYq8Nge5P0xnS9twn1JDbjC1WQ/InVOybPqkp dsVqDMwIgaX7vc3POgve68rFF86wNa5/eFXdJCfLdGsdeqXWdHeSJKpkpfHJwRDJXq3l/I0L2RQ == X-Google-Smtp-Source: APXvYqyxJ2iTl5XlufBKiEvmUrT/Eqz8hm/fcP6MFan69V6nVst06eqmPNGsqWp+sVJISHzp560W9zISw487EmkGq4U= X-Received: by 2002:a63:d705:: with SMTP id d5mr13651541pgg.24.1576197818442; Thu, 12 Dec 2019 16:43:38 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:02 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-6-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 05/15] bugreport: add uname info From: Emily Shaffer 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 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bugreport.c b/bugreport.c index 59d8b5a3af..9c69e3fa34 100644 --- a/bugreport.c +++ b/bugreport.c @@ -8,12 +8,25 @@ 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"); list_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 %s\n", + uname_info.sysname, + uname_info.nodename, + uname_info.release, + uname_info.version, + uname_info.machine); } static const char * const bugreport_usage[] = { From patchwork Fri Dec 13 00:43:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289627 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 3DF0A930 for ; Fri, 13 Dec 2019 00:43:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BB8521655 for ; Fri, 13 Dec 2019 00:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fY/TUXKE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731733AbfLMAnn (ORCPT ); Thu, 12 Dec 2019 19:43:43 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:51309 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731722AbfLMAnl (ORCPT ); Thu, 12 Dec 2019 19:43:41 -0500 Received: by mail-pf1-f202.google.com with SMTP id h22so372308pfo.18 for ; Thu, 12 Dec 2019 16:43: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=moNPuHjYyDs+iOyyWpo7dGT7iFTwBt05Fs9rna+PXXg=; b=fY/TUXKE4sLpgXfwA96C/1tpmnPMp9rFTD1DnzVKfb9fGgJnOOYMD5+zc3Dig/oJdK BVowk/ajHIC5txO3cekp+Sdbbk/B0d1jDAQaxBNVm9We/uxFelCteCAWR8rukpVJ8xCs FbO109O5gV0SYup3j4l/FgDMgATuY+EOQo1726Hf7LqB1bA7zsSICyDLeAcAcAt+it28 OK3QGTwlMPU8D5sQL6slxSXs21QtLpbKonLAQbBAb3Er1bzKfzAQZLOAvBejcTH7HGcF C0/MGKxoXGl0yOyW9hJ0VnjabtX2FJHuN2/tzxJw2C6OZvqAB92V4mETg/02kYePNBMi bJSA== 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=moNPuHjYyDs+iOyyWpo7dGT7iFTwBt05Fs9rna+PXXg=; b=iLKK1WJN4DvPKT2IiVSVe0eII8Rptw3urPD05rl94ck9Xa/q3/2A/aVNstLU9w/37i 0y+qofIrGi16qvMPG/iXbTNNi6jCBJHTmOObCfD6LICyLfU6zYWQMMlH9iHXadYGk0SS amfvuNChujnq+vU6dE+4YPNOmxfW7JMSFHR5HQkInc7m0EA2xRPTF8Pf2mDpb/juVFpl qTSeLBuP4CWgo1nYrgk+esawDIHov888AHbueNO0Srfy3gbE6txjT49GFatieCI1r4I8 FCNzGlkD4te2LmqnxAEagk8Fh/3KGari1o0AwlJFMEtjsYshQa7j9QxK/Uufl+UcYz9g f3ig== X-Gm-Message-State: APjAAAU7jmRy3tUQqZk/SCWybolGBZX0J99NG1oQGdlKZkMHpT3LBuvq Vtn0/5q1EiXMQSJpzwlLgcaNuvwkmXvy7oV0OvrBXwqQZAdK805Ypi0IcRwcur0ZXJMWSrqyRkv x9WQZEebdAApe4qebyNq+7UQze0Mn7v7tGFJeaoKwyG32HB6OAntwxGJnoccWoSboZLX5IGDfHw == X-Google-Smtp-Source: APXvYqwxnRnl6APfuewerGUWe/VownlBcjg1hwOV/ezwQg6srUfWPiMPkYsVvF7nKaNdBQjxlI4BzEmkfJxA9zAIHkA= X-Received: by 2002:a63:2ac2:: with SMTP id q185mr13907714pgq.417.1576197821103; Thu, 12 Dec 2019 16:43:41 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:03 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-7-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 06/15] bugreport: add glibc version From: Emily Shaffer 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 To help pinpoint the source of a regression, it is useful to know the version of libc which the user's Git client was built with. Let's include it alongside the other versioning information, which is used to identify how the client was built. Signed-off-by: Emily Shaffer --- bugreport.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bugreport.c b/bugreport.c index 9c69e3fa34..af715dc157 100644 --- a/bugreport.c +++ b/bugreport.c @@ -4,6 +4,7 @@ #include "strbuf.h" #include "time.h" #include "help.h" +#include static void get_system_info(struct strbuf *sys_info) { @@ -27,6 +28,10 @@ static void get_system_info(struct strbuf *sys_info) uname_info.release, uname_info.version, uname_info.machine); + + strbuf_addstr(sys_info, "glibc version: "); + strbuf_addstr(sys_info, gnu_get_libc_version()); + strbuf_complete_line(sys_info); } static const char * const bugreport_usage[] = { From patchwork Fri Dec 13 00:43:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289631 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 04BA5139A for ; Fri, 13 Dec 2019 00:43:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D648021655 for ; Fri, 13 Dec 2019 00:43:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SqAhNAUQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731734AbfLMAnr (ORCPT ); Thu, 12 Dec 2019 19:43:47 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:46874 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731736AbfLMAno (ORCPT ); Thu, 12 Dec 2019 19:43:44 -0500 Received: by mail-pf1-f201.google.com with SMTP id w127so380197pfb.13 for ; Thu, 12 Dec 2019 16:43: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=hZo1WEGhKd2nJ3J3y99keSOp82CsLSHX0LjnUgO7PZA=; b=SqAhNAUQq4+F3juxrsjv6R4Xguf6Q/2j6SUslRXqdnZPbvD6DnT3SkLgS5dfqdWukK d6MeT9Pm3V2o91Ub1zj7kg6lFAdq7NiXvHSqW3WtSfAxz079LN8Prj+khVkeC/AUDnUz apq5eRXLQfhVL69rEeUTjEXev2iGDz0ZAyXiENQQ3r3kN8CCNUAMWtKHfNtVz1DXO4zP +A8FuRcGhUOfl8lQosTwYgADgkahgSQMYrU/5Z9AjJx2jZO9N+1wHBvq3fXHrpLpqlXy BmpZ7JzI29/7Zobq/QmrRtZY1SIrYWMyHxLtM2riF8HFtl+fjhhfD12SGbhwytfWnuml oMkg== 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=hZo1WEGhKd2nJ3J3y99keSOp82CsLSHX0LjnUgO7PZA=; b=agMbzeRioBZJ4bogFWhHLTgqibOE76dPLd5No/y9aWVGRdzhx/vvsOfmm1/L8MbVvt MIimUhenALyvcHQz1SBcBLc0qmx5ekpWgHvzZm10ZXysPShEbFr5wCW4fAwn4frV5C4N MBl4I16Js8x9COdQbtlM4PA7UqA5tIdTCEDy2GU3OnQXcRELKbapA2H/rRu4hccDEJr/ 8mDkUb0+mUgXPlHSX3V/UeQ5uTwrlLIV8yETirRxLSpg6e0vsfUK3np1JOicJYQMIeNv nT8Cm+OV0dhFvw+F3tkDnA1Ts54bYd0mu+QfR4EGFH7RvZa7Z3SNLetp9B2AHquo8Wls Wbpw== X-Gm-Message-State: APjAAAX5xtruj7Vvb0PYt52JASRyPh3Hg/ycSrNWRycyeNuT020z9AcH HfXb14HdNP19RUUf8CEQdOdZdOTv/O9PU1Pfhgb6spr076zQ9dQFXb3F1hiATX00syjT2XJZFMQ wgp9LQ4GYvRaEMpUE008ibwjOf87o0fWYhjekeuH6mzG4g49AOapZ2NKzkLoIg7j8zI9oR4bCJw == X-Google-Smtp-Source: APXvYqy+WFnDy0TDx1pj5khWXeLpxM0uzDPjFQREZYHBQXXedvUp9bCbt6s+NvMRrmx0JBLMYFEcQrFe0mY+2NWN6mI= X-Received: by 2002:a65:4344:: with SMTP id k4mr13613479pgq.193.1576197823504; Thu, 12 Dec 2019 16:43:43 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:04 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-8-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 07/15] bugreport: add curl version From: Emily Shaffer 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 It's possible for git-http* to be built separately from git; in that case we want to know what version of cURL is used by git-http*, not necessarily which version was present at git-bugreport's build time. So instead, ask git-http-fetch for the version information it knows about. git-http-fetch was chosen as git-http-backend was described as a server-side implementation, and as an accidental fetch in case of problems was considered less harmful than an accidental push. Since it could have been built at a different time, also report the version and built-from commit of git-http-fetch alongside the cURL info. Signed-off-by: Emily Shaffer --- Documentation/git-http-fetch.txt | 5 +++++ bugreport.c | 16 ++++++++++++++++ http-fetch.c | 13 ++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt index 666b042679..2894c5e82b 100644 --- a/Documentation/git-http-fetch.txt +++ b/Documentation/git-http-fetch.txt @@ -10,6 +10,7 @@ SYNOPSIS -------- [verse] 'git http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [--stdin] +'git http-fetch' [-V] DESCRIPTION ----------- @@ -30,6 +31,10 @@ commit-id:: -v:: Report what is downloaded. +-V:: + Report information about the version of git-http-fetch, including the + versions of its dependencies. + -w :: Writes the commit-id into the filename under $GIT_DIR/refs/ on the local end after the transfer is complete. diff --git a/bugreport.c b/bugreport.c index af715dc157..f5598513d9 100644 --- a/bugreport.c +++ b/bugreport.c @@ -5,6 +5,18 @@ #include "time.h" #include "help.h" #include +#include "run-command.h" + +static void get_http_version_info(struct strbuf *http_info) +{ + struct child_process cp = CHILD_PROCESS_INIT; + + argv_array_push(&cp.args, "git"); + argv_array_push(&cp.args, "http-fetch"); + argv_array_push(&cp.args, "-V"); + if (capture_command(&cp, http_info, 0)) + strbuf_addstr(http_info, "'git-http-fetch -V' not supported\n"); +} static void get_system_info(struct strbuf *sys_info) { @@ -32,6 +44,10 @@ static void get_system_info(struct strbuf *sys_info) strbuf_addstr(sys_info, "glibc version: "); strbuf_addstr(sys_info, gnu_get_libc_version()); strbuf_complete_line(sys_info); + + strbuf_addstr(sys_info, "git-http-fetch -V:\n"); + get_http_version_info(sys_info); + strbuf_complete_line(sys_info); } static const char * const bugreport_usage[] = { diff --git a/http-fetch.c b/http-fetch.c index a32ac118d9..31844812a1 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -3,9 +3,18 @@ #include "exec-cmd.h" #include "http.h" #include "walker.h" +#include "version.h" static const char http_fetch_usage[] = "git http-fetch " -"[-c] [-t] [-a] [-v] [--recover] [-w ref] [--stdin] commit-id url"; +"[-c] [-t] [-a] [-v] [-V] [--recover] [-w ref] [--stdin] commit-id url"; + +void NORETURN version_info() +{ + 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()); + exit(0); +} int cmd_main(int argc, const char **argv) { @@ -26,6 +35,8 @@ int cmd_main(int argc, const char **argv) } else if (argv[arg][1] == 'a') { } else if (argv[arg][1] == 'v') { get_verbosely = 1; + } else if (argv[arg][1] == 'V') { + version_info(); } else if (argv[arg][1] == 'w') { write_ref = &argv[arg + 1]; arg++; From patchwork Fri Dec 13 00:43:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289629 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 06B7E930 for ; Fri, 13 Dec 2019 00:43:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9FEC2253D for ; Fri, 13 Dec 2019 00:43:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VOdW3GbP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731744AbfLMAns (ORCPT ); Thu, 12 Dec 2019 19:43:48 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:41711 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731742AbfLMAnq (ORCPT ); Thu, 12 Dec 2019 19:43:46 -0500 Received: by mail-pf1-f202.google.com with SMTP id x6so383913pfx.8 for ; Thu, 12 Dec 2019 16:43: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=YtdEjzBrK3lY1BT8ax8tXHqKEGSgbBflR/DmC9gkdrA=; b=VOdW3GbPiQKJTqA/nYfrbcZd64UOsLzD89af/MyruRy+r8mKtEQEEmJWM+F4lcP1QF jqUWGdB8e4vtwZYCSeYxgxwMq0oXnFlcL88airznGOZ8aZ5gpTb2UXul9UOM8LP3Ztnb zougUNZZZH0kP8A23DVmrNF21cV8Ykw3oX+WyMb8vC4bDk44jT+X0o+vvdR/STOHK6dS S4elUSAFzRV9aK1NtbXW7VirB4XQ3a1Hn6ojuXbK1kKAeW/dSm222nvR6m4ZP60KkQdO QBAyUdq3Zik6IVvyc8C/k+2tSVLuKx6WQWQN+oFEuDbxZMcrWvWaBb3aSHrfqUKS8tTV Kk6w== 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=YtdEjzBrK3lY1BT8ax8tXHqKEGSgbBflR/DmC9gkdrA=; b=pQEABEqS0fg/Sw2fIc9xD9/z9ctoNk0qdDLR3/6mG4GNyugcmVn+Cu+TGsbGUrETao vcVMkIYSk5HyjYEqUBzZzs/y2amvLQzb9loUR8i6Ss51oShgYmxBKgbtp/HgtMJbcv5f a0b/o5D8LFR/aS9UwMvLISQk/x7cjw2S3Suj1NBg0rYXgdk8cGRdJrl0VavNrVJ6H7rU ocZM9svm9L7Ft/zHElRNkLBQ5dNooNiJp2XkbdgcAVZ8h3fYi5Tc5IXbw/tlhwaDH9dl Z9sDbNAQ5G+Seuy9VS7TXh55CyPAn082sQsG7DXDvDersnvv8yMLNbLy4oyYjzF/RWjK ibvg== X-Gm-Message-State: APjAAAVu8o7pz8uUyo6KPlrFKBdlpDIxoH95b1WRzRM5uWOp0qcjwDCt m9MR5G1heood1iQcrCaUmQuvhqq6ku0oAtgn55o2x+fpnGR4gOLM0S9n+hKF8xNAXnnFcZsDE14 8hJ3yCIxPfVPeWWZdrBRggvSpjfVEsZVY+/2CMAp4X0UKBOg3nQBDQqEO8zHy4okP2BzZ6gNOtQ == X-Google-Smtp-Source: APXvYqzQWHdWvYgksefpZGXaLWapirdc55XHHO9R3i3mWjQyhN9Z7/6Y6lwyYx9visnq+FRW8oBQ3JsSxmW2Zc3lhIg= X-Received: by 2002:a63:ea17:: with SMTP id c23mr13911120pgi.85.1576197825930; Thu, 12 Dec 2019 16:43:45 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:05 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-9-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 08/15] bugreport: include user interactive shell From: Emily Shaffer 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 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. $SHELL isn't set by every shell, but getenv() returns NULL in the event the variable isn't found, so we'll see a line like "$SHELL: (null)" to tell us that variable wasn't set. Signed-off-by: Emily Shaffer --- bugreport.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bugreport.c b/bugreport.c index f5598513d9..759cc0b0f8 100644 --- a/bugreport.c +++ b/bugreport.c @@ -45,6 +45,9 @@ static void get_system_info(struct strbuf *sys_info) strbuf_addstr(sys_info, gnu_get_libc_version()); strbuf_complete_line(sys_info); + strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n", + getenv("SHELL")); + strbuf_addstr(sys_info, "git-http-fetch -V:\n"); get_http_version_info(sys_info); strbuf_complete_line(sys_info); From patchwork Fri Dec 13 00:43:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289633 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 81B35139A for ; Fri, 13 Dec 2019 00:43:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C71F21655 for ; Fri, 13 Dec 2019 00:43:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EoCIIyBD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731749AbfLMAnu (ORCPT ); Thu, 12 Dec 2019 19:43:50 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:48574 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbfLMAnt (ORCPT ); Thu, 12 Dec 2019 19:43:49 -0500 Received: by mail-pj1-f73.google.com with SMTP id o34so410511pjb.15 for ; Thu, 12 Dec 2019 16:43:49 -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=P6t6vuXoq++8zpknfpe5SgYeYCpkHgEzkrCEfNje28I=; b=EoCIIyBDKXmiYspEkkNjXoZOuXMMDtEnLlowINrs8llgs15+je6o/dhCnNIKy6bWnu Yv95sufL5d0lggmLr7H3PgyA4yJqIhQvCWXS4goJ6abrd61xmvO/TjhTfxlInEYFFUH7 Q3QK8MZ+yk8I8e0lwH6iMiizYEc+n3/bGEt9MewxwFVzlajj8dr20odGITjZoT6usLAl ygnLB/cDUwvpkEzsk65xyFQvLoKUEHxXWLDXj0DAU/zHrXKgctNTHUl34W7zxDWUPbt8 n/IRaj/FPD+/oNdhwQiY7Bs17KLdvqFhxIHPimlEMQg5CgZJfNOpl9stQUhXu2dgPIbZ 4F4g== 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=P6t6vuXoq++8zpknfpe5SgYeYCpkHgEzkrCEfNje28I=; b=FQEkeO5uYBRl/61/vLHZ159+oaCQoG8oIHXRRj4ABVcfhCqfYwn5CqsNoL8XaUezDJ nc0L5iV67N2GPLbkqvvYiQGBH3y9qWE03QDTVS3xPV+GyhPSplFkHi0N2fgiV6xSkgGD uhyFViKFkQ/OgucFSEn597STuJyeHT+kDt2dPbu4BwvBvlQ0DEpaoVtGnk/y3OYIhn8T t1G0/0hZyY+4w1s9YKqhpexN/E9zLklH19p4dNe6NHbvt1+os85CDjuaV6LDUyM/Oukh hIgMxA6/luH5VeTTWlArRGBm1I3moJiKrLosDqG91qS/N/RJaO60GJ0wmE9Z1Q+JcuuF hcrA== X-Gm-Message-State: APjAAAUigsFjXXRGrouQDfko3EJX+20wJ7VlhH+crImVPXjWEmD7a3Qo OgWYOINO755cGS10p7+WcMV5TOZdnNN8vGR66ffdMIavopDwu0gpEWYyUf1fqZZ0qi4BuS0FI1w ICQ91GfgdEYzBwbv8vullEu06rd8z7H94UGjk6ZN1uxV393r3WVHIdXHaOTTZv/W0OdlFjSqBAA == X-Google-Smtp-Source: APXvYqx33aB8Ks/8RSQ0D6TXMgiM5L+7Y5koN0BPYvwU0oRlsCfgBa9cBCXnLDiivrTGdFu6NuB986Hujqj4vuNF6HU= X-Received: by 2002:a63:1447:: with SMTP id 7mr13748743pgu.22.1576197828631; Thu, 12 Dec 2019 16:43:48 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:06 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-10-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 09/15] bugreport: generate config safelist based on docs From: Emily Shaffer 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 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 | 14 +++-- generate-bugreport-config-safelist.sh | 22 ++++++++ 6 files changed, 83 insertions(+), 37 deletions(-) create mode 100755 generate-bugreport-config-safelist.sh diff --git a/.gitignore b/.gitignore index 5dde2cc4c8..30935621d9 100644 --- a/.gitignore +++ b/.gitignore @@ -191,6 +191,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 c49f55a521..76dc51e2b1 100644 --- a/Makefile +++ b/Makefile @@ -651,7 +651,7 @@ install-perl-script: $(SCRIPT_PERL_GEN) install-python-script: $(SCRIPT_PYTHON_GEN) $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' -.PHONY: clean-perl-script clean-sh-script clean-python-script +.PHONY: clean-perl-script clean-sh-script clean-python-script clean-script-dependencies clean-sh-script: $(RM) $(SCRIPT_SH_GEN) clean-perl-script: @@ -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) . \ @@ -2161,6 +2162,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):\ @@ -2791,7 +2798,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -GEN_HDRS := config-list.h command-list.h unicode-width.h +GEN_HDRS := config-list.h command-list.h unicode-width.h bugreport-config-safelist.h EXCEPT_HDRS := $(GEN_HDRS) compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h @@ -3117,7 +3124,8 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(HCC) $(RM) -r bin-wrappers $(dep_dirs) $(RM) -r po/build/ - $(RM) *.pyc *.pyo */*.pyc */*.pyo config-list.h command-list.h + $(RM) *.pyc *.pyo */*.pyc */*.pyo + $(RM) config-list.h command-list.h bugreport-config-safelist.h $(RM) $(ETAGS_TARGET) tags cscope* $(RM) -r $(GIT_TARNAME) .doc-tmp-dir $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz diff --git a/generate-bugreport-config-safelist.sh b/generate-bugreport-config-safelist.sh new file mode 100755 index 0000000000..06b8e0c3c4 --- /dev/null +++ b/generate-bugreport-config-safelist.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +cat < X-Patchwork-Id: 11289635 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 552F5930 for ; Fri, 13 Dec 2019 00:43:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33CE52173E for ; Fri, 13 Dec 2019 00:43:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Uk1RpqhD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731756AbfLMAnx (ORCPT ); Thu, 12 Dec 2019 19:43:53 -0500 Received: from mail-qv1-f74.google.com ([209.85.219.74]:37366 "EHLO mail-qv1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbfLMAnw (ORCPT ); Thu, 12 Dec 2019 19:43:52 -0500 Received: by mail-qv1-f74.google.com with SMTP id w13so635848qvb.4 for ; Thu, 12 Dec 2019 16:43:51 -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=hYTq6RD1kAa21zZMC8IE5749jJWPV/sWT52ODcbe7dE=; b=Uk1RpqhDp7Pwild/rBF4dgycg97JBJZ+r03BynTD3+ml6wHh3/bUgxh3cC/eojhl9B iBGQcIClSgCe1sTrBWNBKnzDSAtBb+zW5r0FUR44715fouXf1l6jXfXNv6w0LRvGyQe0 2pwZJXUsCQGKPE6sEi2ki7QFIvt1qRdteSe8iDwIUdlovwxy72cmweNYeDmI3uksckOB y80b4eCb3nyh0TQV8LT06DASYsvdLDN5iZDLXdxkd6gnCGhN3zF0TDXjyA+hUBb9AHG/ MRTei48YqYKMQhfuzeeeFHT5a/1l6z3Y5HQ9IBmrmxNq+TDgiV1dkeZm0/8Vz+2THV1E XDYg== 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=hYTq6RD1kAa21zZMC8IE5749jJWPV/sWT52ODcbe7dE=; b=NNYWGp2q8aCbnGkDSgpH08+jEEV0aBV38geghsNhqit1b+xfxDLIa5DJjcfylTjrwi EwUvtxDMmUwQsmtLqG+Jzu35p/+Qh5G17yHUlOiwg/2+rnbojPU9ylNRgR0HJgiVZ383 Q7lKQ9MsY9YksYLBHxAKwITvqNATP5iJQNCcPv8OwJTqzvqdOn9xKIC+m+gnCoQkolXn ggZM4v2PLY7/8aW+yhs50nywoR+hhDL4NFEmXsgAR/lox2mukis7xewMLhE1piIfVkAV xM7FNLADy0QLDOMbE2xqIT/6/zy6zXrUsgalbKqCKApLS0kQdE3jHSfYpo/j5j7+6C9E YJtQ== X-Gm-Message-State: APjAAAWhvcBclIdL+/v2VgTZUj+H/+RsO9uX2TaiRDcOHQXyFsg4dIrj 32h8NXoWvbDqq8eCcGBCFHxIZvbOBtU2myW92EVkQJIBLZVNd5pXqRX7ksnMkxFzTvuDP0i7uID uINecQIUAvTeIn78qKrYZldnNUzZiqn4Mm301V/ICv99mYwMvtd0Ybew94/6oYjJjEvUOeQ7ikA == X-Google-Smtp-Source: APXvYqwUWQ3v/fnf5qfTbzSTFrpB8CPP4PI1LB0Vz+GWqPFggc5fndEjB5VamQ/AJ/8ammuLqXhn7QAAgTUDoY594/I= X-Received: by 2002:a37:644:: with SMTP id 65mr11232910qkg.309.1576197831251; Thu, 12 Dec 2019 16:43:51 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:07 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-11-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 10/15] bugreport: add config values from safelist From: Emily Shaffer 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 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 --- bugreport.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/bugreport.c b/bugreport.c index 759cc0b0f8..1fca28f0b9 100644 --- a/bugreport.c +++ b/bugreport.c @@ -6,6 +6,9 @@ #include "help.h" #include #include "run-command.h" +#include "config.h" +#include "bugreport-config-safelist.h" +#include "khash.h" static void get_http_version_info(struct strbuf *http_info) { @@ -18,6 +21,41 @@ static void get_http_version_info(struct strbuf *http_info) strbuf_addstr(http_info, "'git-http-fetch -V' 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); + printf("ESS: added %s\n", cfg_key); + 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; @@ -53,6 +91,36 @@ static void get_system_info(struct strbuf *sys_info) strbuf_complete_line(sys_info); } +static void gather_safelist() +{ + 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 @@ -114,10 +182,12 @@ int cmd_main(int argc, const char **argv) get_bug_template(&buffer); - // add other contents 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 Dec 13 00:43:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289637 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 793F1139A for ; Fri, 13 Dec 2019 00:43:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 584BF2173E for ; Fri, 13 Dec 2019 00:43:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CFFrXenE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731762AbfLMAnz (ORCPT ); Thu, 12 Dec 2019 19:43:55 -0500 Received: from mail-vk1-f202.google.com ([209.85.221.202]:49511 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbfLMAnz (ORCPT ); Thu, 12 Dec 2019 19:43:55 -0500 Received: by mail-vk1-f202.google.com with SMTP id k4so294932vkh.16 for ; Thu, 12 Dec 2019 16:43:54 -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=pPwKYO4OFf6PjcDKaM3OUDjjtUpTYBkjNIA6p+i+5f0=; b=CFFrXenEPBVCqDspJebES1qAtN4tqoT3f8NNrnOTLR/r2wfhWRrF3IVomRsJTfi6P2 xmwWemCCEaEcIOSl6IhXogcr3MfjY+bg2l8mdssx6CiH+Tehs06LzZBwWsZLKBx79f2l 8an1tmNgeOZwSxxBD3REDp+VB6WUM1c6GNGdO/wIPYdwSbKu97s56oNP+mpqyT2KPHLD TTayOBs7ihFLtIn64r97UhOOrAakOfdbdeMgL9WwmAy7UiQddgbXo+1hVOHiSxPzMHXQ 47EHM8CQ+7nMc4X0K6xomCg1WnzBiA3IbUGbU+dlzS6MJELoZAZO6MPo1IDXdj1pYCNX a9CA== 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=pPwKYO4OFf6PjcDKaM3OUDjjtUpTYBkjNIA6p+i+5f0=; b=DE/jPhILQf2CWR9x+kRFcEfKeGk3hptOeJekU6NLDaDZ5SCBXPj+jHN3LST8y6uqyD hGs6aLzrOf5jxAFMlMjtgEgvvQbQh7KZfuM5QO2bHmrMOH5qqQjV/GP9TTVoanCYZnVA jIvpohz+Dx663T0j0Vq2Y4Gk38I+d21kH2ss/kLfEpabBD0n4rQahbYmo00wQgEMSRP6 2tRQmO7JV85vTJ5QlF21kKEmKzAWeKYeGWYjNcr53+aIurUgjBEikirPkZUbDrmQLGqw fzehc98iyRpSirn0rt+EqqFGZTM28QqAE/And1tkMR/EyCb3ZG3VM4vw6+fWhJk8Jetc IR6w== X-Gm-Message-State: APjAAAXkaGr8VxMRpJksKX1PhrAxOjRyftyXTeXRVJ+LAsLLLiUuAD9v qre73Y2XHZC44SvjZmawYpcSUvCHBYXBx5Jw7K3b8A8DMnsuB8Ccq0TJnq/7+oQS5zCqT9ipZD6 Hbjb2tB2Ehr/Uw8dzamwpctO6Xc+LNVqHj8F0sUR6JCWXUjPzvXEZq0EcvLTFCu1UjK3/S2S8Ag == X-Google-Smtp-Source: APXvYqxxcifKJAMiX7QEsgf9LR267bkZo6YvOX+3AXPd5l8polh+UvjHjxDetye1pD7CaeawXzOYM0Qo/RJPPpAW8wU= X-Received: by 2002:ab0:3387:: with SMTP id y7mr10662423uap.99.1576197833839; Thu, 12 Dec 2019 16:43:53 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:08 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-12-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 11/15] bugreport: collect list of populated hooks From: Emily Shaffer 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 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 | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/bugreport.c b/bugreport.c index 1fca28f0b9..f89cb8d754 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_http_version_info(struct strbuf *http_info) { @@ -121,6 +122,57 @@ static void get_safelisted_config(struct strbuf *config_info) cfgset_clear(&safelist); } +static void get_populated_hooks(struct strbuf *hook_info) +{ + /* + * 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; + int nongit_ok; + + setup_git_directory_gently(&nongit_ok); + + if (nongit_ok) { + 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 @@ -188,6 +240,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); + report = fopen_for_writing(report_path.buf); strbuf_write(&buffer, report); fclose(report); From patchwork Fri Dec 13 00:43:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289639 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 14AA6139A for ; Fri, 13 Dec 2019 00:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E6AC221655 for ; Fri, 13 Dec 2019 00:43:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CTOz1Rlk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731765AbfLMAn5 (ORCPT ); Thu, 12 Dec 2019 19:43:57 -0500 Received: from mail-vk1-f201.google.com ([209.85.221.201]:44513 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731763AbfLMAn5 (ORCPT ); Thu, 12 Dec 2019 19:43:57 -0500 Received: by mail-vk1-f201.google.com with SMTP id k16so303872vko.11 for ; Thu, 12 Dec 2019 16:43:57 -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=ab2bcDVKAZvq03F1lRiy63B2enXZnHSY50w8FqRsyTM=; b=CTOz1Rlky5utrtsaS4yS/mh453m4jgOkVxx6QV6zrDlIKo8pfxQaAol8P2fniVjwTO 1BEd98aSsNlMfVC4aaTV+Mv2Ybt7Hp2n6IBD3xWtSk4S7tAVD2oEf6oSoHnsjtt/vlZj DHioMcMdBGsvzKHCdT1+ft+tvuAfSi0KNhm95hlbbYUEq+fvoFwCYFooWdPyPVal3yOV MbCV6tT1TaClta3+8l9245czqe1uJHCcZI2RaGRIKYiEHFDF1JRz2hBvHXCQ035bd59X ghSQfXrBVu+oQ3dz7GmcwfKO7YoLtlgvlzZf6HxtB9FgW+zHFPeQTPAW3ePJWEQ3eKsl nVuw== 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=ab2bcDVKAZvq03F1lRiy63B2enXZnHSY50w8FqRsyTM=; b=lGzhc2YojBlpedFY7YMBdKPGwNgQBxlJkY5o5R38UW6kMynJkovngwy/1Pm+xOy0It a7McC1WGh0E8V9BJd/EYBBXqo7X7XPhfuW/wV5D2X+8x4yW/kSsZTxujFxkdP6dQn5m4 Pz/xuyVHnikmhUvEBD/joDscYrBxtOhT7YfIRJ5Nyh/96AQCeLJZlJa1mgjbC2yW31Hg UgF95q52t2SDMxItlnXI6pe2ct5TMhgQ2peMlz+uanGevVBPs7F2Axe9gG1K4NRmGvl9 If50AKFq7jvNP+ZXMU5iJSHyrbK93xGUSO+JmxCFfaOlp3wDh3Lw/xR/FzqCwIYGhTxd N2XQ== X-Gm-Message-State: APjAAAXnN07b3rCdnJrwzxWxxzSvhBT2I81IG6g4XA5rpBZY6/CEA3gW +/ljkCoDbtLo10YicOH94SK/RpG0Kc2L5CKPAud3tgFj77kyQD85EAYf8RXbJu7wLea4GqoZ0Ne aDQ3M0oBjXKAccWYdmZX7htYbPRMCl9sr9WnN+tEktNDLN77hHSzwdES3XsC4ETIn47t++XgV5A == X-Google-Smtp-Source: APXvYqwfwqsmnorG2+KMxRpbV1u+1Zqg5NEvseH0btROuAZZaToyeEXFMvoowHsSGG0nkhIQ5CERmfy2WsVo8siJQ9w= X-Received: by 2002:a1f:e3c6:: with SMTP id a189mr11599068vkh.82.1576197836471; Thu, 12 Dec 2019 16:43:56 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:09 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-13-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 12/15] bugreport: count loose objects From: Emily Shaffer 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 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. Rather than directly invoking 'git-count-objects', which may sometimes fail unexpectedly on Git for Windows, manually count the contents of .git/objects. Additionally, since we may wish to inspect other directories' contents for bugreport in the future, put the directory listing into a helper function. Helped-by: Johannes Schindelin Signed-off-by: Emily Shaffer --- bugreport.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/bugreport.c b/bugreport.c index f89cb8d754..3abb83d77f 100644 --- a/bugreport.c +++ b/bugreport.c @@ -173,6 +173,67 @@ static void get_populated_hooks(struct strbuf *hook_info) } } +static int is_hex(const char *string, size_t count) +{ + for (; count; string++, count--) { + if (!isxdigit(*string)) + return 0; + } + return 1; +} + +static void get_loose_object_summary(struct strbuf *obj_info) { + struct dirent *d = NULL; + DIR *dir, *subdir = NULL; + size_t dir_len; + struct strbuf dirpath = STRBUF_INIT; + + strbuf_addstr(&dirpath, get_object_directory()); + strbuf_complete(&dirpath, '/'); + + dir = opendir(dirpath.buf); + if (!dir) { + strbuf_addf(obj_info, "could not open object directory '%s'\n", + dirpath.buf); + strbuf_release(&dirpath); + return; + } + + dir_len = dirpath.len; + + while ((d = readdir(dir))) { + int object_count = 0; + char subdir_name[3]; + + if (d->d_type != DT_DIR) + continue; + + if ((strlen(d->d_name) != 2) || (!is_hex(d->d_name, 2))) + continue; + + /* copy directory name + \0 */ + memcpy(subdir_name, d->d_name, 3); + + strbuf_setlen(&dirpath, dir_len); + strbuf_addstr(&dirpath, d->d_name); + + subdir = opendir(dirpath.buf); + if (!subdir) + continue; + while ((d = readdir(subdir))) + if (d->d_type == DT_REG) + object_count++; + + closedir(subdir); + + strbuf_addf(obj_info, "%s: %d\n", subdir_name, object_count); + } + + + closedir(dir); + strbuf_release(&dirpath); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -243,6 +304,9 @@ int cmd_main(int argc, const char **argv) get_header(&buffer, "Configured Hooks"); get_populated_hooks(&buffer); + 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 Dec 13 00:43:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289641 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 F30DA930 for ; Fri, 13 Dec 2019 00:44:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D13112173E for ; Fri, 13 Dec 2019 00:44:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="J5+usTc1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731770AbfLMAoA (ORCPT ); Thu, 12 Dec 2019 19:44:00 -0500 Received: from mail-qt1-f202.google.com ([209.85.160.202]:46793 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731342AbfLMAoA (ORCPT ); Thu, 12 Dec 2019 19:44:00 -0500 Received: by mail-qt1-f202.google.com with SMTP id d9so697849qtq.13 for ; Thu, 12 Dec 2019 16:43:59 -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=C2sLBme3gm/qdTQaSfkdtC92BFNSfqgpRg1jGgOX4/w=; b=J5+usTc1iB85jPK9z2kZLsA2uOAjXKYfgzioytKr+eA1vPuVmT34/xOlNrrOWfB0Z1 pmssEw2/iDcInnCdX41QhS8T5fdCmlcd5YS1C62DAmcGSRRd7mlhkkECPGnlR9+ONxwS TN26RVN2C16kxZOuJMi5LvOgKfg/I3sVqFSthUSAogPVAr9xMxerODE49nMrwHx7suew ouNWvNCkKBMXXXyZ2cIGg4odTwLEGCa9UMQn3KXL4DhmlPVDJn5XYNfMqWnnRT44QsLd DYeWOOc1iJ+JFEy73LZxsZde+A+UBTiLOW/6u2X54XMzx3Wb758DoX8XbBclKIhJAs5k DKdQ== 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=C2sLBme3gm/qdTQaSfkdtC92BFNSfqgpRg1jGgOX4/w=; b=bMDgmHg+rrsHWB33EDsjKpRSboPkhEFsrXoRbQYvmgYtiXUbcZOmAqRNzIzrOVia2+ uwadVcGX/bdwBJ9LeG5D51QvWPh6k4G2DkliC0N/nTw34g1k2bdYb+izXCNSQJw6nEI6 Y4NvKz2SIogKiMBsX3O92rNU+w3ExZhSX936ulLS9s4PioB8bxmZaeFhJ3W9BsDZv7V5 iG/HWj83+GYA5sJF6ZE2S0Nk3JvxC2E0YJqcaL2a5r0onjXA/5X5jVJ/LKW/1umzry38 SgNn8kuMtfOiBC4Pd6F5aZDE3T4/32SAK0mrjmRjhwpIgokGiti3XhffDrT5FrT6Rvdl mSEg== X-Gm-Message-State: APjAAAUTEt4FO8BgZhBi08neC49xNQ5tHqPACs1Xvn8zVhG2JU+P6XRA 0zgNjVnVGF+YmCR8SkJICsElR4wivCN3yImnQhrsvTf5yepOWJEQzkur8QOf73cAkbvTPt9hnms rK7JGUCgzr01ZYePaQ6gDur+3MhLX0wWGsbRYvcsk1B6eDX802cCtBx4NnCPMLvOqyHfR4rgnzA == X-Google-Smtp-Source: APXvYqxN8zVEy7ts7Z3Q0U50oWVzjln30myrv2RORHu5M2+DPJuilOvkWI7RxhvAZkPQgLYMam0FCN60MUDedqdRJaw= X-Received: by 2002:ad4:4511:: with SMTP id k17mr10559420qvu.135.1576197838898; Thu, 12 Dec 2019 16:43:58 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:10 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-14-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 13/15] bugreport: add packed object summary From: Emily Shaffer 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 Alongside the list of loose objects, it's useful to see the list of object packs as well. It can help us to examine what Git did and did not pack. Signed-off-by: Emily Shaffer --- bugreport.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bugreport.c b/bugreport.c index 3abb83d77f..992d8f9de7 100644 --- a/bugreport.c +++ b/bugreport.c @@ -234,6 +234,34 @@ static void get_loose_object_summary(struct strbuf *obj_info) { strbuf_release(&dirpath); } +static void get_packed_object_summary(struct strbuf *obj_info) +{ + struct strbuf dirpath = STRBUF_INIT; + struct dirent *d; + DIR *dir = NULL; + + strbuf_addstr(&dirpath, get_object_directory()); + strbuf_complete(&dirpath, '/'); + strbuf_addstr(&dirpath, "pack/"); + + dir = opendir(dirpath.buf); + if (!dir) { + strbuf_addf(obj_info, "could not open packed object directory '%s'\n", + dirpath.buf); + strbuf_release(&dirpath); + return; + } + + while ((d = readdir(dir))) { + strbuf_addbuf(obj_info, &dirpath); + strbuf_addstr(obj_info, d->d_name); + strbuf_complete_line(obj_info); + } + + closedir(dir); + strbuf_release(&dirpath); +} + static const char * const bugreport_usage[] = { N_("git bugreport [-o|--output ]"), NULL @@ -307,6 +335,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 Dec 13 00:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289643 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 B0019139A for ; Fri, 13 Dec 2019 00:44:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F64F2173E for ; Fri, 13 Dec 2019 00:44:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Al8ure62" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731772AbfLMAoC (ORCPT ); Thu, 12 Dec 2019 19:44:02 -0500 Received: from mail-vk1-f201.google.com ([209.85.221.201]:42916 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731342AbfLMAoC (ORCPT ); Thu, 12 Dec 2019 19:44:02 -0500 Received: by mail-vk1-f201.google.com with SMTP id 198so307801vkz.9 for ; Thu, 12 Dec 2019 16:44:01 -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=Z2PBOeiNceafL9gMLCWLSaOgNOOycaLR48iAI36O43Y=; b=Al8ure62NMogREvEhNCXRVyIxUX1a/0AdBXAevMIN4KUv9vU3AvLNFtyHYJ11HL4vm q7yBl4LrpmZVa0AFTb/KJG91PMjXs8IEm9dmtdya1w0E/YjESDh7k11snsvlAr2ekWkp BBPsMvoUkynNoT43VRghGbNJU4hpOJvM66FJ6vHqvMcKl0knn9ldUr6eO5497+XhG9d/ csEGycoiZNz3xhQay7YLtmceES5RoUyugkFBqdrDAY/7wkJxvlN2QibTrLpU95r/O2VM 2cZCq9xaQzPp/K715cH9MHyPzbIoMpX0VnDRop0Wcbgzhj5AtY/0zznJaxJeYNpjkrLN vi3g== 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=Z2PBOeiNceafL9gMLCWLSaOgNOOycaLR48iAI36O43Y=; b=EtWGNfM46Xkuz0GiuUumz7icWLXT3ybA6/1gmDSRevR+4P/c8bA+kS1a7guNkzsS5p sjNN2PGP0rL2XGGF7W9uxqJGYb1mED3TMfIDOjcY69ioFcIsQUkvzLueYCUzasNUwXsX tmE+66oq/Yi5lTBibv36EpQhsniZ0fRA+QagMCw8D6KMP2yuOHi80IDOH/jkE8bmy293 lrdco0ylh8N0lpuTP0Ikik7wVkwguGQrlpG1ahmOIx1L3+NyygbW4KknthE1t0Q7Tth0 4ifR5dC65np1/Mqyi5gFAA/J95Ghi37TPpHj7BkoACxvsvDQ792zR9jqhyFBkw5Z6h/Y 9y4w== X-Gm-Message-State: APjAAAWXUT/rX8BQYU1hPTo8EENcFhdGQzDixdqHEPXNec9+DsTfx1u3 J7Nyy+soYyVZwv7njAF+/zyR28kcLgz+JCbbbhRirRIvsTTXcRddHrnSmG9OV1DIhFyBcDK0stT 3+wP+5PjYgzP4Grkh9wosI2NOLXUB8SFFgzSbl6s6pfCs5KTsIdV40BJvie2UIrj1JXMGUha7mQ == X-Google-Smtp-Source: APXvYqwieCdt40Y7nx1Vbjsph++DR6bo91c988leJbx7g1+KP6QTwFdyz/MN1pN0F6DPj3/VbQVo3trjEUkI6a4+0Ew= X-Received: by 2002:a67:e8d1:: with SMTP id y17mr9076322vsn.91.1576197841286; Thu, 12 Dec 2019 16:44:01 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:11 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-15-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 14/15] bugreport: list contents of $OBJDIR/info From: Emily Shaffer 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 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 992d8f9de7..5d300f1c5f 100644 --- a/bugreport.c +++ b/bugreport.c @@ -262,6 +262,51 @@ static void get_packed_object_summary(struct strbuf *obj_info) strbuf_release(&dirpath); } +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 @@ -338,6 +383,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 Dec 13 00:43:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emily Shaffer X-Patchwork-Id: 11289645 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 25FCC139A for ; Fri, 13 Dec 2019 00:44:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04F5522527 for ; Fri, 13 Dec 2019 00:44:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dl6ZJB5Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731732AbfLMAoF (ORCPT ); Thu, 12 Dec 2019 19:44:05 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:57273 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731342AbfLMAoE (ORCPT ); Thu, 12 Dec 2019 19:44:04 -0500 Received: by mail-pg1-f202.google.com with SMTP id a4so327887pgq.23 for ; Thu, 12 Dec 2019 16:44:04 -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=CYTOmTIH021BCK/eU7Pf8plHGlQuQ0XxPruLIpG941U=; b=dl6ZJB5ZXkt/TaHh3eBGvbhHMtiWlrOcbY4HgWjt/O+sHGAaGuacQKJWamFToZ8zV7 PmB6c48Y06WDsUG6IepJ9O3amnR7hKZusXdmrLxX+wf3JWD0oOJkarmxpJkCwblAA/O6 c43vloY82j/SQ2xZOEK9/CG+EhDV6MPTIpzqS/hzU1jzBgvhGvG5zrAAIoo0JpsjhiIu PjpRdb+yjyXU9k+R5XvalMLTadkKXfJzyyuZaYlsZlkcNj2vxzMgQk5RRDGSdLVjRpNe 1G94lvYnApFfzMDdkLue8wGofhV9D5Mpp4IEayIvoXbdmAtqV6Be5Z3IbL7ATJg9PtPm U5Iw== 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=CYTOmTIH021BCK/eU7Pf8plHGlQuQ0XxPruLIpG941U=; b=R3D+PZjV06zCxHCO2mVON0gB3xtnxMqJD+nRs4seEvIzixz97bW7rw82CBFfwDNkPA ZCcT/adXCrvQ4bFjipfeGGIJARE+66DHDIVLzE765PXdtqqZWdJSLX40X1gIukb5W8NH /stqMzZjxwSLTJZD3n2JtBWuKW8A/pKPc73SJF/t9yLKlyTFEmgVI80FsjcO0Xzb9V+f Jeiavdc7ODZv5zSq7GOWO6RGoIhQbldevyHrGl/ANR+EKV4nxFdF90QDYjm1+2roXs+5 3pmWuBjTfTtf5nhqUVnFB2wAFwbVvyb9LUYPcBi3db3HmjOslcHebay2nGY/cF0rndEB O9Vg== X-Gm-Message-State: APjAAAVVyNJbVoWGPj/Y5D8DfjxzdeOShSFguZ+w/VT6FJniMhpGS5ag YtJQgh31h0dEQ9IwverBVnWVfKfbvvH83kXqHsjcdZDjucWZACEtvPF3qtnkIKlUhM9qSVlv0u9 TlEwj5mO0U1XNQT4NoxK5ePcYdCIp9thZ8r8P8FwZySG+yGuVAyUdEz0SBpXTzuvZhJ3weVGkIA == X-Google-Smtp-Source: APXvYqxIajV88D1EIVH1VJW/hd/AWet7t6g1MnjmO0rQFcuxb5p9ZenSg8ZvSdCeD+770EhmHC1XaubS6c5Rk6nZwHU= X-Received: by 2002:a63:3f82:: with SMTP id m124mr13784206pga.431.1576197843654; Thu, 12 Dec 2019 16:44:03 -0800 (PST) Date: Thu, 12 Dec 2019 16:43:12 -0800 In-Reply-To: <20191213004312.169753-1-emilyshaffer@google.com> Message-Id: <20191213004312.169753-16-emilyshaffer@google.com> Mime-Version: 1.0 References: <20191213004312.169753-1-emilyshaffer@google.com> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog Subject: [PATCH v4 15/15] bugreport: summarize contents of alternates file From: Emily Shaffer 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 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. Signed-off-by: Emily Shaffer --- bugreport.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/bugreport.c b/bugreport.c index 5d300f1c5f..d2a3fb1f67 100644 --- a/bugreport.c +++ b/bugreport.c @@ -307,6 +307,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 @@ -386,6 +422,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);