git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phil Hord <hordp@cisco.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-p4: replace each tab with 8 spaces for consistency
Date: Thu, 07 Apr 2011 11:45:24 -0700	[thread overview]
Message-ID: <7v1v1dgat7.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4D9DE7E4.1030808@cisco.com> (Phil Hord's message of "Thu, 07 Apr 2011 12:35:48 -0400")

Phil Hord <hordp@cisco.com> writes:

> This is what I want:
>
>    git fix-whitespace             # fix new ws errors in workdir
>    git fix-whitespace --all       # fix all ws errors in workdir
>    git fix-whitespace foo         # fix new ws errors since foo
>    git fix-whitespace --cached    # fix new ws errors in the index
>    etc.

If you understood the example I gave, you should be able to figure all of
these out.  In the most general case, you would come up with a way to
generate a diff that represents the change you want to fix (e.g. "new
errors" would be comparing the HEAD and the working tree), reverse apply
the diff and then forward apply the same diff with --whitespace=fix, but
often you can omit "reverse apply the diff" step by finding an appropriate
combination between HEAD/index/working tree.

I long time wrote this alias

[alias]
        wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached --whitespace=fix;\
                git co -- ${1-.} \"$@\"' -"

that acts as if you are saying "git add $path" while fixing the whitespace
errors I introduced in the working tree version.

  reply	other threads:[~2011-04-07 18:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07  6:01 [PATCH] git-p4: replace each tab with 8 spaces for consistency Andrew Garber
2011-04-07  7:36 ` Junio C Hamano
2011-04-07 16:35   ` Phil Hord
2011-04-07 18:45     ` Junio C Hamano [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-04-07  6:01 Andrew Garber

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1v1dgat7.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hordp@cisco.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).