From: Larry D'Anna <larry@elder-gods.org>
To: Andreas Ericsson <ae@op5.se>
Cc: John Tapsell <johnflux@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: wsfix alias
Date: Thu, 9 Jul 2009 17:30:28 -0400 [thread overview]
Message-ID: <20090709213028.GA28293@cthulhu> (raw)
In-Reply-To: <4A56590F.9050206@op5.se>
* Andreas Ericsson (ae@op5.se) [090709 16:54]:
> 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
next prev parent reply other threads:[~2009-07-09 21:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-08 23:49 default aliases (ci, di, st, co) Ondrej Certik
2009-07-09 0:13 ` Jakub Narebski
2009-07-09 8:58 ` Graeme Geldenhuys
2009-07-09 16:43 ` Junio C Hamano
2009-07-09 23:08 ` Paolo Bonzini
2009-07-13 6:40 ` Jeff King
2009-07-13 6:43 ` Jeff King
2009-07-13 9:15 ` Paolo Bonzini
2009-07-09 7:00 ` Andreas Ericsson
2009-07-09 8:50 ` Michael J Gruber
2009-07-09 9:04 ` Graeme Geldenhuys
2009-07-09 9:40 ` Jakub Narebski
2009-07-09 9:48 ` Michael J Gruber
2009-07-09 8:58 ` Luciano Miguel Ferreira Rocha
2009-07-12 5:07 ` Ondrej Certik
[not found] ` <20090709160249.GA12830@cthulhu>
2009-07-09 20:54 ` wsfix alias Andreas Ericsson
2009-07-09 21:30 ` Larry D'Anna [this message]
2009-07-09 9:01 ` default aliases (ci, di, st, co) Graeme Geldenhuys
2009-07-09 9:12 ` Matthieu Moy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090709213028.GA28293@cthulhu \
--to=larry@elder-gods.org \
--cc=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=johnflux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.