git-bugreport with fixed VS build
Subsystems (2)
v13 cover git-bugreport with fixed VS build
Two changes from the prior set attempted for 'next':
- https://lore.kernel.org/git/[email protected]
squashed into "help: move list_config_help to builtin/help"
- Danh's SOB line changed to use the correct identity in "bugreport: add compiler info"
When generating this series I did base it on dd/ci-swap-azure-pipelines-with-github-actions in order to get the vs-build CI target; the results are here:
https://github.com/nasamuffin/git/actions/runs/80163844
Thanks.
Emily Shaffer (5):
help: move list_config_help to builtin/help
bugreport: add tool to generate debugging info
bugreport: gather git version and build info
bugreport: add uname info
bugreport: add compiler info
.gitignore | 2 + Documentation/git-bugreport.txt | 52 ++++++++++++ Makefile | 18 +++- bugreport.c | 142 ++++++++++++++++++++++++++++++++ builtin/help.c | 86 +++++++++++++++++++ command-list.txt | 1 + compat/compiler.h | 41 +++++++++ compat/vcbuild/README | 4 +- config.mak.uname | 6 +- generate-cmdlist.sh | 19 ----- generate-configlist.sh | 21 +++++ help.c | 131 +++++++---------------------- help.h | 2 +- strbuf.c | 4 + strbuf.h | 1 + t/t0091-bugreport.sh | 61 ++++++++++++++ 16 files changed, 460 insertions(+), 131 deletions(-) create mode 100644 Documentation/git-bugreport.txt create mode 100644 bugreport.c create mode 100644 compat/compiler.h create mode 100755 generate-configlist.sh create mode 100755 t/t0091-bugreport.sh
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v13 1/5 help: move list_config_help to builtin/help
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.
msvc: the bugreport topic depends on a generated config-list.h file
For reasons explained in 976aaedc (msvc: add a Makefile target to pre-generate the Visual Studio solution, 2019-07-29), some build artifacts we consider non-source files cannot be generated in the Visual Studio environment, and we already have some Makefile tweaks to help Visual Studio to use generated command-list.h header file.
As this topic starts to depend on another such generated header file, config-list.h, let's do the same to it.
--- .gitignore | 1 + Makefile | 13 +++++-- builtin/help.c | 86 ++++++++++++++++++++++++++++++++++++++++++ compat/vcbuild/README | 4 +- config.mak.uname | 6 +-- generate-cmdlist.sh | 19 ---------- generate-configlist.sh | 21 +++++++++++ help.c | 85 ----------------------------------------- help.h | 1 - 9 files changed, 123 insertions(+), 113 deletions(-) create mode 100755 generate-configlist.sh
.gitignore +1 -0
@@ -188,6 +188,7 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/config-list.h /command-list.h *.tar.gz *.dsc
Makefile +10 -3
@@ -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 || \
@@ -2133,7 +2134,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)"' \
@@ -2153,6 +2154,12 @@ $(BUILT_INS): git$X ln -s $< $@ 2>/dev/null || \ cp $< $@ +config-list.h: generate-configlist.sh + +config-list.h: + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ + >$@+ && mv $@+ $@ + command-list.h: generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt
@@ -2786,7 +2793,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -EXCEPT_HDRS := command-list.h unicode-width.h compat/% xdiff/% +EXCEPT_HDRS := command-list.h config-list.h unicode-width.h compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h endif
@@ -2808,7 +2815,7 @@ hdr-check: $(HCO) style: git clang-format --style file --diff --extensions c,h -check: command-list.h +check: config-list.h command-list.h @if sparse; \ then \ echo >&2 "Use 'make sparse' instead"; \
builtin/help.c +86 -0
98 lines not on this page · raw message
compat/vcbuild/README +2 -2
@@ -92,8 +92,8 @@ The Steps of Build Git with VS2008 the git operations. 3. Inside Git's directory run the command: - make command-list.h - to generate the command-list.h file needed to compile git. + make command-list.h config-list.h + to generate the header file needed to compile git. 4. Then either build Git with the GNU Make Makefile in the Git projects root
config.mak.uname +3 -3
@@ -721,9 +721,9 @@ vcxproj: echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets - # Add command-list.h - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h - git add -f command-list.h + # Add command-list.h and config-list.h + $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 config-list.h command-list.h + git add -f config-list.h command-list.h # Add scripts rm -f perl/perl.mak
generate-cmdlist.sh +0 -19
@@ -76,23 +76,6 @@ print_command_list () { echo "};" } -print_config_list () { - cat <<EOF -static const char *config_name_list[] = { -EOF - grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt | - sed '/deprecated/d; s/::$//; s/, */\n/g' | - sort | - while read line - do - echo " \"$line\"," - done - cat <<EOF - NULL, -}; -EOF -} - exclude_programs= while test "--exclude-program" = "$1" do
@@ -113,5 +96,3 @@ echo define_category_names "$1" echo print_command_list "$1" -echo -print_config_list
generate-configlist.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh + +echo "/* Automatically generated by generate-configlist.sh */" +echo + +print_config_list () { + cat <<EOF +static const char *config_name_list[] = { +EOF + grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt | + sed '/deprecated/d; s/::$//; s/, */\n/g' | + sort | + sed 's/^.*$/ "&",/' + cat <<EOF + NULL, +}; +EOF +} + +echo +print_config_list
help.c +0 -85
91 lines not on this page · raw message
help.h +0 -1
@@ -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);
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v13 2/5 bugreport: add tool to generate debugging info
In reply to Emily ShafferTeach 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.
--- .gitignore | 1 + Documentation/git-bugreport.txt | 46 ++++++++++++++ Makefile | 5 ++ bugreport.c | 105 ++++++++++++++++++++++++++++++++ command-list.txt | 1 + strbuf.c | 4 ++ strbuf.h | 1 + t/t0091-bugreport.sh | 61 +++++++++++++++++++ 8 files changed, 224 insertions(+) create mode 100644 Documentation/git-bugreport.txt create mode 100644 bugreport.c create mode 100755 t/t0091-bugreport.sh
.gitignore +1 -0
@@ -25,6 +25,7 @@ /git-bisect--helper /git-blame /git-branch +/git-bugreport /git-bundle /git-cat-file /git-check-attr
Documentation/git-bugreport.txt new file +46 -0
46 lines not on this page · raw message
Makefile +5 -0
@@ -680,6 +680,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
@@ -2462,6 +2463,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)
bugreport.c new file +105 -0
105 lines not on this page · raw message
command-list.txt +1 -0
@@ -54,6 +54,7 @@ git-archive mainporcelain git-bisect mainporcelain info git-blame ancillaryinterrogators complete git-branch mainporcelain history +git-bugreport ancillaryinterrogators git-bundle mainporcelain git-cat-file plumbinginterrogators git-check-attr purehelpers
strbuf.c +4 -0
@@ -554,6 +554,10 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)return sb->len ?fwrite (sb->buf,1 , sb->len, f) :0 ; } +ssize_t strbuf_write_fd (struct strbuf *sb,int fd) +{ +return sb->len ?write (fd, sb->buf, sb->len) :0 ; +}#define STRBUF_MAXLINK (2*PATH_MAX)
strbuf.h +1 -0
@@ -468,6 +468,7 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint);* NUL bytes. */ ssize_t strbuf_write (struct strbuf *sb,FILE *stream); +ssize_t strbuf_write_fd (struct strbuf *sb,int fd);/** * Read a line from a FILE *, overwriting the existing contents of
t/t0091-bugreport.sh new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v13 4/5 bugreport: add uname info
In reply to Emily ShafferThe 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.
--- Documentation/git-bugreport.txt | 1 + bugreport.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)
Documentation/git-bugreport.txt +1 -0
@@ -26,6 +26,7 @@ The following information is requested from the user: The following information is captured automatically: - 'git version --build-options' + - uname sysname, release, version, and machine strings This tool is invoked via the typical Git setup process, which means that in some cases, it might not be able to launch - for example, if a relevant config file
bugreport.c +15 -1
@@ -7,10 +7,24 @@static void get_system_info (struct strbuf *sys_info) { +struct utsname uname_info; +/* 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: " ); +if (uname (&uname_info)) +strbuf_addf (sys_info,_ ("uname() failed with error '%s' (%d)\n" ), +strerror (errno), + errno); +else +strbuf_addf (sys_info,"%s %s %s %s\n" , + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine); }static const char *const bugreport_usage[] = {
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v13 3/5 bugreport: gather git version and build info
In reply to Emily ShafferKnowing 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.
--- Documentation/git-bugreport.txt | 4 +++ bugreport.c | 19 +++++++++++++- help.c | 46 ++++++++++++++++++++------------- help.h | 1 + 4 files changed, 51 insertions(+), 19 deletions(-)
Documentation/git-bugreport.txt +4 -0
@@ -23,6 +23,10 @@ The following information is requested from the user: - Expected behavior - Actual behavior +The following information is captured automatically: + + - 'git version --build-options' + This tool is invoked via the typical Git setup process, which means that in some cases, it might not be able to launch - for example, if a relevant config file is unreadable. In this kind of scenario, it may be helpful to manually gather
bugreport.c +18 -1
@@ -1,8 +1,17 @@ -#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) +{ +/* get git version from native cmd */ +strbuf_addstr (sys_info,_ ("git version:\n" )); +get_version_info (sys_info,1 ); +strbuf_complete_line (sys_info); +}static const char *const bugreport_usage[] = {N_ ("git bugreport [-o|--output-directory <file>] [-s|--suffix <format>]" ),
@@ -32,6 +41,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 ;
@@ -79,6 +93,9 @@ int cmd_main(int argc, const char **argv)/* Prepare the report contents */ get_bug_template (&buffer); +get_header (&buffer,_ ("System Info" )); +get_system_info (&buffer); +/* fopen doesn't offer us an O_EXCL alternative, except with glibc. */ report =open (report_path.buf,O_CREAT |O_EXCL |O_WRONLY ,0666 );
help.c +28 -18
61 lines not on this page · raw message
help.h +1 -0
@@ -37,6 +37,7 @@ void add_cmdname(struct cmdnames *cmds, const char *name, int len);void exclude_cmds (struct cmdnames *cmds,struct cmdnames *excludes);int is_in_cmdlist (struct cmdnames *cmds,const char *name);void list_commands (unsigned int colopts,struct cmdnames *main_cmds,struct cmdnames *other_cmds); +void get_version_info (struct strbuf *buf,int show_build_options);/* * call this to die(), when it is suspected that the user mistyped a
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
PATCH v13 5/5 bugreport: add compiler info
In reply to Emily ShafferTo help pinpoint the source of a regression, it is useful to know some info about the compiler which the user's Git client was built with. By adding a generic get_compiler_info() in 'compat/' we can choose which relevant information to share per compiler; to get started, let's demonstrate the version of glibc if the user built with 'gcc'.
--- Documentation/git-bugreport.txt | 1 + bugreport.c | 6 +++++ compat/compiler.h | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 compat/compiler.h
Documentation/git-bugreport.txt +1 -0
@@ -27,6 +27,7 @@ The following information is captured automatically: - 'git version --build-options' - uname sysname, release, version, and machine strings + - Compiler-specific info string This tool is invoked via the typical Git setup process, which means that in some cases, it might not be able to launch - for example, if a relevant config file
bugreport.c +6 -0
@@ -4,6 +4,7 @@#include "strbuf.h" #include "time.h" #include "help.h" +#include "compat/compiler.h" static void get_system_info (struct strbuf *sys_info) {
@@ -25,6 +26,11 @@ static void get_system_info(struct strbuf *sys_info) uname_info.release, uname_info.version, uname_info.machine); + +strbuf_addstr (sys_info,_ ("compiler info: " )); +get_compiler_info (sys_info); +strbuf_addstr (sys_info,_ ("libc info: " )); +get_libc_info (sys_info); }static const char *const bugreport_usage[] = {
compat/compiler.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
Re: [PATCH v13 1/5] help: move list_config_help to builtin/help
In reply to Emily ShafferQuoted 24 lines · Emily Shaffer
Starting in
3ac68a93fd2, help.o began to depend onbuiltin/branch.o,builtin/clean.o, andbuiltin/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()intobuiltin/help.c(where it makes sense to assume other builtin libraries are present).When
command-list.his 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 <[email protected]>msvc: the bugreport topic depends on a generated
config-list.hfileFor reasons explained in
976aaedc(msvc: add aMakefiletarget to pre-generate the Visual Studio solution, 2019-07-29), some build artifacts we consider non-source files cannot be generated in the Visual Studio environment, and we already have someMakefiletweaks to help Visual Studio to use generatedcommand-list.hheader file.
Quoted 5 lines
As this topic starts to depend on another such generated header file,
config-list.h, let's do the same to it.Signed-off-by Junio C Hamano <[email protected]>---
Forgot to proofread and edit the log message into reasonable shape when you squashed two patches together?
I wonder if the "squash" action of "rebase -i" can be taught to detect a mistake like this?
Re: [PATCH v13 1/5] help: move list_config_help to builtin/help
Quoted 5 lines · Junio C Hamano
Forgot to proofread and edit the log message into reasonable shape when you squashed two patches together?
I wonder if the "squash" action of "rebase -i" can be taught to detect a mistake like this?
Without waiting for an improvement to "rebase -i" ;-), here is what I came up with, with a minimum edit.
Subject: help: move list_config_help to builtin/help
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.
For reasons explained in 976aaedc (msvc: add a Makefile target to pre-generate the Visual Studio solution, 2019-07-29), some build artifacts we consider non-source files cannot be generated in the Visual Studio environment, and we already have some Makefile tweaks to help Visual Studio to use generated command-list.h header file. Do the same to a new generated file, config-list.h, introduced by this change.
Re: [PATCH v13 1/5] help: move list_config_help to builtin/help
In reply to Emily ShafferQuoted 229 lines · Emily Shaffer
Starting in
3ac68a93fd2, help.o began to depend onbuiltin/branch.o,builtin/clean.o, andbuiltin/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()intobuiltin/help.c(where it makes sense to assume other builtin libraries are present).When
command-list.his 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 <[email protected]>msvc: the bugreport topic depends on a generated
config-list.hfileFor reasons explained in
976aaedc(msvc: add aMakefiletarget to pre-generate the Visual Studio solution, 2019-07-29), some build artifacts we consider non-source files cannot be generated in the Visual Studio environment, and we already have someMakefiletweaks to help Visual Studio to use generatedcommand-list.hheader file.As this topic starts to depend on another such generated header file,
config-list.h, let's do the same to it.Signed-off-by Junio C Hamano <[email protected]>--- .gitignore | 1 + Makefile | 13 +++++-- builtin/help.c | 86 ++++++++++++++++++++++++++++++++++++++++++ compat/vcbuild/README | 4 +- config.mak.uname | 6 +-- generate-cmdlist.sh | 19 ---------- generate-configlist.sh | 21 +++++++++++ help.c | 85 ----------------------------------------- help.h | 1 - 9 files changed, 123 insertions(+), 113 deletions(-) create mode 100755 generate-configlist.sh.gitignore +1
-0@@ -188,6 +188,7 @@ /gitweb/gitweb.cgi /gitweb/static/gitweb.js /gitweb/static/gitweb.min.* +/config-list.h /command-list.h *.tar.gz *.dscMakefile +10
-3@@ -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 || \@@ -2133,7 +2134,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)"' \@@ -2153,6 +2154,12 @@ $(BUILT_INS): git$X ln -s $< $@ 2>/dev/null || \ cp $< $@ +config-list.h: generate-configlist.sh + +config-list.h: + $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ + >$@+ && mv $@+ $@ + command-list.h: generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt@@ -2786,7 +2793,7 @@ $(SP_OBJ): %.sp: %.c GIT-CFLAGS FORCE .PHONY: sparse $(SP_OBJ) sparse: $(SP_OBJ) -EXCEPT_HDRS := command-list.h unicode-width.h compat/% xdiff/% +EXCEPT_HDRS := command-list.h config-list.h unicode-width.h compat/% xdiff/% ifndef GCRYPT_SHA256 EXCEPT_HDRS += sha256/gcrypt.h endif@@ -2808,7 +2815,7 @@ hdr-check: $(HCO) style: git clang-format --style file --diff --extensions c,h -check: command-list.h +check: config-list.h command-list.h @if sparse; \ then \ echo >&2 "Use 'make sparse' instead"; \builtin/help.c +86
-0@@ -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" ,"<slot>" , list_config_color_branch_slots }, + {"color.decorate" ,"<slot>" , list_config_color_decorate_slots }, + {"color.diff" ,"<slot>" , list_config_color_diff_slots }, + {"color.grep" ,"<slot>" , list_config_color_grep_slots }, + {"color.interactive" ,"<slot>" , list_config_color_interactive_slots }, + {"color.remote" ,"<slot>" , list_config_color_sideband_slots }, + {"color.status" ,"<slot>" , list_config_color_status_slots }, + {"fsck" ,"<msg-id>" , list_config_fsck_msg_ids }, + {"receive.fsck" ,"<msg-id>" , 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" ))compat/vcbuild/README +2
-2@@ -92,8 +92,8 @@ The Steps of Build Git with VS2008 the git operations. 3. Inside Git's directory run the command: - make command-list.h - to generate the command-list.h file needed to compile git. + make command-list.h config-list.h + to generate the header file needed to compile git. 4. Then either build Git with the GNU Make Makefile in the Git projects rootconfig.mak.uname +0
-0
config.mak.uname vcxproj: · line 725
Quoted 8 lines
config.mak.uname +2
-3@@ -721,9 +721,9 @@ vcxproj: echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets - # Add command-list.h - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h - git add -f command-list.h + # Add command-list.h and config-list.h + $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 config-list.h command-list.h
In <[email protected]>, Dscho suggested to squash his patch instead:
Quoted 176 lines
config.mak.uname +1
-0+ git add -f config-list.h command-list.h # Add scripts rm -f perl/perl.makgenerate-cmdlist.sh +0
-19@@ -76,23 +76,6 @@ print_command_list () { echo "};" } -print_config_list () { - cat <<EOF -static const char *config_name_list[] = { -EOF - grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt | - sed '/deprecated/d; s/::$//; s/, */\n/g' | - sort | - while read line - do - echo " \"$line\"," - done - cat <<EOF - NULL, -}; -EOF -} - exclude_programs= while test "--exclude-program" = "$1" do@@ -113,5 +96,3 @@ echo define_category_names "$1" echo print_command_list "$1" -echo -print_config_listgenerate-configlist.sh new file +21
-0@@ -0,0 +1,21 @@ +#!/bin/sh + +echo "/* Automatically generated by generate-configlist.sh */" +echo + +print_config_list () { + cat <<EOF +static const char *config_name_list[] = { +EOF + grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt | + sed '/deprecated/d; s/::$//; s/, */\n/g' | + sort | + sed 's/^.*$/ "&",/' + cat <<EOF + NULL, +}; +EOF +} + +echo +print_config_listhelp.c +0
-85@@ -407,91 +407,6 @@ void list_common_guides_help(void)putchar ('\n' ); } -struct slot_expansion { -const char *prefix; -const char *placeholder; -void (*fn)(struct string_list *list,const char *prefix); -int found; -}; - -void list_config_help (int for_human) -{ -struct slot_expansion slot_expansions[] = { - {"advice" ,"*" , list_config_advices }, - {"color.branch" ,"<slot>" , list_config_color_branch_slots }, - {"color.decorate" ,"<slot>" , list_config_color_decorate_slots }, - {"color.diff" ,"<slot>" , list_config_color_diff_slots }, - {"color.grep" ,"<slot>" , list_config_color_grep_slots }, - {"color.interactive" ,"<slot>" , list_config_color_interactive_slots }, - {"color.remote" ,"<slot>" , list_config_color_sideband_slots }, - {"color.status" ,"<slot>" , list_config_color_status_slots }, - {"fsck" ,"<msg-id>" , list_config_fsck_msg_ids }, - {"receive.fsck" ,"<msg-id>" , 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;help.h +0
-1@@ -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);Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
Signature · 1 line
Danh
Re: [PATCH v13 1/5] help: move list_config_help to builtin/help
Quoted 18 lines · Danh Doan
config.mak.uname vcxproj: · line 725
Quoted 13 lines · Emily Shaffer
config.mak.uname +2
-3@@ -721,9 +721,9 @@ vcxproj: echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets - # Add command-list.h - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 command-list.h - git add -f command-list.h + # Add command-list.h and config-list.h + $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 config-list.h command-list.hIn <[email protected]>, Dscho suggested to squash his patch instead:
Quoted 1 line
Sorry, I'm an idiot, please ignore my reply.
His patch is used for old series.
Signature · 1 line
Danh
Re: [PATCH v13 1/5] help: move list_config_help to builtin/help
In reply to Junio C HamanoQuoted 5 lines · Junio C Hamano
Quoted 2 lines · Junio C Hamano
Forgot to proofread and edit the log message into reasonable shape when you squashed two patches together?
Less "forgot" and more "wanted to preserve origin", but I'll avoid it next time. Thanks.
Quoted 6 lines
Quoted 3 lines
I wonder if the "squash" action of "rebase -i" can be taught to detect a mistake like this?
Without waiting for an improvement to "rebase -i" ;-), here is what I came up with, with a minimum edit.
Sorry to make more work for you. Thanks, it looks fine.
Quoted 26 lines
Starting in
3ac68a93fd2, help.o began to depend onbuiltin/branch.o,builtin/clean.o, andbuiltin/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()intobuiltin/help.c(where it makes sense to assume other builtin libraries are present).When
command-list.his 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.For reasons explained in
976aaedc(msvc: add aMakefiletarget to pre-generate the Visual Studio solution, 2019-07-29), some build artifacts we consider non-source files cannot be generated in the Visual Studio environment, and we already have someMakefiletweaks to help Visual Studio to use generatedcommand-list.hheader file. Do the same to a new generated file,config-list.h, introduced by this change.Helped-by Junio C Hamano <[email protected]>Signed-off-by Emily Shaffer <[email protected]>
Re: [PATCH v13 2/5] bugreport: add tool to generate debugging info
In reply to Emily ShafferQuoted 24 lines · Emily Shaffer
Teach Git how to prompt the user for a good bug report: reproduction steps, expected behavior, and actual behavior. Later, Git can learn how to collect some diagnostic information from the repository.
If users can send us a well-written bug report which contains diagnostic information we would otherwise need to ask the user for, we can reduce the number of question-and-answer round trips between the reporter and the Git contributor.
Users may also wish to send a report like this to their local "Git expert" if they have put their repository into a state they are confused by.
Signed-off-by Emily Shaffer <[email protected]>---
t/t0091-bugreport.sh new file +2
-0@@ -0,0 +1,61 @@ +#!/bin/sh +
t/t0091-bugreport.sh line 12
Quoted 10 lines
t/t0091-bugreport.sh new file +10
-0+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 () {
I'm afraid that this helper function doesn't do what it was supposed to.
t/t0091-bugreport.sh line 13
Quoted 1 line
t/t0091-bugreport.sh new file +1
-0+ while read -r line
It iterates through each line of stdin, which is a file written by 'git bugreport'.
t/t0091-bugreport.sh line 15
Quoted 2 lines
t/t0091-bugreport.sh new file +2
-0+ do + if test "$(grep "$HEADER_PATTERN" "$line")"
This first tries to find a match in the _file_ called "$line", which never exists, resulting in trace output:
+ check_all_headers_populated
+ read -r line
+ grep ^\[.*\]$ Thank you for filling out a Git bug report!
grep: Thank you for filling out a Git bug report!: No such file or directory
+ test
+ read -r line
+ grep ^\[.*\]$ Please answer the following questions to help us understand your issue.
grep: Please answer the following questions to help us understand your issue.: No such file or directory
+ test
+ read -r line
+ grep ^\[.*\]$
grep: : No such file or directory
[...]
Then, since 'grep' doesn't print any matches to its stdout, it invokes
test ""
which always returns non-zero, so that if condition is never fulfilled.
On first sight I thought that simply changing that 'grep' invocation to something like:
$(printf "%s\n" "$line" | grep "$HEADER_PATTERN")
would be sufficient to fix it, but then the first test failed... and I'm not sure that I understand what this was supposed to check in the first place.
Quoted 15 lines
t/t0091-bugreport.sh new file +15
-0+ then + echo "$line" + read -r nextline + if test -z "$nextline"; then + return 1; + fi + fi + done +} + +test_expect_success 'creates a report with content in the right places' ' + test_when_finished rm git-bugreport-check-headers.txt && + git bugreport -s check-headers && + check_all_headers_populated <git-bugreport-check-headers.txt +'
PATCH 1/1 Makefile: add missing dependencies of 'config-list.h'
In reply to Emily ShafferWe auto-generate the list of supported configuration variables from 'Documentation/config/*.txt', and that list used to be created by the 'generate-cmdlist.sh' helper script and stored in the 'command-list.h' header. Commit 709df95b78 (help: move list_config_help to builtin/help, 2020-04-16) extracted this into a dedicated 'generate-configlist.sh' script and 'config-list.h' header, and added a new target in the 'Makefile' as well, but while doing so it forgot to extract the dependencies of the latter. Consequently, since then 'config-list.h' is not re-generated when 'Documentation/config/*.txt' is updated, while 'command-list.h' is re-generated unnecessarily:
$ touch Documentation/config/log.txt
$ make -j4
GEN command-list.h
CC help.o
AR libgit.aFix this and list all config-related documentation files as dependencies of 'config-list.h' and remove them from the dependencies of 'command-list.h'.
$ touch Documentation/config/log.txt
$ make
GEN config-list.h
CC builtin/help.o
LINK git--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -2151,13 +2151,13 @@ $(BUILT_INS): git$X config-list.h: generate-configlist.sh -config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(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 +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@
Signature · 1 line
2.31.0.346.g7485d9830f
Re: [PATCH v13 2/5] bugreport: add tool to generate debugging info
In reply to SZEDER GáborQuoted 64 lines · SZEDER Gábor
Quoted 24 lines · Emily Shaffer
Teach Git how to prompt the user for a good bug report: reproduction steps, expected behavior, and actual behavior. Later, Git can learn how to collect some diagnostic information from the repository.
If users can send us a well-written bug report which contains diagnostic information we would otherwise need to ask the user for, we can reduce the number of question-and-answer round trips between the reporter and the Git contributor.
Users may also wish to send a report like this to their local "Git expert" if they have put their repository into a state they are confused by.
Signed-off-by Emily Shaffer <[email protected]>---
t/t0091-bugreport.sh new file +2
-0@@ -0,0 +1,61 @@ +#!/bin/sh +t/t0091-bugreport.sh line 12
Quoted 10 lines
t/t0091-bugreport.sh new file +10
-0+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 () {I'm afraid that this helper function doesn't do what it was supposed to.
t/t0091-bugreport.sh line 13
Quoted 1 line
t/t0091-bugreport.sh new file +1
-0+ while read -r lineIt iterates through each line of stdin, which is a file written by 'git bugreport'.
t/t0091-bugreport.sh line 15
Quoted 2 lines
t/t0091-bugreport.sh new file +2
-0+ do + if test "$(grep "$HEADER_PATTERN" "$line")"This first tries to find a match in the _file_ called "$line", which never exists, resulting in trace output:
+
check_all_headers_populated
+ read -r line
+ grep ^\[.*\]$ Thank you for filling out a Git bug report!
grep: Thank you for filling out a Git bug report!: No such file or directory
+ test
+ read -r line
+ grep ^\[.*\]$ Please answer the following questions to help us understand your issue.
grep: Please answer the following questions to help us understand your issue.: No such file or directory
+ test
+ read -r line
+ grep ^\[.*\]$
grep: : No such file or directory
[...]
Quoted 5 lines
Then, since 'grep' doesn't print any matches to its stdout, it invokes
test ""
which always returns non-zero, so that if condition is never fulfilled.
Just a reminder that this test is still broken...
Quoted 24 lines
On first sight I thought that simply changing that 'grep' invocation to something like:
$(printf "%s\n" "$line" | grep "$HEADER_PATTERN")would be sufficient to fix it, but then the first test failed... and I'm not sure that I understand what this was supposed to check in the first place.
Quoted 15 lines
t/t0091-bugreport.sh new file +15
-0+ then + echo "$line" + read -r nextline + if test -z "$nextline"; then + return 1; + fi + fi + done +} + +test_expect_success 'creates a report with content in the right places' ' + test_when_finished rm git-bugreport-check-headers.txt && + git bugreport -s check-headers && + check_all_headers_populated <git-bugreport-check-headers.txt +'
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
In reply to SZEDER GáborQuoted 42 lines · SZEDER Gábor
We auto-generate the list of supported configuration variables from '
Documentation/config/*.txt', and that list used to be created by the 'generate-cmdlist.sh' helper script and stored in the 'command-list.h' header. Commit709df95b78(help: movelist_config_helpto builtin/help, 2020-04-16) extracted this into a dedicated 'generate-configlist.sh' script and 'config-list.h' header, and added a new target in the 'Makefile' as well, but while doing so it forgot to extract the dependencies of the latter. Consequently, since then 'config-list.h' is not re-generated when 'Documentation/config/*.txt' is updated, while 'command-list.h' is re-generated unnecessarily:$ touch Documentation/config/log.txt $ make -j4 GEN command-list.h CC help.o AR libgit.aFix this and list all config-related documentation files as dependencies of '
config-list.h' and remove them from the dependencies of 'command-list.h'.$ touch Documentation/config/log.txt $ make GEN config-list.h CC builtin/help.o LINK gitSigned-off-by SZEDER Gábor <[email protected]>--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Makefile +1
-1@@ -2151,13 +2151,13 @@ $(BUILT_INS): git$X config-list.h: generate-configlist.sh -config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt
Makefile $(BUILT_INS): git$X · line 2163
Quoted 10 lines
Makefile +1
-1$(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 +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@
This change makes sense.
I have a not-yet-submitted patch series where I added some more config/*/*.txt that wouldn't be caught by this rule, I'd updated the Documentation/Makefile, but missed this part in the top-level Makefile.
So a relation question: Does anyone actually prefer this state of affairs of having a Makefile, Documentation/Makefile, t/Makefile t/perf/Makefile and template/Makefile?
It seems to me with ever-closer coupling between them that it's getting to be more of a hassle to manage state between them than it would be to just move them all into one big Makefile.
Re: [PATCH v13 4/5] bugreport: add uname info
In reply to Emily ShafferQuoted 4 lines · Emily Shaffer
The contents of
uname()can give us some insight into what sort of system the user is running on, and help us replicate their setup if need be. The domainname field is not guaranteed to be available, so don't collect it.
Even with _GNU_SOURCE would anyone care about the domainname (the NIS/YP name, not DNS) these days, as opposed to the portable POSIX "nodename" field you're not including?
In any case, I'd think it's a good idea to omit both. People tend not to want to want to include their FQDN (e.g. their employer), and I can't think of a reason we'd care about it for debugging git.
bugreport.c line 27
Quoted 6 lines
[...]
bugreport.c +5
-0+strbuf_addf (sys_info,"%s %s %s %s\n" , + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine);
Since this is completely free-form I'd think:
"sysname: %s\nrelease: %s\nversion: %s\nmachine: %s\nnodename: %s\ndomainname: %s\n",
Or something like that would be better (after pruning out the fields we don't care about).
Re: [PATCH v13 5/5] bugreport: add compiler info
In reply to Emily ShafferQuoted 41 lines · Emily Shaffer
To help pinpoint the source of a regression, it is useful to know some info about the compiler which the user's Git client was built with. By adding a generic
get_compiler_info()in 'compat/' we can choose which relevant information to share per compiler; to get started, let's demonstrate the version of glibc if the user built with 'gcc'.Signed-off-by Emily Shaffer <[email protected]>Helped-by Đoàn Trần Công Danh <[email protected]>Helped-by Johannes Schindelin <[email protected]>--- Documentation/git-bugreport.txt | 1 + bugreport.c | 6 +++++ compat/compiler.h | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 compat/compiler.hDocumentation/git-bugreport.txt +1
-0@@ -27,6 +27,7 @@ The following information is captured automatically: - 'git version --build-options' - uname sysname, release, version, and machine strings + - Compiler-specific info string This tool is invoked via the typical Git setup process, which means that in some cases, it might not be able to launch - for example, if a relevant config filebugreport.c +1
-0@@ -4,6 +4,7 @@#include "strbuf.h" #include "time.h" #include "help.h" +#include "compat/compiler.h" static void get_system_info (struct strbuf *sys_info) {
bugreport.c static void get_system_info(struct strbuf *sys_info) · line 32
Quoted 7 lines
bugreport.c +4
-0@@ -25,6 +26,11 @@ static void get_system_info(struct strbuf *sys_info) uname_info.release, uname_info.version, uname_info.machine); + +strbuf_addstr (sys_info,_ ("compiler info: " )); +get_compiler_info (sys_info); +strbuf_addstr (sys_info,_ ("libc info: " ));
These are marked with _() but not the "clang" etc. below. I'd think that for a git-bugreport tool we'd be better off without any i18n.
Quoted 23 lines
bugreport.c +1
-0+get_libc_info (sys_info); }static const char *const bugreport_usage[] = {compat/compiler.h new file +13
-0@@ -0,0 +1,41 @@ +#ifndef COMPILER_H +#define COMPILER_H + +#include "git-compat-util.h" +#include "strbuf.h" + +#ifdef __GLIBC__ +#include <gnu/libc-version.h> +#endif + +static inline void get_compiler_info (struct strbuf *info) +{ +int len = info->len;
compat/compiler.h line 23
Quoted 10 lines
compat/compiler.h new file +10
-0+#ifdef __clang__ +strbuf_addf (info,"clang: %s\n" , __clang_version__); +#elif defined(__GNUC__) +strbuf_addf (info,"gnuc: %d.%d\n" , __GNUC__, __GNUC_MINOR__); +#endif + +#ifdef _MSC_VER +strbuf_addf (info,"MSVC version: %02d.%02d.%05d\n" , + _MSC_VER /100 , _MSC_VER %100 , _MSC_FULL_VER %100000 ); +#endif
Why the ifdef/elif/ifdef instead of ifdef/elif/elif? Isn't _MSC_VER mutually exclusive with __clang__ and __GNUC__?
Re: [PATCH v13 4/5] bugreport: add uname info
In reply to Ævar Arnfjörð BjarmasonQuoted 24 lines · Ævar Arnfjörð Bjarmason
Quoted 4 lines · Emily Shaffer
The contents of
uname()can give us some insight into what sort of system the user is running on, and help us replicate their setup if need be. The domainname field is not guaranteed to be available, so don't collect it.Even with
_GNU_SOURCEwould anyone care about the domainname (the NIS/YP name, not DNS) these days, as opposed to the portable POSIX "nodename" field you're not including?In any case, I'd think it's a good idea to omit both. People tend not to want to want to include their FQDN (e.g. their employer), and I can't think of a reason we'd care about it for debugging git.
bugreport.c line 27
Quoted 6 lines
[...]
bugreport.c +5
-0+strbuf_addf (sys_info,"%s %s %s %s\n" , + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine);Since this is completely free-form I'd think:
Quoted 4 lines
"sysname: %s\nrelease: %s\nversion: %s\nmachine: %s\nnodename: %s\ndomainname: %s\n",
Or something like that would be better (after pruning out the fields we don't care about).
All true.
By the way, what's this sudden interest in re-reviewing an age old topic?
Re: [PATCH v13 4/5] bugreport: add uname info
Quoted 28 lines · Junio C Hamano
Quoted 26 lines · Ævar Arnfjörð Bjarmason
Quoted 4 lines · Emily Shaffer
The contents of
uname()can give us some insight into what sort of system the user is running on, and help us replicate their setup if need be. The domainname field is not guaranteed to be available, so don't collect it.Even with
_GNU_SOURCEwould anyone care about the domainname (the NIS/YP name, not DNS) these days, as opposed to the portable POSIX "nodename" field you're not including?In any case, I'd think it's a good idea to omit both. People tend not to want to want to include their FQDN (e.g. their employer), and I can't think of a reason we'd care about it for debugging git.
bugreport.c line 27
Quoted 6 lines
[...]
bugreport.c +5
-0+strbuf_addf (sys_info,"%s %s %s %s\n" , + uname_info.sysname, + uname_info.release, + uname_info.version, + uname_info.machine);Since this is completely free-form I'd think:
"sysname: %s\nrelease: %s\nversion: %s\nmachine: %s\nnodename: %s\ndomainname: %s\n",
Quoted 7 lines
Quoted 2 lines
Or something like that would be better (after pruning out the fields we don't care about).
All true.
By the way, what's this sudden interest in re-reviewing an age old topic?
The thread got bumped by SZEDER in [1] and I'd read an April date without noticing the year, so I see this has long-since landed, nevermind :)
Re: [PATCH v13 5/5] bugreport: add compiler info
In reply to Ævar Arnfjörð BjarmasonQuoted 8 lines · Ævar Arnfjörð Bjarmason
Quoted 8 lines
compat/compiler.h new file +8
-0+static inline void get_compiler_info (struct strbuf *info) +{ +int len = info->len; +#ifdef __clang__ +strbuf_addf (info,"clang: %s\n" , __clang_version__); +#elif defined(__GNUC__) +strbuf_addf (info,"gnuc: %d.%d\n" , __GNUC__, __GNUC_MINOR__); +#endif
Quoted 8 lines
compat/compiler.h line 23
Quoted 5 lines
compat/compiler.h new file +5
-0+ +#ifdef _MSC_VER +strbuf_addf (info,"MSVC version: %02d.%02d.%05d\n" , + _MSC_VER /100 , _MSC_VER %100 , _MSC_FULL_VER %100000 ); +#endif Why the ifdef/elif/ifdef instead of ifdef/elif/elif? Isn't
_MSC_VERmutually exclusive with__clang__and__GNUC__?
No, clang-cl is a MSVC emulation from clang, and clang-cl defines both __clang__ and _MSC_VER. See: [mail].
AFAICT, clang-cl is production-usable, Google uses clang-cl to build Google Chrome for Windows fro 2018 [blog]
mail: https://lists.llvm.org/pipermail/cfe-dev/2016-March/048147.html
blog: https://blog.llvm.org/2018/03/clang-is-now-used-to-build-chrome-for.html
Signature · 1 line
Danh
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
In reply to Ævar Arnfjörð BjarmasonQuoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
Makefile +1
-1-config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ >$@+ && mv $@+ $@ command-list.h: generate-cmdlist.sh command-list.txt
Quoted 7 lines
Makefile $(BUILT_INS): git$X · line 2163
Quoted 5 lines
Makefile +1
-1-command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@This change makes sense.
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
Quoted 11 lines
I have a not-yet-submitted patch series where I added some more config/*/*.txt that wouldn't be caught by this rule, I'd updated the
Documentation/Makefile, but missed this part in the top-levelMakefile.So a relation question: Does anyone actually prefer this state of affairs of having a
Makefile,Documentation/Makefile, t/Makefile t/perf/Makefile and template/Makefile?It seems to me with ever-closer coupling between them that it's getting to be more of a hassle to manage state between them than it would be to just move them all into one big
Makefile.
Yes, I'm generally a fan of avoiding recursive make when we can. I think the caveats are:
- it would be nice to continue to have stub Makefiles in sub-directories that trigger the main one (so "cd t && make" continues to work, for example).
- we may need some cleanup of parts of the top-level Makefile which are triggered without dependencies (e.g., I think we unconditionally run some scripts to compute GIT_VERSION in the top-level; this is already a bit wasteful, but may get even more so as we add more rules from sub-directories).
Mostly my argument against it (and why I haven't purused it) would be:
it sounds like a lot of work and risk of regression, and the current system seems pretty fine in practice.
-Peff
Re: [PATCH v13 4/5] bugreport: add uname info
In reply to Ævar Arnfjörð BjarmasonQuoted 9 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Junio C Hamano
By the way, what's this sudden interest in re-reviewing an age old topic?
The thread got bumped by SZEDER in [1] and I'd read an April date without noticing the year, so I see this has long-since landed, nevermind :)
Phew, you scared me :)
- Emily
Re: [PATCH v13 4/5] bugreport: add uname info
Quoted 5 lines · Emily Shaffer
Quoted 4 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Junio C Hamano
By the way, what's this sudden interest in re-reviewing an age old topic?
Quoted 7 lines
Quoted 5 lines
The thread got bumped by SZEDER in [1] and I'd read an April date without noticing the year, so I see this has long-since landed, nevermind :)
Phew, you scared me :)
Even if it has been in the releases, the room for improvement is still there, no?
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
In reply to Jeff KingQuoted 17 lines · Jeff King
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
Makefile +1
-1-config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ >$@+ && mv $@+ $@ command-list.h: generate-cmdlist.sh command-list.txtQuoted 7 lines
Makefile $(BUILT_INS): git$X · line 2163
Quoted 5 lines
Makefile +1
-1-command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@This change makes sense.
Quoted 3 lines
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
We don't need $(wildcard) for git*.txt either, because 'make' expands wildcards in prerequisites, see e.g.:
https://www.gnu.org/software/make/manual/html_node/Wildcard-Examples.html
On a related note: all config variables are now listed in Documentation/config/*.txt; Documentation/*config.txt doesn't contain any, so that could be removed.
Re: [PATCH v13 4/5] bugreport: add uname info
In reply to Emily ShafferQuoted 5 lines · Emily Shaffer
Quoted 4 lines · Ævar Arnfjörð Bjarmason
Quoted 2 lines · Junio C Hamano
By the way, what's this sudden interest in re-reviewing an age old topic?
Quoted 7 lines
Quoted 5 lines
The thread got bumped by SZEDER in [1] and I'd read an April date without noticing the year, so I see this has long-since landed, nevermind :)
Phew, you scared me :)
Doesn't the output of your bugreport tests scares you?
Initialized empty Git repository in /home/szeder/src/git/t/trash directory.t0091-bugreport/.git/ expecting success of 0091.1 'creates a report with content in the right places':
test_when_finished rm git-bugreport-check-headers.txt &&
git bugreport -s check-headers &&
check_all_headers_populated <git-bugreport-check-headers.txt
Created new report at 'git-bugreport-check-headers.txt'.
grep: Thank you for filling out a Git bug report!: No such file or directory
grep: Please answer the following questions to help us understand your issue.: No such file or directory
grep: : No such file or directory
grep: What did you do before the bug happened? (Steps to reproduce your issue): No such file or directory
grep: : No such file or directory
grep: What did you expect to happen? (Expected behavior): No such file or directory
grep: : No such file or directory
grep: What happened instead? (Actual behavior): No such file or directory
grep: : No such file or directory
grep: What's different between what you expected and what actually happened?: No such file or directory
grep: : No such file or directory
grep: Anything else you want to add:: No such file or directory
grep: : No such file or directory
grep: Please review the rest of the bug report below.: No such file or directory
grep: You can delete any lines you don't wish to share.: No such file or directory
grep: : No such file or directory
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.31.0.7.ga9ff022d9b: No such file or directory
grep: cpu: x86_64: No such file or directory
grep: built from commit: a9ff022d9b49e64336612f89100eb5220ed793bd: No such file or directory
grep: sizeof-long: 8: No such file or directory
grep: sizeof-size_t: 8: No such file or directory
grep: shell-path: /bin/sh: No such file or directory
grep: uname: Linux 5.10.17-051017-generic #202102170631 SMP Wed Feb 17 11:37:41 UTC 2021 x86_64: No such file or directory
grep: compiler info: gnuc: 9.3: No such file or directory
grep: libc info: glibc: 2.31: No such file or directory
grep: $SHELL (typically, interactive shell): /bin/bash: No such file or directory
grep: : No such file or directory
grep: : No such file or directory
grep: [Enabled Hooks]: No such file or directory
ok 1 - creates a report with content in the right places
It does scare me...
PATCH 1/1 t0091-bugreport.sh: actually verify some content of report
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:
[A Header]
something
more here
[Another Header]
[Too Early Header]
contents
However, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.31.1.164.g984c2561cd: No such file
This doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after 788a776069 ("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.
Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
---
Quoted 1 line
It does scare me..
Maybe something like this?
t/t0091-bugreport.sh | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-)
t/t0091-bugreport.sh +5 -21
@@ -4,29 +4,13 @@ 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 test "$(grep "$HEADER_PATTERN" "$line")" - then - echo "$line" - read -r nextline - if test -z "$nextline"; then - return 1; - fi - fi - done -} - -test_expect_success 'creates a report with content in the right places' ' +test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt && + grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt ' test_expect_success 'dies if file with same name as report already exists' '
Signature · 1 line
2.31.1.163.ga65ce7f831
Re: [PATCH] t0091-bugreport.sh: actually verify some content of report
Quoted 33 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:[A Header]
something
more here[Another Header]
[Too Early Header]
contentsHowever, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.31.1.164.g984c2561cd: No such fileThis doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after
788a776069("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.
Quoted 3 lines
Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
Nicely described. I agree that the original intent (let alone the implementation) is misguided and we should allow an empty section as a perfectly normal thing.
Quoted 7 lines
Reported-by SZEDER Gábor <[email protected]>Signed-off-by Martin Ågren <[email protected]>---
Quoted 1 line
It does scare me..
Maybe something like this?
...
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 9 lines
t/t0091-bugreport.sh +5
-1+test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt && + grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt '
It is a different matter if it is sufficient to ensure only certain selected lines appear in the report, though. As all the lines lost by this fix comes from 238b439d (bugreport: add tool to generate debugging info, 2020-04-16), it would be nice to hear from Emily.
Thanks.
Re: [PATCH] t0091-bugreport.sh: actually verify some content of report
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:
...
Quoted 18 lines
Quoted 3 lines
Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
Nicely described. I agree that the original intent (let alone the implementation) is misguided and we should allow an empty section as a perfectly normal thing.
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 9 lines
t/t0091-bugreport.sh +5
-1+test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt && + grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt '
Quoted 4 lines
It is a different matter if it is sufficient to ensure only certain selected lines appear in the report, though. As all the lines lost by this fix comes from
238b439d(bugreport: add tool to generate debugging info, 2020-04-16), it would be nice to hear from Emily.
Maybe something like
awk '\''BEGIN { sect="" }
/^\[.*]$/ { sect=$0 }
/./ { print sect, $0 }'\'' \
git-bugreport-check-headers.txt >prefixed &&
grep "^ Thank you for filling out a Git bug report" prefixed &&
grep "^ Please review the rest of the bug report below" prefixed &&
grep "^ You can delete any lines you don.t wish to share" prefixed &&
grep "\[System Info\] git version ..." prefixedSomething like that could be used to verify that a line goes into the right section, as opposed to just seeing that it appears *somewhere*. Or maybe
grep -e Thank.you -e Please.review -e You.can.delete -e "^\[" \
-e git.version git-bugreport-check-headers.txt >actualthen setting up an "expect" and comparing. That would help us verify the order, including which section things appear in. Slightly less friendly for comparing loosely, compared to the awk-then-grep above.
Let's see what Emily thinks about the various alternatives. Maybe she can think of something else.
Martin
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
In reply to Jeff KingQuoted 33 lines · Jeff King
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
Makefile +1
-1-config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ >$@+ && mv $@+ $@ command-list.h: generate-cmdlist.sh command-list.txtQuoted 7 lines
Makefile $(BUILT_INS): git$X · line 2163
Quoted 5 lines
Makefile +1
-1-command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@This change makes sense.
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
Quoted 11 lines
I have a not-yet-submitted patch series where I added some more config/*/*.txt that wouldn't be caught by this rule, I'd updated the
Documentation/Makefile, but missed this part in the top-levelMakefile.So a relation question: Does anyone actually prefer this state of affairs of having a
Makefile,Documentation/Makefile, t/Makefile t/perf/Makefile and template/Makefile?It seems to me with ever-closer coupling between them that it's getting to be more of a hassle to manage state between them than it would be to just move them all into one big
Makefile.
Quoted 6 lines
Yes, I'm generally a fan of avoiding recursive make when we can. I think the caveats are:
- it would be nice to continue to have stub Makefiles in sub-directories that trigger the main one (so "cd t && make" continues to work, for example).
Yeah, we should definitely keep those in place. I also wonder if various rules for local wildcards will be more complex when they need to reach into subdirectories.
Quoted 9 lines
- we may need some cleanup of parts of the top-level
Makefilewhich are triggered without dependencies (e.g., I think we unconditionally run some scripts to computeGIT_VERSIONin the top-level; this is already a bit wasteful, but may get even more so as we add more rules from sub-directories).Mostly my argument against it (and why I haven't purused it) would be:
it sounds like a lot of work and risk of regression, and the current system seems pretty fine in practice.
One edge case I discovered the other day but didn't bother debugging much was make at the top-level failing because "doc.dep" in Documentation/Makefile uses this pattern:
rm x &&
script >xWhich would normally work in one Makefile, but in this case two rules in the top-level called unrelated "make -C Documentation [...]", so both of those sub-processes end up needing to generate the doc.dep, and they race each other.
Another thing fixed (or, worked around) with a wider application of [1].
Re: [PATCH] t0091-bugreport.sh: actually verify some content of report
In reply to Martin ÅgrenQuoted 52 lines · Martin Ågren
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:...
Quoted 18 lines
Quoted 3 lines
Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
Nicely described. I agree that the original intent (let alone the implementation) is misguided and we should allow an empty section as a perfectly normal thing.
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 9 lines
t/t0091-bugreport.sh +5
-1+test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt && + grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt 'Quoted 4 lines
It is a different matter if it is sufficient to ensure only certain selected lines appear in the report, though. As all the lines lost by this fix comes from
238b439d(bugreport: add tool to generate debugging info, 2020-04-16), it would be nice to hear from Emily.Maybe something like
awk '\''BEGIN { sect="" } /^\[.*]$/ { sect=$0 } /./ { print sect, $0 }'\'' \ git-bugreport-check-headers.txt >prefixed && grep "^ Thank you for filling out a Git bug report" prefixed && grep "^ Please review the rest of the bug report below" prefixed && grep "^ You can delete any lines you don.t wish to share" prefixed && grep "\[System Info\] git version ..." prefixedSomething like that could be used to verify that a line goes into the right section, as opposed to just seeing that it appears *somewhere*. Or maybe
grep -e Thank.you -e Please.review -e You.can.delete -e "^\[" \ -e git.version git-bugreport-check-headers.txt >actual
Quoted 6 lines
then setting up an "expect" and comparing. That would help us verify the order, including which section things appear in. Slightly less friendly for comparing loosely, compared to the awk-then-grep above.
Let's see what Emily thinks about the various alternatives. Maybe she can think of something else.
I think a straight-up test_cmp is preferrable, both for correctness and also as self-documentation, you can see from the test what the full expected output is like.
Obviously in this case we can't do a test_cmp on the raw output, as it contains various things from uname.
But it looks like we could do that if we do some light awk/perl/sed munging of the "[System Info]" and "[Enabled Hooks]" section(s).
Or, since we also control the generator we could pass a --no-system-info and/or --no-hooks-info, which may be something some people want for privacy/reporting reasons anyway (e.g. I've often used perlbug and deleted that whole info, because info there has no relevance to the specific issue I'm reporting).
Re: [PATCH] t0091-bugreport.sh: actually verify some content of report
In reply to Martin ÅgrenQuoted 37 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:[A Header]
something
more here[Another Header]
[Too Early Header]
contentsHowever, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.31.1.164.g984c2561cd: No such fileThis doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after
788a776069("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
Quoted 6 lines
Reported-by SZEDER Gábor <[email protected]>Signed-off-by Martin Ågren <[email protected]>---
Quoted 1 line
It does scare me..
Maybe something like this?
Thanks!
Quoted 26 lines
t/t0091-bugreport.sh | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-)t/t0091-bugreport.sh +0
-15@@ -4,29 +4,13 @@ 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 test "$(grep "$HEADER_PATTERN" "$line")" - then - echo "$line" - read -r nextline - if test -z "$nextline"; then - return 1; - fi
t/t0091-bugreport.sh test_description='git bugreport' · line 10
Quoted 10 lines
t/t0091-bugreport.sh +2
-6- fi - done -} - -test_expect_success 'creates a report with content in the right places' ' +test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt &&
This "Please answer" is translated and you look for it with plain 'grep' instead of 'test_i18ngrep', which is fine nowadays... However, Junio queued this patch on top of v2.29.3, which is old enough to still have the GETTEXT_POISON CI job, and fails because of this.
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 4 lines
t/t0091-bugreport.sh +3
-0+ grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt '
I have to wonder, however, whether this is worth testing at all.
Quoted 5 lines
t/t0091-bugreport.sh +0
-0test_expect_success 'dies if file with same name as report already exists' 'Signature · 1 line
2.31.1.163.ga65ce7f831
Re: [PATCH] t0091-bugreport.sh: actually verify some content of report
In reply to Ævar Arnfjörð BjarmasonQuoted 56 lines · Ævar Arnfjörð Bjarmason
Quoted 52 lines · Martin Ågren
Quoted 9 lines · Junio C Hamano
Quoted 6 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:...
Quoted 18 lines
Quoted 3 lines
Let's instead grep for some contents that we expect to find in a bug report. We won't verify that they appear in the right order, but at least we end up verifying the contents more than before this commit.
Nicely described. I agree that the original intent (let alone the implementation) is misguided and we should allow an empty section as a perfectly normal thing.
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 9 lines
t/t0091-bugreport.sh +5
-1+test_expect_success 'creates a report with content' ' test_when_finished rm git-bugreport-check-headers.txt && git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt + grep "^Please answer " git-bugreport-check-headers.txt && + grep "^\[System Info\]$" git-bugreport-check-headers.txt && + grep "^git version:$" git-bugreport-check-headers.txt && + grep "^\[Enabled Hooks\]$" git-bugreport-check-headers.txt 'Quoted 4 lines
It is a different matter if it is sufficient to ensure only certain selected lines appear in the report, though. As all the lines lost by this fix comes from
238b439d(bugreport: add tool to generate debugging info, 2020-04-16), it would be nice to hear from Emily.Maybe something like
awk '\''BEGIN { sect="" } /^\[.*]$/ { sect=$0 } /./ { print sect, $0 }'\'' \ git-bugreport-check-headers.txt >prefixed && grep "^ Thank you for filling out a Git bug report" prefixed && grep "^ Please review the rest of the bug report below" prefixed && grep "^ You can delete any lines you don.t wish to share" prefixed && grep "\[System Info\] git version ..." prefixedSomething like that could be used to verify that a line goes into the right section, as opposed to just seeing that it appears *somewhere*. Or maybe
grep -e Thank.you -e Please.review -e You.can.delete -e "^\[" \ -e git.version git-bugreport-check-headers.txt >actual
Quoted 6 lines
Quoted 6 lines
then setting up an "expect" and comparing. That would help us verify the order, including which section things appear in. Slightly less friendly for comparing loosely, compared to the awk-then-grep above.
Let's see what Emily thinks about the various alternatives. Maybe she can think of something else.
My apologies for the slow reply :)
Quoted 3 lines
I think a straight-up
test_cmpis preferrable, both for correctness and also as self-documentation, you can see from the test what the full expected output is like.
Yeah, I like the sound of this.
Quoted 4 lines
Obviously in this case we can't do a
test_cmpon the raw output, as it contains various things from uname.
Quoted 8 lines
But it looks like we could do that if we do some light awk/perl/sed munging of the "[System Info]" and "[Enabled Hooks]" section(s).
Or, since we also control the generator we could pass a --no-system-info and/or --no-hooks-info, which may be something some people want for privacy/reporting reasons anyway (e.g. I've often used perlbug and deleted that whole info, because info there has no relevance to the specific issue I'm reporting).
This approach sounds more appealing to me than awk munging. I think you're right that folks may not want to share it in some cases.
Thanks for noticing.
- Emily
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
In reply to SZEDER GáborQuoted 25 lines · SZEDER Gábor
Quoted 17 lines · Jeff King
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
Makefile +1
-1-config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ >$@+ && mv $@+ $@ command-list.h: generate-cmdlist.sh command-list.txtQuoted 7 lines
Makefile $(BUILT_INS): git$X · line 2163
Quoted 5 lines
Makefile +1
-1-command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@This change makes sense.
Quoted 3 lines
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
We don't need $(wildcard) for git*.txt either, because 'make' expands wildcards in prerequisites, see e.g.:
Quoted 6 lines
https://www.gnu.org/software/make/manual/html_node/Wildcard-Examples.html
On a related note: all config variables are now listed in
Documentation/config/*.txt;Documentation/*config.txtdoesn't contain any, so that could be removed.
Is it OK for me to keep expecting an update to the patch happen soon?
Thanks.
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
Quoted 27 lines · Junio C Hamano
Quoted 25 lines · SZEDER Gábor
Quoted 17 lines · Jeff King
Quoted 7 lines · Ævar Arnfjörð Bjarmason
Quoted 7 lines
Makefile +1
-1-config-list.h: +config-list.h: Documentation/*config.txt Documentation/config/*.txt $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh \ >$@+ && mv $@+ $@ command-list.h: generate-cmdlist.sh command-list.txtQuoted 7 lines
Makefile $(BUILT_INS): git$X · line 2163
Quoted 5 lines
Makefile +1
-1-command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt +command-list.h: $(wildcard Documentation/git*.txt) $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ command-list.txt >$@+ && mv $@+ $@This change makes sense.
Quoted 3 lines
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
We don't need $(wildcard) for git*.txt either, because 'make' expands wildcards in prerequisites, see e.g.:
Quoted 8 lines
Quoted 6 lines
https://www.gnu.org/software/make/manual/html_node/Wildcard-Examples.html
On a related note: all config variables are now listed in
Documentation/config/*.txt;Documentation/*config.txtdoesn't contain any, so that could be removed.Is it OK for me to keep expecting an update to the patch happen soon?
No, I think this is a good bugfix patch that stands on its own, and further cleanups could be done independently on top and should not block this patch from being merged to master.
I'm inclined to think that this should be merged and then 'so/log-diff-merge' should be queued on top because of the subtle interaction between this bug, the new config variable and the completion tests.
Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'
Quoted 19 lines · SZEDER Gábor
Quoted 18 lines · Junio C Hamano
Quoted 1 line · SZEDER Gábor
On Thu, Apr 08, 2021 at 07:40:41PM -0400, Jeff King wrote:
...
Quoted 13 lines
Quoted 3 lines
I agree it looks like it's moving in the right direction, but I am slightly puzzled by the existing code. Why do we need to use $(wildcard) for git*.txt, but not for the others?
We don't need $(wildcard) for git*.txt either, because 'make' expands wildcards in prerequisites, see e.g.:
https://www.gnu.org/software/make/manual/html_node/Wildcard-Examples.html
On a related note: all config variables are now listed in
Documentation/config/*.txt;Documentation/*config.txtdoesn't contain any, so that could be removed.
Quoted 5 lines
Quoted 1 line
Is it OK for me to keep expecting an update to the patch happen soon?
No, I think this is a good bugfix patch that stands on its own, and further cleanups could be done independently on top and should not block this patch from being merged to master.
That's fair.
Thanks.
PATCH v2 1/1 t0091-bugreport.sh: actually verify some content of report
In reply to Emily ShafferIn the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:
[A Header]
something
more here
[Another Header]
[Too Early Header]
contents
However, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.41.0.2.gfb7d80edca: No such file or directory
This doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after 788a776069 ("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.
Let's instead split this test into three: first verify that we generate a report at all, then check that the introductory blurb looks the way it should, then verify that the "[System Info]" seems to contain the right things. (The "[Enabled Hooks]" section is tested later in the script.)
---
This is a much belated follow-up to v1 [1]. Feedback on that patch ranged from not bothering checking the generated report at all to implementing --no-system-info and --no-hooks-info so that we could easily test the introductory blurb verbatim.
I hope I'm hitting a reasonable middle ground here. Verifying the contents at least somewhat is in line with the original intention of the test. Those --no-...-info could probably be useful to bug reporters, but it feels wrong to me to implement them just to be able to use them in the tests.
[1] https://lore.kernel.org/git/[email protected]/
t/t0091-bugreport.sh | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 23 deletions(-)
t/t0091-bugreport.sh +44 -23
@@ -5,29 +5,50 @@ test_description='git bugreport' TEST_PASSES_SANITIZE_LEAK=true . ./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 test "$(grep "$HEADER_PATTERN" "$line")" - then - echo "$line" - read -r nextline - if test -z "$nextline"; then - return 1; - fi - fi - done -} - -test_expect_success 'creates a report with content in the right places' ' - test_when_finished rm git-bugreport-check-headers.txt && - git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt +test_expect_success 'create a report' ' + git bugreport -s format && + test_file_not_empty git-bugreport-format.txt +' + +test_expect_success 'report contains wanted template (before first section)' ' + awk "/^\[/ { exit } { print }" git-bugreport-format.txt >actual && + cat >expect <<-\EOF && + Thank you for filling out a Git bug report! + Please answer the following questions to help us understand your issue. + + What did you do before the bug happened? (Steps to reproduce your issue) + + What did you expect to happen? (Expected behavior) + + What happened instead? (Actual behavior) + + What'\''s different between what you expected and what actually happened? + + Anything else you want to add: + + Please review the rest of the bug report below. + You can delete any lines you don'\''t wish to share. + + + EOF + test_cmp expect actual +' + +test_expect_success 'sanity check "System Info" section' ' + test_when_finished rm -f git-bugreport-format.txt && + + sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system && + + # The beginning should match "git version --build-info" verbatim, + # but rather than checking bit-for-bit equality, just test some basics. + grep "git version [0-9]." system && + grep "shell-path: ." system && + + # After the version, there should be some more info. + # This is bound to differ from environment to environment, + # so we just do some rather high-level checks. + grep "uname: ." system && + grep "compiler info: ." system ' test_expect_success 'dies if file with same name as report already exists' '
Signature · 1 line
2.41.0.404.g5b50783d6b
Re: [PATCH v2] t0091-bugreport.sh: actually verify some content of report
Hi Martin
Quoted 19 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:[A Header]
something
more here[Another Header]
[Too Early Header]
contentsHowever, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
Quoted 7 lines
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.41.0.2.gfb7d80edca: No such file or directoryThis doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Thanks for the clear description of the problem and for fixing it
Quoted 10 lines
Note that after
788a776069("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.Let's instead split this test into three: first verify that we generate a report at all, then check that the introductory blurb looks the way it should, then verify that the "[System Info]" seems to contain the right things. (The "[Enabled Hooks]" section is tested later in the script.)
That sounds like a good plan
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 2 lines
t/t0091-bugreport.sh +2
-0+test_expect_success 'report contains wanted template (before first section)' ' + awk "/^\[/ { exit } { print }" git-bugreport-format.txt >actual &&
Personally I'd find
sed -n -e '/^\[/q;p' git-bugreport-format.txt >actual
easier to understand but that's probably because I don't use awk very much. I'm not sure it is worth a re-roll though as I see we do use awk in a few of the other test scripts.
Best Wishes
Phillip
Re: [PATCH v2] t0091-bugreport.sh: actually verify some content of report
Hi Phillip,
Quoted 11 lines · Phillip Wood
t/t0091-bugreport.sh test_description='git bugreport' · line 14
Quoted 3 lines
t/t0091-bugreport.sh +2
-0+test_expect_success 'report contains wanted template (before first section)' ' + awk "/^\[/ { exit } { print }" git-bugreport-format.txt >actual &&Personally I'd find
sed -n -e '/^\[/q;p' git-bugreport-format.txt >actualeasier to understand but that's probably because I don't use awk very much. I'm not sure it is worth a re-roll though as I see we do use awk in a few of the other test scripts.
I do see we use sed quite a bit more than awk in the tests. This script doesn't yet use awk and if most feel like you we're probably better off introducing another sed use rather than another awk use.
I'll be happy to post a v3 with only this change. (This script uses "sed -ne" already and I even do so elsewhere in my patch, so I'll be applying s/-n -e/-ne/ to your suggestion.)
Thanks for reviewing!
Martin
PATCH v3 1/1 t0091-bugreport.sh: actually verify some content of report
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:
[A Header]
something
more here
[Another Header]
[Too Early Header]
contents
However, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.41.0.2.gfb7d80edca: No such file or directory
This doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after 788a776069 ("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.
Let's instead split this test into three: first verify that we generate a report at all, then check that the introductory blurb looks the way it should, then verify that the "[System Info]" seems to contain the right things. (The "[Enabled Hooks]" section is tested later in the script.)
---
(Resend of v3, now with correct In-Reply-To.)
t/t0091-bugreport.sh | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 23 deletions(-)
t/t0091-bugreport.sh +44 -23
@@ -5,29 +5,50 @@ test_description='git bugreport' TEST_PASSES_SANITIZE_LEAK=true . ./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 test "$(grep "$HEADER_PATTERN" "$line")" - then - echo "$line" - read -r nextline - if test -z "$nextline"; then - return 1; - fi - fi - done -} - -test_expect_success 'creates a report with content in the right places' ' - test_when_finished rm git-bugreport-check-headers.txt && - git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt +test_expect_success 'create a report' ' + git bugreport -s format && + test_file_not_empty git-bugreport-format.txt +' + +test_expect_success 'report contains wanted template (before first section)' ' + sed -ne "/^\[/q;p" git-bugreport-format.txt >actual && + cat >expect <<-\EOF && + Thank you for filling out a Git bug report! + Please answer the following questions to help us understand your issue. + + What did you do before the bug happened? (Steps to reproduce your issue) + + What did you expect to happen? (Expected behavior) + + What happened instead? (Actual behavior) + + What'\''s different between what you expected and what actually happened? + + Anything else you want to add: + + Please review the rest of the bug report below. + You can delete any lines you don'\''t wish to share. + + + EOF + test_cmp expect actual +' + +test_expect_success 'sanity check "System Info" section' ' + test_when_finished rm -f git-bugreport-format.txt && + + sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system && + + # The beginning should match "git version --build-info" verbatim, + # but rather than checking bit-for-bit equality, just test some basics. + grep "git version [0-9]." system && + grep "shell-path: ." system && + + # After the version, there should be some more info. + # This is bound to differ from environment to environment, + # so we just do some rather high-level checks. + grep "uname: ." system && + grep "compiler info: ." system ' test_expect_success 'dies if file with same name as report already exists' '
Signature · 1 line
2.41.0.404.g5b50783d6b
Re: [PATCH v3] t0091-bugreport.sh: actually verify some content of report
Hi Martin
This version looks good to me, thanks for re-rolling
Phillip
Quoted 125 lines · Martin Ågren
In the first test in this script, 'creates a report with content in the right places', we generate a report and pipe it into our helper
check_all_headers_populated(). The idea of the helper is to find all lines that look like headers ("[Some Header Here]") and to check that the next line is non-empty. This is supposed to catch erroneous outputs such as the following:[A Header]
something
more here[Another Header]
[Too Early Header]
contentsHowever, we provide the lines of the bug report as filenames to grep, meaning we mostly end up spewing errors:
grep: : No such file or directory
grep: [System Info]: No such file or directory
grep: git version:: No such file or directory
grep: git version 2.41.0.2.gfb7d80edca: No such file or directoryThis doesn't disturb the test, which tugs along and reports success, not really having verified the contents of the report at all.
Note that after
788a776069("bugreport: collect list of populated hooks", 2020-05-07), the bug report, which is created in our hook-less test repo, contains an empty section with the enabled hooks. Thus, even the intention of our helper is a bit misguided: there is nothing inherently wrong with having an empty section in the bug report.Let's instead split this test into three: first verify that we generate a report at all, then check that the introductory blurb looks the way it should, then verify that the "[System Info]" seems to contain the right things. (The "[Enabled Hooks]" section is tested later in the script.)
Reported-by SZEDER Gábor <[email protected]>Helped-by Phillip Wood <[email protected]>Signed-off-by Martin Ågren <[email protected]>---
(Resend of v3, now with correct In-Reply-To.)t/t0091-bugreport.sh | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 23 deletions(-)t/t0091-bugreport.sh +44
-23@@ -5,29 +5,50 @@ test_description='git bugreport' TEST_PASSES_SANITIZE_LEAK=true . ./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 test "$(grep "$HEADER_PATTERN" "$line")" - then - echo "$line" - read -r nextline - if test -z "$nextline"; then - return 1; - fi - fi - done -} - -test_expect_success 'creates a report with content in the right places' ' - test_when_finished rm git-bugreport-check-headers.txt && - git bugreport -s check-headers && - check_all_headers_populated <git-bugreport-check-headers.txt +test_expect_success 'create a report' ' + git bugreport -s format && + test_file_not_empty git-bugreport-format.txt +' + +test_expect_success 'report contains wanted template (before first section)' ' + sed -ne "/^\[/q;p" git-bugreport-format.txt >actual && + cat >expect <<-\EOF && + Thank you for filling out a Git bug report! + Please answer the following questions to help us understand your issue. + + What did you do before the bug happened? (Steps to reproduce your issue) + + What did you expect to happen? (Expected behavior) + + What happened instead? (Actual behavior) + + What'\''s different between what you expected and what actually happened? + + Anything else you want to add: + + Please review the rest of the bug report below. + You can delete any lines you don'\''t wish to share. + + + EOF + test_cmp expect actual +' + +test_expect_success 'sanity check "System Info" section' ' + test_when_finished rm -f git-bugreport-format.txt && + + sed -ne "/^\[System Info\]$/,/^$/p" <git-bugreport-format.txt >system && + + # The beginning should match "git version --build-info" verbatim, + # but rather than checking bit-for-bit equality, just test some basics. + grep "git version [0-9]." system && + grep "shell-path: ." system && + + # After the version, there should be some more info. + # This is bound to differ from environment to environment, + # so we just do some rather high-level checks. + grep "uname: ." system && + grep "compiler info: ." system ' test_expect_success 'dies if file with same name as report already exists' '