package com.atlassian.bitbucket.scm.git.command.revlist;

import javax.annotation.Nullable;

/**
 * Enumerates the possible traversal (walk) modes for {@code git rev-list}, controlling use of the {@code --do-walk}
 * and {@code --no-walk} flags.
 */
public enum GitRevListWalk {

    /**
     * Apply {@code git rev-list}'s default behaviour. For Git 1.x, this is a synonym for {@link #DO_WALK}.
     */
    DEFAULT,
    /**
     * Walk commit ancestors.
     */
    DO_WALK("--do-walk"),
    /**
     * Do not walk commit ancestry; instead, only return the explicitly-requested commits.
     * <p>
     * Note: When using this mode, <i>no excludes can be provided</i>; processing excludes requires walking ancestry.
     */
    NO_WALK("--no-walk");

    private final String flag;

    GitRevListWalk() {
        flag = null;
    }

    GitRevListWalk(String flag) {
        this.flag = flag;
    }

    @Nullable
    public String getFlag() {
        return flag;
    }

    public boolean isFlagged() {
        return flag != null;
    }
}
