Re: wsfix alias

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Andreas Ericsson (ae@xxxxxx) [090709 16:54]:
> Larry D'Anna wrote:
>> * Andreas Ericsson (ae@xxxxxx) [090709 03:04]:
>>> I do have one alias, which is "wsfix". It fixes whitespace fsckups I've
>>> added to the index but not yet committed to the worktree. It's not a
>>> particularly complex one, but not exactly simple either.
>>
>> oooh, i can has?
>>
>>       --larry
>
> These are quite stupid and can lose data for you. Please use with some care.
> Oh, and I lied. I have two aliases. wsfixi is the one that applies staged
> stuff. wsfix fixes all whitespace errors since the last commit and stages
> all changes in the index. Again, use with care, and don't hang me if they
> break your day ;-)
>
> Mind the wrapping if your mua does things like that.
>
> [alias]
>  wsfix = !git diff HEAD >P.diff && git reset --hard && git apply --whitespace=fix P.diff && rm -f P.diff
>  wsfixi = !git diff --cached >P.diff && git reset && git apply --whitespace=fix P.diff && rm -f P.diff

a safer one: 

xargs -0 -I: <<'EOF' git config --file ~/.gitconfig alias.wsfix :
!
. "$(git --exec-path)"/git-sh-setup
if git-diff --quiet --exit-code; then
    if git diff --cached --check >/dev/null; then
        exit 0;
    fi
    echo fixing
    git diff --cached > $GIT_DIR/wsfix.diff
    git apply -R $GIT_DIR/wsfix.diff
    git apply --whitespace=fix $GIT_DIR/wsfix.diff
    rm -f $GIT_DIR/wsfix.diff
else
    echo wokring tree is dirty\!
fi
EOF


        --larry
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]