Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalar: two downstream improvements #1569

Closed

Commits on Aug 25, 2023

  1. scalar: add --[no-]src option

    Some users have strong aversions to Scalar's opinion that the repository
    should be in a 'src' directory, even though this creates a clean slate
    for placing build artifacts in adjacent directories.
    
    The new --no-src option allows users to opt out of the default behavior.
    
    While adding options, make sure the usage output by 'scalar clone -h'
    reports the same as the SYNOPSIS line in Documentation/scalar.txt.
    
    Signed-off-by: Derrick Stolee <derrickstolee@github.com>
    derrickstolee committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    e9858b3 View commit details
    Browse the repository at this point in the history
  2. setup: add discover_git_directory_reason()

    There are many reasons why discovering a Git directory may fail. In
    particular, 8959555 (setup_git_directory(): add an owner check for
    the top-level directory, 2022-03-02) added ownership checks as a
    security precaution.
    
    Callers attempting to set up a Git directory may want to inform the user
    about the reason for the failure. For that, expose the enum
    discovery_result from within setup.c and move it into cache.h where
    discover_git_directory() is defined.
    
    I initially wanted to change the return type of discover_git_directory()
    to be this enum, but several callers rely upon the "zero means success".
    The two problems with this are:
    
    1. The zero value of the enum is actually GIT_DIR_NONE, so nonpositive
       results are errors.
    
    2. There are multiple successful states; positive results are
       successful.
    
    It is worth noting that GIT_DIR_NONE is not returned, so we remove this
    option from the enum. We must be careful to keep the successful reasons
    as positive values, so they are given explicit positive values.
    
    Instead of updating all callers immediately, add a new method,
    discover_git_directory_reason(), and convert discover_git_directory() to
    be a thin shim on top of it.
    
    One thing that is important to note is that discover_git_directory()
    previously returned -1 on error, so let's continue that into the future.
    There is only one caller (in scalar.c) that depends on that signedness
    instead of a non-zero check, so clean that up, too.
    
    Because there are extra checks that discover_git_directory_reason() does
    after setup_git_directory_gently_1(), there are other modes that can be
    returned for failure states. Add these modes to the enum, but be sure to
    explicitly add them as BUG() states in the switch of
    setup_git_directory_gently().
    
    Signed-off-by: Derrick Stolee <derrickstolee@github.com>
    derrickstolee committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    3c16fa6 View commit details
    Browse the repository at this point in the history
  3. scalar reconfigure: help users remove buggy repos

    When running 'scalar reconfigure -a', Scalar has warning messages about
    the repository missing (or not containing a .git directory). Failures
    can also happen while trying to modify the repository-local config for
    that repository.
    
    These warnings may seem confusing to users who don't understand what
    they mean or how to stop them.
    
    Add a warning that instructs the user how to remove the warning in
    future installations.
    
    Signed-off-by: Derrick Stolee <derrickstolee@github.com>
    derrickstolee committed Aug 25, 2023
    Configuration menu
    Copy the full SHA
    ac234b1 View commit details
    Browse the repository at this point in the history