News for hackers. Stuff that matters.
Re:What comes after Git by kadoban on Tuesday July 05, 2022 @01:53AM (#31984792)
That's just a convenience command. Git doesn't actually record moves as anything different from a delete and an add. Many of the querying commands (eg `git log`) use heuristics to show moved files, but they end up wrong fairly often, especially if you don't mess with the parameter(s) of the heuristics.
Re:What comes after Git by saxonww on Tuesday July 05, 2022 @02:02AM (#31984850)
In my experience they are correct all of the time for simple renames. It's when you move a file and make substantial edits that it gets confused.

I think it's reasonable to argue that git shouldn't get confused in this scenario, but you could also do your renames in one commit and your changes in another.

Re:What comes after Git by Akronymus on Tuesday July 05, 2022 @02:42AM (#31985095)
Would it make sense to make one commit for the move and one for the changes?
Re:What comes after Git by jraph on Tuesday July 05, 2022 @03:02AM (#31985218)
I wish I didn't have to think about it and git supported file renaming properly so a unit of change that hasn't much sense when it is split can stay a unit, but without it yes, I think it makes sense to commit renames separately so history can be tracked more easily.

I think git can be configured on how hard it tries to find renames from similarity between a deleted file and an added file.

Re:What comes after Git by kruador on Tuesday July 05, 2022 @07:03AM (#31986726)
No, it makes no difference. Git doesn't look at the full history when performing a merge, it just looks for similarity between the paths and files in the commits being merged, and the common base commit (which you can discover by running `git merge-base`). It doesn't keep any metadata about whether something was a move: as far as the actual data structures are concerned, you deleted file a/b/c and added file d/e/f, that have the same file content hash.

You can find more information on how Git now does it at https://blog.palantir.com/optimizing-gits-merge-machinery-1-... . I think this first started to be released in v2.31.0, and completed in v2.33.0. v2.34.0 switched the default merge strategy to the new 'ort' strategy mentioned in that blog.

Re:What comes after Git by avar on Tuesday July 05, 2022 @09:03AM (#31987708)
The "git log" "follow renames" logic isn't the same as conceptually related merge logic.

I think there are unfortunately still cases where what the GP is suggesting improves the UX, i.e. I think some shortcuts are taken when following a file if the content doesn't change.

IIRC this matters particularly for very large renames, at some point during revision walking we'll give up trying to match your A.txt to B.txt, but if they're the same...

Re:What comes after Git by tsimionescu on Tuesday July 05, 2022 @04:13AM (#31985674)
No, because you often have to make changes to the file to get it to compile after loving to a new location. It's much more annoying to review history with changes that can't possibly compile.
Re:What comes after Git by kadoban on Tuesday July 05, 2022 @04:20AM (#31985720)
This isn't necessarily an issue, depending on what you mean by "review". The one case I really run into is bisects, but even for that you can tell it to just skip commits that won't build.
Re:What comes after Git by bloak on Tuesday July 05, 2022 @03:37AM (#31985434)
Yes, in some cases, but it depends on your workflow. Some projects require each commit on the main branch to be fully working and pass all the tests.
Re:What comes after Git by shikoba on Tuesday July 05, 2022 @03:58AM (#31985576)
> It's when you move a file and make substantial edits that it gets confused.

It's your POV that it's the same file. One could argue that it's a new file and the content of the old one embed in the file. That's the huge problem with git users, people cling desperately to the idea of changes, when git is just about snapshots.

Re:What comes after Git by tsimionescu on Tuesday July 05, 2022 @04:12AM (#31985669)
People "cling desperately" to the way they are actually working. That Git uses an alien model that happens to somewhat match what I'm doing doesn't mean I'm "desperately clinging" to the actual reality of what I'm doing (editing a file).
Re:What comes after Git by shikoba on Tuesday July 05, 2022 @07:38AM (#31986986)
So if someone creates a new file and integrate the content of the old file to reach the same folder state than yours, you think s/he does something different?
Re:What comes after Git by tsimionescu on Tuesday July 05, 2022 @09:18AM (#31987868)
Yes? Editing a file is different from creating a new file with some code copied from somewhere else, obviously. They may reach the same end state, but that doesn't make them the same operation.

It also happens that one is much, much more common in software development than the other, so it's a much better mental model of what SEs do.

Re:What comes after Git by shikoba on Tuesday July 05, 2022 @09:55AM (#31988224)
> They may reach the same end state, but that doesn't make them the same operation.

So you're clinging to your mental model. Thanks for proving my point.

Re:What comes after Git by tsimionescu on Wednesday July 06, 2022 @12:49AM (#31996848)
This is how work is actually done, and my mental model matches how I and my colleagues and yours as well actually work.

I could contort my mental model to make it match how Git works, but it is a contortion that some tool imposes on me.

We work in computing, I would expect everyone's mental models to be computational, not equational - different algorithms with the same result are still different. QuickSort is not the same as Merge sort just because they have the same inputs and outputs.

Re:What comes after Git by shikoba on Wednesday July 06, 2022 @03:16AM (#31997792)
The issue is that the path you used to go from A to B is yours, one could use a totally different path. But what really matters is that your product is now in state B. That's what you ship, not the path.
Re:What comes after Git by kadoban on Tuesday July 05, 2022 @09:47AM (#31988138)
Git has both concepts, snapshots and changes. You'd have to contort yourself more than a bit to describe common uses of "git rebase" without viewing it as changes, for instance.

You may be aluding to git's underlying storage being snapshot based, but it actually also has diffs in pack files.

Re:What comes after Git by shikoba on Tuesday July 05, 2022 @09:55AM (#31988219)
> but it actually also has diffs in pack files

Storage optimization, absolutely unrelated to the diff between two snapshots.

Re:What comes after Git by kadoban on Tuesday July 05, 2022 @10:54PM (#31996199)
The semantic layer uses both, and the implementation layer uses both. Saying that it's one or the other just seems misguided.
Re:What comes after Git by shikoba on Wednesday July 06, 2022 @03:18AM (#31997811)
I don't understand your point. Mine was just that git could decide to store only snapshots, it would change nothing except for low level commands that deal directly with objects storage.