Fix example checkout to forbid rather than require --#5184
Fix example checkout to forbid rather than require --#5184pks-t merged 1 commit intolibgit2:masterfrom
Conversation
Make the example program for checkout follow git syntax, where "--" indicates a file. This was likely just a strcmp return value confusion.
| err = -1; | ||
| goto cleanup; | ||
| } else if (strcmp("--", args.argv[args.pos])) { | ||
| } else if (!strcmp("--", args.argv[args.pos])) { |
There was a problem hiding this comment.
Yeah, this definitely looks like an error to me. If you ask me, though, this block could be improved even further: else if (args.pos == args.argc - 1) { resolve_refish... } else { fprintf(stderr, "Only switching between branches is supported"); }. We only support checking out a ref anyway, so we could just assert that we received a single parameter only and, if so, unconditionally pass that to resolve_refish. Because as the code stands right now, we just ignore every parameter after the first one.
There was a problem hiding this comment.
Sure -- there's a ton of possible improvements here. I just happened to notice that while trying to investigate #5185 (which turned out to be only for merges). So I'm unlikely to make further changes right now. Feel free to merge or ignore.
Make the example program for checkout follow git syntax, where "--" indicates a file. This was likely just a strcmp return value confusion.