git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] commit-tree: don't append a newline with -F
@ 2017-09-07 14:41 Ross Kabus
  2017-09-08  1:35 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Ross Kabus @ 2017-09-07 14:41 UTC (permalink / raw)
  To: gitster; +Cc: git, Ross Kabus

This change makes it such that commit-tree -F never appends a newline
character to the supplied commit message (either from file or stdin).

Previously, commit-tree -F would always append a newline character to
the text brought in from file or stdin. This has caused confusion in a
number of ways:
  - This is a plumbing command and it is generally expected not to do
    text cleanup or other niceties.
  - stdin piping with "-F -" appends a newline but stdin piping without
    -F does not append a newline (inconsistent).
  - git-commit does not specifically append a newline to the "-F"
    input. The issue is somewhat muddled by the fact that git-commit
    does pass the message through its --cleanup option, which may add
    such a newline. But for commit-tree to match "commit --cleanup=verbatim",
    we should not do so here.

Signed-off-by: Ross Kabus <rkabus@aerotech.com>
---
 builtin/commit-tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 19e898fa4..2177251e2 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -102,7 +102,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 			if (fd && close(fd))
 				die_errno("git commit-tree: failed to close '%s'",
 					  argv[i]);
-			strbuf_complete_line(&buffer);
 			continue;
 		}
 
-- 
2.13.1.windows.2


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

* Re: [PATCH] commit-tree: don't append a newline with -F
  2017-09-07 14:41 [PATCH] commit-tree: don't append a newline with -F Ross Kabus
@ 2017-09-08  1:35 ` Junio C Hamano
  2017-09-08 22:06   ` Ross Kabus
  2017-09-14 17:05   ` [PATCH v2] commit-tree: do not complete line in -F input Ross Kabus
  0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2017-09-08  1:35 UTC (permalink / raw)
  To: Ross Kabus; +Cc: git

Ross Kabus <rkabus@aerotech.com> writes:

> This change makes it such that commit-tree -F never appends a newline
> character to the supplied commit message (either from file or stdin).
>
> Previously, commit-tree -F would always append a newline character to
> the text brought in from file or stdin.

This is not correct.  The command adds a missing newline only when
the input ended in an incompete line.

I'd rephrase the whole thing like this:

    commit-tree: do not complete line in -F input

    "git commit-tree -F <file>", unlike "cat <file> | git
    commit-tree" (i.e. feeding the same contents from the standard
    input), added a missing final newline when the input ended in an
    incomplete line.

    Correct this inconsistency by leaving the incomplete line as-is,
    as erring on the side of not touching the input is preferrable
    and expected for a plumbing command like "commit-tree".

if I were doing this patch.

Thanks.

> Signed-off-by: Ross Kabus <rkabus@aerotech.com>
> ---
>  builtin/commit-tree.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
> index 19e898fa4..2177251e2 100644
> --- a/builtin/commit-tree.c
> +++ b/builtin/commit-tree.c
> @@ -102,7 +102,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
>  			if (fd && close(fd))
>  				die_errno("git commit-tree: failed to close '%s'",
>  					  argv[i]);
> -			strbuf_complete_line(&buffer);
>  			continue;
>  		}

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

* Re: [PATCH] commit-tree: don't append a newline with -F
  2017-09-08  1:35 ` Junio C Hamano
@ 2017-09-08 22:06   ` Ross Kabus
  2017-09-09  3:22     ` Junio C Hamano
  2017-09-14 17:05   ` [PATCH v2] commit-tree: do not complete line in -F input Ross Kabus
  1 sibling, 1 reply; 5+ messages in thread
From: Ross Kabus @ 2017-09-08 22:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, Sep 7, 2017 at 9:35 PM, Junio C Hamano <gitster@pobox.com> wrote:
>     commit-tree: do not complete line in -F input
>
>     "git commit-tree -F <file>", unlike "cat <file> | git
>     commit-tree" (i.e. feeding the same contents from the standard
>     input), added a missing final newline when the input ended in an
>     incomplete line.
>
>     Correct this inconsistency by leaving the incomplete line as-is,
>     as erring on the side of not touching the input is preferrable
>     and expected for a plumbing command like "commit-tree".

That all makes sense to me and is clearer too, I like this change.
Do I need to resubmit the patch or will you just use that text instead?

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

* Re: [PATCH] commit-tree: don't append a newline with -F
  2017-09-08 22:06   ` Ross Kabus
@ 2017-09-09  3:22     ` Junio C Hamano
  0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2017-09-09  3:22 UTC (permalink / raw)
  To: Ross Kabus; +Cc: git

Ross Kabus <rkabus@aerotech.com> writes:

> On Thu, Sep 7, 2017 at 9:35 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>     commit-tree: do not complete line in -F input
>>
>>     "git commit-tree -F <file>", unlike "cat <file> | git
>>     commit-tree" (i.e. feeding the same contents from the standard
>>     input), added a missing final newline when the input ended in an
>>     incomplete line.
>>
>>     Correct this inconsistency by leaving the incomplete line as-is,
>>     as erring on the side of not touching the input is preferrable
>>     and expected for a plumbing command like "commit-tree".
>
> That all makes sense to me and is clearer too, I like this change.
> Do I need to resubmit the patch or will you just use that text instead?

Unless the change is in the middle of a large series or require more
involved edit [*1*], it is perfectly fine to tell me the maintainer
to do these small menial changes on behalf of you---you explicitly
need to tell me what you want to happen, though.

Thanks.

[Footnote]

*1* ... in which case we have a larger chance of the maintainer
    screwing up while attempting to do so, and I'd prefer to see an
    updated version posted on the list.  That way, we can benefit
    from extra set of eyeballs watching our exchange from the
    sideline.


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

* [PATCH v2] commit-tree: do not complete line in -F input
  2017-09-08  1:35 ` Junio C Hamano
  2017-09-08 22:06   ` Ross Kabus
@ 2017-09-14 17:05   ` Ross Kabus
  1 sibling, 0 replies; 5+ messages in thread
From: Ross Kabus @ 2017-09-14 17:05 UTC (permalink / raw)
  To: gitster; +Cc: git, Ross Kabus

"git commit-tree -F <file>", unlike "cat <file> | git
commit-tree" (i.e. feeding the same contents from the standard
input), added a missing final newline when the input ended in an
incomplete line.

Correct this inconsistency by leaving the incomplete line as-is,
as erring on the side of not touching the input is preferable
and expected for a plumbing command like "commit-tree".

Signed-off-by: Ross Kabus <rkabus@aerotech.com>
---
Fixed up commit message with feedback from Junio.

 builtin/commit-tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 19e898fa4..2177251e2 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -102,7 +102,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 			if (fd && close(fd))
 				die_errno("git commit-tree: failed to close '%s'",
 					  argv[i]);
-			strbuf_complete_line(&buffer);
 			continue;
 		}
 
-- 
2.13.1.windows.2


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

end of thread, other threads:[~2017-09-14 17:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-07 14:41 [PATCH] commit-tree: don't append a newline with -F Ross Kabus
2017-09-08  1:35 ` Junio C Hamano
2017-09-08 22:06   ` Ross Kabus
2017-09-09  3:22     ` Junio C Hamano
2017-09-14 17:05   ` [PATCH v2] commit-tree: do not complete line in -F input Ross Kabus

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