From: Junio C Hamano Date: Thu, 5 Dec 2013 20:59:09 +0000 (-0800) Subject: Merge branch 'jc/ref-excludes' X-Git-Tag: v1.9-rc0~95 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10167eb251e177349eebf24650d3c0cc26bd0d75;p=thirdparty%2Fgit.git Merge branch 'jc/ref-excludes' People often wished a way to tell "git log --branches" (and "git log --remotes --not --branches") to exclude some local branches from the expansion of "--branches" (similarly for "--tags", "--all" and "--glob="). Now they have one. * jc/ref-excludes: rev-parse: introduce --exclude= to tame wildcards rev-list --exclude: export add/clear-ref-exclusion and ref-excluded API rev-list --exclude: tests document --exclude option revision: introduce --exclude= to tame wildcards --- 10167eb251e177349eebf24650d3c0cc26bd0d75 diff --cc Documentation/git-rev-parse.txt index a436b24cc4,4cba660bc8..0d2cdcde55 --- a/Documentation/git-rev-parse.txt +++ b/Documentation/git-rev-parse.txt @@@ -177,20 -155,32 +177,34 @@@ shown. If the pattern does not contai character (`?`, `*`, or `[`), it is turned into a prefix match by appending `/*`. + --exclude=:: + Do not include refs matching '' that the next `--all`, + `--branches`, `--tags`, `--remotes`, or `--glob` would otherwise + consider. Repetitions of this option accumulate exclusion patterns + up to the next `--all`, `--branches`, `--tags`, `--remotes`, or + `--glob` option (other options or arguments do not clear + accumlated patterns). + + + The patterns given should not begin with `refs/heads`, `refs/tags`, or + `refs/remotes` when applied to `--branches`, `--tags`, or `--remotes`, + respectively, and they must begin with `refs/` when applied to `--glob` + or `--all`. If a trailing '/{asterisk}' is intended, it must be given + explicitly. + ---show-toplevel:: - Show the absolute path of the top-level directory. +--disambiguate=:: + Show every object whose name begins with the given prefix. + The must be at least 4 hexadecimal digits long to + avoid listing each and every object in the repository by + mistake. ---show-prefix:: - When the command is invoked from a subdirectory, show the - path of the current directory relative to the top-level - directory. +Options for Files +~~~~~~~~~~~~~~~~~ ---show-cdup:: - When the command is invoked from a subdirectory, show the - path of the top-level directory relative to the current - directory (typically a sequence of "../", or an empty string). +--local-env-vars:: + List the GIT_* environment variables that are local to the + repository (e.g. GIT_DIR or GIT_WORK_TREE, but not GIT_EDITOR). + Only the names of the variables are listed, not their value, + even if they are set. --git-dir:: Show `$GIT_DIR` if defined. Otherwise show the path to diff --cc Documentation/rev-list-options.txt index 2991d70a4a,7de3ad5427..03533af715 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@@ -153,7 -174,23 +153,22 @@@ parents) and `--max-parents=-1` (negati is automatically prepended if missing. If pattern lacks '?', '{asterisk}', or '[', '/{asterisk}' at the end is implied. + --exclude=:: + + Do not include refs matching '' that the next `--all`, + `--branches`, `--tags`, `--remotes`, or `--glob` would otherwise + consider. Repetitions of this option accumulate exclusion patterns + up to the next `--all`, `--branches`, `--tags`, `--remotes`, or + `--glob` option (other options or arguments do not clear + accumlated patterns). + + + The patterns given should not begin with `refs/heads`, `refs/tags`, or + `refs/remotes` when applied to `--branches`, `--tags`, or `--remotes`, + respectively, and they must begin with `refs/` when applied to `--glob` + or `--all`. If a trailing '/{asterisk}' is intended, it must be given + explicitly. + --ignore-missing:: - Upon seeing an invalid object name in the input, pretend as if the bad input was not given. diff --cc builtin/rev-parse.c index 3e8c4cce06,f52f8048bb..1d9ecafd41 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -30,7 -32,7 +32,8 @@@ static int abbrev_ref static int abbrev_ref_strict; static int output_sq; +static int stuck_long; + static struct string_list *ref_excludes; /* * Some arguments are relevant "revision" arguments, @@@ -651,14 -671,13 +662,19 @@@ int cmd_rev_parse(int argc, const char } if (!strcmp(arg, "--remotes")) { for_each_remote_ref(show_reference, NULL); + clear_ref_exclusion(&ref_excludes); + continue; + } + if (!prefixcmp(arg, "--exclude=")) { + add_ref_exclusion(&ref_excludes, arg + 10); continue; } + if (!strcmp(arg, "--local-env-vars")) { + int i; + for (i = 0; local_repo_env[i]; i++) + printf("%s\n", local_repo_env[i]); + continue; + } if (!strcmp(arg, "--show-toplevel")) { const char *work_tree = get_git_work_tree(); if (work_tree) diff --cc revision.h index 89132df2fa,c67c46d716..88967d6a24 --- a/revision.h +++ b/revision.h @@@ -189,11 -190,13 +192,16 @@@ struct rev_info /* line level range that we are chasing */ struct decoration line_log_data; + + /* copies of the parent lists, for --full-diff display */ + struct saved_parents *saved_parents_slab; }; + extern int ref_excluded(struct string_list *, const char *path); + void clear_ref_exclusion(struct string_list **); + void add_ref_exclusion(struct string_list **, const char *exclude); + + #define REV_TREE_SAME 0 #define REV_TREE_NEW 1 /* Only new files */ #define REV_TREE_OLD 2 /* Only files removed */