Skip to content

Commit

Permalink
Merge branch 'jk/slimmed-down'
Browse files Browse the repository at this point in the history
Trim an unused binary and turn a bunch of commands into built-in.

* jk/slimmed-down:
  drop vcs-svn experiment
  make git-fast-import a builtin
  make git-bugreport a builtin
  make credential helpers builtins
  Makefile: drop builtins from MSVC pdb list
  • Loading branch information
gitster committed Sep 3, 2020
2 parents cce5178 + fc47391 commit afd49c3
Show file tree
Hide file tree
Showing 31 changed files with 80 additions and 3,915 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
/git-remote-fd
/git-remote-ext
/git-remote-testpy
/git-remote-testsvn
/git-repack
/git-replace
/git-request-pull
Expand Down
45 changes: 6 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ BUILT_INS =
COMPAT_CFLAGS =
COMPAT_OBJS =
XDIFF_OBJS =
VCSSVN_OBJS =
GENERATED_H =
EXTRA_CPPFLAGS =
FUZZ_OBJS =
Expand Down Expand Up @@ -671,13 +670,9 @@ 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
PROGRAM_OBJS += http-backend.o
PROGRAM_OBJS += imap-send.o
PROGRAM_OBJS += remote-testsvn.o
PROGRAM_OBJS += sh-i18n--envsubst.o
PROGRAM_OBJS += shell.o

Expand Down Expand Up @@ -749,8 +744,6 @@ TEST_BUILTINS_OBJS += test-xml-encode.o
# Do not add more tests here unless they have extra dependencies. Add
# them in TEST_BUILTINS_OBJS above.
TEST_PROGRAMS_NEED_X += test-fake-ssh
TEST_PROGRAMS_NEED_X += test-line-buffer
TEST_PROGRAMS_NEED_X += test-svn-fe
TEST_PROGRAMS_NEED_X += test-tool

TEST_PROGRAMS = $(patsubst %,t/helper/%$X,$(TEST_PROGRAMS_NEED_X))
Expand Down Expand Up @@ -806,7 +799,6 @@ TEST_SHELL_PATH = $(SHELL_PATH)

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
Expand Down Expand Up @@ -1042,6 +1034,7 @@ BUILTIN_OBJS += builtin/archive.o
BUILTIN_OBJS += builtin/bisect--helper.o
BUILTIN_OBJS += builtin/blame.o
BUILTIN_OBJS += builtin/branch.o
BUILTIN_OBJS += builtin/bugreport.o
BUILTIN_OBJS += builtin/bundle.o
BUILTIN_OBJS += builtin/cat-file.o
BUILTIN_OBJS += builtin/check-attr.o
Expand All @@ -1052,6 +1045,9 @@ BUILTIN_OBJS += builtin/checkout-index.o
BUILTIN_OBJS += builtin/checkout.o
BUILTIN_OBJS += builtin/clean.o
BUILTIN_OBJS += builtin/clone.o
BUILTIN_OBJS += builtin/credential-cache.o
BUILTIN_OBJS += builtin/credential-cache--daemon.o
BUILTIN_OBJS += builtin/credential-store.o
BUILTIN_OBJS += builtin/column.o
BUILTIN_OBJS += builtin/commit-graph.o
BUILTIN_OBJS += builtin/commit-tree.o
Expand All @@ -1067,6 +1063,7 @@ BUILTIN_OBJS += builtin/diff.o
BUILTIN_OBJS += builtin/difftool.o
BUILTIN_OBJS += builtin/env--helper.o
BUILTIN_OBJS += builtin/fast-export.o
BUILTIN_OBJS += builtin/fast-import.o
BUILTIN_OBJS += builtin/fetch-pack.o
BUILTIN_OBJS += builtin/fetch.o
BUILTIN_OBJS += builtin/fmt-merge-msg.o
Expand Down Expand Up @@ -1634,11 +1631,8 @@ ifdef NO_INET_PTON
endif
ifdef NO_UNIX_SOCKETS
BASIC_CFLAGS += -DNO_UNIX_SOCKETS
EXCLUDED_PROGRAMS += git-credential-cache git-credential-cache--daemon
else
LIB_OBJS += unix-socket.o
PROGRAM_OBJS += credential-cache.o
PROGRAM_OBJS += credential-cache--daemon.o
endif

ifdef NO_ICONV
Expand Down Expand Up @@ -2346,16 +2340,9 @@ XDIFF_OBJS += xdiff/xpatience.o
XDIFF_OBJS += xdiff/xprepare.o
XDIFF_OBJS += xdiff/xutils.o

VCSSVN_OBJS += vcs-svn/fast_export.o
VCSSVN_OBJS += vcs-svn/line_buffer.o
VCSSVN_OBJS += vcs-svn/sliding_window.o
VCSSVN_OBJS += vcs-svn/svndiff.o
VCSSVN_OBJS += vcs-svn/svndump.o

TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
$(XDIFF_OBJS) \
$(VCSSVN_OBJS) \
$(FUZZ_OBJS) \
common-main.o \
git.o
Expand Down Expand Up @@ -2459,10 +2446,6 @@ 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)
Expand All @@ -2474,10 +2457,6 @@ git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
$(VCSSVN_LIB)

$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
$(QUIET_LNCP)$(RM) $@ && \
ln $< $@ 2>/dev/null || \
Expand All @@ -2494,9 +2473,6 @@ $(LIB_FILE): $(LIB_OBJS)
$(XDIFF_LIB): $(XDIFF_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

$(VCSSVN_LIB): $(VCSSVN_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

export DEFAULT_EDITOR DEFAULT_PAGER

Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
Expand Down Expand Up @@ -2771,10 +2747,6 @@ perf: all

.PHONY: test perf

t/helper/test-line-buffer$X: $(VCSSVN_LIB)

t/helper/test-svn-fe$X: $(VCSSVN_LIB)

.PRECIOUS: $(TEST_OBJS)

t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
Expand Down Expand Up @@ -2901,18 +2873,13 @@ ifdef MSVC
# because it is just a copy/hardlink of git.exe, rather than a unique binary.
$(INSTALL) git.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) git-shell.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) git-upload-pack.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) git-credential-store.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-daemon.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-fast-import.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-http-backend.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-http-fetch.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-http-push.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-imap-send.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-remote-http.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-remote-testsvn.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-sh-i18n--envsubst.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) git-show-index.pdb '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
ifndef DEBUG
$(INSTALL) $(vcpkg_rel_bin)/*.dll '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) $(vcpkg_rel_bin)/*.pdb '$(DESTDIR_SQ)$(bindir_SQ)'
Expand Down Expand Up @@ -3112,7 +3079,7 @@ cocciclean:
clean: profile-clean coverage-clean cocciclean
$(RM) *.res
$(RM) $(OBJECTS)
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
$(RM) $(LIB_FILE) $(XDIFF_LIB)
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
$(RM) $(TEST_PROGRAMS)
$(RM) $(FUZZ_PROGRAMS)
Expand Down
5 changes: 5 additions & 0 deletions builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_blame(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_cat_file(int argc, const char **argv, const char *prefix);
int cmd_checkout(int argc, const char **argv, const char *prefix);
Expand All @@ -138,6 +139,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix);
int cmd_config(int argc, const char **argv, const char *prefix);
int cmd_count_objects(int argc, const char **argv, const char *prefix);
int cmd_credential(int argc, const char **argv, const char *prefix);
int cmd_credential_cache(int argc, const char **argv, const char *prefix);
int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix);
int cmd_credential_store(int argc, const char **argv, const char *prefix);
int cmd_describe(int argc, const char **argv, const char *prefix);
int cmd_diff_files(int argc, const char **argv, const char *prefix);
int cmd_diff_index(int argc, const char **argv, const char *prefix);
Expand All @@ -146,6 +150,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix);
int cmd_difftool(int argc, const char **argv, const char *prefix);
int cmd_env__helper(int argc, const char **argv, const char *prefix);
int cmd_fast_export(int argc, const char **argv, const char *prefix);
int cmd_fast_import(int argc, const char **argv, const char *prefix);
int cmd_fetch(int argc, const char **argv, const char *prefix);
int cmd_fetch_pack(int argc, const char **argv, const char *prefix);
int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
Expand Down
10 changes: 3 additions & 7 deletions bugreport.c → builtin/bugreport.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cache.h"
#include "builtin.h"
#include "parse-options.h"
#include "strbuf.h"
#include "help.h"
Expand Down Expand Up @@ -119,16 +119,14 @@ 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)
int cmd_bugreport(int argc, const char **argv, const char *prefix)
{
struct strbuf buffer = STRBUF_INIT;
struct strbuf report_path = STRBUF_INIT;
int report = -1;
time_t now = time(NULL);
char *option_output = NULL;
char *option_suffix = "%Y-%m-%d-%H%M";
int nongit_ok = 0;
const char *prefix = NULL;
const char *user_relative_path = NULL;

const struct option bugreport_options[] = {
Expand All @@ -139,8 +137,6 @@ int cmd_main(int argc, const char **argv)
OPT_END()
};

prefix = setup_git_directory_gently(&nongit_ok);

argc = parse_options(argc, argv, prefix, bugreport_options,
bugreport_usage, 0);

Expand Down Expand Up @@ -170,7 +166,7 @@ int cmd_main(int argc, const char **argv)
get_system_info(&buffer);

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. */
report = open(report_path.buf, O_CREAT | O_EXCL | O_WRONLY, 0666);
Expand Down
29 changes: 25 additions & 4 deletions credential-cache--daemon.c → builtin/credential-cache--daemon.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "cache.h"
#include "builtin.h"
#include "parse-options.h"

