]> git.cameronkatri.com Git - cgit.git/blobdiff - cgit.c
git: update to v2.30.1
[cgit.git] / cgit.c
diff --git a/cgit.c b/cgit.c
index 2910d4b861d76df28b14f6712d30e3568f4ab65b..08d81a1d4b632af9b725a0a2dbf553cff4d3e6b7 100644 (file)
--- a/cgit.c
+++ b/cgit.c
 
 const char *cgit_version = CGIT_VERSION;
 
+__attribute__((constructor))
+static void constructor_environment()
+{
+       /* Do not look in /etc/ for gitconfig and gitattributes. */
+       setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
+       setenv("GIT_ATTR_NOSYSTEM", "1", 1);
+       unsetenv("HOME");
+       unsetenv("XDG_CONFIG_HOME");
+}
+
 static void add_mimetype(const char *name, const char *value)
 {
        struct string_list_item *item;
@@ -314,11 +324,11 @@ static void querystring_cb(const char *name, const char *value)
                ctx.qry.head = xstrdup(value);
                ctx.qry.has_symref = 1;
        } else if (!strcmp(name, "id")) {
-               ctx.qry.sha1 = xstrdup(value);
-               ctx.qry.has_sha1 = 1;
+               ctx.qry.oid = xstrdup(value);
+               ctx.qry.has_oid = 1;
        } else if (!strcmp(name, "id2")) {
-               ctx.qry.sha2 = xstrdup(value);
-               ctx.qry.has_sha1 = 1;
+               ctx.qry.oid2 = xstrdup(value);
+               ctx.qry.has_oid = 1;
        } else if (!strcmp(name, "ofs")) {
                ctx.qry.ofs = atoi(value);
        } else if (!strcmp(name, "path")) {
@@ -565,18 +575,13 @@ static void prepare_repo_env(int *nongit)
        /* The path to the git repository. */
        setenv("GIT_DIR", ctx.repo->path, 1);
 
-       /* Do not look in /etc/ for gitconfig and gitattributes. */
-       setenv("GIT_CONFIG_NOSYSTEM", "1", 1);
-       setenv("GIT_ATTR_NOSYSTEM", "1", 1);
-       unsetenv("HOME");
-       unsetenv("XDG_CONFIG_HOME");
-
        /* Setup the git directory and initialize the notes system. Both of these
         * load local configuration from the git repository, so we do them both while
         * the HOME variables are unset. */
        setup_git_directory_gently(nongit);
-       init_display_notes(NULL);
+       load_display_notes(NULL);
 }
+
 static int prepare_repo_cmd(int nongit)
 {
        struct object_id oid;
@@ -987,9 +992,9 @@ static void cgit_parse_args(int argc, const char **argv)
                } else if (skip_prefix(argv[i], "--head=", &arg)) {
                        ctx.qry.head = xstrdup(arg);
                        ctx.qry.has_symref = 1;
-               } else if (skip_prefix(argv[i], "--sha1=", &arg)) {
-                       ctx.qry.sha1 = xstrdup(arg);
-                       ctx.qry.has_sha1 = 1;
+               } else if (skip_prefix(argv[i], "--oid=", &arg)) {
+                       ctx.qry.oid = xstrdup(arg);
+                       ctx.qry.has_oid = 1;
                } else if (skip_prefix(argv[i], "--ofs=", &arg)) {
                        ctx.qry.ofs = atoi(arg);
                } else if (skip_prefix(argv[i], "--scan-tree=", &arg) ||
@@ -1032,7 +1037,7 @@ static int calc_ttl(void)
        if (!strcmp(ctx.qry.page, "snapshot"))
                return ctx.cfg.cache_snapshot_ttl;
 
-       if (ctx.qry.has_sha1)
+       if (ctx.qry.has_oid)
                return ctx.cfg.cache_static_ttl;
 
        if (ctx.qry.has_symref)