]> git.ipfire.org Git - thirdparty/git.git/commitdiff
convert: clarify line ending conversion warning
authorAlex Henrie <alexhenrie24@gmail.com>
Fri, 8 Apr 2022 04:41:54 +0000 (22:41 -0600)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Apr 2022 19:53:34 +0000 (12:53 -0700)
The warning about converting line endings is extremely confusing. Its
two sentences each use the word "will" without specifying a timeframe,
which makes it sound like both sentences are referring to the same
timeframe. On top of that, it uses the term "original line endings"
without saying whether "original" means LF or CRLF.

Rephrase the warning to be clear about when the line endings will be
changed and what they will be changed to.

On a platform whose native line endings are not CRLF (e.g. Linux), the
"git add" step in the following sequence triggers the warning in
question:

$ git config core.autocrlf true
$ echo 'Hello world!' >hello.txt
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt
The file will have its original line endings in your working directory

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c
t/t0027-auto-crlf.sh

index 8e39731efb0bd26e9aa6c6341f049f2965e659f2..4d153729da0f185207b85d103905b30e3183796b 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -195,9 +195,9 @@ static void check_global_conv_flags_eol(const char *path,
                if (conv_flags & CONV_EOL_RNDTRP_DIE)
                        die(_("CRLF would be replaced by LF in %s"), path);
                else if (conv_flags & CONV_EOL_RNDTRP_WARN)
-                       warning(_("CRLF will be replaced by LF in %s.\n"
-                                 "The file will have its original line"
-                                 " endings in your working directory"), path);
+                       warning(_("in the working copy of '%s', CRLF will be"
+                                 " replaced by LF the next time Git touches"
+                                 " it"), path);
        } else if (old_stats->lonelf && !new_stats->lonelf ) {
                /*
                 * CRLFs would be added by checkout
@@ -205,9 +205,9 @@ static void check_global_conv_flags_eol(const char *path,
                if (conv_flags & CONV_EOL_RNDTRP_DIE)
                        die(_("LF would be replaced by CRLF in %s"), path);
                else if (conv_flags & CONV_EOL_RNDTRP_WARN)
-                       warning(_("LF will be replaced by CRLF in %s.\n"
-                                 "The file will have its original line"
-                                 " endings in your working directory"), path);
+                       warning(_("in the working copy of '%s', LF will be"
+                                 " replaced by CRLF the next time Git touches"
+                                 " it"), path);
        }
 }
 
index 0feb41a23f2c27db155fc49b6fb3ff7f9106cc53..7f80f463930407410c6d3f671fb1f7833ec3b01e 100755 (executable)
@@ -77,12 +77,12 @@ create_NNO_MIX_files () {
 
 check_warning () {
        case "$1" in
-       LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
-       CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
-       '')                                                      >"$2".expect ;;
+       LF_CRLF) echo "LF will be replaced by CRLF" >"$2".expect ;;
+       CRLF_LF) echo "CRLF will be replaced by LF" >"$2".expect ;;
+       '')                                         >"$2".expect ;;
        *) echo >&2 "Illegal 1": "$1" ; return false ;;
        esac
-       grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq  >"$2".actual
+       sed -e "s/^.* \([^ ]* will be replaced by [^ ]*\) .*$/\1/" "$2" | uniq  >"$2".actual
        test_cmp "$2".expect "$2".actual
 }