4 ms·
You're right that the commit produced by the cherry-pick operation won't be identical to the commit being cherry-picked. It's the diffs that are identical, not
by MaxBarraclough 6y ago
You're right that the commit produced by the cherry-pick operation won't be identical to the commit being cherry-picked. It's the diffs that are identical, not the final result.
It's analogous to how the difference between 5 and 15 is equal to the difference between 105 and 115.
- recursive 6y agoThat doesn't help. The result of subtraction is defined to be a number. The result of a diff is... a nebulously defined concept that somehow describes the changes. It's not clearly (to me) defined which parts of the files are considered to part of the diff and which parts are to be excluded.
- MaxBarraclough 6y ago> The result of subtraction is defined to be a number. A diff shows the difference between two commits (i.e. snapshots). Perhaps a better math analogy: one point can be subtracted from another to give a vector. > It's not clearly (to me) defined which parts of the files are considered to part of the diff and which parts are to be excluded. You're right that it's not precisely defined in that way, but there's a good reason for this. If you move the top line of a file to the bottom, should the diff tool show you that one line was deleted and one new line was added (i.e. that one line having been moved), or should it show all the other lines in the file as having been deleted and re-added in a different place? Both are valid interpretations of the difference between the two snapshots, but of course a real-life diff tool will show the former, as that's what's helpful to the user.
- recursive 6y agoI'm glad that real-life diff tools work in ways that they deem to be useful. But they don't always produce the most sensible result. In fact different algorithms produce different diff visualizations for the same input. I'm just a little uncomfortable with a feature that uses diffs for purposes other than display for humans, since they don't seem to be consistently defined.
- MaxBarraclough 6y ago> I'm just a little uncomfortable with a feature that uses diffs for purposes other than display for humans, since they don't seem to be consistently defined. Sure, I see your point as it applies to cherry-picks/rebasing. Yes, there's no formal guarantee it will do as you expect. The user should always check it manually. Occasionally it doesn't do what you want. I'm of the opinion git cherry-pick should default to behaving like git cherry-pick --no-commit for that reason. edit: > they don't always produce the most sensible result I don't know how much work has been done on language-aware diff/merge algorithms, but I can't see an obvious reason for it to be a dead-end.
- tsimionescu 6y ago> I'm just a little uncomfortable with a feature that uses diffs for purposes other than display for humans Git is based on the idea that it is generally safe to do that. You can't do any kind of work with git other than commits on your own local repo without relying on diffs and merges based on diffs.
- vmchale 6y ago> It's analogous to how the difference between 5 and 15 is equal to the difference between 105 and 115. Patches are torsors? :o
- recursive 6y agoI don't know what it means, but I recall seeing that word once before. That was in the context of explaining git also, so there's probably something to it. https://news.ycombinator.com/item?id=25122863 https://news.ycombinator.com/item?id=25122863