From: Junio C Hamano Date: Tue, 13 Nov 2018 13:37:23 +0000 (+0900) Subject: Merge branch 'ag/rev-parse-all-exclude-fix' X-Git-Tag: v2.20.0-rc0~44 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/20d04b4419559825160c267fb05cc5c683fbece8?ds=inline;hp=-c Merge branch 'ag/rev-parse-all-exclude-fix' "git rev-parse --exclude=* --branches --branches" (i.e. first saying "add only things that do not match '*' out of all branches" and then adding all branches, without any exclusion this time") worked as expected, but "--exclude=* --all --all" did not work the same way, which has been fixed. * ag/rev-parse-all-exclude-fix: rev-parse: clear --exclude list after 'git rev-parse --all' --- 20d04b4419559825160c267fb05cc5c683fbece8 diff --combined builtin/rev-parse.c index 455f62246d,f4847d3008..10d4dab894 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -14,7 -14,6 +14,7 @@@ #include "revision.h" #include "split-index.h" #include "submodule.h" +#include "commit-reach.h" #define DO_REVS 1 #define DO_NOREV 2 @@@ -160,7 -159,7 +160,7 @@@ static void show_rev(int type, const st } } else if (abbrev) - show_with_type(type, find_unique_abbrev(oid->hash, abbrev)); + show_with_type(type, find_unique_abbrev(oid, abbrev)); else show_with_type(type, oid_to_hex(oid)); } @@@ -281,12 -280,8 +281,12 @@@ static int try_difference(const char *a if (symmetric) { struct commit_list *exclude; struct commit *a, *b; - a = lookup_commit_reference(&start_oid); - b = lookup_commit_reference(&end_oid); + a = lookup_commit_reference(the_repository, &start_oid); + b = lookup_commit_reference(the_repository, &end_oid); + if (!a || !b) { + *dotdot = '.'; + return 0; + } exclude = get_merge_bases(a, b); while (exclude) { struct commit *commit = pop_commit(&exclude); @@@ -333,12 -328,12 +333,12 @@@ static int try_parent_shorthands(const return 0; *dotdot = 0; - if (get_oid_committish(arg, &oid)) { + if (get_oid_committish(arg, &oid) || + !(commit = lookup_commit_reference(the_repository, &oid))) { *dotdot = '^'; return 0; } - commit = lookup_commit_reference(&oid); if (exclude_parent && exclude_parent > commit_list_count(commit->parents)) { *dotdot = '^'; @@@ -765,6 -760,7 +765,7 @@@ int cmd_rev_parse(int argc, const char } if (!strcmp(arg, "--all")) { for_each_ref(show_reference, NULL); + clear_ref_exclusion(&ref_excludes); continue; } if (skip_prefix(arg, "--disambiguate=", &arg)) { @@@ -884,8 -880,7 +885,8 @@@ continue; } if (!strcmp(arg, "--is-shallow-repository")) { - printf("%s\n", is_repository_shallow() ? "true" + printf("%s\n", + is_repository_shallow(the_repository) ? "true" : "false"); continue; } @@@ -893,8 -888,8 +894,8 @@@ if (read_cache() < 0) die(_("Could not read the index")); if (the_index.split_index) { - const unsigned char *sha1 = the_index.split_index->base_sha1; - const char *path = git_path("sharedindex.%s", sha1_to_hex(sha1)); + const struct object_id *oid = &the_index.split_index->base_oid; + const char *path = git_path("sharedindex.%s", oid_to_hex(oid)); strbuf_reset(&buf); puts(relative_path(path, prefix, &buf)); } diff --combined t/t6018-rev-list-glob.sh index db8a7834d8,b28075b65d..270e579c2d --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@@ -141,6 -141,18 +141,18 @@@ test_expect_success 'rev-parse accumula compare rev-parse "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches ' + test_expect_success 'rev-parse --branches clears --exclude' ' + compare rev-parse "--exclude=* --branches --branches" "--branches" + ' + + test_expect_success 'rev-parse --tags clears --exclude' ' + compare rev-parse "--exclude=* --tags --tags" "--tags" + ' + + test_expect_success 'rev-parse --all clears --exclude' ' + compare rev-parse "--exclude=* --all --all" "--all" + ' + test_expect_success 'rev-list --glob=refs/heads/subspace/*' ' compare rev-list "subspace/one subspace/two" "--glob=refs/heads/subspace/*" @@@ -255,28 -267,32 +267,28 @@@ test_expect_success 'rev-list accumulat compare rev-list "--exclude=refs/remotes/* --exclude=refs/tags/* --all" --branches ' -test_expect_failure 'rev-list should succeed with empty output on empty stdin' ' - >expect && - git rev-list --stdin actual && - test_cmp expect actual +test_expect_success 'rev-list should succeed with empty output on empty stdin' ' + git rev-list --stdin actual && + test_must_be_empty actual ' test_expect_success 'rev-list should succeed with empty output with all refs excluded' ' - >expect && git rev-list --exclude=* --all >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'rev-list should succeed with empty output with empty --all' ' ( test_create_repo empty && cd empty && - >expect && git rev-list --all >actual && - test_cmp expect actual + test_must_be_empty actual ) ' test_expect_success 'rev-list should succeed with empty output with empty glob' ' - >expect && git rev-list --glob=does-not-match-anything >actual && - test_cmp expect actual + test_must_be_empty actual ' test_expect_success 'shortlog accepts --glob/--tags/--remotes' '