@@ -344,7 +344,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
344
344
const char * object_ref , * tag ;
345
345
struct ref_lock * lock ;
346
346
347
- int annotate = 0 , sign = 0 , force = 0 , lines = 0 ,
347
+ int annotate = 0 , sign = 0 , force = 0 , lines = -1 ,
348
348
list = 0 , delete = 0 , verify = 0 ;
349
349
const char * msgfile = NULL , * keyid = NULL ;
350
350
struct msg_arg msg = { 0 , STRBUF_INIT };
@@ -380,9 +380,19 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
380
380
}
381
381
if (sign )
382
382
annotate = 1 ;
383
+ if (argc == 0 && !(delete || verify ))
384
+ list = 1 ;
383
385
386
+ if ((annotate || msg .given || msgfile || force ) &&
387
+ (list || delete || verify ))
388
+ usage_with_options (git_tag_usage , options );
389
+
390
+ if (list + delete + verify > 1 )
391
+ usage_with_options (git_tag_usage , options );
384
392
if (list )
385
- return list_tags (argv [0 ], lines );
393
+ return list_tags (argv [0 ], lines == -1 ? 0 : lines );
394
+ if (lines != -1 )
395
+ die ("-n option is only allowed with -l." );
386
396
if (delete )
387
397
return for_each_tag_name (argv , delete_tag );
388
398
if (verify )
@@ -407,11 +417,6 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
407
417
}
408
418
}
409
419
410
- if (argc == 0 ) {
411
- if (annotate )
412
- usage_with_options (git_tag_usage , options );
413
- return list_tags (NULL , lines );
414
- }
415
420
tag = argv [0 ];
416
421
417
422
object_ref = argc == 2 ? argv [1 ] : "HEAD" ;
0 commit comments