Re: Bug report - Can create worktrees from bare repo / such worktrees can fool is_bare_repository()

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

 



> what about the comparison code where is_bare_repository_cfg is
> compared with 1 (it is a boolean and sometimes set to -1). This
> would not generally pass a code review.

I'm sorry, I'm afraid I don't completely follow.  Wouldn't the most
straightforward change be to simply follow the documented
recommendation when we create the worktree config in `git
sparse-checkout init`?  Specifically,

    @@ -374,6 +374,9 @@ static int set_config(enum sparse_checkout_mode mode)
                           "core.sparseCheckoutCone",
                           mode == MODE_CONE_PATTERNS ? "true" : NULL);

    +    if (is_bare_repository())
    +      git_config_set_in_file_gently(config_path, "core.bare", "false");
    +
         if (mode == MODE_NO_PATTERNS)
             set_sparse_index_config(the_repository, 0);

Are we saying the comparison within is_bare_repository() may not be
appropriate in this case?

---

Or maybe it makes more sense to call set_git_work_tree() somewhere
sensible such that get_git_work_tree() will return non-null.  Doing a
deeper dive into the code, that might be the *real* root cause
(assuming the_repository->worktree is NULL in this scenario; I have
not run git through a debugger).  Such a change could have
farther-reaching consequences, though.



[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