export: Refactor gbox walking code into its own routines
[navymail.git] / fromgit / exec_cmd.cocci
blobc6b68fbefd14ef5111878826a66735a20b8d1995
1 // Tweak git/exec-cmd.c for navymail needs
2 // Copyright (C) 2011  Kirill Smelkov <kirr@navytux.spb.ru>
3 //
4 // This program is free software: you can Use, Study, Modify and Redistribute it
5 // under the terms of the GNU General Public License version 2. This program is
6 // distributed WITHOUT ANY WARRANTY. See COPYING file for full License terms.
8 @@
9 @@
10  #include "..."
11 +#include "navymail/navymail.h"
14 // system_path: always use runtime prefix, navymail way
17  system_path(const char *path)
18  {
19 -  ...  // kill init for static const char prefix under #ifdef
20 +  const char *prefix = navymail_prefix();
22    struct strbuf d = STRBUF_INIT;
24    if (is_absolute_path(path))
25      return path;
27 -  ...  // kill git's approach to runtime prefix under #ifdef
29    strbuf_addf(&d, "%s/%s", prefix, path);
30    ...
31  }
33 // git's set/get exec_path -> navymail
36 -git_set_argv_exec_path
37 +navymail_set_argv_exec_path
38  (const char *exec_path)
39  {
40    ...
41    setenv(
42 -         EXEC_PATH_ENVIRONMENT,
43 +         NAVYMAIL_EXEC_PATH_ENV,
44           exec_path, 1);
45  }
49 -git_exec_path
50 +navymail_exec_path
51  (void)
52  {
53    ...
54    env = getenv(
55 -         EXEC_PATH_ENVIRONMENT
56 +         NAVYMAIL_EXEC_PATH_ENV
57    );
58    ...
59 -  return system_path(GIT_EXEC_PATH);
60    // XXX how to use NAVYMAIL_EXEC_PATH_ENV here?
61 +  /* argv_exec_path should be set early by navymail_setup_path() */
62 +  die("BUG: both argv_exec_path and $NAVYMAIL_EXEC_PATH unset.");
63  }
68  * XXX at present "git" is changed to "navymail" in prepare_git_cmd() and
69  * execv_git_cmd(). I'm not sure this is not correct, because we might want to
70  * change those functions to navymail_ later and run git via our own special
71  * helper. Postponing this issue.
72  */
75 // include "common.cocci"  (XXX "included" by build system via generating %.cocci+)