git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 1/2] init: support --import to add all files and commit  right after init
Date: Thu, 26 Mar 2009 09:54:56 +1100	[thread overview]
Message-ID: <fcaeb9bf0903251554o5c6d390cmbb81d06f9886f8e2@mail.gmail.com> (raw)
In-Reply-To: <20090325113510.GB4437@coredump.intra.peff.net>

2009/3/25 Jeff King <peff@peff.net>:
> On Wed, Mar 25, 2009 at 09:58:40PM +1100, Nguyễn Thái Ngọc Duy wrote:
>
>> -'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]]
>> +'git init' [-q | --quiet] [--bare] [--template=<template_directory>]
>> +           [--shared[=<permissions>]] [-m|--import [<message>]]
>
> What happened to --import=? Whether or not "--import <arg>" works, the
> --long-opt= form should always work.
>
>> +             else if (!strcmp(arg, "--import") || !strcmp(arg, "-m")) {
>> +                     if (i+1 >= argc)
>> +                             import_message = "Initial commit";
>> +                     else {
>> +                             import_message = argv[2];
>> +                             i++;
>> +                             argv++;
>> +                     }
>> +             }
>
> This is the wrong way to do optional arguments. It means that
>
>  git init --template=foo --import
>
> is different from
>
>  git init --import --template=foo
>
> I think what you want is:
>
>  else if (!strcmp(arg, "-m")) {
>    if (i+1 >= argc)
>      die("-m requires an import message");
>    import_message = argv[2];
>    i++;
>    argv++;
>  }
>  else if (!strcmp(arg, "--import"))
>    import_message = "Initial commit";
>  else if (!prefixcmp(arg, "--import="))
>      import_message = arg+9;
>
> That is, --import has a message or not depending on the '=', and "-m"
> always has a message. If you want "-m" to optionally have a message then
> it must be used as
>
>  git init -mfoo

Right. Should not work late (or send it in the same night). Will rework.
-- 
Duy

  reply	other threads:[~2009-03-25 22:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25 10:58 [PATCH 1/2] init: support --import to add all files and commit right after init Nguyễn Thái Ngọc Duy
2009-03-25 11:35 ` Jeff King
2009-03-25 22:54   ` Nguyen Thai Ngoc Duy [this message]
2009-03-25 11:56 ` Santi Béjar
2009-03-25 12:38   ` Johannes Schindelin
2009-03-25 12:42     ` Jeff King
2009-03-25 12:49       ` Santi Béjar
2009-03-26 21:23         ` Markus Heidelberg
2009-03-27  2:03           ` Johannes Schindelin
2009-03-27  5:06             ` Jeff King
2009-03-27  5:08               ` Jeff King
2009-03-28 10:58             ` Markus Heidelberg
2009-03-28 12:39               ` Johannes Schindelin
2009-03-28 13:09                 ` Markus Heidelberg
  -- strict thread matches above, loose matches on Subject: below --
2009-03-26 10:10 Nguyễn Thái Ngọc Duy
2009-03-26 10:13 ` Jeff King

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

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

  git send-email \
    --in-reply-to=fcaeb9bf0903251554o5c6d390cmbb81d06f9886f8e2@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.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.
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).