git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] sequencer.c: unify error messages
@ 2017-10-13 17:51 Ralf Thielow
  2017-10-13 21:12 ` René Scharfe
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ralf Thielow @ 2017-10-13 17:51 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Junio C Hamano, 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.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index e258bb646..b0e6459a5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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);
-- 
2.15.0.rc0.296.g7b26d72


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

* Re: [PATCH] sequencer.c: unify error messages
  2017-10-13 17:51 [PATCH] sequencer.c: unify error messages Ralf Thielow
@ 2017-10-13 21:12 ` René Scharfe
  2017-10-15 17:07   ` Ralf Thielow
  2017-10-15 15:24 ` Johannes Schindelin
  2017-10-15 17:07 ` [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash() Ralf Thielow
  2 siblings, 1 reply; 9+ messages in thread
From: René Scharfe @ 2017-10-13 21:12 UTC (permalink / raw)
  To: Ralf Thielow, git; +Cc: Johannes Schindelin, Junio C Hamano

Am 13.10.2017 um 19:51 schrieb 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().

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

> While at there, remove a full stop in another error message.
> 
> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
> ---
>   sequencer.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index e258bb646..b0e6459a5 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -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?

>   		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?

>   		close(fd);
>   		strbuf_release(&buf);
> 

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

* Re: [PATCH] sequencer.c: unify error messages
  2017-10-13 17:51 [PATCH] sequencer.c: unify error messages Ralf Thielow
  2017-10-13 21:12 ` René Scharfe
@ 2017-10-15 15:24 ` Johannes Schindelin
  2017-10-15 17:07 ` [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash() Ralf Thielow
  2 siblings, 0 replies; 9+ messages in thread
From: Johannes Schindelin @ 2017-10-15 15:24 UTC (permalink / raw)
  To: Ralf Thielow; +Cc: git, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

Hi Ralf,

On Fri, 13 Oct 2017, Ralf Thielow wrote:

> 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

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

* Re: [PATCH] sequencer.c: unify error messages
  2017-10-13 21:12 ` René Scharfe
@ 2017-10-15 17:07   ` Ralf Thielow
  0 siblings, 0 replies; 9+ messages in thread
From: Ralf Thielow @ 2017-10-15 17:07 UTC (permalink / raw)
  To: René Scharfe; +Cc: git, Johannes Schindelin, Junio C Hamano

2017-10-13 23:12 GMT+02:00 René Scharfe <l.s.r@web.de>:
> Am 13.10.2017 um 19:51 schrieb 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().
>
> Would it make sense to factor out rewriting the to-do file to avoid
> code duplication in the first place?
>
>> While at there, remove a full stop in another error message.
>>
>> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
>> ---
>>   sequencer.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sequencer.c b/sequencer.c
>> index e258bb646..b0e6459a5 100644
>> --- a/sequencer.c
>> +++ b/sequencer.c
>> @@ -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?
>

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

>>               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?
>
>>               close(fd);
>>               strbuf_release(&buf);
>>

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

* [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()
  2017-10-13 17:51 [PATCH] sequencer.c: unify error messages Ralf Thielow
  2017-10-13 21:12 ` René Scharfe
  2017-10-15 15:24 ` Johannes Schindelin
@ 2017-10-15 17:07 ` Ralf Thielow
  2017-10-16  1:52   ` Junio C Hamano
  2 siblings, 1 reply; 9+ messages in thread
From: Ralf Thielow @ 2017-10-15 17:07 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Junio C Hamano, 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().

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
---
 sequencer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index e258bb646..75f5356f6 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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);
-- 
2.15.0.rc0.296.g7b26d72


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

* Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()
  2017-10-15 17:07 ` [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash() Ralf Thielow
@ 2017-10-16  1:52   ` Junio C Hamano
  2017-10-16 11:32     ` Johannes Schindelin
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2017-10-16  1:52 UTC (permalink / raw)
  To: Ralf Thielow; +Cc: git, Johannes Schindelin

Ralf Thielow <ralf.thielow@gmail.com> writes:

> 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?

>
> Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
> ---
>  sequencer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index e258bb646..75f5356f6 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -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);

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

* Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()
  2017-10-16  1:52   ` Junio C Hamano
@ 2017-10-16 11:32     ` Johannes Schindelin
  2017-10-16 12:36       ` Philip Oakley
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Schindelin @ 2017-10-16 11:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Ralf Thielow, git

Hi Junio,

On Mon, 16 Oct 2017, Junio C Hamano wrote:

> Ralf Thielow <ralf.thielow@gmail.com> writes:
> 
> > 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

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

* Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()
  2017-10-16 11:32     ` Johannes Schindelin
@ 2017-10-16 12:36       ` Philip Oakley
  2017-10-16 12:46         ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Philip Oakley @ 2017-10-16 12:36 UTC (permalink / raw)
  To: Johannes Schindelin, Junio C Hamano; +Cc: Ralf Thielow, git

From: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>
> On Mon, 16 Oct 2017, Junio C Hamano wrote:
>
>> Ralf Thielow <ralf.thielow@gmail.com> writes:
>>
>> > 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?"
>
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


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

* Re: [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash()
  2017-10-16 12:36       ` Philip Oakley
@ 2017-10-16 12:46         ` Junio C Hamano
  0 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2017-10-16 12:46 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Johannes Schindelin, Ralf Thielow, git

"Philip Oakley" <philipoakley@iee.org> writes:

> 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.

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

end of thread, other threads:[~2017-10-16 12:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 17:51 [PATCH] sequencer.c: unify error messages Ralf Thielow
2017-10-13 21:12 ` René Scharfe
2017-10-15 17:07   ` Ralf Thielow
2017-10-15 15:24 ` Johannes Schindelin
2017-10-15 17:07 ` [PATCH v2] sequencer.c: fix and unify error messages in rearrange_squash() Ralf Thielow
2017-10-16  1:52   ` Junio C Hamano
2017-10-16 11:32     ` Johannes Schindelin
2017-10-16 12:36       ` Philip Oakley
2017-10-16 12:46         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).