Skip to contentSkip to conversation

git-bugreport with fixed VS build

PATCH In review Emily Shaffer 8 participants 40 messages Apr 16, 2020 – Jul 5, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 188bd1c3de..61bf5142a9 100644
@@ -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
index ef1ff2228f..d4aff7f9b5 100644
@@ -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
index 1b6dabf5a2..42292e7c09 100644
@@ -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
index 0ab8e00938..f880cc2792 100644
@@ -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
index 71158f7d8b..45fecf8bdf 100755
@@ -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
new file mode 100755
index 0000000000..8692fe5cf4
@@ -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
index 7a455beeb7..9071894e8c 100644
@@ -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
#15 lore raw

PATCH v13 2/5 bugreport: add tool to generate debugging info

In reply to 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.

---
 .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
index 61bf5142a9..ee509a2ad2 100644
@@ -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
index d4aff7f9b5..b0a9073788 100644
@@ -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
index 2087894655..185e5e3f05 100644
@@ -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
index bb0065ccaf..3bfcaababb 100644
@@ -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
index ce8e49c0b2..801a3694ec 100644
@@ -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
#19 lore raw

PATCH v13 4/5 bugreport: add uname info

In reply to 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.

---
 Documentation/git-bugreport.txt |  1 +
 bugreport.c                     | 16 +++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)
Documentation/git-bugreport.txt +1 -0
index f44ae8cbe7..17b0d14e8d 100644
@@ -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
index 4cdb58bbaa..1a3172bcec 100644
@@ -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
#18 lore raw

PATCH v13 3/5 bugreport: gather git version and build info

In reply to Emily Shaffer

Knowing which version of Git a user has and how it was built allows us to more precisely pin down the circumstances when a certain issue occurs, so teach bugreport how to tell us the same output as 'git version --build-options'.

It's not ideal to directly call 'git version --build-options' because that output goes to stdout. Instead, wrap the version string in a helper within help.[ch] library, and call that helper from within the bugreport library.

---
 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
index 1f9fde5cde..f44ae8cbe7 100644
@@ -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
index f6f53a5e8e..4cdb58bbaa 100644
@@ -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
index 9071894e8c..500521b908 100644
@@ -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
#37 lore raw

PATCH v13 5/5 bugreport: add compiler info

In reply to 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'.

---
 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
index 17b0d14e8d..643d1b2884 100644
@@ -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
index 1a3172bcec..089b939a87 100644
@@ -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
#2 lore raw

Re: [PATCH v13 1/5] help: move list_config_help to builtin/help

In reply to Emily Shaffer
Quoted 24 lines · Emily Shaffer

Starting in 3ac68a93fd2, help.o began to depend on builtin/branch.o, builtin/clean.o, and builtin/config.o. This meant that help.o was unusable outside of the context of the main Git executable.

To make help.o usable by other commands again, move list_config_help() into builtin/help.c (where it makes sense to assume other builtin libraries are present).

When command-list.h is included but a member is not used, we start to hear a compiler warning. Since the config list is generated in a fairly different way than the command list, and since commands and config options are semantically different, move the config list into its own header and move the generator into its own script and build rule.

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.

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.

---

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?

#3 lore raw

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.

#5 lore raw

Re: [PATCH v13 1/5] help: move list_config_help to builtin/help

In reply to Emily Shaffer
Quoted 229 lines · Emily Shaffer

Starting in 3ac68a93fd2, help.o began to depend on builtin/branch.o, builtin/clean.o, and builtin/config.o. This meant that help.o was unusable outside of the context of the main Git executable.

To make help.o usable by other commands again, move list_config_help() into builtin/help.c (where it makes sense to assume other builtin libraries are present).

When command-list.h is included but a member is not used, we start to hear a compiler warning. Since the config list is generated in a fairly different way than the command list, and since commands and config options are semantically different, move the config list into its own header and move the generator into its own script and build rule.

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
index 188bd1c3de..61bf5142a9 100644
@@ -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
index ef1ff2228f..d4aff7f9b5 100644
@@ -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
index e5590d7787..1c5f2b9255 100644
@@ -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
index 1b6dabf5a2..42292e7c09 100644
@@ -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 +0 -0
index 0ab8e00938..f880cc2792 100644

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:

https://lore.kernel.org/git/[email protected]/

Quoted 176 lines
config.mak.uname +1 -0
+	git add -f config-list.h command-list.h
 
 	# Add scripts
 	rm -f perl/perl.mak
generate-cmdlist.sh +0 -19
index 71158f7d8b..45fecf8bdf 100755
@@ -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
new file mode 100755
index 0000000000..8692fe5cf4
@@ -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
index cf67624a94..a21487db77 100644
@@ -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
index 7a455beeb7..9071894e8c 100644
@@ -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
#6 lore raw

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
index 0ab8e00938..f880cc2792 100644
@@ -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 1 line

https://lore.kernel.org/git/[email protected]/

Sorry, I'm an idiot, please ignore my reply.
His patch is used for old series.

Signature · 1 line
Danh
#4 lore raw

Re: [PATCH v13 1/5] help: move list_config_help to builtin/help

In reply to Junio C Hamano
Quoted 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 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.

#16 lore raw

Re: [PATCH v13 2/5] bugreport: add tool to generate debugging info

In reply to Emily Shaffer
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.

---

t/t0091-bugreport.sh new file +2 -0
new file mode 100755
index 0000000000..2e73658a5c
@@ -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
+'
#7 lore raw

PATCH 1/1 Makefile: add missing dependencies of 'config-list.h'

In reply to Emily Shaffer

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. 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.a

Fix 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
index 5a022367d4..2c41f125e0 100644
@@ -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
#17 lore raw

Re: [PATCH v13 2/5] bugreport: add tool to generate debugging info

In reply to SZEDER Gábor
Quoted 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.

---

t/t0091-bugreport.sh new file +2 -0
new file mode 100755
index 0000000000..2e73658a5c
@@ -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
[...]

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
+'
#8 lore raw

Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'

In reply to SZEDER Gábor
Quoted 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. 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.a

Fix 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 +1 -1
index 5a022367d4..2c41f125e0 100644
@@ -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.

#20 lore raw

Re: [PATCH v13 4/5] bugreport: add uname info

In reply to Emily Shaffer
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_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).

#38 lore raw

Re: [PATCH v13 5/5] bugreport: add compiler info

In reply to Emily Shaffer
Quoted 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'.

---
 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
index 17b0d14e8d..643d1b2884 100644
@@ -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 +1 -0
index 1a3172bcec..089b939a87 100644
@@ -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
new file mode 100644
index 0000000000..10dbb65937
@@ -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__?

#21 lore raw

Re: [PATCH v13 4/5] bugreport: add uname info

In reply to Ævar Arnfjörð Bjarmason
Quoted 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_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:

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?

#22 lore raw

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_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",

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

1. https://lore.kernel.org/git/[email protected]/

#39 lore raw

Re: [PATCH v13 5/5] bugreport: add compiler info

In reply to Ævar Arnfjörð Bjarmason
Quoted 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_VER mutually 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
#9 lore raw

Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'

In reply to Ævar Arnfjörð Bjarmason
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.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-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.

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

#23 lore raw

Re: [PATCH v13 4/5] bugreport: add uname info

In reply to Ævar Arnfjörð Bjarmason
Quoted 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 :)

1. https://lore.kernel.org/git/[email protected]/

Phew, you scared me :)

- Emily

#24 lore raw

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

1. https://lore.kernel.org/git/[email protected]/

Phew, you scared me :)

Even if it has been in the releases, the room for improvement is still there, no?

#10 lore raw

Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'

In reply to Jeff King
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.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.

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.

#25 lore raw

Re: [PATCH v13 4/5] bugreport: add uname info

In reply to Emily Shaffer
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 :)

1. https://lore.kernel.org/git/[email protected]/

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...

#26 lore raw

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
index 526304ff95..9111c4c26f 100755
@@ -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
#27 lore raw

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]
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.

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

---

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.

#28 lore raw

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 ..." prefixed

Something 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

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.

Martin

#14 lore raw

Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'

In reply to Jeff King
Quoted 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.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-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.

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 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.

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 >x

Which 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].

1. https://lore.kernel.org/git/[email protected]/

#29 lore raw

Re: [PATCH] t0091-bugreport.sh: actually verify some content of report

In reply to Martin Ågren
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 ..." prefixed

Something 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).

#36 lore raw

Re: [PATCH] t0091-bugreport.sh: actually verify some content of report

In reply to Martin Ågren
Quoted 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]
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 6 lines

---

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
index 526304ff95..9111c4c26f 100755
@@ -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 -0
 test_expect_success 'dies if file with same name as report already exists' '
Signature · 1 line
2.31.1.163.ga65ce7f831
#30 lore raw

Re: [PATCH] t0091-bugreport.sh: actually verify some content of report

In reply to Ævar Arnfjörð Bjarmason
Quoted 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 ..." prefixed

Something 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_cmp is 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_cmp on 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

#11 lore raw

Re: [PATCH] Makefile: add missing dependencies of 'config-list.h'

In reply to SZEDER Gábor
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.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.

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.txt doesn't contain any, so that could be removed.

Is it OK for me to keep expecting an update to the patch happen soon?

Thanks.

#12 lore raw

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.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.

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.txt doesn'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.

#13 lore raw

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.txt doesn'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.

#31 lore raw

PATCH v2 1/1 t0091-bugreport.sh: actually verify some content of report

In reply to Emily Shaffer

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

---
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
index b6d2f591ac..9390631b17 100755
@@ -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
#32 lore raw

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]
contents

However, 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 directory

This 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

#33 lore raw

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 >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.

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

#34 lore raw

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
index b6d2f591ac..f6998269be 100755
@@ -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
#35 lore raw

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]
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
index b6d2f591ac..f6998269be 100755
@@ -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' '