From: Robert Dailey <rcdailey.lists@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: git add without whitespace
Date: Mon, 30 May 2016 14:50:05 -0500 [thread overview]
Message-ID: <CAHd499Drdt6GoScdksNNWLrsvG3Dex7fTYNhatL-qboCPW5RZQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqlh2r8ixu.fsf@gitster.mtv.corp.google.com>
On Mon, May 30, 2016 at 2:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
> I have had this in my ~/.gitconfig for a long time.
>
> [alias]
> wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached --whitespace=fix;\
> git co -- ${1-.} \"$@\"' -"
>
> That is, "take what's different from the _index_ and the working
> tree, apply that difference while correcting whitespace errors to
> the index, and check the result out to the working tree". This
> would _not_ touch existing whitespace-damaged lines that you are not
> touching, and honours the customized definition of what is
> considered whitespace breakage for each paths (which you set up with
> the attributes system).
>
I like your solution better than mine because it utilizes the rules
defined in .gitattributes. I think that's a really good idea. But
other than that, yours is functionally the same as what I'm doing,
right? I just want to make sure I understand: What ends up in the
index/staging area is the code MINUS the trailing whitespace (e.g.
whitespace errors)?
What does the checkout at the end do? That part confuses me (granted
I'm not well-versed with bash script).
Thanks for the feedback. Looks like this is niche enough that an
alias/script is probably the best solution.
next prev parent reply other threads:[~2016-05-30 19:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 15:26 git add without whitespace Robert Dailey
2016-05-30 19:06 ` Junio C Hamano
2016-05-30 19:50 ` Robert Dailey [this message]
2016-05-30 22:00 ` Junio C Hamano
2016-05-31 15:03 ` Robert Dailey
2016-05-31 16:16 ` Junio C Hamano
2016-05-31 15:59 ` Christian Neukirchen
2016-05-31 16:27 ` demerphq
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=CAHd499Drdt6GoScdksNNWLrsvG3Dex7fTYNhatL-qboCPW5RZQ@mail.gmail.com \
--to=rcdailey.lists@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).