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

Re: [PATCH 2/2] cmd_fetch_pack(): fix constness problem and memory leak

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
May 2, 2012, 11:14 UTC
Message-ID
<CACsJy8AE7Y1Y5Drda39OfSKwTQN7oSSrb2Ai+jq_hi8XC4dtsw@mail.gmail.com>
In-Reply-To
<1335955259-15309-3-git-send-email-mhagger@alum.mit.edu>
On Wed, May 2, 2012 at 5:40 PM,  <mhagger@alum.mit.edu> wrote:
Show 117 quoted lines
>                const char *arg = argv[i];
>
> -               if (*arg == '-') {
> -                       if (!prefixcmp(arg, "--upload-pack=")) {
> -                               args.uploadpack = arg + 14;
> -                               continue;
> -                       }
> -                       if (!prefixcmp(arg, "--exec=")) {
> -                               args.uploadpack = arg + 7;
> -                               continue;
> -                       }
> -                       if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
> -                               args.quiet = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
> -                               args.lock_pack = args.keep_pack;
> -                               args.keep_pack = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--thin", arg)) {
> -                               args.use_thin_pack = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--include-tag", arg)) {
> -                               args.include_tag = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--all", arg)) {
> -                               args.fetch_all = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--stdin", arg)) {
> -                               args.stdin_refs = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("-v", arg)) {
> -                               args.verbose = 1;
> -                               continue;
> -                       }
> -                       if (!prefixcmp(arg, "--depth=")) {
> -                               args.depth = strtol(arg + 8, NULL, 0);
> -                               continue;
> -                       }
> -                       if (!strcmp("--no-progress", arg)) {
> -                               args.no_progress = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--stateless-rpc", arg)) {
> -                               args.stateless_rpc = 1;
> -                               continue;
> -                       }
> -                       if (!strcmp("--lock-pack", arg)) {
> -                               args.lock_pack = 1;
> -                               pack_lockfile_ptr = &pack_lockfile;
> -                               continue;
> -                       }
> -                       usage(fetch_pack_usage);
> +               if (!prefixcmp(arg, "--upload-pack=")) {
> +                       args.uploadpack = arg + 14;
> +                       continue;
> +               }
> +               if (!prefixcmp(arg, "--exec=")) {
> +                       args.uploadpack = arg + 7;
> +                       continue;
> +               }
> +               if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
> +                       args.quiet = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
> +                       args.lock_pack = args.keep_pack;
> +                       args.keep_pack = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--thin", arg)) {
> +                       args.use_thin_pack = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--include-tag", arg)) {
> +                       args.include_tag = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--all", arg)) {
> +                       args.fetch_all = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--stdin", arg)) {
> +                       args.stdin_refs = 1;
> +                       continue;
> +               }
> +               if (!strcmp("-v", arg)) {
> +                       args.verbose = 1;
> +                       continue;
> +               }
> +               if (!prefixcmp(arg, "--depth=")) {
> +                       args.depth = strtol(arg + 8, NULL, 0);
> +                       continue;
>                }
> -               dest = arg;
> -               heads = (char **)(argv + i + 1);
> -               nr_heads = argc - i - 1;
> -               break;
> +               if (!strcmp("--no-progress", arg)) {
> +                       args.no_progress = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--stateless-rpc", arg)) {
> +                       args.stateless_rpc = 1;
> +                       continue;
> +               }
> +               if (!strcmp("--lock-pack", arg)) {
> +                       args.lock_pack = 1;
> +                       pack_lockfile_ptr = &pack_lockfile;
> +                       continue;
> +               }
> +               usage(fetch_pack_usage);

Ugh, perhaps you can convert the above to parse_options() too while you're making changes in this part? You can say no, I'll do it (my itch anyway).

-- 
Duy
Previous: mhagger@alum.mit.eduNext: Michael Haggerty
Message 4 of 13 in “Fix some constness errors in fetch-pack”
  1. 0/2 Fix some constness errors in fetch-packmhagger@alum.mit.edu, May 2, 2012
  2. 1/2 cmd_fetch_pack(): declare dest to be constmhagger@alum.mit.edu, May 2, 2012
  3. 2/2 cmd_fetch_pack(): fix constness problem and memory leakmhagger@alum.mit.edu, May 2, 2012
  4. Nguyen Thai Ngoc DuyMay 2, 2012
  5. Michael HaggertyMay 2, 2012
  6. 0/3 Fix some constness errors in fetch-pack and parseopt conversionNguyễn Thái Ngọc Duy, May 2, 2012
  7. 1/3 cmd_fetch_pack(): declare dest to be constNguyễn Thái Ngọc Duy, May 2, 2012
  8. 2/3 fetch-pack: use parse_options()Nguyễn Thái Ngọc Duy, May 2, 2012
  9. 3/3 cmd_fetch_pack(): fix constness problem and memory leakNguyễn Thái Ngọc Duy, May 2, 2012
  10. Junio C HamanoMay 2, 2012
  11. Junio C HamanoMay 21, 2012
  12. Michael HaggertyMay 21, 2012
  13. Michael HaggertyMay 19, 2012

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.