Necoro’s Blog

Blog? Blog? There is no blog…

Archive for March 2010

Managing your configuration files with Git and StGit. Revisited #2

leave a comment »

Ok … I wrote about using Git and StGit and about how I ditched StGit and used plain Git. So – just a short update: I reverted back to using StGit :D. I updated the two mentioned posts.

Oh – and for my convenience, I wrote a “small” function in zsh which does the “pop, commit, push, push” cycle needed if you want to have a patch applied directly in Git and not in StGit. You can find it here (function “cci”) … or below.

cci ()
    if [[ $# == 0 ]]; then
        echo "No message given. Aborting."
        return 1

    local message=$1
    local tok=__cci__

    pushd -q ~

    cstg diff
    echo -n "Is this ok? [y/n] "
    if ! read -q; then
        echo "I would have done the wrong thing ... aborting!"
        return 2

    echo ">> Creating new patch"
    cstg new $tok -m "$message"
    echo ">> Refreshing"
    cstg refresh

    if [[ -z $(cstg files) ]]; then
        echo "Ehm - this patch is empty. Narf. Aborting!"
        echo "Deleting useless patch"
        cstg del $tok
        return 3

    echo ">> Committing"
    cstg commit $tok
    if [[ -n $(cstg series --applied) ]]; then
        echo "Urgs! Something went wrong. There are still patches applied."
        echo "Clean up for yourself. Aborting here!"
        return 4
    echo ">> Pushing to remote"
    config push

    echo ">> Re-apply patches"
    cstg push -a

    echo ">> Done"

    popd -q

Written by Necoro

March 27, 2010 at 15:28