Zaonce...
loading...

This Planet is a Tedious Place...

23/06/16 Did that interactive git rebase work?

When I do a non-trivial interactive git rebase, I almost always want to check that there are no unexpected differences between my final commit and the original pre-rebase commit. I usually remember half way through the rebase to add a branch to the original commit, and add it using gitk, as it's handily displaying the pre-rebase history.

I've finally realised that I could make this much simpler with a hook, so I've added a local git hook (.git/hooks/pre-rebase) which contains the following:

#!/bin/sh
git branch before-rebase-`date "+%H%M%S"`


This will add the branch, named something like before-rebase-121451, for you automatically.

It will need manually removing afterwards, once you're happy, but makes it much easier to see where you were if you forgot before you started.

Once you've completed the rebase, you can just select the original commit (indicated by the branch) and compare the differences with the new head commit. It also means you can go back to the pre-rebase commit easily if the result is not what you intended.

posted by Gruntfuggly # 12:25 10 comments


04/03/16 Remembering a partially filled form

Thanks to HTML5, here's a handy snippet of jQuery which will store unsubmitted form data (text fields, texatareas and selects) so that you don't lose everything on a page refresh or when accidentally closing a window. It's also handy if you need to repeatedly submit a form with the same data.

$( "input[type=text], textarea, select" ).each( function()
{
var id = $( this ).prop( "id" ) + "-store";
var previous = localStorage.getItem( id );
if( previous !== null )
{
$( this ).val( previous );
}
$( this ).change( function()
{
localStorage.setItem( id, $( this ).val() );
} );
} );

This can be extended to checkboxes too, but it's slightly different:

$( "input[type=checkbox]" ).each( function()
{
var id = $( this ).prop( "id" ) + "-store";
var previous = localStorage.getItem( id );
if( previous !== null )
{
$( this ).prop( "checked", previous === "true" );
}
$( this ).change( function()
{
localStorage.setItem( id, $( this ).prop( "checked" ) );
} );
} );

posted by Gruntfuggly # 16:48 1 comment