git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: wsfix alias

From
Larry D'Anna <larry@elder-gods.org>
Date
Jul 9, 2009, 21:30 UTC
Message-ID
<20090709213028.GA28293@cthulhu>
In-Reply-To
<4A56590F.9050206@op5.se>
* Andreas Ericsson (ae@op5.se) [090709 16:54]:
Show 21 quoted lines
> Larry D'Anna wrote:
>> * Andreas Ericsson (ae@op5.se) [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
Previous: Andreas Ericsson
Message 19 of 19 in “default aliases (ci, di, st, co)”
  1. Ondrej CertikJul 8, 2009
  2. Jakub NarebskiJul 9, 2009
  3. Graeme GeldenhuysJul 9, 2009
  4. Junio C HamanoJul 9, 2009
  5. Paolo BonziniJul 9, 2009
  6. Jeff KingJul 13, 2009
  7. Jeff KingJul 13, 2009
  8. Paolo BonziniJul 13, 2009
  9. Andreas EricssonJul 9, 2009
  10. Michael J GruberJul 9, 2009
  11. Graeme GeldenhuysJul 9, 2009
  12. Jakub NarebskiJul 9, 2009
  13. Michael J GruberJul 9, 2009
  14. Luciano Miguel Ferreira RochaJul 9, 2009
  15. Ondrej CertikJul 12, 2009
  16. Graeme GeldenhuysJul 9, 2009
  17. Matthieu MoyJul 9, 2009
  18. wsfix aliasAndreas Ericsson, Jul 9, 2009
  19. Larry D'AnnaJul 9, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.