Subject: Re: [PATCH 1/2] convert: add a helper to determine the correct EOL for a given path

From: Torsten Bögershausen <[email-masked]>
Date: Sat, 23 Jan 2016 08:05:28 +0100

On 2016-01-22 20.04, Johannes Schindelin wrote:
> Hi Junio,
> 
> On Fri, 22 Jan 2016, Junio C Hamano wrote:
> 
>> Johannes Schindelin <[email-masked]> writes:
>>
>>> Signed-off-by: Johannes Schindelin <[email-masked]>
>>> ---
>>
>> This change somehow ringed a bell and reminded me of your recent
>> ls-files stuff.  Are there things that these topics can use from
>> each other?
> 
> Quite possibly. I'll have a look tomorrow.

Something like this should do:
(Fully untested)

enum eol eol_for_path(const char *path, const char *src, size_t len)
{
  struct conv_attrs ca;
  if (!path)
     path = "*"; /* catch * text=xxx */
  convert_attrs(&ca, path);
  ca.crlf_action = input_crlf_action(ca.crlf_action, ca.eol_attr);

  return output_eol(crlf_action);
}