Re: [PATCH v8] ls-files: Add eol diagnostics

2015-12-30 Thread Junio C Hamano
Ramsay Jones  writes:

>> +Show line endings ("eolinfo") and the text/eol attributes 
>> ("texteolattr") of
>> files.
>> +"eolinfo" is the file content identification used by Git when
>> +the "text" attribute is "auto", or core.autocrlf != false.
>> ++
>> +"eolinfo" is either "" (when the the info is not available"), or one of 
>> "binary",
>> +"text-no-eol", "text-lf", "text-crlf" or "text-crlf-lf".
>
> 
>
> Again, I think this list reads better as: binary, none, lf, crlf and mixed.
>
> If you prefer to have 'text' in there somewhere, how about:
>
>binary, text-none, text-lf, text-crlf, text-mixed.
>
> :-D

Yup, these shorter ones, especially without "text-" prefix, read
easier to humans; scripts won't mind either way, so I'd prefer that
shorter version.

Thanks for reminding the thread.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8] ls-files: Add eol diagnostics

2015-12-30 Thread Junio C Hamano
Torsten Bögershausen  writes:

> Add test cases in t0027, thanks to Junio C Hamano for the optimized
> grep-less sed expression.

Please drop this part; it is embarrassing.

You wouldn't thank all the mentors you have ever had from whom you
learned programming in your log messages, either ;-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8] ls-files: Add eol diagnostics

2015-12-30 Thread Ramsay Jones


On 30/12/15 12:57, Torsten Bögershausen wrote:
> When working in a cross-platform environment, a user wants to
> check if text files are stored normalized in the repository and if
> .gitattributes are set appropriately.
> 
> Make it possible to let Git show the line endings in the index and
> in the working tree and the effective text/eol attributes.
> 
> The end of line ("eolinfo") are shown like this:
> "binary"   binary file
> "text-no-eol"  text file without any EOL
> "text-lf"  text file with LF
> "text-crlf"text file with CRLF
> "text-crlf-lf" text file with mixed line endings.
> 
> The effective text/eol attribute is one of these:
> "", "-text", "text", "text=auto", "eol=lf", "eol=crlf"
> 
> git ls-files --eol gives an output like this:
> 
> i/text-no-eol   w/text-no-eol   attr/text=auto t/t5100/empty
> i/binaryw/binaryattr/-text t/test-binary-2.png
> i/text-lf   w/text-lf   attr/eol=lft/t5100/rfc2047-info-0007
> i/text-lf   w/text-crlf attr/eol=crlf  doit.bat
> i/text-crlf-lf  w/text-crlf-lf  attr/  locale/XX.po
> 
> Add test cases in t0027, thanks to Junio C Hamano for the optimized
> grep-less sed expression.
> 
> Helped-By: Eric Sunshine 
> Signed-off-by: Torsten Bögershausen 
> ---
> Changes since v7:
> - Remove the "may change" from commit message.
> - Run make doc, improved git-ls-files.txt
>  Documentation/git-ls-files.txt |  23 +
>  builtin/ls-files.c |  19 +++
>  convert.c  |  85 +++
>  convert.h  |   3 ++
>  t/t0027-auto-crlf.sh   | 112 
> -
>  5 files changed, 230 insertions(+), 12 deletions(-)
> 
> diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
> index e26f01f..13b0e1d 100644
> --- a/Documentation/git-ls-files.txt
> +++ b/Documentation/git-ls-files.txt
> @@ -12,6 +12,7 @@ SYNOPSIS
>  'git ls-files' [-z] [-t] [-v]
>   
> (--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*
>   (-[c|d|o|i|s|u|k|m])*
> + [--eol]
>   [-x |--exclude=]
>   [-X |--exclude-from=]
>   [--exclude-per-directory=]
> @@ -147,6 +148,19 @@ a space) at the start of each line:
>   possible for manual inspection; the exact format may change at
>   any time.
>  +--eol::
> + Show line endings ("eolinfo") and the text/eol attributes 
> ("texteolattr") of
> files.
> + "eolinfo" is the file content identification used by Git when
> + the "text" attribute is "auto", or core.autocrlf != false.
> ++
> +"eolinfo" is either "" (when the the info is not available"), or one of 
> "binary",
> +"text-no-eol", "text-lf", "text-crlf" or "text-crlf-lf".



Again, I think this list reads better as: binary, none, lf, crlf and mixed.

If you prefer to have 'text' in there somewhere, how about:

   binary, text-none, text-lf, text-crlf, text-mixed.

:-D

(I promise not the mention it again!)



ATB,
Ramsay Jones

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8] ls-files: Add eol diagnostics

2015-12-30 Thread Torsten Bögershausen
When working in a cross-platform environment, a user wants to
check if text files are stored normalized in the repository and if
.gitattributes are set appropriately.

Make it possible to let Git show the line endings in the index and
in the working tree and the effective text/eol attributes.

The end of line ("eolinfo") are shown like this:
"binary"   binary file
"text-no-eol"  text file without any EOL
"text-lf"  text file with LF
"text-crlf"text file with CRLF
"text-crlf-lf" text file with mixed line endings.

