Skip to content

Commit c83e8c1

Browse files
stefanbellergitster
authored andcommitted
hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP
This task emerged from b04ba2b (parse-options: deprecate OPT_BOOLEAN, 2011-09-27). hash-object is a plumbing layer command, so better not change the input/output behavior for now. Unfortunately we have these lines relying on the count up mechanism of OPT_BOOLEAN: if (hashstdin > 1) errstr = "Multiple --stdin arguments are not supported"; Using OPT_BOOL will make "git hash-object --stdin --stdin" the same as "git hash-object --stdin", resulting in just one object, which will surprise users with an expectation to see two objects hashed. Because it is not good to silently succeed and give an unexpected result, even when the expectation is unrealistic, we use COUNTUP to explicitly catch such an error. Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05efb7b commit c83e8c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static const char *vpath;
7171
static const struct option hash_object_options[] = {
7272
OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
7373
OPT_BOOL('w', NULL, &write_object, N_("write the object into the object database")),
74-
OPT_BOOLEAN( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
74+
OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
7575
OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")),
7676
OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
7777
OPT_STRING( 0 , "path", &vpath, N_("file"), N_("process file as it were from this path")),

0 commit comments

Comments
 (0)