2 * Navymail - a program to store and synchronize mail in Git.
3 * Copyright (C) 2011 Kirill Smelkov <kirr@navytux.spb.ru>
5 * This program is free software: you can Use, Study, Modify and Redistribute it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * See COPYING file for full License terms.
22 * Main driver for executing commands.
30 #include "git-compat-util.h"
31 #include "run-command.h"
33 #include "navymail/navymail.h"
34 #include "navymail/compat/progexe.h"
37 /* TODO move out-of-here + autogenerate. XXX dup in configure.ac */
38 const char navymail_version_string
[] = "0.001";
42 /* Setup libexec and other paths for navymail at runtime */
43 static const char *prefix
, *man_path
, *info_path
, *html_path
;
45 const char *navymail_prefix() { return prefix
; }
46 const char *navymail_man_path() { return man_path
; }
47 const char *navymail_info_path() { return info_path
; }
48 const char *navymail_html_path() { return html_path
; }
50 void navymail_setup_path()
53 const char *exec_path
;
56 * This simulates runtime prefix.
58 exe
= xstrdup(xprogexe());
62 * TODO also support installed case
64 prefix
= xstrdup(dirname(exe
)); /* '/path/to/navymail' -> '/path/to' */
67 /* NOTE setting this early, still allows exec-path to be overriden via
69 exec_path
= xstrdup(mkpath("%s/cmd", prefix
));
70 if (!getenv(NAVYMAIL_EXEC_PATH_ENV
))
71 navymail_set_argv_exec_path(exec_path
);
73 /* XXX man,info,html are stubs - i.e. they are not used atm */
74 man_path
= xstrdup(mkpath("%s/Documentation/man", prefix
));
75 info_path
= xstrdup(mkpath("%s/Documentation/info", prefix
));
76 html_path
= xstrdup(mkpath("%s/Documentation/html", prefix
));
83 const char *setup_navymail_directory_gently(int *non_navymail
)
85 const char *navymail_dir
;
87 /* require navymail-dir to be explicitly set */
88 navymail_dir
= getenv(NAVYMAIL_DIR_ENVIRONMENT
);
96 /* propagate navymail-dir to git-dir */
97 setenv(GIT_DIR_ENVIRONMENT
, navymail_dir
, 1);
100 is_bare_repository_cfg
= 1;
102 return setup_git_directory_gently(non_navymail
);
106 const char *setup_navymail_directory()
111 prefix
= setup_navymail_directory_gently(&non_navymail
);
113 if (!getenv(NAVYMAIL_DIR_ENVIRONMENT
))
114 die("What is your navymail-dir?");
116 die("Repo setup failed");
124 /* the rest of the code comes from tweaked git/git.c */
125 #include "fromgit/git.c"