The effective text/eol attribute is one of these:
"", "-text", "text", "text=auto", "eol=lf", "eol=crlf"

git ls-files --eol gives an output like this:

i/text-no-eol   w/text-no-eol   attr/text=auto t/t5100/empty
i/binaryw/binaryattr/-text t/test-binary-2.png
i/text-lf   w/text-lf   attr/eol=lft/t5100/rfc2047-info-0007
i/text-lf   w/text-crlf attr/eol=crlf  doit.bat
i/text-crlf-lf  w/text-crlf-lf  attr/  locale/XX.po

Add test cases in t0027, thanks to Junio C Hamano for the optimized
grep-less sed expression.

Helped-By: Eric Sunshine 
Signed-off-by: Torsten Bögershausen 
---
Changes since v7:
- Remove the "may change" from commit message.
- Run make doc, improved git-ls-files.txt
 Documentation/git-ls-files.txt |  23 +
 builtin/ls-files.c |  19 +++
 convert.c  |  85 +++
 convert.h  |   3 ++
 t/t0027-auto-crlf.sh   | 112 -
 5 files changed, 230 insertions(+), 12 deletions(-)

diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index e26f01f..13b0e1d 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -12,6 +12,7 @@ SYNOPSIS
 'git ls-files' [-z] [-t] [-v]

(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])*
(-[c|d|o|i|s|u|k|m])*
+   [--eol]
[-x |--exclude=]
[-X |--exclude-from=]
[--exclude-per-directory=]
@@ -147,6 +148,19 @@ a space) at the start of each line:
possible for manual inspection; the exact format may change at
any time.
 +--eol::
+   Show line endings ("eolinfo") and the text/eol attributes 
("texteolattr") of
files.
+   "eolinfo" is the file content identification used by Git when
+   the "text" attribute is "auto", or core.autocrlf != false.
++
+"eolinfo" is either "" (when the the info is not available"), or one of 
"binary",
+"text-no-eol", "text-lf", "text-crlf" or "text-crlf-lf".
++
+The "texteolattr" can be "", "-text", "text", "text=auto", "eol=lf", 
"eol=crlf".
++
+Both the content in the index ("i/") and the content in the working tree ("w/")
+are shown for regular files, followed by the "texteolattr" ("attr/").
+
 \--::
Do not interpret any more arguments as options.
 @@ -161,6 +175,15 @@ which case it outputs:
  [ ]   
 +'git ls-files --eol' will show
+   i/ w/ attr/ 
+
+'git ls-files --eol -o' will show
+   i/  w/ attr/ 
+
+'git ls-files --eol -s' will show
+[ ]   i/ w/ attr/ 
+
 'git ls-files --unmerged' and 'git ls-files --stage' can be used to examine
 detailed information on unmerged paths.
 diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b6a7cb0..9eacc64 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -27,6 +27,7 @@ static int show_killed;
 static int show_valid_bit;
 static int line_terminator = '\n';
 static int debug_mode;
+static int show_eol;
  static const char *prefix;
 static int max_prefix_len;
@@ -47,6 +48,21 @@ static const char *tag_modified = "";
 static const char *tag_skip_worktree = "";
 static const char *tag_resolve_undo = "";
 +static void write_eolinfo(const struct cache_entry *ce, const char *path)
+{
+   struct stat st;
+   const char *i_txt = "";
+   const char *w_txt = "";
+   if (!show_eol)
+   return;
+   if (ce && S_ISREG(ce->ce_mode))
+   i_txt = get_cached_convert_stats_ascii(ce->name);
+   if (!lstat(path, ) && S_ISREG(st.st_mode))
+   w_txt = get_wt_convert_stats_ascii(path);
+   printf("i/%-13s w/%-13s attr/%-9s ", i_txt, w_txt,
+get_convert_attr_ascii(path));
+}
+
 static void write_name(const char *name)
 {
/*
@@ -68,6 +84,7 @@ static void show_dir_entry(const char *tag, struct dir_entry 
*ent)
return;
fputs(tag, stdout);
+   write_eolinfo(NULL, ent->name);
write_name(ent->name);
 }
 @@ -170,6 +187,7 @@ static void show_ce_entry(const char *tag, const struct
cache_entry *ce)
   find_unique_abbrev(ce->sha1,abbrev),
   ce_stage(ce));
}
+   write_eolinfo(ce, ce->name);
write_name(ce->name);
if (debug_mode) {
const struct stat_data *sd = 

Re: [PATCH v8] ls-files: Add eol diagnostics

2015-12-30 Thread Torsten Bögershausen
>> "binary"   binary file
>> "text-no-eol"  text file without any EOL
>> "text-lf"  text file with LF
>> "text-crlf"text file with CRLF
>> "text-crlf-lf" text file with mixed line endings.

> If you prefer to have 'text' in there somewhere, how about:
> 
>binary, text-none, text-lf, text-crlf, text-mixed.

text-none could be OK.

text-mixed as well, but the you can't run
"git ls-files | grep i/text-crlf"
any more to get an impression if there are un-normalized files,
which may, may, need normalization.

Thanks for the reminder,
lets wait a couple of days and see if there are more voices.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html