git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
16216bff8ebf56e8f38c79b30021fba50f1cc5c1 blob 4832 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
 
#include "cache.h"
#include "parse-options.h"
#include "stdio.h"
#include "strbuf.h"
#include "time.h"
#include "help.h"
#include "compat/compiler.h"
#include "run-command.h"
#include "config.h"
#include "bugreport-config-safelist.h"
#include "khash.h"

static void get_git_remote_https_version_info(struct strbuf *version_info)
{
	struct child_process cp = CHILD_PROCESS_INIT;

	argv_array_push(&cp.args, "git");
	argv_array_push(&cp.args, "remote-https");
	argv_array_push(&cp.args, "--build-info");
	if (capture_command(&cp, version_info, 0))
	    strbuf_addstr(version_info, "'git-remote-https --build-info' not supported\n");
}

static void get_system_info(struct strbuf *sys_info)
{
	struct utsname uname_info;
	char *shell = NULL;

	/* get git version from native cmd */
	strbuf_addstr(sys_info, "git version:\n");
	get_version_info(sys_info, 1);
	strbuf_complete_line(sys_info);

	/* system call for other version info */
	strbuf_addstr(sys_info, "uname -a: ");
	if (uname(&uname_info))
		strbuf_addf(sys_info, "uname() failed with code %d\n", errno);
	else
		strbuf_addf(sys_info, "%s %s %s %s\n",
			    uname_info.sysname,
			    uname_info.release,
			    uname_info.version,
			    uname_info.machine);

	strbuf_addstr(sys_info, "compiler info: ");
	get_compiler_info(sys_info);
	strbuf_complete_line(sys_info);

	shell = getenv("SHELL");
	strbuf_addf(sys_info, "$SHELL (typically, interactive shell): %s\n",
		    shell ? shell : "<unset>");

	strbuf_addstr(sys_info, "git-remote-https --build-info:\n");
	get_git_remote_https_version_info(sys_info);
	strbuf_complete_line(sys_info);
}

static void get_safelisted_config(struct strbuf *config_info)
{
	size_t idx;
	struct string_list_item *it = NULL;
	struct key_value_info *kv_info = NULL;

	for (idx = 0; idx < ARRAY_SIZE(bugreport_config_safelist); idx++) {
		const struct string_list *list =
			git_config_get_value_multi(bugreport_config_safelist[idx]);

		if (!list)
			continue;

		strbuf_addf(config_info, "%s:\n", bugreport_config_safelist[idx]);
		for_each_string_list_item(it, list) {
			kv_info = it->util;
			strbuf_addf(config_info, "  %s (%s)\n", it->string,
				    kv_info ? config_scope_name(kv_info->scope)
					    : "source unknown");
		}
	}
}

static const char * const bugreport_usage[] = {
	N_("git bugreport [-o|--output-directory <file>] [-s|--suffix <format>]"),
	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 share.\n");

	strbuf_addstr(template, template_text);
	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;
	struct strbuf report_path = STRBUF_INIT;
	FILE *report;
	time_t now = time(NULL);
	char *option_output = NULL;
	char *option_suffix = "%F-%H%M";
	struct stat statbuf;
	int nongit_ok = 0;

	const struct option bugreport_options[] = {
		OPT_STRING('o', "output-directory", &option_output, N_("path"),
			   N_("specify a destination for the bugreport file")),
		OPT_STRING('s', "suffix", &option_suffix, N_("format"),
			   N_("specify a strftime format suffix for the filename")),
		OPT_END()
	};

	/* Prerequisite for hooks and config checks */
	setup_git_directory_gently(&nongit_ok);

	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, option_suffix, localtime(&now), 0, 0);
	strbuf_addstr(&report_path, ".txt");

	if (!stat(report_path.buf, &statbuf))
		die("'%s' already exists", report_path.buf);

	get_bug_template(&buffer);

	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);

	if (report == NULL) {
		strbuf_release(&report_path);
		die("couldn't open '%s' for writing", report_path.buf);
	}

	strbuf_write(&buffer, report);
	fclose(report);

	fprintf(stderr, _("Created new report at '%s'.\n"), report_path.buf);

	UNLEAK(buffer);
	UNLEAK(report_path);
	return -launch_editor(report_path.buf, NULL, NULL);
}
debug log:

solving 16216bff8e ...
found 16216bff8e in https://public-inbox.org/git/20200206004108.261317-11-emilyshaffer@google.com/
found 9b51250155 in https://public-inbox.org/git/20200206004108.261317-9-emilyshaffer@google.com/
found da5859c131 in https://public-inbox.org/git/20200206004108.261317-8-emilyshaffer@google.com/
found aaeb94c10c in https://public-inbox.org/git/20200206004108.261317-7-emilyshaffer@google.com/
found 4c4b877ea1 in https://public-inbox.org/git/20200206004108.261317-6-emilyshaffer@google.com/
found dd21be9d68 in https://public-inbox.org/git/20200206004108.261317-5-emilyshaffer@google.com/
found db46fb88be in https://public-inbox.org/git/20200206004108.261317-4-emilyshaffer@google.com/

applying [1/7] https://public-inbox.org/git/20200206004108.261317-4-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
new file mode 100644
index 0000000000..db46fb88be


applying [2/7] https://public-inbox.org/git/20200206004108.261317-5-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index db46fb88be..dd21be9d68 100644


applying [3/7] https://public-inbox.org/git/20200206004108.261317-6-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index dd21be9d68..4c4b877ea1 100644


applying [4/7] https://public-inbox.org/git/20200206004108.261317-7-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index 4c4b877ea1..aaeb94c10c 100644


applying [5/7] https://public-inbox.org/git/20200206004108.261317-8-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index aaeb94c10c..da5859c131 100644


applying [6/7] https://public-inbox.org/git/20200206004108.261317-9-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index da5859c131..9b51250155 100644


applying [7/7] https://public-inbox.org/git/20200206004108.261317-11-emilyshaffer@google.com/
diff --git a/bugreport.c b/bugreport.c
index 9b51250155..16216bff8e 100644

Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.
Checking patch bugreport.c...
Applied patch bugreport.c cleanly.

index at:
100644 16216bff8ebf56e8f38c79b30021fba50f1cc5c1	bugreport.c

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git