git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] convert: clarify line ending conversion warning
@ 2022-04-04  5:51 Alex Henrie
  2022-04-04  6:06 ` Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alex Henrie @ 2022-04-04  5:51 UTC (permalink / raw)
  To: git, prohaska, eyvind.bernhardsen, gitster; +Cc: Alex Henrie

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 that line endings have not been changed
in the working directory but will be changed on the next checkout, and
explicitly say which line endings the file currently has in the working
directory.

Example commands to trigger the warning on Linux:

git config core.autocrlf true
echo 'Hello world!' > hello.txt
git add hello.txt
git commit -m "Add hello.txt"

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 convert.c            | 14 ++++++++------
 t/t0027-auto-crlf.sh |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/convert.c b/convert.c
index 8e39731efb..b024d74222 100644
--- a/convert.c
+++ b/convert.c
@@ -195,9 +195,10 @@ 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(_("CRLF will be replaced by LF in %s the next"
+				  " time you check it out.\n"
+				  "For now, the file still has CRLF line"
+				  " endings in your working directory."), path);
 	} else if (old_stats->lonelf && !new_stats->lonelf ) {
 		/*
 		 * CRLFs would be added by checkout
@@ -205,9 +206,10 @@ 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(_("LF will be replaced by CRLF in %s the next"
+				  " time you check it out.\n"
+				  "For now, the file still has LF line"
+				  " endings in your working directory."), path);
 	}
 }
 
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
index 0feb41a23f..31f471c4b1 100755
--- a/t/t0027-auto-crlf.sh
+++ b/t/t0027-auto-crlf.sh
@@ -82,7 +82,7 @@ check_warning () {
 	'')	                                                 >"$2".expect ;;
 	*) echo >&2 "Illegal 1": "$1" ; return false ;;
 	esac
-	grep "will be replaced by" "$2" | sed -e "s/\(.*\) in [^ ]*$/\1/" | uniq  >"$2".actual
+	grep "will be replaced by" "$2" | sed -e "s/\(.*\) in .*$/\1/" | uniq  >"$2".actual
 	test_cmp "$2".expect "$2".actual
 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-05  4:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-04  5:51 [PATCH] convert: clarify line ending conversion warning Alex Henrie
2022-04-04  6:06 ` Ævar Arnfjörð Bjarmason
2022-04-04 15:22 ` Tao Klerks
2022-04-04 17:23   ` Alex Henrie
2022-04-05  4:03     ` Tao Klerks
2022-04-04 16:53 ` Junio C Hamano
2022-04-04 17:21   ` Alex Henrie
2022-04-04 19:37     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).