Subject: Re: [PATCH 3/4] pack-objects.c: do stdin parsing via revision.c's API

From: Junio C Hamano <[email-masked]>
Date: Wed, 09 Jun 2021 17:10:25 +0900

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> @@ -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.