[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 03/11] CODING_STYLE(tools/ocaml): add 'make format' and remove tabs




> On 19 Dec 2022, at 11:52, Anthony PERARD <anthony.perard@xxxxxxxxxx> wrote:
> 
> On Fri, Dec 16, 2022 at 06:25:12PM +0000, Edwin Török wrote:
>> + git ls-files '*.c' '*.h' | xargs -n1 sed -ie 's/\t/    /g'
> 
> Seen as there's a patch adding .clang-format, what the point of this
> command?

The diff to change tabs to spaces (and the equivalent one from ocp-indent) can 
be proven
to introduce 0 changes by looking at the diff with ignore-whitespace.
Proving the same with ocamlformat or clang-format is more difficult (and in 
particular if you keep rebasing commits from after the reformat commit to 
before it
you risk losing the change if you don't redo the format commit correctly).

So I intended to do this gradually: first get indentation to be consistent, and 
then get formatting to be consistent later once
the former has been accepted and committed.

> 
> "-ie" means to ask sed to change file in-place an keep a copy of the
> original file with "e" as suffix. So please replace that by "-i~" or
> "-i -e" or just "-i", with the first one create a "~" backup, the last
> two not creating a backup at all and probably what you wanted. ("-e" is
> optional as there's only a single command)
> 

Thanks for pointing it out, what I wanted is 'sed -i -e', and you can usually 
merge multiple single char flags into a single one,
except that is not the case for -i, and I keep making this mistake.

.PHONY: format
format:
        git ls-files '*.ml' '*.mli' | xargs -n1 ocp-indent -i
        git ls-files '*.c' '*.h' | xargs -n1 sed -i 's/\t/    /g'


--Edwin


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.