Skip to content

The git-root not working with submodules #1

Open

Description

@dbranco-sdc

It should use --absolute-git-dir to make it compatible with a submodule structure

Activity

  1. JPeer264 commented on Jan 17, 2023

    @JPeer264
    Owner

    That is a great suggestion. Should this be available with an option to enable/disable it? I would enable this by default, where you can disable it with { detectSubmodule: false } (default is set to true). However, this would mean a breaking change in my eyes.

  2. dbranco-sdc commented on Jan 17, 2023

    @dbranco-sdc
    Author

    Hello

    That is a great suggestion. Should this be available with an option to enable/disable it? I would enable this by default, where you can disable it with { detectSubmodule: false } (default is set to true). However, this would mean a breaking change in my eyes.

    Not sure where that option should live, but its usecase depends on what's implemented. According to the documentation we have the following:

           --git-dir
               Show $GIT_DIR if defined. Otherwise show the path to the .git directory. The path shown, when relative, is relative to the current working directory.
    
               If $GIT_DIR is not defined and the current directory is not detected to lie in a Git repository or work tree print a message to stderr and exit with nonzero status.
    ...
           --show-toplevel
               Show the (by default, absolute) path of the top-level directory of the working tree. If there is no working tree, report an error.
    ...
           --absolute-git-dir
               Like --git-dir, but its output is always the canonicalized absolute path.
    

    So I believe if we are in a submodule structure we are always good with the --absolute-git-dir else the top level is more than enough.

    To check if the current directory is a submodule, you could use git rev-parse --show-superproject-working-tree and if there is any output then you are part of a submodule. Like this there wont be any breaking change I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions