From: Junio C Hamano Date: Tue, 23 Feb 2010 20:05:18 +0000 (-0800) Subject: Merge branch 'il/rev-glob' X-Git-Tag: v1.7.1-rc0~43^2~13 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/80eac928ae11d4e417feddcc6a1ec373cf41e14f?ds=inline;hp=-c Merge branch 'il/rev-glob' --- 80eac928ae11d4e417feddcc6a1ec373cf41e14f diff --combined Documentation/git-log.txt index ff4063b020,0acd526303..0e39bb61ee --- a/Documentation/git-log.txt +++ b/Documentation/git-log.txt @@@ -14,9 -14,9 +14,9 @@@ DESCRIPTIO ----------- Shows the commit logs. -The command takes options applicable to the 'git-rev-list' +The command takes options applicable to the 'git rev-list' command to control what is shown and how, and options applicable to -the 'git-diff-*' commands to control how the changes +the 'git diff-*' commands to control how the changes each commit introduces are shown. @@@ -107,6 -107,17 +107,17 @@@ git log --follow builtin-rev-list.c: those commits that occurred before the file was given its present name. + git log --branches --not --remotes=origin:: + + Shows all commits that are in any of local branches but not in + any of remote tracking branches for 'origin' (what you have that + origin doesn't). + + git log master --not --remotes=*/master:: + + Shows all commits that are in local master but not in any remote + repository master branches. + Discussion ---------- diff --combined Documentation/git-rev-list.txt index 78d3f48dfb,f85711676b..ae17c8a6fb --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@@ -9,7 -9,7 +9,7 @@@ git-rev-list - Lists commit objects in SYNOPSIS -------- [verse] -'git-rev-list' [ \--max-count=number ] +'git rev-list' [ \--max-count=number ] [ \--skip=number ] [ \--max-age=timestamp ] [ \--min-age=timestamp ] @@@ -21,9 -21,10 +21,10 @@@ [ \--full-history ] [ \--not ] [ \--all ] - [ \--branches ] - [ \--tags ] - [ \--remotes ] + [ \--branches[=pattern] ] + [ \--tags=[pattern] ] + [ \--remotes=[pattern] ] + [ \--glob=glob-pattern ] [ \--stdin ] [ \--quiet ] [ \--topo-order ] @@@ -93,8 -94,8 +94,8 @@@ between the two operands. The followin 'rev-list' is a very essential git command, since it provides the ability to build and traverse commit ancestry graphs. For this reason, it has a lot of different options that enables it to be -used by commands as different as 'git-bisect' and -'git-repack'. +used by commands as different as 'git bisect' and +'git repack'. OPTIONS ------- diff --combined Documentation/git-rev-parse.txt index d375f1af10,61f4835a10..c9184fcc76 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@@ -15,16 -15,16 +15,16 @@@ DESCRIPTIO Many git porcelainish commands take mixture of flags (i.e. parameters that begin with a dash '-') and parameters -meant for the underlying 'git-rev-list' command they use internally +meant for the underlying 'git rev-list' command they use internally and flags and parameters for the other commands they use -downstream of 'git-rev-list'. This command is used to +downstream of 'git rev-list'. This command is used to distinguish between them. OPTIONS ------- --parseopt:: - Use 'git-rev-parse' in option parsing mode (see PARSEOPT section below). + Use 'git rev-parse' in option parsing mode (see PARSEOPT section below). --keep-dashdash:: Only meaningful in `--parseopt` mode. Tells the option parser to echo @@@ -36,17 -36,17 +36,17 @@@ that take options themself. --sq-quote:: - Use 'git-rev-parse' in shell quoting mode (see SQ-QUOTE + Use 'git rev-parse' in shell quoting mode (see SQ-QUOTE section below). In contrast to the `--sq` option below, this mode does only quoting. Nothing else is done to command input. --revs-only:: Do not output flags and parameters not meant for - 'git-rev-list' command. + 'git rev-list' command. --no-revs:: Do not output flags and parameters meant for - 'git-rev-list' command. + 'git rev-list' command. --flags:: Do not output non-flag parameters. @@@ -74,7 -74,7 +74,7 @@@ properly quoted for consumption by shell. Useful when you expect your parameter to contain whitespaces and newlines (e.g. when using pickaxe `-S` with - 'git-diff-\*'). In contrast to the `--sq-quote` option, + 'git diff-\*'). In contrast to the `--sq-quote` option, the command input is still interpreted as usual. --not:: @@@ -103,18 -103,25 +103,28 @@@ --all:: Show all refs found in `$GIT_DIR/refs`. - --branches:: - Show branch refs found in `$GIT_DIR/refs/heads`. - - --tags:: - Show tag refs found in `$GIT_DIR/refs/tags`. - - --remotes:: - Show tag refs found in `$GIT_DIR/refs/remotes`. + --branches[=pattern]:: + --tags[=pattern]:: + --remotes[=pattern]:: + Show all branches, tags, or remote-tracking branches, + respectively (i.e., refs found in `$GIT_DIR/refs/heads`, + `$GIT_DIR/refs/tags`, or `$GIT_DIR/refs/remotes`, + respectively). + + + If a `pattern` is given, only refs matching the given shell glob are + shown. If the pattern does not contain a globbing character (`?`, + `\*`, or `[`), it is turned into a prefix match by appending `/\*`. + + --glob=pattern:: + Show all refs matching the shell glob pattern `pattern`. If + the pattern does not start with `refs/`, this is automatically + prepended. If the pattern does not contain a globbing + character (`?`, `\*`, or `[`), it is turned into a prefix + match by appending `/\*`. +--show-toplevel:: + Show the absolute path of the top-level directory. + --show-prefix:: When the command is invoked from a subdirectory, show the path of the current directory relative to the top-level @@@ -148,12 -155,12 +158,12 @@@ --since=datestring:: --after=datestring:: Parse the date string, and output the corresponding - --max-age= parameter for 'git-rev-list'. + --max-age= parameter for 'git rev-list'. --until=datestring:: --before=datestring:: Parse the date string, and output the corresponding - --min-age= parameter for 'git-rev-list'. + --min-age= parameter for 'git rev-list'. ...:: Flags and parameters to be parsed. @@@ -174,7 -181,7 +184,7 @@@ blobs contained in a commit name the same commit object if there are no other object in your repository whose object name starts with dae86e. -* An output from 'git-describe'; i.e. a closest tag, optionally +* An output from 'git describe'; i.e. a closest tag, optionally followed by a dash and a number of commits, followed by a dash, a `g`, and an abbreviated object name. @@@ -200,13 -207,13 +210,13 @@@ + HEAD names the commit your changes in the working tree is based on. FETCH_HEAD records the branch you fetched from a remote repository -with your last 'git-fetch' invocation. +with your last 'git fetch' invocation. ORIG_HEAD is created by commands that moves your HEAD in a drastic way, to record the position of the HEAD before their operation, so that you can change the tip of the branch back to the state before you ran them easily. MERGE_HEAD records the commit(s) you are merging into your branch -when you run 'git-merge'. +when you run 'git merge'. * A ref followed by the suffix '@' with a date specification enclosed in a brace @@@ -311,7 -318,7 +321,7 @@@ G H I SPECIFYING RANGES ----------------- -History traversing commands such as 'git-log' operate on a set +History traversing commands such as 'git log' operate on a set of commits, not just a single commit. To these commands, specifying a single revision with the notation described in the previous section means the set of commits reachable from that @@@ -352,7 -359,7 +362,7 @@@ Here are a handful of examples PARSEOPT -------- -In `--parseopt` mode, 'git-rev-parse' helps massaging options to bring to shell +In `--parseopt` mode, 'git rev-parse' helps massaging options to bring to shell scripts the same facilities C builtins have. It works as an option normalizer (e.g. splits single switches aggregate values), a bit like `getopt(1)` does. @@@ -364,7 -371,7 +374,7 @@@ usage on the standard error stream, an Input Format ~~~~~~~~~~~~ -'git-rev-parse --parseopt' input format is fully text based. It has two parts, +'git rev-parse --parseopt' input format is fully text based. It has two parts, separated by a line that contains only `--`. The lines before the separator (should be more than one) are used for the usage. The lines after the separator describe the options. @@@ -423,13 -430,13 +433,13 @@@ eval `echo "$OPTS_SPEC" | git rev-pars SQ-QUOTE -------- -In `--sq-quote` mode, 'git-rev-parse' echoes on the standard output a +In `--sq-quote` mode, 'git rev-parse' echoes on the standard output a single line suitable for `sh(1)` `eval`. This line is made by normalizing the arguments following `--sq-quote`. Nothing other than quoting the arguments is done. If you want command input to still be interpreted as usual by -'git-rev-parse' before the output is shell quoted, see the `--sq` +'git rev-parse' before the output is shell quoted, see the `--sq` option. Example diff --combined builtin-rev-parse.c index cbe5b428ad,d14fe20692..a8c5043ded --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@@ -41,6 -41,7 +41,7 @@@ static int is_rev_argument(const char * "--all", "--bisect", "--dense", + "--branches=", "--branches", "--header", "--max-age=", @@@ -51,8 -52,11 +52,11 @@@ "--objects-edge", "--parents", "--pretty", + "--remotes=", "--remotes", + "--glob=", "--sparse", + "--tags=", "--tags", "--topo-order", "--date-order", @@@ -569,24 -573,37 +573,43 @@@ int cmd_rev_parse(int argc, const char for_each_ref_in("refs/bisect/good", anti_reference, NULL); continue; } + if (!prefixcmp(arg, "--branches=")) { + for_each_glob_ref_in(show_reference, arg + 11, + "refs/heads/", NULL); + continue; + } if (!strcmp(arg, "--branches")) { for_each_branch_ref(show_reference, NULL); continue; } + if (!prefixcmp(arg, "--tags=")) { + for_each_glob_ref_in(show_reference, arg + 7, + "refs/tags/", NULL); + continue; + } if (!strcmp(arg, "--tags")) { for_each_tag_ref(show_reference, NULL); continue; } + if (!prefixcmp(arg, "--glob=")) { + for_each_glob_ref(show_reference, arg + 7, NULL); + continue; + } + if (!prefixcmp(arg, "--remotes=")) { + for_each_glob_ref_in(show_reference, arg + 10, + "refs/remotes/", NULL); + continue; + } if (!strcmp(arg, "--remotes")) { for_each_remote_ref(show_reference, NULL); continue; } + if (!strcmp(arg, "--show-toplevel")) { + const char *work_tree = get_git_work_tree(); + if (work_tree) + puts(work_tree); + continue; + } if (!strcmp(arg, "--show-prefix")) { if (prefix) puts(prefix); diff --combined revision.c index f3b82d97bc,1e9277d335..1d3457cb6a --- a/revision.c +++ b/revision.c @@@ -699,12 -699,18 +699,18 @@@ static int handle_one_ref(const char *p return 0; } + static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs, + unsigned flags) + { + cb->all_revs = revs; + cb->all_flags = flags; + } + static void handle_refs(struct rev_info *revs, unsigned flags, int (*for_each)(each_ref_fn, void *)) { struct all_refs_cb cb; - cb.all_revs = revs; - cb.all_flags = flags; + init_all_refs_cb(&cb, revs, flags); for_each(handle_one_ref, &cb); } @@@ -1161,22 -1167,13 +1167,22 @@@ static int handle_revision_opt(struct r revs->verbose_header = 1; } else if (!strcmp(arg, "--pretty")) { revs->verbose_header = 1; + revs->pretty_given = 1; get_commit_format(arg+8, revs); } else if (!prefixcmp(arg, "--pretty=") || !prefixcmp(arg, "--format=")) { revs->verbose_header = 1; + revs->pretty_given = 1; get_commit_format(arg+9, revs); + } else if (!strcmp(arg, "--show-notes")) { + revs->show_notes = 1; + revs->show_notes_given = 1; + } else if (!strcmp(arg, "--no-notes")) { + revs->show_notes = 0; + revs->show_notes_given = 1; } else if (!strcmp(arg, "--oneline")) { revs->verbose_header = 1; get_commit_format("oneline", revs); + revs->pretty_given = 1; revs->abbrev_commit = 1; } else if (!strcmp(arg, "--graph")) { revs->topo_order = 1; @@@ -1361,6 -1358,30 +1367,30 @@@ int setup_revisions(int argc, const cha handle_refs(revs, flags, for_each_remote_ref); continue; } + if (!prefixcmp(arg, "--glob=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref(handle_one_ref, arg + 7, &cb); + continue; + } + if (!prefixcmp(arg, "--branches=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 11, "refs/heads/", &cb); + continue; + } + if (!prefixcmp(arg, "--tags=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 7, "refs/tags/", &cb); + continue; + } + if (!prefixcmp(arg, "--remotes=")) { + struct all_refs_cb cb; + init_all_refs_cb(&cb, revs, flags); + for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb); + continue; + } if (!strcmp(arg, "--reflog")) { handle_reflog(revs, flags); continue;