mirror of
https://github.com/git/git.git
synced 2026-03-13 10:23:30 +01:00
Merge commit 'junio/spr/prefix-relocate-maint' into spr/prefix-relocate-maint
Conflicts: Makefile
This commit is contained in:
23
Makefile
23
Makefile
@@ -756,6 +756,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
|
||||
NO_PERL_MAKEMAKER = YesPlease
|
||||
NO_R_TO_GCC_LINKER = YesPlease
|
||||
INTERNAL_QSORT = YesPlease
|
||||
RUNTIME_PREFIX = YesPlease
|
||||
NO_POSIX_ONLY_PROGRAMS = YesPlease
|
||||
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch
|
||||
COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
|
||||
@@ -764,10 +765,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
|
||||
EXTLIBS += -lws2_32
|
||||
X = .exe
|
||||
NOEXECTEMPL = .noexec
|
||||
gitexecdir = ../libexec/git-core
|
||||
template_dir = ../share/git-core/templates/
|
||||
ETC_GITCONFIG = ../etc/gitconfig
|
||||
htmldir=../doc/git/html/
|
||||
htmldir=/doc/git/html/
|
||||
endif
|
||||
ifneq (,$(findstring arm,$(uname_M)))
|
||||
ARM_SHA1 = YesPlease
|
||||
@@ -992,6 +990,9 @@ ifdef INTERNAL_QSORT
|
||||
COMPAT_CFLAGS += -DINTERNAL_QSORT
|
||||
COMPAT_OBJS += compat/qsort.o
|
||||
endif
|
||||
ifdef RUNTIME_PREFIX
|
||||
COMPAT_CFLAGS += -DRUNTIME_PREFIX
|
||||
endif
|
||||
|
||||
ifdef THREADED_DELTA_SEARCH
|
||||
BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
|
||||
@@ -1053,6 +1054,12 @@ htmldir_SQ = $(subst ','\'',$(htmldir))
|
||||
prefix_SQ = $(subst ','\'',$(prefix))
|
||||
sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
|
||||
|
||||
ETC_GITCONFIG_SQ_C = $(subst /,\057,$(ETC_GITCONFIG_SQ))
|
||||
bindir_SQ_C = $(subst /,\057,$(bindir_SQ))
|
||||
gitexecdir_SQ_C = $(subst /,\057,$(gitexecdir_SQ))
|
||||
htmldir_SQ_C = $(subst /,\057,$(htmldir_SQ))
|
||||
template_dir_SQ_C = $(subst /,\057,$(template_dir_SQ))
|
||||
|
||||
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
|
||||
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
|
||||
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
|
||||
@@ -1104,7 +1111,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
|
||||
|
||||
help.o: help.c common-cmds.h GIT-CFLAGS
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
|
||||
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
|
||||
'-DGIT_HTML_PATH="$(htmldir_SQ_C)"' \
|
||||
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
|
||||
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
|
||||
|
||||
@@ -1212,12 +1219,12 @@ git.o git.spec \
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
|
||||
|
||||
exec_cmd.o: exec_cmd.c GIT-CFLAGS
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ_C)"' -DBINDIR='"$(bindir_SQ_C)"' $<
|
||||
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ_C)"' $<
|
||||
|
||||
config.o: config.c GIT-CFLAGS
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ_C)"' $<
|
||||
|
||||
http.o: http.c GIT-CFLAGS
|
||||
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
|
||||
|
||||
3
daemon.c
3
daemon.c
@@ -1055,6 +1055,9 @@ int main(int argc, char **argv)
|
||||
gid_t gid = 0;
|
||||
int i;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
/* Without this we cannot rely on waitpid() to tell
|
||||
* what happened to our children.
|
||||
*/
|
||||
|
||||
64
exec_cmd.c
64
exec_cmd.c
@@ -9,17 +9,65 @@ static const char *argv0_path;
|
||||
|
||||
const char *system_path(const char *path)
|
||||
{
|
||||
if (!is_absolute_path(path) && argv0_path) {
|
||||
struct strbuf d = STRBUF_INIT;
|
||||
strbuf_addf(&d, "%s/%s", argv0_path, path);
|
||||
path = strbuf_detach(&d, NULL);
|
||||
#ifdef RUNTIME_PREFIX
|
||||
static const char *prefix;
|
||||
|
||||
assert(argv0_path);
|
||||
assert(is_absolute_path(argv0_path));
|
||||
|
||||
if (!prefix) {
|
||||
const char *strip[] = {
|
||||
GIT_EXEC_PATH,
|
||||
BINDIR,
|
||||
0
|
||||
};
|
||||
const char **s;
|
||||
|
||||
for (s = strip; *s; s++) {
|
||||
const char *sargv = argv0_path + strlen(argv0_path);
|
||||
const char *ss = *s + strlen(*s);
|
||||
while (argv0_path < sargv && *s < ss
|
||||
&& (*sargv == *ss ||
|
||||
(is_dir_sep(*sargv) && is_dir_sep(*ss)))) {
|
||||
sargv--;
|
||||
ss--;
|
||||
}
|
||||
if (*s == ss) {
|
||||
struct strbuf d = STRBUF_INIT;
|
||||
strbuf_add(&d, argv0_path, sargv - argv0_path);
|
||||
prefix = strbuf_detach(&d, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!prefix) {
|
||||
fprintf(stderr, "RUNTIME_PREFIX requested for path '%s', "
|
||||
"but prefix computation failed.\n", path);
|
||||
return path;
|
||||
}
|
||||
|
||||
struct strbuf d = STRBUF_INIT;
|
||||
strbuf_addf(&d, "%s/%s", prefix, path);
|
||||
path = strbuf_detach(&d, NULL);
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
void git_set_argv0_path(const char *path)
|
||||
const char *git_extract_argv0_path(const char *argv0)
|
||||
{
|
||||
argv0_path = path;
|
||||
const char *slash = argv0 + strlen(argv0);
|
||||
|
||||
do
|
||||
--slash;
|
||||
while (slash >= argv0 && !is_dir_sep(*slash));
|
||||
|
||||
if (slash >= argv0) {
|
||||
argv0_path = xstrndup(argv0, slash - argv0);
|
||||
return slash + 1;
|
||||
}
|
||||
|
||||
return argv0;
|
||||
}
|
||||
|
||||
void git_set_argv_exec_path(const char *exec_path)
|
||||
@@ -63,9 +111,7 @@ void setup_path(void)
|
||||
|
||||
strbuf_init(&new_path, 0);
|
||||
|
||||
add_path(&new_path, argv_exec_path);
|
||||
add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
|
||||
add_path(&new_path, system_path(GIT_EXEC_PATH));
|
||||
add_path(&new_path, git_exec_path());
|
||||
add_path(&new_path, argv0_path);
|
||||
|
||||
if (old_path)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define GIT_EXEC_CMD_H
|
||||
|
||||
extern void git_set_argv_exec_path(const char *exec_path);
|
||||
extern void git_set_argv0_path(const char *path);
|
||||
extern const char* git_extract_argv0_path(const char *path);
|
||||
extern const char* git_exec_path(void);
|
||||
extern void setup_path(void);
|
||||
extern const char **prepare_git_cmd(const char **argv);
|
||||
|
||||
@@ -150,6 +150,7 @@ Format of STDIN stream:
|
||||
#include "refs.h"
|
||||
#include "csum-file.h"
|
||||
#include "quote.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
#define PACK_ID_BITS 16
|
||||
#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
|
||||
@@ -2395,6 +2396,9 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
unsigned int i, show_stats = 1;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
setup_git_directory();
|
||||
git_config(git_pack_config, NULL);
|
||||
if (!pack_compression_seen && core_compression_seen)
|
||||
|
||||
20
git.c
20
git.c
@@ -416,23 +416,13 @@ static void execv_dashed_external(const char **argv)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
|
||||
char *slash = (char *)cmd + strlen(cmd);
|
||||
const char *cmd;
|
||||
int done_alias = 0;
|
||||
|
||||
/*
|
||||
* Take the basename of argv[0] as the command
|
||||
* name, and the dirname as the default exec_path
|
||||
* if we don't have anything better.
|
||||
*/
|
||||
do
|
||||
--slash;
|
||||
while (cmd <= slash && !is_dir_sep(*slash));
|
||||
if (cmd <= slash) {
|
||||
*slash++ = 0;
|
||||
git_set_argv0_path(cmd);
|
||||
cmd = slash;
|
||||
}
|
||||
if (argv[0] && *argv[0])
|
||||
cmd = git_extract_argv0_path(argv[0]);
|
||||
else
|
||||
cmd = "git-help";
|
||||
|
||||
/*
|
||||
* "git-xxxx" is the same as "git xxxx", but we obviously:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "cache.h"
|
||||
#include "blob.h"
|
||||
#include "quote.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
static void hash_object(const char *path, enum object_type type, int write_object)
|
||||
{
|
||||
@@ -65,6 +66,9 @@ int main(int argc, char **argv)
|
||||
int hashstdin = 0;
|
||||
int stdin_paths = 0;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
|
||||
for (i = 1 ; i < argc; i++) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "tree.h"
|
||||
#include "progress.h"
|
||||
#include "fsck.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
static const char index_pack_usage[] =
|
||||
"git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
|
||||
@@ -877,6 +878,9 @@ int main(int argc, char **argv)
|
||||
unsigned char pack_sha1[20];
|
||||
int nongit = 0;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
setup_git_directory_gently(&nongit);
|
||||
git_config(git_index_pack_config, NULL);
|
||||
|
||||
|
||||
@@ -467,6 +467,9 @@ int main(int argc, char **argv)
|
||||
int i;
|
||||
char *dir = NULL;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
argv++;
|
||||
for (i = 1; i < argc; i++) {
|
||||
char *arg = *argv++;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "cache.h"
|
||||
#include "blob.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
static char *create_temp_file(unsigned char *sha1)
|
||||
{
|
||||
@@ -25,6 +26,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
unsigned char sha1[20];
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
if (argc != 2)
|
||||
usage("git-unpack-file <sha1>");
|
||||
if (get_sha1(argv[1], sha1))
|
||||
|
||||
@@ -616,6 +616,9 @@ int main(int argc, char **argv)
|
||||
int i;
|
||||
int strict = 0;
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
char *arg = argv[i];
|
||||
|
||||
|
||||
4
var.c
4
var.c
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) Eric Biederman, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "exec_cmd.h"
|
||||
|
||||
static const char var_usage[] = "git var [-l | <variable>]";
|
||||
|
||||
@@ -56,6 +57,9 @@ int main(int argc, char **argv)
|
||||
usage(var_usage);
|
||||
}
|
||||
|
||||
if (argv[0] && *argv[0])
|
||||
git_extract_argv0_path(argv[0]);
|
||||
|
||||
setup_git_directory_gently(&nongit);
|
||||
val = NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user