@matheusbsbs / matheus-bagliano / commits / 2fb3f6db96
Fork 0

Add calls to git_extract_argv0_path() in programs that call git_config_*

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. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Steffen Prohaska committed Jan 18, 2009 at 13:00 UTC 2fb3f6db96492b680899f9e40f434eeb4c778a84
16 files changed +45
daemon.c
+2
@@ -937,6 +937,8 @@ int main(int argc, char **argv)
937 gid_t gid = 0;
938 int i;
939
940 + git_extract_argv0_path(argv[0]);
941 +
942 for (i = 1; i < argc; i++) {
943 char *arg = argv[i];
944
fast-import.c
+3
@@ -150,6 +150,7 @@ Format of STDIN stream:
150 #include "refs.h"
151 #include "csum-file.h"
152 #include "quote.h"
153 +#include "exec_cmd.h"
154
155 #define PACK_ID_BITS 16
156 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
@@ -2406,6 +2407,8 @@ int main(int argc, const char **argv)
2407 {
2408 unsigned int i, show_stats = 1;
2409
2410 + git_extract_argv0_path(argv[0]);
2411 +
2412 setup_git_directory();
2413 git_config(git_pack_config, NULL);
2414 if (!pack_compression_seen && core_compression_seen)
hash-object.c
+3
@@ -8,6 +8,7 @@
8 #include "blob.h"
9 #include "quote.h"
10 #include "parse-options.h"
11 +#include "exec_cmd.h"
12
13 static void hash_fd(int fd, const char *type, int write_object, const char *path)
14 {
@@ -81,6 +82,8 @@ int main(int argc, const char **argv)
82
83 type = blob_type;
84
85 + git_extract_argv0_path(argv[0]);
86 +
87 git_config(git_default_config, NULL);
88
89 argc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);
http-push.c
+2
@@ -2184,6 +2184,8 @@ int main(int argc, char **argv)
2184 struct ref *ref;
2185 char *rewritten_url = NULL;
2186
2187 + git_extract_argv0_path(argv[0]);
2188 +
2189 setup_git_directory();
2190
2191 remote = xcalloc(sizeof(*remote), 1);
imap-send.c
+3
@@ -23,6 +23,7 @@
23 */
24
25 #include "cache.h"
26 +#include "exec_cmd.h"
27 #ifdef NO_OPENSSL
28 typedef void *SSL;
29 #endif
@@ -1389,6 +1390,8 @@ int main(int argc, char **argv)
1390 int total, n = 0;
1391 int nongit_ok;
1392
1393 + git_extract_argv0_path(argv[0]);
1394 +
1395 /* init the random number generator */
1396 arc4_init();
1397
index-pack.c
+3
@@ -8,6 +8,7 @@
8 #include "tree.h"
9 #include "progress.h"
10 #include "fsck.h"
11 +#include "exec_cmd.h"
12
13 static const char index_pack_usage[] =
14 "git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
@@ -880,6 +881,8 @@ int main(int argc, char **argv)
881 struct pack_idx_entry **idx_objects;
882 unsigned char pack_sha1[20];
883
884 + git_extract_argv0_path(argv[0]);
885 +
886 /*
887 * We wish to read the repository's config file if any, and
888 * for that it is necessary to call setup_git_directory_gently().
merge-index.c
+3
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "run-command.h"
3 +#include "exec_cmd.h"
4
5 static const char *pgm;
6 static const char *arguments[9];
@@ -93,6 +94,8 @@ int main(int argc, char **argv)
94 if (argc < 3)
95 usage("git-merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
96
97 + git_extract_argv0_path(argv[0]);
98 +
99 setup_git_directory();
100 read_cache();
101
merge-tree.c
+3
@@ -2,6 +2,7 @@
2 #include "tree-walk.h"
3 #include "xdiff-interface.h"
4 #include "blob.h"
5 +#include "exec_cmd.h"
6
7 static const char merge_tree_usage[] = "git-merge-tree <base-tree> <branch1> <branch2>";
8 static int resolve_directories = 1;
@@ -344,6 +345,8 @@ int main(int argc, char **argv)
345 if (argc != 4)
346 usage(merge_tree_usage);
347
348 + git_extract_argv0_path(argv[0]);
349 +
350 setup_git_directory();
351
352 buf1 = get_tree_descriptor(t+0, argv[1]);
mktag.c
+3
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "tag.h"
3 +#include "exec_cmd.h"
4
5 /*
6 * A signature file has a very simple fixed format: four lines
@@ -159,6 +160,8 @@ int main(int argc, char **argv)
160 if (argc != 1)
161 usage("git-mktag < signaturefile");
162
163 + git_extract_argv0_path(argv[0]);
164 +
165 setup_git_directory();
166
167 if (strbuf_read(&buf, 0, 4096) < 0) {
mktree.c
+3
@@ -6,6 +6,7 @@
6 #include "cache.h"
7 #include "quote.h"
8 #include "tree.h"
9 +#include "exec_cmd.h"
10
11 static struct treeent {
12 unsigned mode;
@@ -70,6 +71,8 @@ int main(int ac, char **av)
71 unsigned char sha1[20];
72 int line_termination = '\n';
73
74 + git_extract_argv0_path(av[0]);
75 +
76 setup_git_directory();
77
78 while ((1 < ac) && av[1][0] == '-') {
pack-redundant.c
+3
@@ -7,6 +7,7 @@
7 */
8
9 #include "cache.h"
10 +#include "exec_cmd.h"
11
12 #define BLKSIZE 512
13
@@ -601,6 +602,8 @@ int main(int argc, char **argv)
602 unsigned char *sha1;
603 char buf[42]; /* 40 byte sha1 + \n + \0 */
604
605 + git_extract_argv0_path(argv[0]);
606 +
607 setup_git_directory();
608
609 for (i = 1; i < argc; i++) {
patch-id.c
+3
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "exec_cmd.h"
3
4 static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)
5 {
@@ -79,6 +80,8 @@ int main(int argc, char **argv)
80 if (argc != 1)
81 usage(patch_id_usage);
82
83 + git_extract_argv0_path(argv[0]);
84 +
85 generate_id_list();
86 return 0;
87 }
unpack-file.c
+3
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "blob.h"
3 +#include "exec_cmd.h"
4
5 static char *create_temp_file(unsigned char *sha1)
6 {
@@ -25,6 +26,8 @@ int main(int argc, char **argv)
26 {
27 unsigned char sha1[20];
28
29 + git_extract_argv0_path(argv[0]);
30 +
31 if (argc != 2)
32 usage("git-unpack-file <sha1>");
33 if (get_sha1(argv[1], sha1))
update-server-info.c
+3
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "exec_cmd.h"
3
4 static const char update_server_info_usage[] =
5 "git update-server-info [--force]";
@@ -19,6 +20,8 @@ int main(int ac, char **av)
20 if (i != ac)
21 usage(update_server_info_usage);
22
23 + git_extract_argv0_path(av[0]);
24 +
25 setup_git_directory();
26
27 return !!update_server_info(force);
upload-pack.c
+2
@@ -616,6 +616,8 @@ int main(int argc, char **argv)
616 int i;
617 int strict = 0;
618
619 + git_extract_argv0_path(argv[0]);
620 +
621 for (i = 1; i < argc; i++) {
622 char *arg = argv[i];
623
var.c
+3
@@ -4,6 +4,7 @@
4 * Copyright (C) Eric Biederman, 2005
5 */
6 #include "cache.h"
7 +#include "exec_cmd.h"
8
9 static const char var_usage[] = "git var [-l | <variable>]";
10
@@ -56,6 +57,8 @@ int main(int argc, char **argv)
57 usage(var_usage);
58 }
59
60 + git_extract_argv0_path(argv[0]);
61 +
62 setup_git_directory_gently(&nongit);
63 val = NULL;
64