gitbutlerapp/gitbutler · error

line : squash requires at least two commits

Error message

line {line_number}: squash requires at least two commits

What it means

A `squash` step combines two or more commits, so the parser rejects `squash` lines with fewer than two commit arguments. The error is raised before any commit resolution happens and includes the line number of the offending line.

Solutions

  1. Add a second (or more) commit hash to the `squash` line: `squash <hash1> <hash2>`.
  2. If only one commit remains, replace `squash <hash>` with `pick <hash>` (and optionally `merge` for upstream commits).
  3. Remove the line if the step is no longer needed.

Example fix

// before (script text)
squash 2222222
// after
squash 2222222 3333333
Defensive patterns

Strategy: validation

Validate before calling

function validateSquashArity(line: string, lineNo: number): string | null {
  const [cmd, ...args] = line.split('|')[0].trim().split(/\s+/).filter(Boolean);
  if (cmd !== 'squash') return null;
  if (args.length < 2) return `line ${lineNo}: squash requires at least two commits`;
  return null;
}

Type guard

const squashHasTwoPlusCommits = (line: string): boolean => {
  const [cmd, ...args] = line.split('|')[0].trim().split(/\s+/).filter(Boolean);
  return cmd === 'squash' && args.length >= 2;
};

Try / catch

try {
  const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
  const m = /line (\d+): squash requires at least two commits/.exec(String(err));
  if (m) showEditorErrorAtLine(Number(m[1]), 'squash needs 2+ commits, or convert to pick');
  else throw err;
}

Prevention

When it happens

Trigger: Calling parse_integration_steps_script with `squash` alone, or `squash <hash>` with only one commit. Also triggered when whitespace-only tokens follow `squash <hash>` so that only one real argument remains.

Common situations: A user deletes one of the hashes from a squash line while editing, intending to keep a single commit and not realizing a lone commit needs `pick` instead, or leaves a partially-removed squash line behind.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

                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");
                }
                let commit = arguments
                    .first()
                    .copied()
                    .expect("validated merge arity above");
                InteractiveIntegrationStep::Merge {
                    commit_id: resolve_commit(commit, &allowed_commits).map_err(|err| {
                        anyhow::anyhow!("line {line_number}: invalid merge commit: {err}")
                    })?,
                }
            }
            "squash" => {
                if arguments.len() < 2 {
                    bail!("line {line_number}: squash requires at least two commits");
                }
                let commits = arguments
                    .iter()
                    .map(|commit| {
                        resolve_commit(commit, &allowed_commits).map_err(|err| {
                            anyhow::anyhow!(
                                "line {line_number}: invalid squash commit '{commit}': {err}"
                            )
                        })
                    })
                    .collect::<Result<Vec<_>>>()?;
                InteractiveIntegrationStep::Squash {
                    commits,
                    message: message_part
                        .map(parse_message_clause)
                        .transpose()
                        .map_err(|err| {
                            anyhow::anyhow!("line {line_number}: invalid squash message: {err}")

View on GitHub (pinned to 58e5313667)