Skip to content

Commit

Permalink
commands,git,lfs: invert RemoteRefs() tags option
Browse files Browse the repository at this point in the history
As suggested by larsxschneider on PR review, we can avoid one
negation of the new Boolean argument we have added to the RemoteRefs()
function in our "git" package, in a prior commit in this PR, if we
invert the flag's sense and rename it from ignoreTags to withTags.

We also take the opportunity to update the code comments which describe
the action of the RemoteRefs() function so as to indicate that the
inclusion of tag refs in the returned list of refs is now optional.
  • Loading branch information
chrisd8088 committed Oct 7, 2024
1 parent f984672 commit ef60fc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion commands/command_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func getRemoteRefs(l *tasklog.Logger) (map[string][]*git.Ref, error) {
if migrateSkipFetch {
refsForRemote, err = git.CachedRemoteRefs(remote)
} else {
refsForRemote, err = git.RemoteRefs(remote, false)
refsForRemote, err = git.RemoteRefs(remote, true)
}

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,12 +1277,12 @@ func Fetch(remotes ...string) error {
return err
}

// RemoteRefs returns a list of branches & tags for a remote by actually
// accessing the remote via git ls-remote.
func RemoteRefs(remoteName string, ignoreTags bool) ([]*Ref, error) {
// RemoteRefs returns a list of branches and, optionally, tags for a remote
// by actually accessing the remote via git ls-remote.
func RemoteRefs(remoteName string, withTags bool) ([]*Ref, error) {
var ret []*Ref
args := []string{"ls-remote", "--heads", "-q"}
if !ignoreTags {
if withTags {
args = append(args, "--tags")
}
args = append(args, remoteName)
Expand All @@ -1308,7 +1308,7 @@ func RemoteRefs(remoteName string, ignoreTags bool) ([]*Ref, error) {

typ := RefTypeRemoteBranch
if ns == "tags" {
if ignoreTags {
if !withTags {
return nil, errors.New(tr.Tr.Get("unexpected tag returned by `git ls-remote --heads`: %s %s", name, sha))
}
typ = RefTypeRemoteTag
Expand Down
2 changes: 1 addition & 1 deletion lfs/gitscanner_remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func calcSkippedRefs(remote string) []string {

// Since CachedRemoteRefs() only returns branches, request that
// RemoteRefs() ignore tags and also return only branches.
actualRemoteRefs, _ := git.RemoteRefs(remote, true)
actualRemoteRefs, _ := git.RemoteRefs(remote, false)

// The list of remote refs can be very large, so convert them to
// a set for faster lookups in the skip calculation loop.
Expand Down

0 comments on commit ef60fc0

Please sign in to comment.