Stefan Zager <> writes:

> If anyone has a recommendation for a less labor-intensive way to do
> this in emacs, I'd be very grateful.

This is not "do this in emacs", but here is a possible approach.

You can ask "git diff" about what you changed, and actually apply
the change while fixing whitespace errors.  I.e.

        git diff sha1_file.c | git apply --cached --whitespace=fix
        git diff
        git checkout sha1_file.c

The first step will add a cleaned-up version to your index.

The second "diff" (optional) is to see what whitespace errors are
introduced when going from that cleaned-up version to what you have
in the working tree.

With the last step you would update the working tree version to the
cleaned-up version from the index.

        wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached 
                git co -- ${1-.} \"$@\"' -"
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to