Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Detect and prevent empty-diff PRs from being auto-marked as merged during stack submit

Open
#488 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
cli

Research direction

Reproduce the empty-diff stack in the issue, then trace the gh stack init and gh stack submit flows that create or submit PRs. Determine where a branch has no commits beyond its base and define whether the command should warn or stop. Done means the empty-diff case no longer gets silently auto-marked as merged, with coverage for the reported stack scenario.

Written by the indexing model from the issue text.

Description

Summary

When using gh stack, it's possible to end up with a PR whose head branch has no commits beyond its base branch (i.e., an empty diff). When this happens, GitHub automatically marks that PR as "merged" as soon as it is synchronized (e.g., via gh stack submit pushing to origin), even though no actual merge was intended.

Repro scenario

Given a stack main <- branch A <- branch B:

  1. Commit to A (intending it for B).
  2. Check out B from A without making a new commit.
  3. Push B and open PRs for A and B.
  4. Run gh stack init to adopt the two branches into a stack.
  5. Run gh stack submit.

Because B's branch contains no commits beyond A, GitHub treats the PR for B as having "no diff" against its base, and the subsequent push/synchronize causes GitHub to automatically mark PR B as merged into A — even though the user never intended or triggered a merge.

Observed example

After running gh stack init followed by gh stack submit, PR #15 (branch B) was unexpectedly shown as merged into PR #14 (branch A), because branch B had no unique commits relative to branch A.

Request

gh stack should proactively detect this situation (a branch in the stack with no commits ahead of its base) and warn or prevent the user from creating/submitting a PR in that state, rather than letting it silently get auto-merged by GitHub.

Context

Reported by @jschnapper, triaged by @skarim, in a Slack thread.

Created from a Slack conversation.

Dominant language
Go
Stars
1.5k
Forks
73
Avg merge
1d 8h
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/gh-stack

All issues in github/gh-stack

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.