Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6adb0db78d8f84537ee7861ba20ea57f276499cc
      
https://github.com/WebKit/WebKit/commit/6adb0db78d8f84537ee7861ba20ea57f276499cc
  Author: David Kilzer <[email protected]>
  Date:   2026-02-18 (Wed, 18 Feb 2026)

  Changed paths:
    M Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py
    M Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py
    M Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py
    M Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py

  Log Message:
  -----------
  git-webkit update fails when run from a git worktree
<https://bugs.webkit.org/show_bug.cgi?id=306957>
<rdar://169630851>

Reviewed by Jonathan Bedard.

The `pull()` method in `git.py` currently runs `git fetch origin
main:main` to update the local branch reference before rebasing.  Git
refuses to update a branch that is checked out in any worktree as a
safety mechanism to prevent data corruption.

To fix the bug, add an `is_worktree` property that detects git worktrees
by comparing git_directory to common_directory.  Skip the fetch call in
`pull()` when running in a worktree since `git pull origin main --rebase`
already updates the `origin/main` remote tracking ref.

Change `pull_request.py` to use the remote tracking ref `origin/main`
instead of the local `main` branch, which is always up-to-date after
the pull regardless of whether the fetch was skipped.

Fix `_maybe_update_default_branch_ref_from_fetch_head()` to read
`FETCH_HEAD` from `git_directory` instead of `common_directory` since
`FETCH_HEAD` is a per-worktree file.  This fixes a webkitscmpy warning
about non-fast-forward updates that only appeared in git worktrees.
Also add `capture_output=True` to the `filter-branch` command in
`pull()` to suppress git warnings.

* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/local/git.py:
(Git.git_directory): Add.
- Add property that returns the result of `git rev-parse --git-dir`.
(Git.is_worktree): Add.
- Add property to detect git worktrees.
(Git._maybe_update_default_branch_ref_from_fetch_head):
- Read FETCH_HEAD from git_directory instead of common_directory.
(Git.pull):
- Skip fetch call when in a worktree.
- Add capture_output=True to filter-branch command.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/mocks/local/git.py:
(Git.__init__):
- Add mock for `git rev-parse --git-dir`.
- Add is_worktree kwargs parameter and instance attribute.
(Git._fetch_with_refspec): Add.
- Add mock for worktree fetch failure.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/program/pull_request.py:
(PullRequest.create_pull_request):
- Use remote tracking ref instead of local branch.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/git_unittest.py:
(TestGit.test_is_worktree_false_for_normal_repo): Add.
- Add test for normal repository.
(TestGit.test_is_worktree_true_for_worktree): Add.
- Add test for worktree repository.
(TestGit.test_fetch_fails_in_worktree): Add.
- Add test for fetch failure in worktree.
(TestGit.test_pull_rebase_with_branch): Add.
- Add test for normal repository pull.
(TestGit.test_pull_rebase_with_branch_checked_out_in_worktree): Add.
- Add test for worktree pull.
(TestGit.test_fetch_head_in_worktree_uses_git_directory): Add.
- Add test for FETCH_HEAD read from git_directory in worktree.

Canonical link: https://commits.webkit.org/307764@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to