make git-bugreport a builtin
There's no reason that bugreport has to be a separate binary. And since it links against libgit.a, it has a rather large disk footprint. Let's make it a builtin, which reduces the size of a stripped installation from 24MB to 22MB. This also simplifies our Makefile a bit. And we can take advantage of builtin niceties like RUN_SETUP_GENTLY. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b5dd96b70a
commit
d7a5649c82
6
Makefile
6
Makefile
@ -671,7 +671,6 @@ EXTRA_PROGRAMS =
|
|||||||
# ... and all the rest that could be moved out of bindir to gitexecdir
|
# ... and all the rest that could be moved out of bindir to gitexecdir
|
||||||
PROGRAMS += $(EXTRA_PROGRAMS)
|
PROGRAMS += $(EXTRA_PROGRAMS)
|
||||||
|
|
||||||
PROGRAM_OBJS += bugreport.o
|
|
||||||
PROGRAM_OBJS += daemon.o
|
PROGRAM_OBJS += daemon.o
|
||||||
PROGRAM_OBJS += fast-import.o
|
PROGRAM_OBJS += fast-import.o
|
||||||
PROGRAM_OBJS += http-backend.o
|
PROGRAM_OBJS += http-backend.o
|
||||||
@ -1041,6 +1040,7 @@ BUILTIN_OBJS += builtin/archive.o
|
|||||||
BUILTIN_OBJS += builtin/bisect--helper.o
|
BUILTIN_OBJS += builtin/bisect--helper.o
|
||||||
BUILTIN_OBJS += builtin/blame.o
|
BUILTIN_OBJS += builtin/blame.o
|
||||||
BUILTIN_OBJS += builtin/branch.o
|
BUILTIN_OBJS += builtin/branch.o
|
||||||
|
BUILTIN_OBJS += builtin/bugreport.o
|
||||||
BUILTIN_OBJS += builtin/bundle.o
|
BUILTIN_OBJS += builtin/bundle.o
|
||||||
BUILTIN_OBJS += builtin/cat-file.o
|
BUILTIN_OBJS += builtin/cat-file.o
|
||||||
BUILTIN_OBJS += builtin/check-attr.o
|
BUILTIN_OBJS += builtin/check-attr.o
|
||||||
@ -2458,10 +2458,6 @@ endif
|
|||||||
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
|
git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
|
||||||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
|
$(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)
|
git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
|
||||||
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
|
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
|
||||||
$(IMAP_SEND_LDFLAGS) $(LIBS)
|
$(IMAP_SEND_LDFLAGS) $(LIBS)
|
||||||
|
@ -119,6 +119,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix);
|
|||||||
int cmd_bisect__helper(int argc, const char **argv, const char *prefix);
|
int cmd_bisect__helper(int argc, const char **argv, const char *prefix);
|
||||||
int cmd_blame(int argc, const char **argv, const char *prefix);
|
int cmd_blame(int argc, const char **argv, const char *prefix);
|
||||||
int cmd_branch(int argc, const char **argv, const char *prefix);
|
int cmd_branch(int argc, const char **argv, const char *prefix);
|
||||||
|
int cmd_bugreport(int argc, const char **argv, const char *prefix);
|
||||||
int cmd_bundle(int argc, const char **argv, const char *prefix);
|
int cmd_bundle(int argc, const char **argv, const char *prefix);
|
||||||
int cmd_cat_file(int argc, const char **argv, const char *prefix);
|
int cmd_cat_file(int argc, const char **argv, const char *prefix);
|
||||||
int cmd_checkout(int argc, const char **argv, const char *prefix);
|
int cmd_checkout(int argc, const char **argv, const char *prefix);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "cache.h"
|
#include "builtin.h"
|
||||||
#include "parse-options.h"
|
#include "parse-options.h"
|
||||||
#include "strbuf.h"
|
#include "strbuf.h"
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
@ -119,7 +119,7 @@ static void get_header(struct strbuf *buf, const char *title)
|
|||||||
strbuf_addf(buf, "\n\n[%s]\n", title);
|
strbuf_addf(buf, "\n\n[%s]\n", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmd_main(int argc, const char **argv)
|
int cmd_bugreport(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
struct strbuf buffer = STRBUF_INIT;
|
struct strbuf buffer = STRBUF_INIT;
|
||||||
struct strbuf report_path = STRBUF_INIT;
|
struct strbuf report_path = STRBUF_INIT;
|
||||||
@ -127,8 +127,6 @@ int cmd_main(int argc, const char **argv)
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
char *option_output = NULL;
|
char *option_output = NULL;
|
||||||
char *option_suffix = "%Y-%m-%d-%H%M";
|
char *option_suffix = "%Y-%m-%d-%H%M";
|
||||||
int nongit_ok = 0;
|
|
||||||
const char *prefix = NULL;
|
|
||||||
const char *user_relative_path = NULL;
|
const char *user_relative_path = NULL;
|
||||||
|
|
||||||
const struct option bugreport_options[] = {
|
const struct option bugreport_options[] = {
|
||||||
@ -139,8 +137,6 @@ int cmd_main(int argc, const char **argv)
|
|||||||
OPT_END()
|
OPT_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
prefix = setup_git_directory_gently(&nongit_ok);
|
|
||||||
|
|
||||||
argc = parse_options(argc, argv, prefix, bugreport_options,
|
argc = parse_options(argc, argv, prefix, bugreport_options,
|
||||||
bugreport_usage, 0);
|
bugreport_usage, 0);
|
||||||
|
|
||||||
@ -170,7 +166,7 @@ int cmd_main(int argc, const char **argv)
|
|||||||
get_system_info(&buffer);
|
get_system_info(&buffer);
|
||||||
|
|
||||||
get_header(&buffer, _("Enabled Hooks"));
|
get_header(&buffer, _("Enabled Hooks"));
|
||||||
get_populated_hooks(&buffer, nongit_ok);
|
get_populated_hooks(&buffer, !startup_info->have_repository);
|
||||||
|
|
||||||
/* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
|
/* fopen doesn't offer us an O_EXCL alternative, except with glibc. */
|
||||||
report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
|
@ -501,7 +501,7 @@ unset(CMAKE_REQUIRED_INCLUDES)
|
|||||||
|
|
||||||
#programs
|
#programs
|
||||||
set(PROGRAMS_BUILT
|
set(PROGRAMS_BUILT
|
||||||
git git-bugreport git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
|
git git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
|
||||||
git-shell git-remote-testsvn)
|
git-shell git-remote-testsvn)
|
||||||
|
|
||||||
if(NOT CURL_FOUND)
|
if(NOT CURL_FOUND)
|
||||||
@ -624,9 +624,6 @@ list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
|
|||||||
add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
|
add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
|
||||||
target_link_libraries(git common-main)
|
target_link_libraries(git common-main)
|
||||||
|
|
||||||
add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
|
|
||||||
target_link_libraries(git-bugreport common-main)
|
|
||||||
|
|
||||||
add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
|
add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
|
||||||
target_link_libraries(git-daemon common-main)
|
target_link_libraries(git-daemon common-main)
|
||||||
|
|
||||||
|
1
git.c
1
git.c
@ -479,6 +479,7 @@ static struct cmd_struct commands[] = {
|
|||||||
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP },
|
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP },
|
||||||
{ "blame", cmd_blame, RUN_SETUP },
|
{ "blame", cmd_blame, RUN_SETUP },
|
||||||
{ "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },
|
{ "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },
|
||||||
|
{ "bugreport", cmd_bugreport, RUN_SETUP_GENTLY },
|
||||||
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY | NO_PARSEOPT },
|
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY | NO_PARSEOPT },
|
||||||
{ "cat-file", cmd_cat_file, RUN_SETUP },
|
{ "cat-file", cmd_cat_file, RUN_SETUP },
|
||||||
{ "check-attr", cmd_check_attr, RUN_SETUP },
|
{ "check-attr", cmd_check_attr, RUN_SETUP },
|
||||||
|
Reference in New Issue
Block a user