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

remote: branch setting fixes #1789

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Sep 11, 2024

  1. remote: fix set-branches when no branches are set

    To replace the list of branches to be fetched "git remote set-branches"
    first removes the fetch refspecs for the remote and then creates a new
    set of fetch refspecs based and the branches passed on the commandline.
    When deleting the existing refspecs git_config_set_multivar_gently()
    will return a non-zero result if there was nothing to delete.
    Unfortunately the calling code treats that as an error and bails out
    rather than setting up the new branches. Fix this by not treating a
    return value of CONFIG_NOTHING_SET as an error.
    
    Reported-by: Han Jiang <[email protected]>
    Signed-off-by: Phillip Wood <[email protected]>
    phillipwood committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    d95a07a View commit details
    Browse the repository at this point in the history
  2. remote: print an error if refspec cannot be removed

    If the existing fetch refspecs cannot be removed when replacing the set
    of branches to fetch with "git remote set-branches" the command silently
    fails. Add an error message to tell the user what when wrong.
    
    Signed-off-by: Phillip Wood <[email protected]>
    phillipwood committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    a8dfe40 View commit details
    Browse the repository at this point in the history
  3. remote add: use strvec to store tracking branches

    Store the list of branches to track in a ’struct strvec' instead of a
    'struct string_list'. This in preparation for the next commit where it
    will be convenient to have them stored in a NULL terminated array. This
    means that we now duplicate the strings when storing them but the
    overhead is not significant.
    
    Signed-off-by: Phillip Wood <[email protected]>
    phillipwood committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    f30c77b View commit details
    Browse the repository at this point in the history
  4. remote: check branch names

    Make sure the names passed to "git remote add -t <branch>" and "git
    remote set-branches <branch>" are syntactically valid so that we do not
    create invalid refspecs. This check needs to be performed before
    creating the remote or modifying the existing configuration so a new
    function is added rather than modifying add_branch()
    
    Tests are added for both commands that to ensure (i) we report all the
    invalid branch names passed on the command line, (ii) the branch names
    are validated before modifying the configuration and (iii) wildcards
    are accepted.
    
    Signed-off-by: Phillip Wood <[email protected]>
    phillipwood committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    dba3124 View commit details
    Browse the repository at this point in the history