git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Adam Brewster" <adambrewster@gmail.com>
Cc: git@vger.kernel.org,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Mark Levedahl" <mdl123@verizon.net>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Jakub Narebski" <jnareb@gmail.com>
Subject: Re: [PATCH/v3] bundle.c: added --stdin option to git-bundle
Date: Sat, 05 Jul 2008 11:15:06 -0700	[thread overview]
Message-ID: <7vod5crydx.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <c376da900807050930i6d1da898s624be58adc6f1751@mail.gmail.com> (Adam Brewster's message of "Sat, 5 Jul 2008 12:30:53 -0400")

"Adam Brewster" <adambrewster@gmail.com> writes:

> Subject: Re: [PATCH/v3] bundle.c: added --stdin option to git-bundle

When the change is not about implementation detail (in which case you do
want to name the source file and perhaps even a function name), but about
a new feature that is visible to the end-users of a command, we'd want the
message talk in terms of what the new feature does, not how the new
feature is invoked nor where it is implemented.  In other words, something
like these are preferred:

	git-bundle: add --stdin
        Teach git-bundle to read tips and basis from standard input

and don't say "You did" in past tense --- say things in imperative mood
instead, as if you are commanding the person who applies the patch to make
it happen.  Older log entries in our history (e.g. "git log -n 20 v0.99")
may give you a better feel.

And give a few lines of obvious justfication in the body of the commit log
message, e.g.

	This patch allows the caller to feed the revision parameters to
	git-bundle from its standard input.  This way, a script do not
	have to worry about limitation of the length of command line.

to explain why this is good.  In order to explain that you may have to
talk about other things (like what it does and how it does it), but keep
in mind that the primary thing you should talk about is _why_.

> ... because it already implies that this option is available.

If that is the case, please mention in the commit log message something
like "Even though the documentation said "bundle --stdin" is accepted it
didn't.  This patch teaches the option to the command".

But I do not think there is no such implication.  "bundle create" may take
list of positive and negative refs as arguments or --branches, but it does
not take (and it shouldn't -- I do not think it should take --bisect
option, for example) artibrary options that rev-list command accepts.

>  bundle.c |   22 ++++++++++++++++++++--
>  1 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/bundle.c b/bundle.c
> index 0ba5df1..b44a4af 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -227,8 +227,26 @@ int create_bundle(struct bundle_header *header,
> const char *path,

Wrapped.

>         /* write references */
>         argc = setup_revisions(argc, argv, &revs, NULL);
> -       if (argc > 1)
> -               return error("unrecognized argument: %s'", argv[1]);
> +
> +       for (i = 1; i < argc; i++) {
> +               if ( !strcmp(argv[i], "--stdin") ) {

Style.

> +                       char line[1000];
> +                               while (fgets(line, sizeof(line),
> stdin) != NULL) {

Too deep indentation.  Wrapped.

> +                               int len = strlen(line);
> +                               if (len && line[len - 1] == '\n')
> +                                       line[--len] = '\0';
> +                               if (!len)
> +                                       break;
> +                               if (line[0] == '-')
> +                                       die("options not supported in
> --stdin mode");
> +                               if (handle_revision_arg(line, &revs, 0, 1))
> +                                       die("bad revision '%s'", line);
> +                       }
> +                       continue;
> +               }
> +
> +               return error("unrecognized argument: %s'", argv[i]);
> +       }

Having said that, I think copying and pasting read_revisions_from_stdin()
in bundle.c is a wrong approach to take.  Probably the function can easily
be split out of builtin-rev-list.c and moved to revision.c or somewhere
(which will be the first patch), and then a separate patch can add a few
lines to call it from bundle.c.

  parent reply	other threads:[~2008-07-05 18:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-05 16:30 [PATCH/v3] bundle.c: added --stdin option to git-bundle Adam Brewster
2008-07-05 16:54 ` Jakub Narebski
2008-07-05 18:15 ` Junio C Hamano [this message]
2008-07-05 20:40   ` [PATCH v4 0/3] Adam Brewster
2008-07-05 20:40     ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 20:40       ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-05 20:40         ` [PATCH] Add git-basis.perl to contrib directory Adam Brewster
2008-07-05 20:48       ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Miklos Vajna
2008-07-05 21:26         ` [PATCH v5] Adam Brewster
2008-07-05 21:26           ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 21:26             ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-06  0:57               ` Teach git-bundle to read revision arguments from stdin like git-rev-list Junio C Hamano
2008-07-06 14:28                 ` Adam Brewster
2008-07-06 14:28                   ` [PATCH] git-rev-list: tolerate multiple --stdin options Adam Brewster
2008-07-06 14:28                     ` [PATCH] Teach git-bundle to read revision arguments from stdin like Adam Brewster
2008-07-06  1:50           ` [PATCH v5] Junio C Hamano
2008-07-06  2:49             ` Adam Brewster
2008-07-06  0:57         ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vod5crydx.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=adambrewster@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=mdl123@verizon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).