News for hackers. Stuff that matters.
Re:Why SQLite Does Not Use Git by amerkhalid on Tuesday April 10, 2018 @10:32PM (#16807587)
I am not a git expert or anything, but I have helped resolve weird git issues for my teammates usually using a lot of Google and StackOverflow.

I just know 5 basic commands; pull, push, commit, branch, and merge. Never ran into any issues. People who run into issues are usually editing git log or doing something fancy with “advanced” commands. I have a feeling that these people get into trouble with git cause they issue commands without really knowing what those commands do or even what they want to achieve.

Re:Why SQLite Does Not Use Git by flatline on Tuesday April 10, 2018 @10:58PM (#16807694)
Start working in a repo with submodules and you suddenly have to understand a lot more and can get into trouble with no idea how you did it.
Re:Why SQLite Does Not Use Git by xxpor on Wednesday April 11, 2018 @12:12AM (#16807970)
I use submodules every day, never had a problem with them. What do people complain about when it comes to them?

My mental model is basically that they're separate repos, and the main repo has a pointer to a commit in the submodule. Do your work that needs to be done for the submodule, push your changes, and then check out that new commit. Make a commit in the main repo to officially bump the submodule to that new commit. Done.

The annoying part is when you do a pull on the main repo, you have to remember to run git submodule update --recursive.

Re:Why SQLite Does Not Use Git by friend-monoid on Wednesday April 11, 2018 @03:00AM (#16808709)
Because you have the .gitmodules file, the .git/config file, the index, and .git/modules directory, each of which can get out of sync with the others.

If, for example, you add a submodule with the wrong url, then want to change the url, then you instinctively change .gitmodules. But that won't work, and it won't even nearly work.

If you add a submodule, then remove it, but not from all of those places, and try to add the submodule again (say, to a different path), then you also get wierd errors.

If you add a submodule and want to move it to another directory then just no.

Oh and also one time a colleague ran into problems because he had added the repo to the index directly - with git add ..

Oh and let's talk about tracking submodule branches and how you can mess that up by entering the submodule directories and running commands...

Re:Why SQLite Does Not Use Git by AstralStorm on Wednesday April 11, 2018 @04:02AM (#16808978)
Why do you want to bypass the tool at the first glance? Git submodule command has a way to update these urls...
Re:Why SQLite Does Not Use Git by friend-monoid on Wednesday April 11, 2018 @12:11PM (#16812589)
Heh, good question.

But seriously, the fact that there is a .gitmodules file lulls you into a sense that that file is "the configuration file". If you don't know about these other files, then it's natural to edit .gitmodules. When you make errors, the fixing those errors are pretty hard. There is no "git submodule remove x" or "git submodule set-url" or "git submodule mv".

For example, do you know how, on the top of your head, to get an existing submodule to track a branch?

How do you think someone who does not quite understand git would do it? Even with a pretty ok understanding of git infernal, you can put yourself deep in the gutter. (case in point, if you enter the submodule directory and push head to a new commit, you can just "git add submodule-directory" to get point the submodule to the new commit. But if you were to change upstream url or branch or something else in the submodule, you're screwed. That's not intuitive by a long shot)

Edit: git submodule sync is not enough by the way... You can fuck up your repo like crazy even if you sync the two configuration files.

Re:Why SQLite Does Not Use Git by flatline on Wednesday April 11, 2018 @12:51AM (#16808133)
Right, it’s not that hard, but there are some gotchas. The most common problem I see is the local submodule being out of sync with the remote superproject. Pushes across submodules are not atomic. Accidentally working from a detached head then trying to switch to a long out of date branch can be an issue, as can keeping multiple submodules synced to the head on the same branch. Recursive submodules are, as you mentioned, even more fun.
Re:Why SQLite Does Not Use Git by AstralStorm on Wednesday April 11, 2018 @04:06AM (#16808994)
The same problem appears in any non monolithic project. In any SCM I know of.

Git subrepo or subtree are some of a solution but not quite complete and easy to use.

In some other scms (P4 and SVN, partly hg) the answer is don't do that, which had a whole lot of its own problems.

Re:Why SQLite Does Not Use Git by chris_wot on Wednesday April 11, 2018 @02:39AM (#16808606)
Oh, so that's what you do!
Re:Why SQLite Does Not Use Git by xxpor on Wednesday April 11, 2018 @11:11AM (#16811883)
Heh, I probably made it sound more complicated than it really is. Just think of it as a pointer that needs to be manually updated.
Re:Why SQLite Does Not Use Git by relics443 on Tuesday April 10, 2018 @11:10PM (#16807734)
I'm comfortable with most advanced git stuff. I don't touch submodules.
Re:Why SQLite Does Not Use Git by _pmf_ on Wednesday April 11, 2018 @02:56AM (#16808701)
> I don't touch submodules.

What's the alternative? Managing all dependencies by an external dependency manager does not exactly reduce complexity (if you're not within a closed ecosystem like Java + Maven that has a mature, de-facto standard dependency manager; npm might count, too).

It's absolutely not feasible for C++ projects; all projects that do this have horrible hacks upon hacks to fetch and mangle data and usually require gratuitous "make clean"s to untangle.

Re:Why SQLite Does Not Use Git by buserror on Wednesday April 11, 2018 @08:02AM (#16810231)
I use git sub-trees. Actually I love the thing. They give you a 'linear' history, and allow you to merge/pull/push into their original tree, keeping the history (if you require it).
Re:Why SQLite Does Not Use Git by _pmf_ on Wednesday April 11, 2018 @09:31AM (#16810874)
Never heard of them (well, probably in passing); will look into is. Thanks!
Re:Why SQLite Does Not Use Git by yawaramin on Saturday April 14, 2018 @03:05PM (#16838870)
Why isn't it feasible for C++ projects?
Re:Why SQLite Does Not Use Git by lilbobbytables on Tuesday April 10, 2018 @11:11PM (#16807735)
Oh you can fuck right off with submodules!
Re:Why SQLite Does Not Use Git by greasyjon1 on Wednesday April 11, 2018 @12:39PM (#16812878)
^^^ this comment is supposed to be humor, not douchebaggery, by the way. Easy on the downvotes.
Re:Why SQLite Does Not Use Git by nurettin on Wednesday April 11, 2018 @12:44AM (#16808101)
I never had any problems the past 6 years I've been using Git professionally. But then someone asked me what to do when Git prevents you from changing branches and not knowing they did not stage, I told them to stash or commit. They stashed and the changes were gone.

My point is, while your basic commands do the work, your habits and knowledge keep you from losing code like this without you knowing.

Re:Why SQLite Does Not Use Git by bonzini on Wednesday April 11, 2018 @01:49AM (#16808379)
Why were the changes gone? Why couldn't they "git stash pop"?
Re:Why SQLite Does Not Use Git by nurettin on Wednesday April 11, 2018 @03:26AM (#16808820)
Unstaged or untracked changes were gone. They couldn't get those back after pop. I can't remember which.
Re:Why SQLite Does Not Use Git by amalag on Wednesday April 11, 2018 @09:01AM (#16810652)
Untracked files are not stashed, that is true.
Re:Why SQLite Does Not Use Git by bonzini on Thursday April 12, 2018 @11:05AM (#16821654)
They're also not deleted by "git stash" though.
Re:Why SQLite Does Not Use Git by TomK32 on Wednesday April 11, 2018 @02:48AM (#16808649)
Is no one reading git's help pages before running a command the first time?

Not even once I lost I code worked on with git. stash is a reliable companion across branches and large timespans.

Re:Why SQLite Does Not Use Git by mrweasel on Wednesday April 11, 2018 @02:42AM (#16808622)
I do like Git, most of the time, but really, not a single problem, in six years?

When using Git daily we never really did anything complicated, just a few feature branches per developer, commit, push, pull-request, merge. Basic stuff. We had Git crap out all the time. Never something that couldn't be fixed, but sometimes the fix was: copy your changes somewhere else, nuke your local repo, clone, copy changes in and then commit an continue as normal.

Re:Why SQLite Does Not Use Git by dbt00 on Wednesday April 11, 2018 @03:23AM (#16808800)
I’ve been using git since 2007 and never ever even wanted to try nuking a checkout and starting over to recover from anything, much less did so. (Did have a nameless terrible Java ide plug-in do it for me once.)
Re:Why SQLite Does Not Use Git by Ace17 on Wednesday April 11, 2018 @01:37AM (#16808342)
So you're not using checkout, reset, and diff?
Re:Why SQLite Does Not Use Git by amerkhalid on Wednesday April 11, 2018 @09:53AM (#16811053)
Good point, forgot about checkout, diff, clone, blame, add, rm, rebase, init, and probably a few more.

Haven't used reset personally though but only when trying to fix someone's repo.

Re:Why SQLite Does Not Use Git by e12e on Wednesday April 11, 2018 @01:56AM (#16808409)
Or fetch?
Re:Why SQLite Does Not Use Git by OJFord on Wednesday April 11, 2018 @02:11AM (#16808481)
I think a lot of people ignore fetch and only ever pull.
Re:Why SQLite Does Not Use Git by e12e on Wednesday April 11, 2018 @12:27PM (#16812744)
I think it's the most important sources of my cognitive dissonance around git. It strengthens the illusion that a working directly is somehow related to a git store, which it really isn't.

You have a working directly/checkout - that can be: identical (apart from ignored files) to some version in git; or different.

If it's different ; some or all changes can be marked for storing in the git repo - most commonly as a new commit.

It's a bit unfortunate that the repo typically is inside your work directory/checkout - under '.git' along with some files like hooks, that are not in the repo at all...

Re:Why SQLite Does Not Use Git by TomK32 on Wednesday April 11, 2018 @02:44AM (#16808631)
But you'd have to stash before pull. At least with my config where a pull will rebase automatically.
Re:Why SQLite Does Not Use Git by OJFord on Wednesday April 11, 2018 @08:58AM (#16810623)
I use `git config pull.rebase true` too, but that doesn't mean you _have_ to stash first, just as rebase manually wouldn't - depends if there's a conflict.

Same is true of merge-based pull.

Re:Why SQLite Does Not Use Git by e12e on Wednesday April 11, 2018 @02:50PM (#16814218)
Except for saving some typing, is there any benefit to stash over local branches?

In other words, shouldn't git just fix ux for branches and rip out stash?

Re:Why SQLite Does Not Use Git by OJFord on Wednesday April 25, 2018 @01:50AM (#16918887)
So "some typing" would be:

    # git stash:
    prev_ref="$(git rev-parse --abbrev-ref HEAD)"
    git checkout -b wip-stash
    git add .
    git commit -m 'wip stuff'
    git checkout "$prev_ref"
    
    # git stash pop:
    git checkout wip-stash -- .
    git checkout -D wip-stash
It's quite a considerable saving. I suppose by "fix UX" you mean make it so the saving would be less anyway, but I think really they're just conceptually different:

    - branch: pointer to a line of history, i.e. a commit and inherently its ancestors
    - stash: a single commit-like dump of patches
If stashing disappeared from git tomorrow, I think I'd use orphan commits rather than branches to replace it.
Re:Why SQLite Does Not Use Git by _pmf_ on Wednesday April 11, 2018 @02:48AM (#16808648)
pull == "just fuck my shit up"
Re:Why SQLite Does Not Use Git by whym on Tuesday April 10, 2018 @11:12PM (#16807738)
EDIT: I guess I misread it. On reflection what I wrote really doesn't make sense so let me retract.
Re:Why SQLite Does Not Use Git by jhall1468 on Tuesday April 10, 2018 @11:26PM (#16807796)
`cherry-pick` is just plucking a single commit and adding it the commit history of the current branch, and `rebase` is what civilized people use when they don't want merge commits plaguing their entire code base.
Re:Why SQLite Does Not Use Git by YZF on Wednesday April 11, 2018 @12:07AM (#16807953)
merge is what civilized people who care about getting history and context in their repository use ;) ... I worked a lot in git using both rebase and merge workflows and I'll be darned if I understand the fear of the merge commit ... If work happened in parallel, which it often does, we have a way of capturing that so we can see things in a logical order ...
Re:Why SQLite Does Not Use Git by jhall1468 on Wednesday April 11, 2018 @11:03AM (#16811772)
Polluting the master repo with a bunch of irrelevant commits isn't giving you context, it's giving you pollution. There's nothing to fear about merge commits. It's about wasting everyone's time by adding your 9 commits to fix a single bug to the history. I work on teams, and we care about tasks. The fact that your task took you 9 commits is irrelevant to me. What is relevant is the commit that shows you completed the task.
Re:Why SQLite Does Not Use Git by sameerds on Wednesday April 11, 2018 @01:54AM (#16808396)
It's not really a fear of the merge commit. In a massively collaborative project, almost everything is happening in parallel, and most of that history is not important. The merge makes sense when there is an "official" branch in the project, with a separate effort spent on it. It's likely that people working on that branch rebase within the branch when collaborating, and then merge the branch as a whole when it is ready to join the mainstream.
Re:Why SQLite Does Not Use Git by buserror on Wednesday April 11, 2018 @08:08AM (#16810271)
Ah, you can learn the beauty of merge AND rebase at the same time then...

Here to 'present' feature branches, we take a feature development branch will all the associated crud... Once it's ready to merge, the dev checkouts a new 'please merge me' branch, resets (or rebase -i --autosquash) to the original head, and re-lay all the changes as a set of 'public' commits to the subsystems, with proper headings, documentation etc.

At the end, he has the exact same code as the dirty branch, but clean... So he merges --no-ff the dirty branch in (no conflicts, same code!) and then the maintainer can merge --no-ff that nice, clean branch in the trunk/master.

What it gives us is a real, true history of the development (the dirty branch is kept) -- and a nice clean set of commits that is easy to review/push (the clean branch).

Re:Why SQLite Does Not Use Git by salt-licker on Wednesday April 11, 2018 @02:02AM (#16808441)
Sometimes I want to take a subset of the commits out of a coworker's merge on staging to push to production, and then put all non-pushed commits on top of the production branch to form a new staging branch. I find having a linear history with no merges helpful for reasoning about conflict resolution during this process. What advantages do merged timelines give in this context?
Re:Why SQLite Does Not Use Git by YZF on Sunday April 15, 2018 @08:15PM (#16845806)
What I like about merges it that it shows you how the conflicts were resolved. You can see the two versions and the resolved and you can validate it was resolved properly. With a rebase workflow you see the resolutions as if nothing else existed, you can't tell the difference between an intentional change and a bad resolution...
Re:Why SQLite Does Not Use Git by jsjohnst on Wednesday April 11, 2018 @01:05AM (#16808208)
> merge is a what civilized people who care about getting history and context in their repository use

> I'll be darned if I understand the fear of the merge commit

I apologize in advance for not adding much substance in this reply, but I agree too much to just upvote alone.

Re:Why SQLite Does Not Use Git by johnx123-up on Wednesday April 11, 2018 @01:54AM (#16808397)
Just curious... are you working in a team using git workflow?
Re:Why SQLite Does Not Use Git by amerkhalid on Wednesday April 11, 2018 @09:58AM (#16811108)
Yes, my direct team is small of 4 devs but the main repo we work on is used by 100+ devs. We use git workflow (new branch for each feature) for the main repo and github style workflow (clone and then submit PR) for some other repos.