Skip to content

sync subcommand with --pull does not support negative refspecs #1444

Closed
@ryan-ph

Description

@ryan-ph

Description of the bug

Git v2.29.0 supports negative refspecs to allow filtering which refspecs to ignore.

It seems like git branchless sync --pull does not currently respect this and will cause panics if a negative refspec is specified in the git config.

Example git config specifying a negative refspec for any branches with an underscore prefix

[remote "origin"]
    fetch = ^refs/heads/_*

[2024/11/26] edit: seems like this also occurs with the hide subcommand if the target is a branch name that hasn't yet been pushed to the remote

Expected behavior

When running git branchless sync --pull, I expect all refs to be fetched from the remote following all git refspec rules (i.e. all refs which match postive refspecs and do not match any negative refspecs), and all local refs to be updated.

Actual behavior

A panic:

$ git sync --pull
branchless: running command: git fetch --all
branchless: processing 1 update: remote branch origin/master
From github.com:**********
   1cbda20c5530..7aebefa5462d  master        -> origin/master
branchless: processing 1 update: remote branch origin/fix-inventory
 * [new branch]                fix-inventory -> origin/fix-inventory
The application panicked (crashed).
Message:  A fatal error occurred:
   0: could not find upstream branch for branch with name 'master': '^refs/heads/_*' is not a valid refspec.; class=Invalid (3)
   1: '^refs/heads/_*' is not a valid refspec.; class=Invalid (3)

Version of rustc

No response

Automated bug report

No response

Version of git-branchless

git-branchless-opts 0.10.0

Version of git

git version 2.44.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions