git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Passing **envp around in git.c

From
SCStephen Cuppett <cuppett@gmail.com>
Date
Jun 11, 2007, 21:15 UTC
Message-ID
<316a20a40706111415i3181df45oabd1564313eea3bc@mail.gmail.com>

Is there a reason for passing char** envp around in git.c or is it a vestige of something older? It's sent into handle_internal_command from main; however, it's never used. Looks like it might have been used before, but then replaced with getenv. The code probably gets optimized out at compile time, but to clean up:

diff --git a/git.c b/git.c
index 29b55a1..614baed 100644
--- a/git.c
+++ b/git.c
@@ -216,7 +216,7 @@ const char git_version_string[] = GIT_VERSION;
  */
 #define NOT_BARE       (1<<2)

-static void handle_internal_command(int argc, const char **argv, char **envp)
+static void handle_internal_command(int argc, const char **argv)
 {
        const char *cmd = argv[0];
        static struct cmd_struct {
@@ -358,7 +358,7 @@ int main(int argc, const char **argv, char **envp)
        if (!prefixcmp(cmd, "git-")) {
                cmd += 4;
                argv[0] = cmd;
-               handle_internal_command(argc, argv, envp);
+               handle_internal_command(argc, argv);
                die("cannot handle %s internally", cmd);
        }

@@ -390,7 +390,7 @@ int main(int argc, const char **argv, char **envp)

        while (1) {
                /* See if it's an internal command */
-               handle_internal_command(argc, argv, envp);
+               handle_internal_command(argc, argv);

                /* .. then try the external ones */
                execv_git_cmd(argv);
Message 1 of 1 in “Passing **envp around in git.c”
  1. Stephen CuppettJun 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.