Frage

Let's say we have 5 patches for a file, and 4 of the patches changed the file content and add new lines. But we can still apply a single patch 5 to the git tree. Why? Since I thought the line numbers has changed, and so the line contents didn't match any more. How does git determine which line I made a change? Through the three line context of the change? I don't think it is plausible.

BTW, how to generate a number zero patch like [PATCH 0/5]? It seems format patch can only generate from 0001.

War es hilfreich?

Lösung

Through the three line context of the change?

This is how git apply describes it:

Ensure at least <n> lines of surrounding context match before and after each change.
When fewer lines of surrounding context exist they all must match.

So yes, even if the line numbers changed, the context is still key in determining if a patch should apply or not.


Regarding the numbering aspect, I didn't test, but see if the --start-number option of git format-patch command can help:

--start-number <n>

Start numbering the patches at <n> instead of 1.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top