git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] init: support --import to add all files and commit right after init

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Mar 25, 2009, 22:54 UTC
Message-ID
<fcaeb9bf0903251554o5c6d390cmbb81d06f9886f8e2@mail.gmail.com>
In-Reply-To
<20090325113510.GB4437@coredump.intra.peff.net>
2009/3/25 Jeff King <peff@peff.net>:
Show 46 quoted lines
> 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
Previous: Jeff KingNext: Santi Béjar
Message 3 of 14 in “init: support --import to add all files and commit right after init”
  1. 1/2 init: support --import to add all files and commit right after initNguyễn Thái Ngọc Duy, Mar 25, 2009
  2. Jeff KingMar 25, 2009
  3. Nguyen Thai Ngoc DuyMar 25, 2009
  4. Santi BéjarMar 25, 2009
  5. Johannes SchindelinMar 25, 2009
  6. Jeff KingMar 25, 2009
  7. Santi BéjarMar 25, 2009
  8. Markus HeidelbergMar 26, 2009
  9. Johannes SchindelinMar 27, 2009
  10. Jeff KingMar 27, 2009
  11. Jeff KingMar 27, 2009
  12. Markus HeidelbergMar 28, 2009
  13. Johannes SchindelinMar 28, 2009
  14. Markus HeidelbergMar 28, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.