Skip to content

Commit c4112bb

Browse files
peffgitster
authored andcommitted
git-remote: show all remotes with "git remote show"
Many other commands use the "no arguments" form to show a list (e.g., git-branch, git-tag). While we did show all remotes for just "git remote", we displayed a usage error for "git remote show" with no arguments. This is counterintuitive, since by giving it _more_ information, we get _less_ result. The usage model can now be thought of as: - "git remote show <remote>": show a remote - "git remote show": show all remotes - "git remote": assume "show"; i.e., shorthand for "git remote show" Signed-off-by: Jeff King <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7134973 commit c4112bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

builtin-remote.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ static const char * const builtin_remote_usage[] = {
1919

2020
static int verbose;
2121

22+
static int show_all(void);
23+
2224
static inline int postfixcmp(const char *string, const char *postfix)
2325
{
2426
int len1 = strlen(string), len2 = strlen(postfix);
@@ -380,8 +382,11 @@ static int show_or_prune(int argc, const char **argv, int prune)
380382

381383
argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
382384

383-
if (argc < 1)
385+
if (argc < 1) {
386+
if (!prune)
387+
return show_all();
384388
usage_with_options(builtin_remote_usage, options);
389+
}
385390

386391
memset(&states, 0, sizeof(states));
387392
for (; argc; argc--, argv++) {

0 commit comments

Comments
 (0)