Skip to content

Refuse to push changes with a dirty git client#155946

Open
Daniel-B-Smith wants to merge 2 commits intorust-lang:mainfrom
Daniel-B-Smith:smithdb/dirty-verify
Open

Refuse to push changes with a dirty git client#155946
Daniel-B-Smith wants to merge 2 commits intorust-lang:mainfrom
Daniel-B-Smith:smithdb/dirty-verify

Conversation

@Daniel-B-Smith
Copy link
Copy Markdown
Contributor

I've run into the issue more than once where I've fixed an issue in my client but forgotten to commit it one way or another. The verification succeeds because the files on disk are correct even though the files in the commit being pushed are incorrect.

This change checks to see if there are any uncommitted changes or untracked files in the client before running the tidy checks.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Mark-Simulacrum

@chenyukang
Copy link
Copy Markdown
Member

I'm not sure this is the way everyone need to follow, I definitely want to push to remote even there are untrack files left(for example some test files, etc), I may push to remote then git clean -fd to remove them later.

@Daniel-B-Smith
Copy link
Copy Markdown
Contributor Author

Daniel-B-Smith commented Apr 29, 2026 via email

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb/dirty-verify branch from 80ce775 to 650a1cb Compare May 5, 2026 16:09
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 5, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

This comment has been minimized.

@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb/dirty-verify branch 2 times, most recently from 91b0ccd to bc046f2 Compare May 5, 2026 16:22
@Daniel-B-Smith Daniel-B-Smith force-pushed the smithdb/dirty-verify branch 2 times, most recently from c9ad739 to 74eecd9 Compare May 5, 2026 16:58
@Daniel-B-Smith
Copy link
Copy Markdown
Contributor Author

I updated the check to ignore untracked files. PTAL

Comment thread src/etc/pre-push.sh
fi

if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
echo "error: working tree is dirty, refusing to push"
Copy link
Copy Markdown
Member

@chenyukang chenyukang May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems better:

if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
    echo "error: tracked files have uncommitted changes, refusing to push"
    echo "       commit, stash, or discard those changes first."
    echo "       untracked files are ignored by this check."
    echo "You may use \`git push --no-verify\` to skip this check."
    exit 1
fi

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants