cmd_fetch_pack(): combine the loop termination conditions
If an argument that does not start with '-' is found, the loop is terminated. So move that check into the for-loop condition. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
May 21, 2012 at 09:59 UTC
ff22ff9909a09d775c740f31443f96edd5b5e006
1 file changed
+55
-58
builtin/fetch-pack.c
+55
-58
@@ -910,67 +910,64 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
910
packet_trace_identity("fetch-pack");
911
912
heads = NULL;
913
- for (i = 1; i < argc; i++) {
913
+ for (i = 1; i < argc && *argv[i] == '-'; i++) {
914
const char *arg = argv[i];
915
916
- if (*arg == '-') {
917
- if (!prefixcmp(arg, "--upload-pack=")) {
918
- args.uploadpack = arg + 14;
919
- continue;
920
- }
921
- if (!prefixcmp(arg, "--exec=")) {
922
- args.uploadpack = arg + 7;
923
- continue;
924
- }
925
- if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
926
- args.quiet = 1;
927
- continue;
928
- }
929
- if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
930
- args.lock_pack = args.keep_pack;
931
- args.keep_pack = 1;
932
- continue;
933
- }
934
- if (!strcmp("--thin", arg)) {
935
- args.use_thin_pack = 1;
936
- continue;
937
- }
938
- if (!strcmp("--include-tag", arg)) {
939
- args.include_tag = 1;
940
- continue;
941
- }
942
- if (!strcmp("--all", arg)) {
943
- args.fetch_all = 1;
944
- continue;
945
- }
946
- if (!strcmp("--stdin", arg)) {
947
- args.stdin_refs = 1;
948
- continue;
949
- }
950
- if (!strcmp("-v", arg)) {
951
- args.verbose = 1;
952
- continue;
953
- }
954
- if (!prefixcmp(arg, "--depth=")) {
955
- args.depth = strtol(arg + 8, NULL, 0);
956
- continue;
957
- }
958
- if (!strcmp("--no-progress", arg)) {
959
- args.no_progress = 1;
960
- continue;
961
- }
962
- if (!strcmp("--stateless-rpc", arg)) {
963
- args.stateless_rpc = 1;
964
- continue;
965
- }
966
- if (!strcmp("--lock-pack", arg)) {
967
- args.lock_pack = 1;
968
- pack_lockfile_ptr = &pack_lockfile;
969
- continue;
970
- }
971
- usage(fetch_pack_usage);
916
+ if (!prefixcmp(arg, "--upload-pack=")) {
917
+ args.uploadpack = arg + 14;
918
+ continue;
919
+ }
920
+ if (!prefixcmp(arg, "--exec=")) {
921
+ args.uploadpack = arg + 7;
922
+ continue;
923
+ }
924
+ if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
925
+ args.quiet = 1;
926
+ continue;
927
+ }
928
+ if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
929
+ args.lock_pack = args.keep_pack;
930
+ args.keep_pack = 1;
931
+ continue;
932
+ }
933
+ if (!strcmp("--thin", arg)) {
934
+ args.use_thin_pack = 1;
935
+ continue;
936
+ }
937
+ if (!strcmp("--include-tag", arg)) {
938
+ args.include_tag = 1;
939
+ continue;
940
+ }
941
+ if (!strcmp("--all", arg)) {
942
+ args.fetch_all = 1;
943
+ continue;
944
}
973
- break;
945
+ if (!strcmp("--stdin", arg)) {
946
+ args.stdin_refs = 1;
947
+ continue;
948
+ }
949
+ if (!strcmp("-v", arg)) {
950
+ args.verbose = 1;
951
+ continue;
952
+ }
953
+ if (!prefixcmp(arg, "--depth=")) {
954
+ args.depth = strtol(arg + 8, NULL, 0);
955
+ continue;
956
+ }
957
+ if (!strcmp("--no-progress", arg)) {
958
+ args.no_progress = 1;
959
+ continue;
960
+ }
961
+ if (!strcmp("--stateless-rpc", arg)) {
962
+ args.stateless_rpc = 1;
963
+ continue;
964
+ }
965
+ if (!strcmp("--lock-pack", arg)) {
966
+ args.lock_pack = 1;
967
+ pack_lockfile_ptr = &pack_lockfile;
968
+ continue;
969
+ }
970
+ usage(fetch_pack_usage);
971
}
972
973
if (i < argc)