Skip to content

Main content

Git Diff Hunk New Line Span Tool

Calculate git diff hunk new line span from explicit caller-supplied inputs.

Loading tool…

Description

Return the new-side half-open span from a restricted diff hunk header.

Git and diff tokens encode references, object metadata and patch coordinates. Parsing a local token does not resolve repository objects, establish identity or prove that a patch is complete or applicable.

Return the new-side half-open span from a restricted diff hunk header.

When to use this tool

Use Git Diff Hunk New Line Span when inspecting the stated bounded Git or patch token.

How to use the tool and how it works

  1. Enter header. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read start, count, endExclusive. Use the output convention below.

Return the new-side half-open span from a restricted diff hunk header. Parse the plus range, default omitted count to one, require nonnegative safe start/count and return endExclusive = start+count.1

Input fieldMeaning and unitsAccepted input
headerHeaderRequired. Text; maximum UTF-16 length 8192.
Output fieldInterpretationReturned shape
startStartRequired. Safe integer.
countCountRequired. Safe integer.
endExclusiveEnd ExclusiveRequired. Safe integer.
json
{
  "input": {
    "header": "@@ -1,3 +5,4 @@"
  },
  "output": {
    "start": 5,
    "count": 4,
    "endExclusive": 9
  }
}

Limitations and assumptions

  • Old-side numeric fields are only syntactically matched; no hunk body or patch applicability is verified.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Use Git itself against the intended repository for object resolution, complete validation, history interpretation or patch application.

References

  1. Calculation and input contract: development/git-diff-hunk-new-line-span — tool.io

Similar or alternative tools