gitproto

package
v0.0.0-...-0852f73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gitproto provides helpers for stabilizing git smart-HTTP cache keys.

Only IsUploadPackRequest and NormalizeUploadPackBody are exported; the pkt-line framing parser is an implementation detail.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUploadPackRequest

func IsUploadPackRequest(r *http.Request) bool

IsUploadPackRequest reports whether r is a smart-HTTP git-upload-pack POST. All three of method, path suffix, and Content-Type must match so that an unrelated POST sharing the URL suffix isn't routed through normalization.

func NormalizeUploadPackBody

func NormalizeUploadPackBody(data []byte) []byte

NormalizeUploadPackBody returns a stable cache-key input derived from a git-upload-pack POST body. The output is hash input only — never sent on the wire.

Stripped (per-process noise that doesn't shape the pack):

  • standalone "agent=" / "session-id=" pkt-lines (v2 capabilities)
  • inline " agent=" / " session-id=" tokens on v1 want lines

Preserved (everything that can change the upstream response): wants, haves, capabilities, command=, deepen/shallow, filter, ref-prefix, object-format, and all framing packets. Re-encoding recomputes pkt-line length prefixes, so requests differing only in a stripped value's length still hash equal.

Malformed input is returned unchanged so callers fall back to opaque hashing (cache miss is acceptable; collision is not).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL