gitbutlerapp/gitbutler · error

line : pick requires exactly one commit

Error message

line {line_number}: pick requires exactly one commit

What it means

The integration script parser (`parse_integration_steps_script` in but-workspace) validates each non-comment line of the edited `pick`/`merge`/`squash` script. A `pick` line must name exactly one commit argument. This error is raised when the line contains zero or more than one argument (e.g. `pick` alone, or `pick a b`). The line number is included so the user's editor can pinpoint the bad line.

Solutions

  1. Edit the offending line so `pick` is followed by exactly one commit hash from the editable divergence (e.g. `pick 3333333`).
  2. If you meant to combine commits, use `squash <hash1> <hash2> ...` which accepts two or more commits.
  3. If the extra tokens were options (like `-x` or a comment), move them to a `#` comment line, which the parser ignores.
  4. Delete the line entirely if it is an empty `pick` with no commit.

Example fix

// before (script text)
pick 3333333 4444444
// after
pick 3333333
pick 4444444
Defensive patterns

Strategy: validation

Validate before calling

function validatePickLine(line: string, lineNo: number): string | null {
  const tokens = line.split(/\s+/).filter(Boolean);
  if (tokens[0] !== 'pick') return null;
  if (tokens.length !== 2) return `line ${lineNo}: pick requires exactly one commit`;
  return null;
}

Type guard

const isPickWithOneArg = (line: string): boolean =>
  line.trim().split(/\s+/).filter(Boolean).length === 2 && line.trim().startsWith('pick ');

Try / catch

try {
  const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
  const m = /line (\d+): pick requires exactly one commit/.exec(String(err));
  if (m) showEditorErrorAtLine(Number(m[1]), 'pick must reference exactly one commit');
  else throw err;
}

Prevention

When it happens

Trigger: Calling parse_integration_steps_script with a script containing `pick` with no argument, `pick <a> <b>` (two or more hashes), or trailing tokens that split as whitespace-separated arguments on a `pick` line.

Common situations: A user hand-editing the integration script in a text editor adds a second commit to a `pick` line, deletes the hash but leaves the command, or pastes in rebase-todo-style lines where `pick` is expected to accept extra options (like `pick -x <hash>` or fixup/reword keywords that the parser treats as arguments).

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/df0fa0d89af974cf. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:48

        if trimmed.is_empty() || trimmed.starts_with('#') {
            continue;
        }

        let (command_part, message_part) = split_message_clause(trimmed)
            .with_context(|| format!("line {line_number}: invalid message clause"))?;
        let tokens = command_part.split_whitespace().collect::<Vec<_>>();
        let Some(command) = tokens.first().copied() else {
            continue;
        };
        let arguments = tokens.get(1..).unwrap_or_default();

        let step = match command {
            "pick" => {
                if message_part.is_some() {
                    bail!("line {line_number}: pick does not accept a message clause");
                }
                if arguments.len() != 1 {
                    bail!("line {line_number}: pick requires exactly one commit");
                }
                let commit = arguments
                    .first()
                    .copied()
                    .expect("validated pick arity above");
                InteractiveIntegrationStep::Pick {
                    commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {
                        anyhow::anyhow!("line {line_number}: invalid pick commit: {err}")
                    })?,
                }
            }
            "merge" => {
                if message_part.is_some() {
                    bail!("line {line_number}: merge does not accept a message clause");
                }
                if arguments.len() != 1 {
                    bail!("line {line_number}: merge requires exactly one commit");
                }

View on GitHub (pinned to 58e5313667)