From: Junio C Hamano Date: Fri, 25 May 2007 04:35:29 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.5.3-rc0~197 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/18bece43675ea0dc9022a7868865e02808b7af7f?hp=-c Merge branch 'maint' * maint: fix memory leak in parse_object when check_sha1_signature fails name-rev: tolerate clock skew in committer dates Update bash completion for git-config options Teach bash completion about recent log long options Teach bash completion about 'git remote update' Update bash completion header documentation Remove a duplicate --not option in bash completion Teach bash completion about git-shortlog Hide the plumbing diff-{files,index,tree} from bash completion Update bash completion to ignore some more plumbing commands --- 18bece43675ea0dc9022a7868865e02808b7af7f diff --combined builtin-name-rev.c index a639e2feda,2d94eaaa6a..d3c42ed67e --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@@ -4,6 -4,8 +4,8 @@@ #include "tag.h" #include "refs.h" + #define CUTOFF_DATE_SLOP 86400 /* one day */ + static const char name_rev_usage[] = "git-name-rev [--tags | --refs=] ( --all | --stdin | committish [committish...] )\n"; @@@ -83,7 -85,6 +85,7 @@@ copy_data struct name_ref_data { int tags_only; + int name_only; const char *ref_filter; }; @@@ -111,10 -112,6 +113,10 @@@ static int name_ref(const char *path, c if (!prefixcmp(path, "refs/heads/")) path = path + 11; + else if (data->tags_only + && data->name_only + && !prefixcmp(path, "refs/tags/")) + path = path + 10; else if (!prefixcmp(path, "refs/")) path = path + 5; @@@ -154,7 -151,7 +156,7 @@@ int cmd_name_rev(int argc, const char * { struct object_array revs = { 0, 0, NULL }; int as_is = 0, all = 0, transform_stdin = 0; - struct name_ref_data data = { 0, NULL }; + struct name_ref_data data = { 0, 0, NULL }; git_config(git_default_config); @@@ -170,9 -167,6 +172,9 @@@ if (!strcmp(*argv, "--")) { as_is = 1; continue; + } else if (!strcmp(*argv, "--name-only")) { + data.name_only = 1; + continue; } else if (!strcmp(*argv, "--tags")) { data.tags_only = 1; continue; @@@ -216,6 -210,8 +218,8 @@@ add_object_array((struct object *)commit, *argv, &revs); } + if (cutoff) + cutoff = cutoff - CUTOFF_DATE_SLOP; for_each_ref(name_ref, &data); if (transform_stdin) { @@@ -271,17 -267,14 +275,17 @@@ struct object * obj = get_indexed_object(i); if (!obj) continue; - printf("%s %s\n", sha1_to_hex(obj->sha1), get_rev_name(obj)); + if (!data.name_only) + printf("%s ", sha1_to_hex(obj->sha1)); + printf("%s\n", get_rev_name(obj)); } } else { int i; - for (i = 0; i < revs.nr; i++) - printf("%s %s\n", - revs.objects[i].name, - get_rev_name(revs.objects[i].item)); + for (i = 0; i < revs.nr; i++) { + if (!data.name_only) + printf("%s ", revs.objects[i].name); + printf("%s\n", get_rev_name(revs.objects[i].item)); + } } return 0;