Repository: dolthub/dolt
File: go/libraries/doltcore/sqle/database.go (Go)

Code before:
		if err != nil {
			return nil, false, err
		}
		if !resolve.UseSearchPath || isDoltgresSystemTable {
			sess := dsess.DSessFromSess(ctx.Session)
			var rootsProvider env.RootsProvider[*sql.Context]
			rootsProvider = dsess.NewSessionStateAdapter(
				sess, db.RevisionQualifiedName(),
				concurrentmap.New[string, env.Remote](),
				concurrentmap.New[string, env.BranchConfig](),
				concurrentmap.New[string, env.Remote]())
			ws, err := sess.WorkingSet(ctx, db.RevisionQualifiedName())
			if err != nil {
				return nil, false, err
			}

			asOf, ok := asOf.(string)
			if !ok {
				return nil, false, fmt.Errorf(
					"unexpected type for asOf param: %T", asOf)
			}

			// If |asOf| is set, then we need to get the correct roots for the
			// status table to use. We skip the special revision spec, HEAD,
			// because it represents the current branch.
			if asOf != "" && strings.ToUpper(asOf) != "HEAD" {
				// If |asOf| is a branch name, then grab the working set for that
				// branch and use its data.
				ddb, ok := ds.GetDoltDB(ctx, ctx.GetCurrentDatabase())
				if !ok {
					return nil, false, fmt.Errorf(
						"unable to get DoltDB for database %s", ctx.GetCurrentDatabase())
				}

				_, hasBranch, err := ddb.HasBranch(ctx, asOf)
				if err != nil {
					return nil, false, err
				}
				if hasBranch {
					branchRoots, err := getRootsForBranch(ctx, ddb, asOf)
					if err != nil {
						return nil, false, err
					}
					rootsProvider = &staticRootsProvider{
						roots: branchRoots,
					}
				} else {
					// If this isn't a branch, then it's a tag or a commit, or a
					// commit spec. In all of these cases, dolt_status will have
					// no data, because there is no valid head/working/staged roots,
					// so we provide a nil rootsProvider

Review comment (suggestion):
```suggestion
			if asOf != "" && !strings.EqualFold("HEAD") {
```

Code after:
		if err != nil {
			return nil, false, err
		}
		if !resolve.UseSearchPath || isDoltgresSystemTable {
			sess := dsess.DSessFromSess(ctx.Session)
			var rootsProvider env.RootsProvider[*sql.Context]
			rootsProvider = dsess.NewSessionStateAdapter(
				sess, db.RevisionQualifiedName(),
				concurrentmap.New[string, env.Remote](),
				concurrentmap.New[string, env.BranchConfig](),
				concurrentmap.New[string, env.Remote]())
			ws, err := sess.WorkingSet(ctx, db.RevisionQualifiedName())
			if err != nil {
				return nil, false, err
			}

			asOf, ok := asOf.(string)
			if !ok {
				return nil, false, fmt.Errorf(
					"unexpected type for asOf param: %T", asOf)
			}

			// If |asOf| is set, then we need to get the correct roots for the
			// status table to use. We skip the special revision spec, HEAD,
			// because it represents the current branch.
			if asOf != "" && !strings.EqualFold(asOf, "HEAD") {
				// If |asOf| is a branch name, then grab the working set for that
				// branch and use its data.
				ddb, ok := ds.GetDoltDB(ctx, ctx.GetCurrentDatabase())
				if !ok {
					return nil, false, fmt.Errorf(
						"unable to get DoltDB for database %s", ctx.GetCurrentDatabase())
				}

				_, hasBranch, err := ddb.HasBranch(ctx, asOf)
				if err != nil {
					return nil, false, err
				}
				if hasBranch {
					branchRoots, err := getRootsForBranch(ctx, ddb, asOf)
					if err != nil {
						return nil, false, err
					}
					rootsProvider = &staticRootsProvider{
						roots: branchRoots,
					}
				} else {
					// If this isn't a branch, then it's a tag or a commit, or a
					// commit spec. In all of these cases, dolt_status will have
					// no data, because there is no valid head/working/staged roots,
					// so we provide a nil rootsProvider