convert: clarify line ending conversion warning

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>

Alex Henrie committed Apr 7, 2022 at 22:41 UTC c970d30c2c362259316b5d63ef81fde591095a1b
2 files changed +10 -10
convert.c
+6 -6
@@ -195,9 +195,9 @@ static void check_global_conv_flags_eol(const char *path,
195 if (conv_flags & CONV_EOL_RNDTRP_DIE)
196 die(_("CRLF would be replaced by LF in %s"), path);
197 else if (conv_flags & CONV_EOL_RNDTRP_WARN)
198 - warning(_("CRLF will be replaced by LF in %s.\n"
199 - "The file will have its original line"
200 - " endings in your working directory"), path);
198 + warning(_("in the working copy of '%s', CRLF will be"
199 + " replaced by LF the next time Git touches"
200 + " it"), path);
201 } else if (old_stats->lonelf && !new_stats->lonelf ) {
202 /*
203 * CRLFs would be added by checkout
@@ -205,9 +205,9 @@ static void check_global_conv_flags_eol(const char *path,
205 if (conv_flags & CONV_EOL_RNDTRP_DIE)
206 die(_("LF would be replaced by CRLF in %s"), path);
207 else if (conv_flags & CONV_EOL_RNDTRP_WARN)
208 - warning(_("LF will be replaced by CRLF in %s.\n"
209 - "The file will have its original line"
210 - " endings in your working directory"), path);
208 + warning(_("in the working copy of '%s', LF will be"
209 + " replaced by CRLF the next time Git touches"
210 + " it"), path);
211 }
212 }
213
t/t0027-auto-crlf.sh
+4 -4
@@ -77,12 +77,12 @@ create_NNO_MIX_files () {
77
78 check_warning () {
79 case "$1" in
80 - LF_CRLF) echo "warning: LF will be replaced by CRLF" >"$2".expect ;;
81 - CRLF_LF) echo "warning: CRLF will be replaced by LF" >"$2".expect ;;
82 - '') >"$2".expect ;;
80 + LF_CRLF) echo "LF will be replaced by CRLF" >"$2".expect ;;
81 + CRLF_LF) echo "CRLF will be replaced by LF" >"$2".expect ;;
82 + '') >"$2".expect ;;
83 *) echo >&2 "Illegal 1": "$1" ; return false ;;
84 esac
85 - grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq >"$2".actual
85 + sed -e "s/^.* \([^ ]* will be replaced by [^ ]*\) .*$/\1/" "$2" | uniq >"$2".actual
86 test_cmp "$2".expect "$2".actual
87 }
88