Re: How do you deal with incomplete commits?
Am Mon, 02 Nov 2020 17:51:29 + schrieb David Jarvie : > On Monday 02 Nov 2020 18:39:52 Thomas Friedrichsmeier wrote: > > I ended up writing a local pre-commit hook, which has the advantage > > of triggering on the commit directly after "the problem commit", > > thus increasing the likelihood there is still a trivial way to sort > > things out. > > Would you mind sharing the hook which you wrote? I've had the same > dilemma as you, and your hook seems a good solution. Sure: https://invent.kde.org/-/snippets/1341 Regards Thomas pgpdEefD6jOA0.pgp Description: Digitale Signatur von OpenPGP
Re: How do you deal with incomplete commits?
On Monday, November 2, 2020 7:00:40 PM CET David Hurka wrote: > It would probably be nice to have some post-checkout commit, with which you > can spit you own WIP commit message in your face, right after you switch to > your work branch. Horrible wording, sorry. It means: It would probably be nice to have some post-checkout hook, which displays your own WIP commit message, right after you switch to your work branch.
Re: How do you deal with incomplete commits?
El lun., 2 de nov. de 2020 a la(s) 15:01, David Hurka (david.hu...@mailbox.org) escribió: > > > I ended up writing a local pre-commit hook, which has the advantage of > > triggering on the commit directly after "the problem commit", thus > > increasing the likelihood there is still a trivial way to sort > > things out. > > It would probably be nice to have some post-checkout commit, with which you > can spit you own WIP commit message in your face, right after you switch to > your work branch. > > There are update.sample and post-update.sample, but my git knowledge is > missing in this point. What is “update”? You want 'post-checkout' for this. The 'update' and 'post-update' aren't useful here, they are for the server-side of git push (see the 'githooks' manpage). > And now that we discovered that this is possible: I would like to have the > pre-commit hook globally, that would fit my workflow nicely. How can I do > that? My home directory is unfortunately not a git repository. ;) You can use ~/.gitconfig to change core.hooksPath to a central directory, but then per-repository hooks will no longer work (search hooksPath in the 'git-config' manpage). That's a shame, I hoped there would be a way to have both global and per-repo hooks... -- Nicolás
Re: How do you deal with incomplete commits?
> I ended up writing a local pre-commit hook, which has the advantage of > triggering on the commit directly after "the problem commit", thus > increasing the likelihood there is still a trivial way to sort > things out. It would probably be nice to have some post-checkout commit, with which you can spit you own WIP commit message in your face, right after you switch to your work branch. There are update.sample and post-update.sample, but my git knowledge is missing in this point. What is “update”? And now that we discovered that this is possible: I would like to have the pre-commit hook globally, that would fit my workflow nicely. How can I do that? My home directory is unfortunately not a git repository. ;)
Re: How do you deal with incomplete commits?
On Monday 02 Nov 2020 18:39:52 Thomas Friedrichsmeier wrote: > I ended up writing a local pre-commit hook, which has the advantage of > triggering on the commit directly after "the problem commit", thus > increasing the likelihood there is still a trivial way to sort > things out. Would you mind sharing the hook which you wrote? I've had the same dilemma as you, and your hook seems a good solution. -- David Jarvie. KDE developer, KAlarm author.
Re: How do you deal with incomplete commits?
Am Sun, 01 Nov 2020 09:52:27 -0800 schrieb Thiago Macieira : > On Saturday, 31 October 2020 08:25:40 PST Thomas Friedrichsmeier > wrote: > > thanks for your answer (also to Nate). But to clarify, my question > > is really: How do I _force_ myself to clean up in time? > > If you're pushing to a code review system of any kind, it doesn't > matter. First, you should always review what you've sent for review > anyway and you can notice you pushed something incomplete. At that > point don't create the review request or write that it isn't yet > ready for review. > > Second, your reviewers should notice it's incomplete and won't > approve. Well, the context that I'm worrying about, here, is one where reviews are not mandatory and not the norm. I ended up writing a local pre-commit hook, which has the advantage of triggering on the commit directly after "the problem commit", thus increasing the likelihood there is still a trivial way to sort things out. (For good measure I also activated the pre-push hook as mentioned by Nicolas.) Thomas pgpyYsBFzYQzr.pgp Description: Digitale Signatur von OpenPGP
Re: How do you deal with incomplete commits?
On Saturday, 31 October 2020 08:25:40 PST Thomas Friedrichsmeier wrote: > thanks for your answer (also to Nate). But to clarify, my question is > really: How do I _force_ myself to clean up in time? If you're pushing to a code review system of any kind, it doesn't matter. First, you should always review what you've sent for review anyway and you can notice you pushed something incomplete. At that point don't create the review request or write that it isn't yet ready for review. Second, your reviewers should notice it's incomplete and won't approve. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DPG Cloud Engineering
Re: How do you deal with incomplete commits?
El sáb., 31 de oct. de 2020 a la(s) 15:19, Thomas Friedrichsmeier (thomas.friedrichsme...@kdemail.net) escribió: > > Am Sat, 31 Oct 2020 17:09:22 +0100 > schrieb David Hurka : > > Maybe you could write your own commit hook, which prevents commiting > > anything when `git log --oneline` matches, say /\A INCOMPLETE/x. > > Hm, true, it doesn't have to be a server-side hook. Thanks for pointing > me in the right direction. > > Thomas I was going to try writing a client-side hook to block pushes if the commit message has a certain keyword, but I found the pre-push.sample included with git already does *exactly* that :D All you need to do is rename .git/hooks/pre-push.sample to remove the .sample suffix. -- Nicolás
Re: How do you deal with incomplete commits?
Am Sat, 31 Oct 2020 17:09:22 +0100 schrieb David Hurka : > Maybe you could write your own commit hook, which prevents commiting > anything when `git log --oneline` matches, say /\A INCOMPLETE/x. Hm, true, it doesn't have to be a server-side hook. Thanks for pointing me in the right direction. Thomas pgpzsSvcguO9R.pgp Description: Digitale Signatur von OpenPGP
Re: How do you deal with incomplete commits?
On Saturday, October 31, 2020 4:38:09 PM CET Thomas Baumgart wrote: > Hi, > > On Samstag, 31. Oktober 2020 16:24:51 CET Thomas Friedrichsmeier wrote: > > Hi, > > > > thanks for your answer (also to Nate). But to clarify, my question is > > really: How do I _force_ myself to clean up in time? > > Reading your question over and over, I don't see where git is mentioned :) > This leads to a short answer: self-discipline. > > My impression is that you look for a some magic feature in git that forces > you to clean up in time. Not sure if something like that exists. Maybe you could write your own commit hook, which prevents commiting anything when `git log --oneline` matches, say /\A INCOMPLETE/x.
Re: How do you deal with incomplete commits?
Hi, Am Sat, 31 Oct 2020 16:38:09 +0100 schrieb Thomas Baumgart : > Reading your question over and over, I don't see where git is > mentioned :) This leads to a short answer: self-discipline. > > My impression is that you look for a some magic feature in git that > forces you to clean up in time. Not sure if something like that > exists. fair enough. And yes, I am looking for some magic feature in git. If that doesn't yet exist, then how about adding a hook (server-side) that will reject any commit containing "NOPUSH" (or whatever) in the commit message, though? Of course, if I'm the only one to be this sloppy, I'll have to resort to the knots-in-the-handkerchief-method, after all... Thomas pgpLnbKIjzqud.pgp Description: Digitale Signatur von OpenPGP
Re: How do you deal with incomplete commits?
Hi, On Samstag, 31. Oktober 2020 16:24:51 CET Thomas Friedrichsmeier wrote: > Hi, > > thanks for your answer (also to Nate). But to clarify, my question is > really: How do I _force_ myself to clean up in time? Reading your question over and over, I don't see where git is mentioned :) This leads to a short answer: self-discipline. My impression is that you look for a some magic feature in git that forces you to clean up in time. Not sure if something like that exists. > Am Sat, 31 Oct 2020 15:44:35 +0100 > schrieb Thomas Baumgart : > > > On Samstag, 31. Oktober 2020 13:39:04 CET Thomas Friedrichsmeier > > wrote: > > [...] > > > > Say I'm working on a feature in branch A. I have some changes in my > > > working copy that are so half-baked that I don't want them to end > > > up in the commit history as such, but I don't want to throw them > > > away, either. > > > > I assume, you don't thing about pushing those at all. > > Right, I do not intend to push those, but I'm afraid, I might (esp. in > case I'm returning to my work days, weeks or even months, later). So > I'm looking for a way to stop myself from doing so. -- Regards Thomas Baumgart https://www.signal.org/ Signal, the better WhatsApp - My friend couldn't afford to pay his water bill. So I sent him a 'get well soon' card. - signature.asc Description: This is a digitally signed message part.
Re: How do you deal with incomplete commits?
Hi, thanks for your answer (also to Nate). But to clarify, my question is really: How do I _force_ myself to clean up in time? Am Sat, 31 Oct 2020 15:44:35 +0100 schrieb Thomas Baumgart : > On Samstag, 31. Oktober 2020 13:39:04 CET Thomas Friedrichsmeier > wrote: [...] > > Say I'm working on a feature in branch A. I have some changes in my > > working copy that are so half-baked that I don't want them to end > > up in the commit history as such, but I don't want to throw them > > away, either. > > I assume, you don't thing about pushing those at all. Right, I do not intend to push those, but I'm afraid, I might (esp. in case I'm returning to my work days, weeks or even months, later). So I'm looking for a way to stop myself from doing so. Thomas pgpYXFleXij8C.pgp Description: Digitale Signatur von OpenPGP
Re: How do you deal with incomplete commits?
Work branches or a branch in a personal fork seem appropriate for this, and then you can interactively rebase to clean up the history before you submit a merge request. That's what I do. Nate
Re: How do you deal with incomplete commits?
Hi Thomas, On Samstag, 31. Oktober 2020 13:39:04 CET Thomas Friedrichsmeier wrote: > Hi all, > > may I pick your brains for this question that keeps coming up for me? > > Say I'm working on a feature in branch A. I have some changes in my > working copy that are so half-baked that I don't want them to end up in > the commit history as such, but I don't want to throw them away, either. I assume, you don't thing about pushing those at all. > Now I want to switch to branch B for something unrelated. What do I do > with my changes? How do you folks deal with this? > > 1) Stash my changes, then switch. Works, but the stash is something > that I tend to forget about, when going back, and this method get > messy, quickly, when dealing with several branches at once. > > 2) Commit the changes, anyway, but marked as "WIP" or similar, and use > commit --amend, when coming back. However, it wouldn't be the first > time that I forgot to amend, after all, and pushed my WIP-commits. > > 2a) I could use a "work/" branch, which would at least give me a chance > to correct this after pushing. I'd still have to remember to do so, > before merging my work into a regular branch, though. > > 2b) What I'd really like to see is a commit keyword that would make git > throw an error, if I try to commit something on top of it, thus forcing > me to use commit --amend. > > 2c) Alternatively, do we have a keyword that would prevent a commit > from being pushed (or from being merged to something that is not a > "work/" branch)? That would not be as nice as 2b, IMO, but it would > still catch my usual mistakes. > > Any other solution that I am missing? Do we have something along the > lines of 2c (not according to our docs, AFAICS)? You can use interactive rebase of those unpushed commits so that the ones belonging to each other form a single one (so to say post commit --amend). I sometimes do that to cleanup the history (when I forgot to --amend). -- Regards Thomas Baumgart https://www.signal.org/ Signal, the better WhatsApp - If your on the hunt for helping hands, look down your arms -- unknown source - signature.asc Description: This is a digitally signed message part.