Skip to contentSkip to conversation

sequencer.c: unify error messages

PATCH In review Ralf Thielow 5 participants 9 messages Oct 13, 2017 – Oct 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sequencer.c: unify error messages

When ftruncate() in rearrange_squash() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

While at there, remove a full stop in another error message.

---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sequencer.c +2 -2
index e258bb646..b0e6459a5 100644
@@ -2948,9 +2948,9 @@ int rearrange_squash(void)
 		if (fd < 0)
 			res = error_errno(_("could not open '%s'"), todo_file);
 		else if (write(fd, buf.buf, buf.len) < 0)
-			res = error_errno(_("could not read '%s'."), todo_file);
+			res = error_errno(_("could not read '%s'"), todo_file);
 		else if (ftruncate(fd, buf.len) < 0)
-			res = error_errno(_("could not finish '%s'"),
+			res = error_errno(_("could not truncate '%s'"),
 					   todo_file);
 		close(fd);
 		strbuf_release(&buf);
Signature · 1 line
2.15.0.rc0.296.g7b26d72
#1 lore raw

Am 13.10.2017 um 19:51 schrieb Ralf Thielow:

Quoted 4 lines

When ftruncate() in rearrange_squash() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

Would it make sense to factor out rewriting the to-do file to avoid code duplication in the first place?

Quoted 12 lines

While at there, remove a full stop in another error message.

---
  sequencer.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
sequencer.c +0 -0
index e258bb646..b0e6459a5 100644

sequencer.c int rearrange_squash(void) · line 2951

Quoted 5 lines
sequencer.c +1 -1
@@ -2948,9 +2948,9 @@ int rearrange_squash(void)
  		if (fd < 0)
  			res = error_errno(_("could not open '%s'"), todo_file);
  		else if (write(fd, buf.buf, buf.len) < 0)
-			res = error_errno(_("could not read '%s'."), todo_file);
+			res = error_errno(_("could not read '%s'"), todo_file);
                                                       ^^^^

That should read "write", right?

sequencer.c int rearrange_squash(void) · line 2954

Quoted 4 lines
sequencer.c +1 -1
  		else if (ftruncate(fd, buf.len) < 0)
-			res = error_errno(_("could not finish '%s'"),
+			res = error_errno(_("could not truncate '%s'"),
  					   todo_file);

Hmm, why call ftruncate(2) instead of opening the file with O_TRUNC?

Quoted 3 lines
sequencer.c +0 -0
  		close(fd);
  		strbuf_release(&buf);
#2 lore raw

2017-10-13 23:12 GMT+02:00 René Scharfe <[email protected]>:

Quoted 27 lines

Am 13.10.2017 um 19:51 schrieb Ralf Thielow:

Quoted 4 lines

When ftruncate() in rearrange_squash() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

Would it make sense to factor out rewriting the to-do file to avoid code duplication in the first place?

Quoted 12 lines

While at there, remove a full stop in another error message.

---
  sequencer.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
sequencer.c +0 -0
index e258bb646..b0e6459a5 100644

sequencer.c int rearrange_squash(void) · line 2951

Quoted 5 lines
sequencer.c +1 -1
@@ -2948,9 +2948,9 @@ int rearrange_squash(void)
              if (fd < 0)
                      res = error_errno(_("could not open '%s'"), todo_file);
              else if (write(fd, buf.buf, buf.len) < 0)
-                     res = error_errno(_("could not read '%s'."), todo_file);
+                     res = error_errno(_("could not read '%s'"), todo_file);
                                                       ^^^^
Quoted 2 lines

That should read "write", right?

Sure. I'll send a new version of this patch to fix the messages. Maybe someone else picks up the other things. Thanks.

Quoted 10 lines

sequencer.c int rearrange_squash(void) · line 2954

Quoted 4 lines
sequencer.c +1 -1
              else if (ftruncate(fd, buf.len) < 0)
-                     res = error_errno(_("could not finish '%s'"),
+                     res = error_errno(_("could not truncate '%s'"),
                                         todo_file);

Hmm, why call ftruncate(2) instead of opening the file with O_TRUNC?

Quoted 3 lines
sequencer.c +0 -0
              close(fd);
              strbuf_release(&buf);
#3 lore raw
In reply to Ralf Thielow

Hi Ralf,

Quoted 6 lines · Ralf Thielow

When ftruncate() in rearrange_squash() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

While at there, remove a full stop in another error message.

Thanks, looks good (maybe s/read/write/ as pointed out by René, though?).

Ciao,
Dscho

#4 lore raw

PATCH v2 1/1 sequencer.c: fix and unify error messages in rearrange_squash()

In reply to Ralf Thielow

When the write opertion fails, we write that we could not read. Change the error message to match the operation and remove the full stop at the end.

When ftruncate() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sequencer.c +2 -2
index e258bb646..75f5356f6 100644
@@ -2948,9 +2948,9 @@ int rearrange_squash(void)
 		if (fd < 0)
 			res = error_errno(_("could not open '%s'"), todo_file);
 		else if (write(fd, buf.buf, buf.len) < 0)
-			res = error_errno(_("could not read '%s'."), todo_file);
+			res = error_errno(_("could not write '%s'"), todo_file);
 		else if (ftruncate(fd, buf.len) < 0)
-			res = error_errno(_("could not finish '%s'"),
+			res = error_errno(_("could not truncate '%s'"),
 					   todo_file);
 		close(fd);
 		strbuf_release(&buf);
Signature · 1 line
2.15.0.rc0.296.g7b26d72
#5 lore raw

Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()

Quoted 7 lines · Ralf Thielow

When the write opertion fails, we write that we could not read. Change the error message to match the operation and remove the full stop at the end.

When ftruncate() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

Wouldn't it be more accurate to say we couldn't ftruncate, though?

Quoted 22 lines
---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sequencer.c +2 -2
index e258bb646..75f5356f6 100644
@@ -2948,9 +2948,9 @@ int rearrange_squash(void)
 		if (fd < 0)
 			res = error_errno(_("could not open '%s'"), todo_file);
 		else if (write(fd, buf.buf, buf.len) < 0)
-			res = error_errno(_("could not read '%s'."), todo_file);
+			res = error_errno(_("could not write '%s'"), todo_file);
 		else if (ftruncate(fd, buf.len) < 0)
-			res = error_errno(_("could not finish '%s'"),
+			res = error_errno(_("could not truncate '%s'"),
 					   todo_file);
 		close(fd);
 		strbuf_release(&buf);
#6 lore raw

Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()

Hi Junio,

Quoted 11 lines · Junio C Hamano
Quoted 7 lines · Ralf Thielow

When the write opertion fails, we write that we could not read. Change the error message to match the operation and remove the full stop at the end.

When ftruncate() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

Wouldn't it be more accurate to say we couldn't ftruncate, though?

This is an end-user facing error message, right? Should we not let users who are happily oblivious of POSIX nomenclature remain happily oblivious?

In other words, I would be finer with "truncate" than with "ftruncate... wait, huh? Is that even English?"

Ciao,
Dscho

#7 lore raw

Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()

From: "Johannes Schindelin" <[email protected]>

Quoted 12 lines · Junio C Hamano
Quoted 11 lines
Quoted 7 lines · Ralf Thielow

When the write opertion fails, we write that we could not read. Change the error message to match the operation and remove the full stop at the end.

When ftruncate() fails, we write that we couldn't finish the operation on the todo file. It is more accurate to write that we couldn't truncate as we do in other calls of ftruncate().

Quoted 8 lines
Quoted 1 line

Wouldn't it be more accurate to say we couldn't ftruncate, though?

This is an end-user facing error message, right? Should we not let users who are happily oblivious of POSIX nomenclature remain happily oblivious?

In other words, I would be finer with "truncate" than with "ftruncate... wait, huh? Is that even English?"

Hi, 'Truncate' is real English, but it is not that common in normal usage.

My dictionary suggests that it means 'cut off at the tip' such as a truncated cone. However the thesaurus is far more relaxed about the common idioms that truncate at the tail such as: clip, crop, cut short, trim, abbreviate, curtail, etc.

So perhaps "could not trim '%s'".

--
Philip

#8 lore raw

Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()

Quoted 8 lines · Philip Oakley

Hi, 'Truncate' is real English, but it is not that common in normal usage.

My dictionary suggests that it means 'cut off at the tip' such as a truncated cone. However the thesaurus is far more relaxed about the common idioms that truncate at the tail such as: clip, crop, cut short, trim, abbreviate, curtail, etc.

So perhaps "could not trim '%s'".

Truncate is fine, as there is already another instance that barfs with "cannot truncate" upon an error from ftruncate(), and the patch merely matches the two error messages.