Re: [PATCH 3/4] pack-objects.c: do stdin parsing via revision.c's API
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 9, 2021, 08:10 UTC
- Message-ID
- <xmqqk0n3ihla.fsf@gitster.g>
- In-Reply-To
- <patch-3.4-1a9eb26587-20210608T121008Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 40 quoted lines
> @@ -3761,39 +3789,11 @@ static void get_object_list(int ac, const char **av)
> /* make sure shallows are read */
> is_repository_shallow(the_repository);
>
> + revs.stdin_handling = REV_INFO_STDIN_ALWAYS_READ;
> + revs.handle_stdin_line = get_object_list_handle_stdin_line;
> + revs.stdin_line_priv = &flags;
> setup_revisions(ac, av, &revs, &s_r_opt);
>
> - save_warning = warn_on_object_refname_ambiguity;
> - warn_on_object_refname_ambiguity = 0;
> -
> - while (fgets(line, sizeof(line), stdin) != NULL) {
> - int len = strlen(line);
> - if (len && line[len - 1] == '\n')
> - line[--len] = 0;
> - if (!len)
> - break;
> - if (*line == '-') {
> - if (!strcmp(line, "--not")) {
> - flags ^= UNINTERESTING;
> - write_bitmap_index = 0;
> - continue;
> - }
> - if (starts_with(line, "--shallow ")) {
> - struct object_id oid;
> - if (get_oid_hex(line + 10, &oid))
> - die("not an object name '%s'", line + 10);
> - register_shallow(the_repository, &oid);
> - use_bitmap_index = 0;
> - continue;
> - }
> - die(_("not a rev '%s'"), line);
> - }
> - if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
> - die(_("bad revision '%s'"), line);
> - }
> -
> - warn_on_object_refname_ambiguity = save_warning;
> -OK, so this shows the primary value of the entire series---we managed to lose handwritten loop around a logic that gets migrated into a callback function that has been used to read revisions from the standard input elsewhere in the system.
All four patches are cleanly explained and nicely done.
Thanks.