#ifndef NO_UNIX_SOCKETS

#include "config.h"
#include "tempfile.h"
#include "credential.h"
#include "unix-socket.h"
#include "parse-options.h"

struct credential_cache_entry {
struct credential item;
Expand Down Expand Up @@ -257,7 +260,7 @@ static void init_socket_directory(const char *path)
free(path_copy);
}

int cmd_main(int argc, const char **argv)
int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
{
struct tempfile *socket_file;
const char *socket_path;
Expand All @@ -275,7 +278,7 @@ int cmd_main(int argc, const char **argv)

git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);

argc = parse_options(argc, argv, NULL, options, usage, 0);
argc = parse_options(argc, argv, prefix, options, usage, 0);
socket_path = argv[0];

if (!socket_path)
Expand All @@ -295,3 +298,21 @@ int cmd_main(int argc, const char **argv)

return 0;
}

#else

int cmd_credential_cache_daemon(int argc, const char **argv, const char *prefix)
{
const char * const usage[] = {
"git credential-cache--daemon [options] <action>",
"",
"credential-cache--daemon is disabled in this build of Git",
NULL
};
struct option options[] = { OPT_END() };

argc = parse_options(argc, argv, prefix, options, usage, 0);
die(_("credential-cache--daemon unavailable; no unix socket support"));
}

#endif /* NO_UNIX_SOCKET */
29 changes: 25 additions & 4 deletions credential-cache.c → builtin/credential-cache.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "cache.h"
#include "builtin.h"
#include "parse-options.h"

#ifndef NO_UNIX_SOCKETS

#include "credential.h"
#include "string-list.h"
#include "parse-options.h"
#include "unix-socket.h"
#include "run-command.h"

Expand Down Expand Up @@ -96,7 +99,7 @@ static char *get_socket_path(void)
return socket;
}

int cmd_main(int argc, const char **argv)
int cmd_credential_cache(int argc, const char **argv, const char *prefix)
{
char *socket_path = NULL;
int timeout = 900;
Expand All @@ -113,7 +116,7 @@ int cmd_main(int argc, const char **argv)
OPT_END()
};

argc = parse_options(argc, argv, NULL, options, usage, 0);
argc = parse_options(argc, argv, prefix, options, usage, 0);
if (!argc)
usage_with_options(usage, options);
op = argv[0];
Expand All @@ -134,3 +137,21 @@ int cmd_main(int argc, const char **argv)

return 0;
}

#else

int cmd_credential_cache(int argc, const char **argv, const char *prefix)
{
const char * const usage[] = {
"git credential-cache [options] <action>",
"",
"credential-cache is disabled in this build of Git",
NULL
};
struct option options[] = { OPT_END() };

argc = parse_options(argc, argv, prefix, options, usage, 0);
die(_("credential-cache unavailable; no unix socket support"));
}

#endif /* NO_UNIX_SOCKETS */
6 changes: 3 additions & 3 deletions credential-store.c → builtin/credential-store.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cache.h"
#include "builtin.h"
#include "lockfile.h"
#include "credential.h"
#include "string-list.h"
Expand Down Expand Up @@ -143,7 +143,7 @@ static void lookup_credential(const struct string_list *fns, struct credential *
return; /* Found credential */
}

int cmd_main(int argc, const char **argv)
int cmd_credential_store(int argc, const char **argv, const char *prefix)
{
const char * const usage[] = {
"git credential-store [<options>] <action>",
Expand All @@ -161,7 +161,7 @@ int cmd_main(int argc, const char **argv)

umask(077);

argc = parse_options(argc, (const char **)argv, NULL, options, usage, 0);
argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
if (argc != 1)
usage_with_options(usage, options);
op = argv[0];
Expand Down
3 changes: 1 addition & 2 deletions fast-import.c → builtin/fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -3511,14 +3511,13 @@ static void parse_argv(void)
build_mark_map(&sub_marks_from, &sub_marks_to);
}

int cmd_main(int argc, const char **argv)
int cmd_fast_import(int argc, const char **argv, const char *prefix)
{
unsigned int i;

if (argc == 2 && !strcmp(argv[1], "-h"))
usage(fast_import_usage);

setup_git_directory();
reset_pack_idx_option(&pack_idx_opts);
git_pack_config();

Expand Down

0 comments on commit afd49c3

Please sign in to comment.