From 8ed472bcbb8a5eb47354050606129f13487c6e53 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 17 Aug 2008 08:58:21 +0200 Subject: [PATCH] Add call to git_extract_argv0_path() to various programs Programs that use git_config need to find the global configuration. When runtime prefix computation is enabled, this requires that git_extract_argv0_path() is called early in the program's main(). This commit adds the necessary calls. --- http-push.c | 3 +++ imap-send.c | 4 ++++ merge-index.c | 4 ++++ merge-tree.c | 4 ++++ mktag.c | 4 ++++ mktree.c | 4 ++++ pack-redundant.c | 4 ++++ patch-id.c | 4 ++++ update-server-info.c | 4 ++++ 9 files changed, 35 insertions(+) diff --git a/http-push.c b/http-push.c index 6805288857..47fa1cb6b3 100644 --- a/http-push.c +++ b/http-push.c @@ -2170,6 +2170,9 @@ int main(int argc, char **argv) struct ref *ref; char *rewritten_url = NULL; + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + setup_git_directory(); remote = xcalloc(sizeof(*remote), 1); diff --git a/imap-send.c b/imap-send.c index 1ec1310921..6714f9114c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -23,6 +23,7 @@ */ #include "cache.h" +#include "exec_cmd.h" typedef struct store_conf { char *name; @@ -1293,6 +1294,9 @@ main(int argc, char **argv) int r; int total, n = 0; + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + /* init the random number generator */ arc4_init(); diff --git a/merge-index.c b/merge-index.c index 7827e87a92..5d89eadba0 100644 --- a/merge-index.c +++ b/merge-index.c @@ -1,5 +1,6 @@ #include "cache.h" #include "run-command.h" +#include "exec_cmd.h" static const char *pgm; static const char *arguments[9]; @@ -93,6 +94,9 @@ int main(int argc, char **argv) if (argc < 3) usage("git-merge-index [-o] [-q] (-a | [--] *)"); + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + setup_git_directory(); read_cache(); diff --git a/merge-tree.c b/merge-tree.c index 02fc10f7e6..51061ae604 100644 --- a/merge-tree.c +++ b/merge-tree.c @@ -2,6 +2,7 @@ #include "tree-walk.h" #include "xdiff-interface.h" #include "blob.h" +#include "exec_cmd.h" static const char merge_tree_usage[] = "git-merge-tree "; static int resolve_directories = 1; @@ -345,6 +346,9 @@ int main(int argc, char **argv) if (argc != 4) usage(merge_tree_usage); + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + setup_git_directory(); buf1 = get_tree_descriptor(t+0, argv[1]); diff --git a/mktag.c b/mktag.c index 0b34341f71..44490a6729 100644 --- a/mktag.c +++ b/mktag.c @@ -1,5 +1,6 @@ #include "cache.h" #include "tag.h" +#include "exec_cmd.h" /* * A signature file has a very simple fixed format: four lines @@ -159,6 +160,9 @@ int main(int argc, char **argv) if (argc != 1) usage("git-mktag < signaturefile"); + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + setup_git_directory(); strbuf_init(&buf, 0); diff --git a/mktree.c b/mktree.c index e0da110a98..0e83fc935b 100644 --- a/mktree.c +++ b/mktree.c @@ -6,6 +6,7 @@ #include "cache.h" #include "quote.h" #include "tree.h" +#include "exec_cmd.h" static struct treeent { unsigned mode; @@ -70,6 +71,9 @@ int main(int ac, char **av) unsigned char sha1[20]; int line_termination = '\n'; + if (av[0] && *av[0]) + git_extract_argv0_path(av[0]); + setup_git_directory(); while ((1 < ac) && av[1][0] == '-') { diff --git a/pack-redundant.c b/pack-redundant.c index 25b81a445c..8ff450b319 100644 --- a/pack-redundant.c +++ b/pack-redundant.c @@ -7,6 +7,7 @@ */ #include "cache.h" +#include "exec_cmd.h" #define BLKSIZE 512 @@ -601,6 +602,9 @@ int main(int argc, char **argv) unsigned char *sha1; char buf[42]; /* 40 byte sha1 + \n + \0 */ + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + setup_git_directory(); for (i = 1; i < argc; i++) { diff --git a/patch-id.c b/patch-id.c index 9349bc5580..775e2954bd 100644 --- a/patch-id.c +++ b/patch-id.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "exec_cmd.h" static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c) { @@ -79,6 +80,9 @@ int main(int argc, char **argv) if (argc != 1) usage(patch_id_usage); + if (argv[0] && *argv[0]) + git_extract_argv0_path(argv[0]); + generate_id_list(); return 0; } diff --git a/update-server-info.c b/update-server-info.c index 7e8209ea4b..286a4dd517 100644 --- a/update-server-info.c +++ b/update-server-info.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "exec_cmd.h" static const char update_server_info_usage[] = "git update-server-info [--force]"; @@ -19,6 +20,9 @@ int main(int ac, char **av) if (i != ac) usage(update_server_info_usage); + if (av[0] && *av[0]) + git_extract_argv0_path(av[0]); + setup_git_directory(); return !!update_server_info(force);