git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
To: git@vger.kernel.org
Cc: newren@gmail.com, gitster@pobox.com, johannes.schindelin@gmx.de
Subject: [GSOC][RFC] Heed core.bare from template config file when no command line override given, as a microproject.
Date: Wed, 3 Jan 2024 03:37:18 +0530	[thread overview]
Message-ID: <85d4e83c-b6c4-4308-ac8c-a65c911c8a95@gmail.com> (raw)

Hello,

I'm currently an undergrad beginning my journey of contributing to the
Git project. I am seeking feedback on doing "Heed core.bare from
template config file when no command line override given" described
here 
https://lore.kernel.org/git/5b39c530f2a0edf3b1492fa13a1132d622a0678e.1684218850.git.gitgitgadget@gmail.com/
by Elijah Newren, as a microproject. I would like to know from the
community, if the complexity and scope of the project is appropriate
for a microproject.

Approach:
As described by Elijah in commit message that fixing this cannot be
done in the create_default_files() function as it occurs too late.
This is because both clone and init have different checks and steps
for working with bare flag, like clone creates a new directory
[name].git and sets the GIT_DIR_ENVIRONMENT to it (when not provided
with an explicit dir name arg), while init sets the
GIT_DIR_ENVIRONMENT to the current working directory (when not
provided with an dir name arg). Also there are other steps like
setting no_checkout in a bare repository in builtin/clone.c. These are
all command specific steps which occur in builtin/clone.c and
builtin/init-db.c ,before we ever hit the TODO comment via
[builtin/clone.c]cmd_clone()->[setup.c]init_db()->
[setup.c]create_default_files().

Therefore, rather than centralizing the code in setup.c and adding a
bunch of if-else statements to handle different command specific
scenarios related to bare option, I propose to add a check for
template file config just after parsing of the flags and args in
builtin/init-db.c and builtin/clone.c.

e.g. in builtin/init-db.c :

static int template_bare_config(const char *var, const char *value,
                     const struct config_context *ctx, void *cb)
{
       if(!strcmp(var,"core.bare")) {
             is_bare_repository_cfg = git_config_bool(var, value);
       }
       return 0;
}

int cmd_init_db(int argc, const char **argv, const char *prefix)
{
...
...
       if(is_bare_repository_cfg==-1) {
             if(!template_dir)
                   git_config_get_pathname("init.templateDir",
                                           &template_dir);

             if(template_dir) {
                   const char* template_config_path
                                = xstrfmt("%s/config",
                   struct stat st;

                   if(!stat(template_config_path, &st) &&
                     !S_ISDIR(st.st_mode)) {
                         git_config_from_file(template_bare_cfg,
                                        template_config_path, NULL);
                   }
             }
...
...
       return init_db(git_dir, real_git_dir, template_dir, hash_algo,
                      initial_branch, init_shared_repository, flags);
}

I also wanted to know if the global config files should have an effect
in deciding if the repo is bare or not.

Curious to know your thoughts on, if this is the right approach or
does it require doing refactoring to bring all the logic in setup.c.
Based on your feedback, I can quickly send a patch.

p.s.: Apologies for the weird indenting, due to 70 character limit.
consider it just a prototype.

Thanks!


             reply	other threads:[~2024-01-02 22:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 22:07 Ghanshyam Thakkar [this message]
2024-01-04 10:24 ` [GSOC][RFC] Heed core.bare from template config file when no command line override given, as a microproject Christian Couder
2024-01-04 10:39   ` Ghanshyam Thakkar
2024-01-05  2:11   ` Elijah Newren
2024-01-05 15:59     ` Junio C Hamano
2024-01-06 12:07       ` Ghanshyam Thakkar
2024-01-08 17:32         ` Junio C Hamano
2024-01-19  1:43           ` Elijah Newren
2024-02-29 13:41 ` [PATCH] setup: clarify TODO comment about ignoring core.bare Ghanshyam Thakkar
2024-02-29 19:15   ` Junio C Hamano
2024-02-29 20:58     ` Ghanshyam Thakkar
2024-03-04 15:18   ` [PATCH v2] setup: remove unnecessary variable Ghanshyam Thakkar
2024-03-04 18:16     ` Junio C Hamano
2024-03-04 21:27       ` Ghanshyam Thakkar
2024-03-04 21:53         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85d4e83c-b6c4-4308-ac8c-a65c911c8a95@gmail.com \
    --to=shyamthakkar001@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).