[GSOC][RFC] Heed core.bare from template config file when no command line override given, as a microproject.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx/
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!




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux