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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux