Stav Alfi
Stav Alfi

Reputation: 13923

Conflicts from apply and stash

While reading some tutorials/stackoveflow content, I read that conflicts can also occur with stash and apply.

For example: (From git-scm/git-apply---3way

-3

--3way

When the patch does not apply cleanly, fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to, and we have those blobs available locally, possibly leaving the conflict markers in the files in the working tree for the user to resolve. This option implies the --index option, and is incompatible with the --reject and the --cached options.

Is When the patch does not apply cleanly equal to getting conflicts?

How can we get conflicts not from merging operations? Are those conflicts any different then merge conflicts? I would love to see some graph examples.

Upvotes: 3

Views: 313

Answers (1)

VonC
VonC

Reputation: 1324318

Is When the patch does not apply cleanly equal to getting conflicts?

No: it is not applied "cleanly" when it cannot find the "context" of a hunk (set of lines on a patch) in the target file (the one where you apply the patch).
A patch is using "context diffs" and "unified diffs" (also known as "unidiffs"), which surround each change with context lines (lines that are supposed to be before and after the modification to apply), as well as range (line number where the modification occurs). A patch can then use this "context" to locate the region to be patched even if it has been displaced by changes earlier in the file, using the line numbers in the diffs as a starting point.

But if the modifications of the target do interfere with the patch (meaning: if the context is no longer there in the target file, because of modified or deleted lines), then it (the patch) does not apply cleanly.

How can we get conflicts not from merging operations?

You only get merge conflict when switching to a 3-way merge.
In that case, you have a common ancestor which gives you the ability to know whether or not a chunk is a change from the origin and whether or not changes conflict.
See more on the three-way merge in "Guiffy SureMerge - A Trustworthy 3-Way Merge".

https://www.guiffy.com/images/3waydiag.jpg

Upvotes: 3

Related Questions