Commits on Source 5

  • GitLab Release Tools Bot's avatar
  • Mustafa Bayar's avatar
    diff: Add whole-diff hash option to GetPatchID · 9e488fdd
    Mustafa Bayar authored
    GetPatchID computes a patch ID by piping git-diff(1) into
    `git patch-id --verbatim`. We use `--verbatim` to keep whitespace, but it
    also turns on `--stable`, which hashes each file diff on its own and adds
    the hashes together. That sum only makes the ID independent of the order
    the files appear in, and we do not need it: Gitaly generates the diff
    itself, so the order is always the same.
    
    `--unstable` hashes the whole diff at once, which is what we want, but git
    will not combine it with `--verbatim`. So this adds a whole_diff_hash
    option that skips git-patch-id(1) altogether. When it is set, Gitaly
    normalizes the diff exactly as `git patch-id --verbatim` would and hashes
    it once with SHA256. Hunk headers and "index" lines are left out so that
    line numbers and blob IDs do not change the result, which is what lets a
    patch ID survive a rebase.
    
    Our normalization matches git's in every case but one: we also hash the
    file header that ends a binary diff, which git drops. This changes
    nothing that exists today, since whole_diff_hash is new, and it only
    matters in a rare case, a mode-only change right after a binary diff.
    There git hashes nothing that identifies the file, so two patches that
    change the same binary but chmod different files get the same ID. Hashing
    the header keeps them apart.
    
    Gitaly always passes --full-index, so a binary diff should always carry
    an "index" line. A missing one is treated as an error only as a safety
    check.
    
    The diff is read with ReadSlice(3) instead of ReadBytes(3) so we do not
    allocate a string for every line. On a ~40MB diff this roughly halves the
    time and cuts allocations from about 205k to 4.
    
    The normalization is tested against git itself, not against our reading
    of git. For a single-file patch git's per-file sum equals a single hash,
    so `git patch-id --verbatim` is an exact reference. Multi-file patches are
    checked by splitting the diff per file and reproducing git's sum.
    
    Fixes: https://gitlab.com/gitlab-org/gitaly/-/issues/7350
    Changelog: added
    Co-Authored-By: default avatarClaude Fable 5 <noreply@anthropic.com>
    9e488fdd
  • Olivier Campeau's avatar
    Merge branch 'mb-backport-7350-19-2' into '19-2-stable' · a27b9819
    Olivier Campeau authored
    Add whole-diff hash option to GetPatchID
    
    See merge request gitlab-org/gitaly!9170
    
    Merged-by: Olivier Campeau's avatarOlivier Campeau <ocampeau@gitlab.com>
    Approved-by: Olivier Campeau's avatarOlivier Campeau <ocampeau@gitlab.com>
    Co-authored-by: default avatarMustafa Bayar <mbayar@gitlab.com>
    a27b9819
  • GitLab Release Tools Bot's avatar
    Update changelog for 19.2.6 · 617d36f9
    GitLab Release Tools Bot authored
    [ci skip]
    617d36f9
  • GitLab Release Tools Bot's avatar
    Update VERSION files · f2d4feb1
    GitLab Release Tools Bot authored
    f2d4feb1
Loading
Loading