{"thread":{"id":"29583","subject":"[RFC/PATCH] tag: make list exclude !<pattern>","startedAt":"2012-02-09T19:43:35Z","lastAt":"2012-03-03T21:31:52Z","messageCount":83,"participants":["Tom Grennan","Nguyen Thai Ngoc Duy","Junio C Hamano","Michael Haggerty","Jakub Narebski","Johannes Sixt","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"184256","messageId":"1328816616-18124-1-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":null,"subject":"[RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-09T19:43:35Z","receivedAt":"2012-02-09T19:43:35Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Please see the following patch which filters the tag list of \"!\" prefaced\npatterns.  If this is deemed desirable and correct, I'll resubmit with updated\ndocumentation and unit tests.\n\nThanks,\nTom Grennan (1):\n  tag: make list exclude !<pattern>\n\n builtin/tag.c |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\n-- \n1.7.8\n"},{"id":"184257","messageId":"1328816616-18124-2-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1328816616-18124-1-git-send-email-tmgrennan@gmail.com","subject":"[RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-09T19:43:36Z","receivedAt":"2012-02-09T19:43:36Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Use the \"!\" prefix to ignore tags of the given pattern.\nThis has precedence over other matching patterns.\nFor example,\n\n  $ git tag -l \\!*-rc? v1.7.8*\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n  $ git tag -l v1.7.8* \\!*-rc?\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n\nThis is equivalent to,\n\n  $ git tag -l v1.7.8* | grep -v '\\-rc.'\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n builtin/tag.c |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 31f02e8..b9ef718 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -32,13 +32,18 @@ struct tag_filter {\n \n static int match_pattern(const char **patterns, const char *ref)\n {\n+\tint ret;\n+\n \t/* no pattern means match everything */\n \tif (!*patterns)\n \t\treturn 1;\n-\tfor (; *patterns; patterns++)\n-\t\tif (!fnmatch(*patterns, ref, 0))\n-\t\t\treturn 1;\n-\treturn 0;\n+\tfor (ret = 0; *patterns; patterns++)\n+\t\tif (**patterns == '!') {\n+\t\t    if (!fnmatch(*patterns+1, ref, 0))\n+\t\t\t    return 0;\n+\t\t} else if (!fnmatch(*patterns, ref, 0))\n+\t\t\tret = 1;\n+\treturn ret;\n }\n \n static int in_commit_list(const struct commit_list *want, struct commit *c)\n-- \n1.7.8\n"},{"id":"184290","messageId":"20120210000020.GA21092@tgrennan-laptop","threadId":"29583","inReplyTo":"1328816616-18124-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-10T00:00:20Z","receivedAt":"2012-02-10T00:00:20Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Thu, Feb 09, 2012 at 11:43:36AM -0800, Tom Grennan wrote:\n>Use the \"!\" prefix to ignore tags of the given pattern.\n>This has precedence over other matching patterns.\n>For example,\n...\n\n> static int match_pattern(const char **patterns, const char *ref)\n> {\n>+\tint ret;\n>+\n> \t/* no pattern means match everything */\n> \tif (!*patterns)\n> \t\treturn 1;\n>-\tfor (; *patterns; patterns++)\n>-\t\tif (!fnmatch(*patterns, ref, 0))\n>-\t\t\treturn 1;\n>-\treturn 0;\n>+\tfor (ret = 0; *patterns; patterns++)\n>+\t\tif (**patterns == '!') {\n>+\t\t    if (!fnmatch(*patterns+1, ref, 0))\n>+\t\t\t    return 0;\n>+\t\t} else if (!fnmatch(*patterns, ref, 0))\n>+\t\t\tret = 1;\n>+\treturn ret;\n> }\n\nCorrection, match_pattern() needs to be as follows to support all these cases,\n  $ git tag -l\n  $ git tag -l \\!*-rc?\n  $ git tag -l \\!*-rc? v1.7.8*\n  $ git tag -l v1.7.8* \\!*-rc?\n  $ git tag -l v1.7.8*\n\n-- \nTomG\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 31f02e8..e99be5c 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -32,13 +32,16 @@ struct tag_filter {\n \n static int match_pattern(const char **patterns, const char *ref)\n {\n-\t/* no pattern means match everything */\n-\tif (!*patterns)\n-\t\treturn 1;\n+\tint had_match_pattern = 0, had_match = 0;\n+\n \tfor (; *patterns; patterns++)\n-\t\tif (!fnmatch(*patterns, ref, 0))\n-\t\t\treturn 1;\n-\treturn 0;\n+\t\tif (**patterns != '!') {\n+\t\t\thad_match_pattern = 1;\n+\t\t\tif (!fnmatch(*patterns, ref, 0))\n+\t\t\t\thad_match = 1;\n+\t\t} else if (!fnmatch(*patterns+1, ref, 0))\n+\t\t\treturn 0;\n+\treturn had_match_pattern ? had_match : 1;\n }\n \n static int in_commit_list(const struct commit_list *want, struct commit *c)\n"},{"id":"184328","messageId":"CACsJy8DVXCLb50Vd0fTU+yNP2q7Gkcr88muHuzxq1jhfJW5Q9w@mail.gmail.com","threadId":"29583","inReplyTo":"1328816616-18124-1-git-send-email-tmgrennan@gmail.com","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-02-10T06:34:26Z","receivedAt":"2012-02-10T06:34:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 10, 2012 at 2:43 AM, Tom Grennan <tmgrennan@gmail.com> wrote:\n> Please see the following patch which filters the tag list of \"!\" prefaced\n> patterns.  If this is deemed desirable and correct, I'll resubmit with updated\n> documentation and unit tests.\n\ngit-branch, git-tag and git-for-each-ref are in the same family. I\nthink it's good to that all three commands share things, like this\npattern matching.\n\nAbout the '!' for exclusion, maybe it's better to move from fnmatch()\nas matching machinery to pathspec. Then when git learns negative\npathspec [1], we have this feature for free.\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072\n-- \nDuy\n"},{"id":"184378","messageId":"20120210185516.GA4903@tgrennan-laptop","threadId":"29583","inReplyTo":"CACsJy8DVXCLb50Vd0fTU+yNP2q7Gkcr88muHuzxq1jhfJW5Q9w@mail.gmail.com","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-10T18:55:16Z","receivedAt":"2012-02-10T18:55:16Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Fri, Feb 10, 2012 at 01:34:26PM +0700, Nguyen Thai Ngoc Duy wrote:\n>On Fri, Feb 10, 2012 at 2:43 AM, Tom Grennan <tmgrennan@gmail.com> wrote:\n>> Please see the following patch which filters the tag list of \"!\" prefaced\n>> patterns.  If this is deemed desirable and correct, I'll resubmit with updated\n>> documentation and unit tests.\n>\n>git-branch, git-tag and git-for-each-ref are in the same family. I\n>think it's good to that all three commands share things, like this\n>pattern matching.\n\nYes, git-branch and git-tag could now use a common match_patterns() but\ngit-for-each-ref needs some rearranging; as will: git-describe,\ngit-replace, git-ls-remote, git-name-rev, and git-show-branch.\n\nIf we pursue this, it may be best to first add match_patterns() to ./refs.[ch]\nthen incrementally modify these builtin commands to use it.\n  \n>About the '!' for exclusion, maybe it's better to move from fnmatch()\n>as matching machinery to pathspec. Then when git learns negative\n>pathspec [1], we have this feature for free.\n>\n>[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072\n\nI have to study this more. I'm not sure that --exclude has precedence\nover matches. It also looks like this would require a lot more change to\nthe above.\n\nThanks,\nTomG\n"},{"id":"184417","messageId":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"20120210185516.GA4903@tgrennan-laptop","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T02:16:54Z","receivedAt":"2012-02-11T02:16:54Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Fri, 10 Feb 2012 10:55:16 -0800, Tom Grennan wrote:\n>On Fri, Feb 10, 2012 at 01:34:26PM +0700, Nguyen Thai Ngoc Duy wrote:\n>>On Fri, Feb 10, 2012 at 2:43 AM, Tom Grennan <tmgrennan@gmail.com> wrote:\n>>> Please see the following patch which filters the tag list of \"!\" prefaced\n>>> patterns.  If this is deemed desirable and correct, I'll resubmit with updated\n>>> documentation and unit tests.\n>>\n>>git-branch, git-tag and git-for-each-ref are in the same family. I\n>>think it's good to that all three commands share things, like this\n>>pattern matching.\n>\n>Yes, git-branch and git-tag could now use a common match_patterns() but\n>git-for-each-ref needs some rearranging; as will: git-describe,\n>git-replace, git-ls-remote, git-name-rev, and git-show-branch.\n>\n>If we pursue this, it may be best to first add match_patterns() to ./refs.[ch]\n>then incrementally modify these builtin commands to use it.\n\nThe following series implements !<pattern> with: git-tag, git-branch, and\ngit-for-each-ref.\n\nThis still requires Documentation and unit test updates but I think these are\nclose to functionally complete.\n\n>>About the '!' for exclusion, maybe it's better to move from fnmatch()\n>>as matching machinery to pathspec. Then when git learns negative\n>>pathspec [1], we have this feature for free.\n>>\n>>[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072\n\nAfter looking at this some more, I don't understand the value of replacing\nlibc:fnmatch().  Or are you just referring to '--exclude' instead of\n[!]<pattern> argument parsing?\n\n---\n\nTom Grennan (4):\n  refs: add common refname_match_patterns()\n  tag: use refs.c:refname_match_patterns()\n  branch: use refs.c:refname_match_patterns()\n  for-each-ref: use refs.c:refname_match_patterns()\n\n Documentation/git-tag.txt |   10 ++++++----\n builtin/branch.c          |   16 ++--------------\n builtin/for-each-ref.c    |   23 +++--------------------\n builtin/tag.c             |   15 ++-------------\n refs.c                    |   14 ++++++++++++++\n refs.h                    |    8 ++++++++\n 6 files changed, 35 insertions(+), 51 deletions(-)\n\n-- \n1.7.8\n"},{"id":"184421","messageId":"1328926618-17167-2-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T02:16:55Z","receivedAt":"2012-02-11T02:16:55Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Signed-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n refs.c |   14 ++++++++++++++\n refs.h |    8 ++++++++\n 2 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex b8843bb..b42eb4a 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1057,6 +1057,20 @@ int refname_match(const char *abbrev_name, const char *full_name, const char **r\n \treturn 0;\n }\n \n+int refname_match_patterns(const char **patterns, const char *refname)\n+{\n+\tint given_match_pattern = 0, had_match = 0;\n+\n+\tfor (; *patterns; patterns++)\n+\t\tif (**patterns != '!') {\n+\t\t\tgiven_match_pattern = 1;\n+\t\t\tif (!fnmatch(*patterns, refname, 0))\n+\t\t\t\thad_match = 1;\n+\t\t} else if (!fnmatch(*patterns+1, refname, 0))\n+\t\t\treturn 0;\n+\treturn given_match_pattern ? had_match : 1;\n+}\n+\n static struct ref_lock *verify_lock(struct ref_lock *lock,\n \tconst unsigned char *old_sha1, int mustexist)\n {\ndiff --git a/refs.h b/refs.h\nindex 00ba1e2..13015ba 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -152,4 +152,12 @@ int update_ref(const char *action, const char *refname,\n \t\tconst unsigned char *sha1, const unsigned char *oldval,\n \t\tint flags, enum action_on_err onerr);\n \n+/**\n+ * Returns:\n+ *   1 with NULL patterns\n+ *   0 if refname fnmatch()es any ! prefaced pattern\n+ *   1 if refname fnmatch()es any pattern\n+ */\n+extern int refname_match_patterns(const char **patterns, const char *refname);\n+\n #endif /* REFS_H */\n-- \n1.7.8\n"},{"id":"184420","messageId":"1328926618-17167-3-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 2/4] tag: use refs.c:refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T02:16:56Z","receivedAt":"2012-02-11T02:16:56Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"This will exclude tags matching patterns prefaced with the '!'\ncharacter.  This has precedence over other matching patterns.\nFor example,\n\n  $ git tag -l \\!*-rc? v1.7.8*\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n  $ git tag -l v1.7.8* \\!*-rc?\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n\nThis is equivalent to,\n\n  $ git tag -l v1.7.8* | grep -v '\\-rc.'\n\nWithout a matching pattern, filter all tags with the \"!\" patterns,\n  $ ./git-tag -l \\!*-rc?\n  gitgui-0.10.0\n  gitgui-0.10.1\n  gitgui-0.10.2\n  ...\n  v1.7.8.3\n  v1.7.8.4\n  v1.7.9\n\nThat is equivalent to,\n\n  $ git tag -l | grep -v '\\-rc.'\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n Documentation/git-tag.txt |   10 ++++++----\n builtin/tag.c             |   15 ++-------------\n 2 files changed, 8 insertions(+), 17 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 53ff5f6..56ea2fa 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]\n \t<tagname> [<commit> | <object>]\n 'git tag' -d <tagname>...\n-'git tag' [-n[<num>]] -l [--contains <commit>] [<pattern>...]\n+'git tag' [-n[<num>]] -l [--contains <commit>] [[!]<pattern>...]\n 'git tag' -v <tagname>...\n \n DESCRIPTION\n@@ -75,13 +75,15 @@ OPTIONS\n \tIf no number is given to `-n`, only the first line is printed.\n \tIf the tag is not annotated, the commit message is displayed instead.\n \n--l <pattern>::\n---list <pattern>::\n+-l [!]<pattern>::\n+--list [!]<pattern>::\n \tList tags with names that match the given pattern (or all if no\n \tpattern is given).  Running \"git tag\" without arguments also\n \tlists all tags. The pattern is a shell wildcard (i.e., matched\n \tusing fnmatch(3)).  Multiple patterns may be given; if any of\n-\tthem matches, the tag is shown.\n+\tthem matches, the tag is shown.  If the pattern is prefaced with\n+\tthe '!' character, all tags matching the pattern are filtered\n+\tfrom the list.\n \n --contains <commit>::\n \tOnly list tags which contain the specified commit.\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 31f02e8..7f99424 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -19,7 +19,7 @@\n static const char * const git_tag_usage[] = {\n \t\"git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]\",\n \t\"git tag -d <tagname>...\",\n-\t\"git tag -l [-n[<num>]] [<pattern>...]\",\n+\t\"git tag -l [-n[<num>]] [[!]<pattern>...]\",\n \t\"git tag -v <tagname>...\",\n \tNULL\n };\n@@ -30,17 +30,6 @@ struct tag_filter {\n \tstruct commit_list *with_commit;\n };\n \n-static int match_pattern(const char **patterns, const char *ref)\n-{\n-\t/* no pattern means match everything */\n-\tif (!*patterns)\n-\t\treturn 1;\n-\tfor (; *patterns; patterns++)\n-\t\tif (!fnmatch(*patterns, ref, 0))\n-\t\t\treturn 1;\n-\treturn 0;\n-}\n-\n static int in_commit_list(const struct commit_list *want, struct commit *c)\n {\n \tfor (; want; want = want->next)\n@@ -88,7 +77,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n {\n \tstruct tag_filter *filter = cb_data;\n \n-\tif (match_pattern(filter->patterns, refname)) {\n+\tif (refname_match_patterns(filter->patterns, refname)) {\n \t\tint i;\n \t\tunsigned long size;\n \t\tenum object_type type;\n-- \n1.7.8\n"},{"id":"184419","messageId":"1328926618-17167-4-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 3/4] branch: use refs.c:refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T02:16:57Z","receivedAt":"2012-02-11T02:16:57Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Signed-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n builtin/branch.c |   16 ++--------------\n 1 files changed, 2 insertions(+), 14 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 7095718..7dfc693 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -266,18 +266,6 @@ struct append_ref_cb {\n \tint ret;\n };\n \n-static int match_patterns(const char **pattern, const char *refname)\n-{\n-\tif (!*pattern)\n-\t\treturn 1; /* no pattern always matches */\n-\twhile (*pattern) {\n-\t\tif (!fnmatch(*pattern, refname, 0))\n-\t\t\treturn 1;\n-\t\tpattern++;\n-\t}\n-\treturn 0;\n-}\n-\n static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data)\n {\n \tstruct append_ref_cb *cb = (struct append_ref_cb *)(cb_data);\n@@ -312,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,\n \tif ((kind & ref_list->kinds) == 0)\n \t\treturn 0;\n \n-\tif (!match_patterns(cb->pattern, refname))\n+\tif (!refname_match_patterns(cb->pattern, refname))\n \t\treturn 0;\n \n \tcommit = NULL;\n@@ -542,7 +530,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);\n \n \tdetached = (detached && (kinds & REF_LOCAL_BRANCH));\n-\tif (detached && match_patterns(pattern, \"HEAD\"))\n+\tif (detached && refname_match_patterns(pattern, \"HEAD\"))\n \t\tshow_detached(&ref_list);\n \n \tfor (i = 0; i < ref_list.index; i++) {\n-- \n1.7.8\n"},{"id":"184418","messageId":"1328926618-17167-5-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 4/4] for-each-ref: use refs.c:refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T02:16:58Z","receivedAt":"2012-02-11T02:16:58Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Signed-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n builtin/for-each-ref.c |   23 +++--------------------\n 1 files changed, 3 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex b01d76a..2c9cc47 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -781,25 +781,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f\n \tstruct refinfo *ref;\n \tint cnt;\n \n-\tif (*cb->grab_pattern) {\n-\t\tconst char **pattern;\n-\t\tint namelen = strlen(refname);\n-\t\tfor (pattern = cb->grab_pattern; *pattern; pattern++) {\n-\t\t\tconst char *p = *pattern;\n-\t\t\tint plen = strlen(p);\n-\n-\t\t\tif ((plen <= namelen) &&\n-\t\t\t    !strncmp(refname, p, plen) &&\n-\t\t\t    (refname[plen] == '\\0' ||\n-\t\t\t     refname[plen] == '/' ||\n-\t\t\t     p[plen-1] == '/'))\n-\t\t\t\tbreak;\n-\t\t\tif (!fnmatch(p, refname, FNM_PATHNAME))\n-\t\t\t\tbreak;\n-\t\t}\n-\t\tif (!*pattern)\n-\t\t\treturn 0;\n-\t}\n+\tif (!refname_match_patterns(cb->grab_pattern, refname))\n+\t\treturn 0;\n \n \t/*\n \t * We do not open the object yet; sort may only need refname\n@@ -974,7 +957,7 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)\n }\n \n static char const * const for_each_ref_usage[] = {\n-\t\"git for-each-ref [options] [<pattern>]\",\n+\t\"git for-each-ref [options] [[!]<pattern>...]\",\n \tNULL\n };\n \n-- \n1.7.8\n"},{"id":"184422","messageId":"7vaa4qnk4u.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1328926618-17167-1-git-send-email-tmgrennan@gmail.com","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T03:06:57Z","receivedAt":"2012-02-11T03:06:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n>>If we pursue this, it may be best to first add match_patterns() to ./refs.[ch]\n>>then incrementally modify these builtin commands to use it.\n>\n> The following series implements !<pattern> with: git-tag, git-branch, and\n> git-for-each-ref.\n>\n> This still requires Documentation and unit test updates but I think these are\n> close to functionally complete.\n>\n>>>About the '!' for exclusion, maybe it's better to move from fnmatch()\n>>>as matching machinery to pathspec. Then when git learns negative\n>>>pathspec [1], we have this feature for free.\n>>>\n>>>[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072\n>\n> After looking at this some more, I don't understand the value of replacing\n> libc:fnmatch().  Or are you just referring to '--exclude' instead of\n> [!]<pattern> argument parsing?\n\nI have not formed a firm opinion on Nguyen's idea to reuse pathspec\nmatching infrastructure for this purpose, so I wouldn't comment on that\npart. It certainly looks attractive, as it allows users to learn one and\nonly one extended matching syntax, but at the same time, it has a risk to\nmislead people to think that the namespace for refs is similar to that of\nthe filesystem paths, which I see as a mild downside.\n\nIn any case, I do not like the structure of this series. If it followed\nour usual pattern, it would consist of patches in this order:\n\n - Patch 1 would extract match_pattern() from builtin/tag.c and introduce\n   the new helper function refname_match_patterns() to refs.c.  It updates\n   the call sites of match_pattern() in builtin/tag.c, match_patterns() in\n   builtin/branch.c, and the implementation of grab_single_ref() in\n   builtin/for-each-ref.c with a call to the new helper function.\n\n   This step can and probably should be done as three sub-steps.  1a would\n   move builtin/tag.c::match_pattern() to refs.::refname_match_patterns(),\n   1b would use the new helper in builtin/branch.c and 1c would do the\n   same for builtin/for-each-ref.c.\n\n   It is important that this patch does so without introducing any new\n   functionality to the new function over the old one. When done this way,\n   there is no risk of introducing new bugs at 1a because it is purely a\n   code movement and renaming; 1b could introduce a bug that changes\n   semantics for bulitin/branch.c if its match_patterns() does things\n   differently from match_pattern() lifted from builtin/tag.c, and if it\n   is found out to be buggy, we can discard 1b without discarding 1a. Same\n   for 1c, which I highly suspect will introduce regression without\n   looking at the code (for-each-ref is prefix-match only), that can\n   safely be discarded.\n\n   This is to make it easier to ensure that the update does not introduce\n   new bugs.\n\n - Patch 2 would then add the new functionality to the new helper. It\n   would also adjust the documentation of the three end user facing\n   commands to describe the fallout coming from this change, and adds new\n   tests to make sure future changes will not break this new\n   functionality.\n\nThat is, first refactor and clean-up without adding anything new, and then\nbuild new stuff on solidified ground.\n\nDo we allow a refname whose pathname component begins with '!', by the\nway?  If we do, how does a user look for a tag whose name is \"!xyzzy\"?\n\"Naming your tag !xyzzy used to be allowed but it is now forbidden after\nthis patch\" is not an acceptable answer---it is called a regression.  If\nthe negation operator were \"^\" or something that we explicitly forbid from\na refname, we wouldn't have such a problem.\n"},{"id":"184436","messageId":"4F3614F6.2000106@alum.mit.edu","threadId":"29583","inReplyTo":"1328926618-17167-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-11T07:12:54Z","receivedAt":"2012-02-11T07:12:54Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/11/2012 03:16 AM, Tom Grennan wrote:\n> diff --git a/refs.h b/refs.h\n> index 00ba1e2..13015ba 100644\n> --- a/refs.h\n> +++ b/refs.h\n> @@ -152,4 +152,12 @@ int update_ref(const char *action, const char *refname,\n>  \t\tconst unsigned char *sha1, const unsigned char *oldval,\n>  \t\tint flags, enum action_on_err onerr);\n>  \n> +/**\n> + * Returns:\n> + *   1 with NULL patterns\n> + *   0 if refname fnmatch()es any ! prefaced pattern\n> + *   1 if refname fnmatch()es any pattern\n> + */\n> +extern int refname_match_patterns(const char **patterns, const char *refname);\n> +\n>  #endif /* REFS_H */\n\nThis comment is unclear and incomplete.\n\n1. What does \"NULL patterns\" mean?  Your code fails if patterns==NULL,\nso I guess you mean \"1 if there are no patterns in the list\".\n\n2. Since the three conditions are not mutually exclusive, you should say\nhow they are connected.  I believe that you want something like \"A\notherwise B otherwise C\".\n\n3. You haven't specified what happens if refname matches neither a\n!-prefixed pattern nor a non-!-prefixed pattern.  Does this behavior\ndepend on which types of patterns were present in the list?\n\nI see that you have described the behavior more completely in the commit\nmessage for patch 2/4, but the commit message is not enough: this\nbehavior should be described precisely in both code comments (when the\nfunction is defined) and in the user documentation (when the\nfunctionality is added to a command).\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184439","messageId":"7vy5s9n70x.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"7vaa4qnk4u.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T07:50:06Z","receivedAt":"2012-02-11T07:50:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>    ... Same\n>    for 1c, which I highly suspect will introduce regression without\n>    looking at the code (for-each-ref is prefix-match only), ...\n\nThis part needs correction.  for-each-ref matches the command line\narguments differently from branch --list and tag --list in two important\nways.\n\n (1) It allows (not \"only\" which was a mistake in my earlier message)\n     prefix matching, e.g. \"for-each-ref refs/heads/\", in addition to\n     fnmatch(); and\n\n (2) The fnmatch() call is made with FNM_PATHMAME, which \"branch --list\"\n     and \"tag --list\" does not use.\n\nStrictly speaking, therefore, if you make all three commands to use the\nsame matching logic, there is no way to avoid regression.  If you choose\nto use fnmatch() without FNM_PATHNAME, then for-each-ref suddenly starts\nmatching wildcards across name hierarchy boundary '/' for a pattern that\ndoes not match today, e.g. \"git for-each-ref 'refs/heads/*'\" was a good\nway to grab only the integration branches while excluding individual topic\nbranches such as refs/heads/tg/tag-points-at, but this technique can no\nlonger be used for such a purpose, which is an unpleasant regression.\n\nI personally think that it was an annoying UI mistake that we let branch\nand tag call fnmatch without FNM_PATHNAME, but we cannot fix it lightly,\neither.  People who use hierchical branch names (e.g. maint-1.0/$topic,\nmaint-2.0/$topic, and feature-2.0/$topic) may already be used to list all\nthe topics on the maintenance tracks with \"branch --list 'maint*'\", and we\nneed to keep \"branch --list\" and \"tag --list\" working as they expect.\n\nOne possible way forward (now I am talking about a longer term solution)\nwould be to introduce\n\n\trefname_match_pattern(const char *refname,\n        \t\t      const char **pattern,\n                              unsigned flags);\n\nwhere flags can tell the implementation if FNM_PATHNAME should be used,\nand if prefix matching should be attempted, so that the three commands\nshare the single same matching function while still retaining their\ncurrent behaviour in the initial round.  Inside the implementation, we\nwould use good old fnmatch(), with or without FNM_PATHNAME, depending on\nthe flags the caller passes.\n\nIn a future versions, we may want to have \"branch/tag --list\" also ask for\nFNM_PATHNAME (this *is* a backward incompatible change, so it needs to be\nperformed across major version boundary, with backward compatibility\nconfigurations, deprecation warnings and whole nine yards). Under the new\nmatch function, today's \"branch --list 'maint*'\" needs to be spelled as\n\"branch --list 'maint*/*'\" or something.  The prefix matching is probably\nsafer to enable by default without causing big regression hassle if we\nlimit the prefix match to only patterns that end with an explicit slash,\nas users already *know* today's \"branch --list tg/\" would not match\nanything (because the pattern does not even match a brahch 'tg', so it is\nunlikely they are using it and expecting only 'tg' to match), which means\nthat is an unlikely input we can safely give new meaning to match anything\nunder tg/ hierarchy.\n"},{"id":"184440","messageId":"4F361DD4.9020108@alum.mit.edu","threadId":"29583","inReplyTo":"7vaa4qnk4u.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-11T07:50:44Z","receivedAt":"2012-02-11T07:50:44Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/11/2012 04:06 AM, Junio C Hamano wrote:\n> Tom Grennan <tmgrennan@gmail.com> writes:\n>> The following series implements !<pattern> with: git-tag, git-branch, and\n>> git-for-each-ref.\n>>\n>> This still requires Documentation and unit test updates but I think these are\n>> close to functionally complete.\n>\n> Do we allow a refname whose pathname component begins with '!', by the\n> way?  If we do, how does a user look for a tag whose name is \"!xyzzy\"?\n> \"Naming your tag !xyzzy used to be allowed but it is now forbidden after\n> this patch\" is not an acceptable answer---it is called a regression.  If\n> the negation operator were \"^\" or something that we explicitly forbid from\n> a refname, we wouldn't have such a problem.\n\nAccording to git-check-ref-format(1), '!' are allowed in reference\nnames.  (Whether that was a good idea is another question, but now we\nhave to support it.)\n\nSo using \"^\" would be an option.  A problem is that the new meaning is\nnot consistent with the use of \"^\" in rev-list, and therefore would (1)\nbe confusing and (2) prevent the addition of a similar syntax in rev-list.\n\nCurrently,\n\n    git rev-list A B ^C\n\nmeans \"revisions reachable from A or B but not from C\".  (For simplicity\nassume that A, B, and C are literal reference names without wildcards.)\n The proposal, amended to use \"^\" instead of \"!\", is that\n\n    git for-each-ref A B ^C\n\nshould mean \"the reference names A and B but not C\".  Therefore, the command\n\n    git rev-list $(git for-each-ref A B ^C)\n\n, which consistency suggests should do the same thing as the first\ncommand, would in fact be equivalent to\n\n    git rev-list A B\n\nMoreover, it *would* be nice to have this kind of exclude-branch-name\nsyntax in rev-parse.  Many times I have wanted to type the equivalent of\n\n    gitk --all --not-branch=remotes/korg/*\n\nThat is, \"show the commits starting at *all branches except for the\nspecified branches*\".  This is different than \"show *the commits\nstarting at all branches* except for *the commits reachable from the\nspecified branches*\", because I want to see the *complete* history of\nthe non-excluded branches.  (Is there an easy way to do this now?)  The\nproposed functionality is a step forward; I could type\n\n    gitk $(git for-each-ref !remotes/korg/*)\n\nBut it would be even nicer if this could be expressed directly in rev-parse.\n\nIn summary, I suggest we consider using a more verbose syntax for this\nnew functionality (probably via one or more new options, for example\n--not-branch=PATTERN, --not-tag=PATTERN, and/or --not-ref=PATTERN) that\ncannot be confused with the existing syntax for excluding commits.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184442","messageId":"7vpqdln68v.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1328926618-17167-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T08:06:56Z","receivedAt":"2012-02-11T08:06:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> +int refname_match_patterns(const char **patterns, const char *refname)\n> +{\n> +\tint given_match_pattern = 0, had_match = 0;\n> +\n> +\tfor (; *patterns; patterns++)\n> +\t\tif (**patterns != '!') {\n> +\t\t\tgiven_match_pattern = 1;\n> +\t\t\tif (!fnmatch(*patterns, refname, 0))\n> +\t\t\t\thad_match = 1;\n> +\t\t} else if (!fnmatch(*patterns+1, refname, 0))\n> +\t\t\treturn 0;\n> +\treturn given_match_pattern ? had_match : 1;\n> +}\n\nThis, while its semantics seem sane, is highly inefficient when you have\nmany patterns, and you will be calling this to filter dozens of refs.  And\nit can trivially improved by first pre-parsing the pattern[] array.\n\n * If you know the patterns do not have any negative entry, you can return\n   true upon seeing the first match. Because you do not pre-parse the\n   pattern[] array, this loop does not know if there is any negative one,\n   and has to scan it always all the way.\n\n * If you arrange the pattern[] array so that it has negative ones early,\n   again, you can return false upon seeing the first hit with a negative\n   one. If your input has negative ones at the end, the loop ends up\n   scanning all the way, noting the positive matches, only to discard upon\n   seeing the negative match at the end.\n\nThat is why I said Nguyen's idea of reusing pathspec matching logic\nsomewhat attractive, even though I think it has downsides (the exact\nmatching logic for pathspec is more similar to that of for-each-ref\nand very different from branch/tag).\n"},{"id":"184443","messageId":"7vlio9n5ym.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"4F361DD4.9020108@alum.mit.edu","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T08:13:05Z","receivedAt":"2012-02-11T08:13:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> The proposal, amended to use \"^\" instead of \"!\", is that\n>\n>     git for-each-ref A B ^C\n>\n> should mean \"the reference names A and B but not C\".  Therefore, the command\n>\n>     git rev-list $(git for-each-ref A B ^C)\n>\n> , which consistency suggests should do the same thing as the first\n> command,...\n\nThat is an utter rubbish that does not even deserve a response.\n\nYour argument is like saying\n\n     git for-each-ref A\n\nand\n\n     git for-each-ref $(git rev-parse A)\n\nshould somehow magically produce the same (or related) result. The\nfor-each-ref command operates on refname patterns, while rev-list and\nrev-parse takes object names.\n"},{"id":"184447","messageId":"m3sjihu18t.fsf@localhost.localdomain","threadId":"29583","inReplyTo":"7vy5s9n70x.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-02-11T10:13:13Z","receivedAt":"2012-02-11T10:13:13Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> In a future versions, we may want to have \"branch/tag --list\" also ask for\n> FNM_PATHNAME (this *is* a backward incompatible change, so it needs to be\n> performed across major version boundary, with backward compatibility\n> configurations, deprecation warnings and whole nine yards). Under the new\n> match function, today's \"branch --list 'maint*'\" needs to be spelled as\n> \"branch --list 'maint*/*'\" or something.\n\nOr \"branch --list 'maint**'\n\n-- \nJakub Narebski\n"},{"id":"184456","messageId":"CACsJy8B3pHZLUuqnmZuqfAo-B=LAm5Q6M4waf4sK8387E9U+uA@mail.gmail.com","threadId":"29583","inReplyTo":"m3sjihu18t.fsf@localhost.localdomain","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2012-02-11T14:06:22Z","receivedAt":"2012-02-11T14:06:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Feb 11, 2012 at 5:13 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> In a future versions, we may want to have \"branch/tag --list\" also ask for\n>> FNM_PATHNAME (this *is* a backward incompatible change, so it needs to be\n>> performed across major version boundary, with backward compatibility\n>> configurations, deprecation warnings and whole nine yards). Under the new\n>> match function, today's \"branch --list 'maint*'\" needs to be spelled as\n>> \"branch --list 'maint*/*'\" or something.\n\nOne of the reasons I proposed pathspec is to avoid another set of\nmatching syntax in addition to gitattr, gitignore and pathspec,\nPathspec magic makes it extensible, FNM_PATHNAME be set that way.\n\n> Or \"branch --list 'maint**'\n\nBut this comes up a few times already on gitignore discussions. We\nhave fnmatch.c in compat for Windows. Someone just needs to step up\nand implement \"**\". It would also a nice thing to add to pathspec\nsyntax, if we can forget the backward compatibility nightmare.\n-- \nDuy\n"},{"id":"184467","messageId":"7v4nuxmdba.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"m3sjihu18t.fsf@localhost.localdomain","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T18:31:53Z","receivedAt":"2012-02-11T18:31:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> In a future versions, we may want to have \"branch/tag --list\" also ask for\n>> FNM_PATHNAME (this *is* a backward incompatible change, so it needs to be\n>> performed across major version boundary, with backward compatibility\n>> configurations, deprecation warnings and whole nine yards). Under the new\n>> match function, today's \"branch --list 'maint*'\" needs to be spelled as\n>> \"branch --list 'maint*/*'\" or something.\n>\n> Or \"branch --list 'maint**'\n\nThat is one of the things covered by \"or something\", and I deliberately\nleft it like so because all the good things that can happen \"In future\nversion\" are irrelevant at the present _unless_ the required first step\nyou omitted from your quote is not done properly, and I didn't want to\ninvite people to derail the discussion into such a tangent that does not\nyet have any value.\n\nPlease don't.\n"},{"id":"184470","messageId":"20120211190856.GB4903@tgrennan-laptop","threadId":"29583","inReplyTo":"7vaa4qnk4u.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T19:08:56Z","receivedAt":"2012-02-11T19:08:56Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Fri, Feb 10, 2012 at 07:06:57PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>>>If we pursue this, it may be best to first add match_patterns() to ./refs.[ch]\n>>>then incrementally modify these builtin commands to use it.\n>>\n>> The following series implements !<pattern> with: git-tag, git-branch, and\n>> git-for-each-ref.\n>>\n>> This still requires Documentation and unit test updates but I think these are\n>> close to functionally complete.\n>>\n>>>>About the '!' for exclusion, maybe it's better to move from fnmatch()\n>>>>as matching machinery to pathspec. Then when git learns negative\n>>>>pathspec [1], we have this feature for free.\n>>>>\n>>>>[1] http://thread.gmane.org/gmane.comp.version-control.git/189645/focus=190072\n>>\n>> After looking at this some more, I don't understand the value of replacing\n>> libc:fnmatch().  Or are you just referring to '--exclude' instead of\n>> [!]<pattern> argument parsing?\n>\n>I have not formed a firm opinion on Nguyen's idea to reuse pathspec\n>matching infrastructure for this purpose, so I wouldn't comment on that\n>part. It certainly looks attractive, as it allows users to learn one and\n>only one extended matching syntax, but at the same time, it has a risk to\n>mislead people to think that the namespace for refs is similar to that of\n>the filesystem paths, which I see as a mild downside.\n>\n>In any case, I do not like the structure of this series. If it followed\n>our usual pattern, it would consist of patches in this order:\n>\n> - Patch 1 would extract match_pattern() from builtin/tag.c and introduce\n>   the new helper function refname_match_patterns() to refs.c.  It updates\n>   the call sites of match_pattern() in builtin/tag.c, match_patterns() in\n>   builtin/branch.c, and the implementation of grab_single_ref() in\n>   builtin/for-each-ref.c with a call to the new helper function.\n>\n>   This step can and probably should be done as three sub-steps.  1a would\n>   move builtin/tag.c::match_pattern() to refs.::refname_match_patterns(),\n>   1b would use the new helper in builtin/branch.c and 1c would do the\n>   same for builtin/for-each-ref.c.\n>\n>   It is important that this patch does so without introducing any new\n>   functionality to the new function over the old one. When done this way,\n>   there is no risk of introducing new bugs at 1a because it is purely a\n>   code movement and renaming; 1b could introduce a bug that changes\n>   semantics for bulitin/branch.c if its match_patterns() does things\n>   differently from match_pattern() lifted from builtin/tag.c, and if it\n>   is found out to be buggy, we can discard 1b without discarding 1a. Same\n>   for 1c, which I highly suspect will introduce regression without\n>   looking at the code (for-each-ref is prefix-match only), that can\n>   safely be discarded.\n>\n>   This is to make it easier to ensure that the update does not introduce\n>   new bugs.\n>\n> - Patch 2 would then add the new functionality to the new helper. It\n>   would also adjust the documentation of the three end user facing\n>   commands to describe the fallout coming from this change, and adds new\n>   tests to make sure future changes will not break this new\n>   functionality.\n>\n>That is, first refactor and clean-up without adding anything new, and then\n>build new stuff on solidified ground.\n\nNuts! I have the cart before the horse. I'll try to rearrange the series as\nsuggested by tomorrow. Thanks.\n\n>Do we allow a refname whose pathname component begins with '!', by the\n>way?  If we do, how does a user look for a tag whose name is \"!xyzzy\"?\n>\"Naming your tag !xyzzy used to be allowed but it is now forbidden after\n>this patch\" is not an acceptable answer---it is called a regression.  If\n>the negation operator were \"^\" or something that we explicitly forbid from\n>a refname, we wouldn't have such a problem.\n\nCool, as I recall, v7 or earlier /bin/sh also used \"^\" to preface\nexclusion patterns. Another option is the bash extglob syntax of\n!(pattern) although I'd prefer \"^\" b/c one wouldn't have to quote it\nwith bash:\n  $ git branch --list ^pu\n\n-- \nTomG\n"},{"id":"184471","messageId":"20120211191748.GC4903@tgrennan-laptop","threadId":"29583","inReplyTo":"4F3614F6.2000106@alum.mit.edu","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T19:17:48Z","receivedAt":"2012-02-11T19:17:48Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Sat, Feb 11, 2012 at 08:12:54AM +0100, Michael Haggerty wrote:\n>On 02/11/2012 03:16 AM, Tom Grennan wrote:\n>> diff --git a/refs.h b/refs.h\n>> index 00ba1e2..13015ba 100644\n>> --- a/refs.h\n>> +++ b/refs.h\n>> @@ -152,4 +152,12 @@ int update_ref(const char *action, const char *refname,\n>>  \t\tconst unsigned char *sha1, const unsigned char *oldval,\n>>  \t\tint flags, enum action_on_err onerr);\n>>  \n>> +/**\n>> + * Returns:\n>> + *   1 with NULL patterns\n>> + *   0 if refname fnmatch()es any ! prefaced pattern\n>> + *   1 if refname fnmatch()es any pattern\n>> + */\n>> +extern int refname_match_patterns(const char **patterns, const char *refname);\n>> +\n>>  #endif /* REFS_H */\n>\n>This comment is unclear and incomplete.\n>\n>1. What does \"NULL patterns\" mean?  Your code fails if patterns==NULL,\n>so I guess you mean \"1 if there are no patterns in the list\".\n>\n>2. Since the three conditions are not mutually exclusive, you should say\n>how they are connected.  I believe that you want something like \"A\n>otherwise B otherwise C\".\n>\n>3. You haven't specified what happens if refname matches neither a\n>!-prefixed pattern nor a non-!-prefixed pattern.  Does this behavior\n>depend on which types of patterns were present in the list?\n>\n>I see that you have described the behavior more completely in the commit\n>message for patch 2/4, but the commit message is not enough: this\n>behavior should be described precisely in both code comments (when the\n>function is defined) and in the user documentation (when the\n>functionality is added to a command).\n\nYes, I didn't explicitly state that the precedence is the order written\nand in correctly described the first case. How about?\n\n/**\n * Returns in highest to lowest precedence:\n *   1 with an empty patterns list\n *   0 if refname fnmatch()es any ^ prefaced pattern\n *   1 if refname fnmatch()es any other pattern\n *   0 otherwise\n */\n\nThanks,\nTomG\n"},{"id":"184473","messageId":"20120211193742.GD4903@tgrennan-laptop","threadId":"29583","inReplyTo":"7vpqdln68v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T19:37:42Z","receivedAt":"2012-02-11T19:37:42Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Sat, Feb 11, 2012 at 12:06:56AM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> +int refname_match_patterns(const char **patterns, const char *refname)\n>> +{\n>> +\tint given_match_pattern = 0, had_match = 0;\n>> +\n>> +\tfor (; *patterns; patterns++)\n>> +\t\tif (**patterns != '!') {\n>> +\t\t\tgiven_match_pattern = 1;\n>> +\t\t\tif (!fnmatch(*patterns, refname, 0))\n>> +\t\t\t\thad_match = 1;\n>> +\t\t} else if (!fnmatch(*patterns+1, refname, 0))\n>> +\t\t\treturn 0;\n>> +\treturn given_match_pattern ? had_match : 1;\n>> +}\n>\n>This, while its semantics seem sane, is highly inefficient when you have\n>many patterns, and you will be calling this to filter dozens of refs.  And\n>it can trivially improved by first pre-parsing the pattern[] array.\n>\n> * If you know the patterns do not have any negative entry, you can return\n>   true upon seeing the first match. Because you do not pre-parse the\n>   pattern[] array, this loop does not know if there is any negative one,\n>   and has to scan it always all the way.\n>\n> * If you arrange the pattern[] array so that it has negative ones early,\n>   again, you can return false upon seeing the first hit with a negative\n>   one. If your input has negative ones at the end, the loop ends up\n>   scanning all the way, noting the positive matches, only to discard upon\n>   seeing the negative match at the end.\n>\n>That is why I said Nguyen's idea of reusing pathspec matching logic\n>somewhat attractive, even though I think it has downsides (the exact\n>matching logic for pathspec is more similar to that of for-each-ref\n>and very different from branch/tag).\n\nYes, I should have stated that this emphasized containment over\nefficiency.  If instead we stipulate that the caller must list exclusion\npatterns before others, this could simply be:\n\nint match_pattern(const char **patterns, const char *refname)\n{\n\tif (*patterns)\n\t\treturn 1;\n\tfor (; *patterns && **patterns == '!'; patterns++)\n\t\tif (!fnmatch(*patterns+1, refname, 0))\n\t\t\treturn 0;\n\tfor (; *patterns; patterns++)\n\t\tif (!fnmatch(*patterns, refname, 0))\n\t\t\treturn 1;\n\treturn 0;\n}\n\nOf course I'd add a with_exclusions_first() before the\nrespective ref iterator.\n\n-- \nTomG\n"},{"id":"184474","messageId":"20120211194719.GE4903@tgrennan-laptop","threadId":"29583","inReplyTo":"7vy5s9n70x.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-11T19:47:19Z","receivedAt":"2012-02-11T19:47:19Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Fri, Feb 10, 2012 at 11:50:06PM -0800, Junio C Hamano wrote:\n>Junio C Hamano <gitster@pobox.com> writes:\n>\n>>    ... Same\n>>    for 1c, which I highly suspect will introduce regression without\n>>    looking at the code (for-each-ref is prefix-match only), ...\n\nOK I'll study this further and run through t6300-for-each-ref.sh\nI see it has a bunch of errors.\nI think there are similar issues using match_pattern() with\nshow-branch and ls-remote.\n\nThanks,\n\n>This part needs correction.  for-each-ref matches the command line\n>arguments differently from branch --list and tag --list in two important\n>ways.\n>\n> (1) It allows (not \"only\" which was a mistake in my earlier message)\n>     prefix matching, e.g. \"for-each-ref refs/heads/\", in addition to\n>     fnmatch(); and\n>\n> (2) The fnmatch() call is made with FNM_PATHMAME, which \"branch --list\"\n>     and \"tag --list\" does not use.\n>\n>Strictly speaking, therefore, if you make all three commands to use the\n>same matching logic, there is no way to avoid regression.  If you choose\n>to use fnmatch() without FNM_PATHNAME, then for-each-ref suddenly starts\n>matching wildcards across name hierarchy boundary '/' for a pattern that\n>does not match today, e.g. \"git for-each-ref 'refs/heads/*'\" was a good\n>way to grab only the integration branches while excluding individual topic\n>branches such as refs/heads/tg/tag-points-at, but this technique can no\n>longer be used for such a purpose, which is an unpleasant regression.\n>\n>I personally think that it was an annoying UI mistake that we let branch\n>and tag call fnmatch without FNM_PATHNAME, but we cannot fix it lightly,\n>either.  People who use hierchical branch names (e.g. maint-1.0/$topic,\n>maint-2.0/$topic, and feature-2.0/$topic) may already be used to list all\n>the topics on the maintenance tracks with \"branch --list 'maint*'\", and we\n>need to keep \"branch --list\" and \"tag --list\" working as they expect.\n>\n>One possible way forward (now I am talking about a longer term solution)\n>would be to introduce\n>\n>\trefname_match_pattern(const char *refname,\n>        \t\t      const char **pattern,\n>                              unsigned flags);\n>\n>where flags can tell the implementation if FNM_PATHNAME should be used,\n>and if prefix matching should be attempted, so that the three commands\n>share the single same matching function while still retaining their\n>current behaviour in the initial round.  Inside the implementation, we\n>would use good old fnmatch(), with or without FNM_PATHNAME, depending on\n>the flags the caller passes.\n>\n>In a future versions, we may want to have \"branch/tag --list\" also ask for\n>FNM_PATHNAME (this *is* a backward incompatible change, so it needs to be\n>performed across major version boundary, with backward compatibility\n>configurations, deprecation warnings and whole nine yards). Under the new\n>match function, today's \"branch --list 'maint*'\" needs to be spelled as\n>\"branch --list 'maint*/*'\" or something.  The prefix matching is probably\n>safer to enable by default without causing big regression hassle if we\n>limit the prefix match to only patterns that end with an explicit slash,\n>as users already *know* today's \"branch --list tg/\" would not match\n>anything (because the pattern does not even match a brahch 'tg', so it is\n>unlikely they are using it and expecting only 'tg' to match), which means\n>that is an unlikely input we can safely give new meaning to match anything\n>under tg/ hierarchy.\n>\n"},{"id":"184485","messageId":"7vzkcpkkbd.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"20120211193742.GD4903@tgrennan-laptop","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-11T23:43:34Z","receivedAt":"2012-02-11T23:43:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> Yes, I should have stated that this emphasized containment over\n> efficiency.  If instead we stipulate that the caller must list exclusion\n> patterns before others, this could simply be:\n\nNo.\n\nYou have to pre-parse and rearrange the pattern[] list *only once* before\nmatching them against dozens of refs, so instead of forcing the callers do\nanything funky, you give a function that gets a pattern[] list and returns\nsomething that can be efficiently used by the match_pattern() function,\nand have the caller pass that thing, not the original pattern[] list, to\nthe match_pattern() function.\n\nThat is how pathspec matching side of the logic is arranged.\n\nI keep saying that it is probably not a good idea to directly reuse the\npathspec code, but you would want to study and learn from the overall\nstructure of it.\n"},{"id":"184545","messageId":"4F3898F8.2000201@alum.mit.edu","threadId":"29583","inReplyTo":"20120211191748.GC4903@tgrennan-laptop","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-13T05:00:40Z","receivedAt":"2012-02-13T05:00:40Z","isPatch":false,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/11/2012 08:17 PM, Tom Grennan wrote:\n> Yes, I didn't explicitly state that the precedence is the order written\n> and in correctly described the first case. How about?\n> \n> /**\n>  * Returns in highest to lowest precedence:\n>  *   1 with an empty patterns list\n>  *   0 if refname fnmatch()es any ^ prefaced pattern\n>  *   1 if refname fnmatch()es any other pattern\n>  *   0 otherwise\n>  */\n\nMuch better; thanks.\n\nPlease note that this choice of semantics limits its power.  For\nexample, if the rule were instead (like with gitattributes(5)) \"if more\nthan one pattern matches a refname, a later pattern overrides an earlier\npattern\", then one could do things like\n\n    refs/remotes/*/* !refs/remotes/gitster/* refs/remotes/gitster/master\n\nto include specific references within a hierarchy that is otherwise\nexcluded.\n\nHowever, since rev-list apparently uses a rule more like the one that\nyou are proposing, it might be better to be consistent than to choose a\ndifferent convention.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184546","messageId":"4F389FB1.2070706@alum.mit.edu","threadId":"29583","inReplyTo":"7vlio9n5ym.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-13T05:29:21Z","receivedAt":"2012-02-13T05:29:21Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/11/2012 09:13 AM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>> The proposal, amended to use \"^\" instead of \"!\", is that\n>>\n>>     git for-each-ref A B ^C\n>>\n>> should mean \"the reference names A and B but not C\".  Therefore, the command\n>>\n>>     git rev-list $(git for-each-ref A B ^C)\n>>\n>> , which consistency suggests should do the same thing as the first\n>> command,...\n> \n> That is an utter rubbish that does not even deserve a response.\n> \n> Your argument is like saying\n> \n>      git for-each-ref A\n> \n> and\n> \n>      git for-each-ref $(git rev-parse A)\n> \n> should somehow magically produce the same (or related) result. The\n> for-each-ref command operates on refname patterns, while rev-list and\n> rev-parse takes object names.\n\nOf *course* they operate on different namespaces.  But part of the way\nthat revisions are selected using rev-list is by *selecting or excluding\nrefnames* from which it should crawl.  How long do you think it will be\nbefore somebody asks for rev-list to be able to crawl from a set of\nbranches *except for those that match some pattern*?  (Hint: I more or\nless asked for this feature in the \"rubbish\" email that you quoted.)  At\nthat point we will have to say one of the following:\n\n\"Your suggestion is utter rubbish; just type 'git rev-list $(git\nfor-each-ref A B ^C)'.\"\n\nThis is an acceptable (though somewhat verbose) answer for the Unix\ncommand line; for msgit users it is useless, and it probably cannot be\nused in non-command-line scenarios like the gitk \"edit view\" dialog.\n\n\"Sure, but we have to invent yet another syntax because the one used by\nfor-each-ref conflicts with the existing syntax of rev-list.\"  This\nwould be the standard git project practice of letting the UI accrete\ninto an ever more incomprehensible mess.\n\nThat is why I suggest that we choose a new syntax *now* for for-each-ref\n(and \"branch --list\", \"tag --list\", etc) so that the same syntax can be\nused later in rev-list, rev-parse, etc.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184548","messageId":"7vsjifgrwl.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"4F389FB1.2070706@alum.mit.edu","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-13T06:37:46Z","receivedAt":"2012-02-13T06:37:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> Of *course* they operate on different namespaces.  But part of the way\n> that revisions are selected using rev-list is by *selecting or excluding\n> refnames* from which it should crawl.\n\nI am appalled if that is truly the understanding of yours, after having\ntaken more than a few patches from you to fairly core parts of Git.\n\n\"rev-list A ^B\" does not say \"include A and exclude B from which rev-list\nshould crawl\" AT ALL.  We _actively_ crawl from both A and B.  It is that\nwhat are reachable from B is painted in a color different from the color\nin which we paint what are reachable from A.\n\nA better pair you could have mentioned would be for-each-ref vs rev-parse\n(not rev-list).  What Tom wanted with \"do not show the refs that match the\npattern\" he originally wanted to give to \"tag --list\" would be\n\n\tfor-each-ref A ^B\n\nthat is \"show ref that matches A but do not show if it also matches B\",\nwhile what you want to say is \"I want to paint A in positive color and\npaint B in negative color, and I want to get a canonical notation to do\nso\", it is spelled with rev-parse, not for-each-ref, like this:\n\n\trev-parse A ^B\n\nIn other words,\n\n\tgit rev-list $(git rev-parse A ^B)\n\nwould be the equivalent to \"git rev-list A ^B\".\n\nMaybe you are troubled that there are multiple concepts of negation, which\nultimately comes from the undeniable fact that for-each-ref and rev-parse\noperate on entities in different concept domain (refnames and objects)?\nAnd if we decide to use \"^\", then these two different concepts of negation\nare both expressed with the same operator \"prefix ^\", leading to\nconfusion?\n\nI am kind of sympathetic to that argument, and it might be a better idea\nto avoid using \"^\" as the negation for matching operator, in order to make\nit more apparent to the users that for-each-ref and rev-parse operate on\ndifferent concepts. But at the same time, if you know these are distinct\nconcepts, using the same \"^\" operator as a consistent way to express the\n\"negation\" that is applicable in each concept domain does make it easier\nfor users as they gain experience. I tend to avoid making things too hard\nfor experienced users for the sake of flattening the very early learning\ncurve when possible, because nobody will stay novice forever.\n"},{"id":"184560","messageId":"4F38D9D4.5000203@alum.mit.edu","threadId":"29583","inReplyTo":"7vsjifgrwl.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-13T09:37:24Z","receivedAt":"2012-02-13T09:37:24Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/13/2012 07:37 AM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>> Of *course* they operate on different namespaces.  But part of the way\n>> that revisions are selected using rev-list is by *selecting or excluding\n>> refnames* from which it should crawl.\n> \n> I am appalled if that is truly the understanding of yours, after having\n> taken more than a few patches from you to fairly core parts of Git.\n> \n> \"rev-list A ^B\" does not say \"include A and exclude B from which rev-list\n> should crawl\" AT ALL.  We _actively_ crawl from both A and B.  It is that\n> what are reachable from B is painted in a color different from the color\n> in which we paint what are reachable from A.\n\nPlease read my emails more carefully before insulting me.\n\nIt is perfectly clear to me that there are two types of exclusion that\nwe are talking about.  And *both* of them are (or should be) relevant to\nrev-parse.\n\nTake the following repository with three branches:\n\no---o---o---o  A\n     \\   \\\n      \\   o---o  C\n       \\\n        o---o  B\n\nIf I do \"git rev-list A B ^C\" then I get the commits marked \"*\" in the\nfollowing diagram\n\no---o---o---*  A\n     \\   \\\n      \\   o---o  C\n       \\\n        *---*  B\n\nBy excluding C I have necessarily excluded a part of the history of A and B.\n\nIf we assume that the proposed feature is implemented and I do \"git\nrev-list $(git for-each-ref --format='%(refname)' A B ^C)\", then I get\nsomething different:\n\n*---*---*---*  A\n     \\   \\\n      \\   o---o  C\n       \\\n        *---*  B\n\nI argue that this is a useful selection.  For example, maybe I want to\nremove the clutter of branch C from my view, but I still want to see the\n*whole* history of branches A and B.  The middle selection doesn't do it.\n\nObviously this is not really necessary if there are only three branches,\nbut if there are dozens, and if A, B, and C are patterns rather than\nliteral branch names, then it can be very convenient.\n\nFor example, suppose I want to see the status of all of my submissions\nin your repository in the context of your main branches plus my local\nbranches.  It would be great to be able to type\n\n    gitk --with-branch='refs/heads/*' \\\n         --with-branch='remotes/gitster/*' \\\n         --without-branch='remotes/gitster/*/**' \\\n         --with-branch='remotes/gitster/mh/*'\n\nI don't know of a way to do that now.\n\n> A better pair you could have mentioned would be for-each-ref vs rev-parse\n> (not rev-list).  What Tom wanted with \"do not show the refs that match the\n> pattern\" he originally wanted to give to \"tag --list\" would be\n> \n> \tfor-each-ref A ^B\n> \n> that is \"show ref that matches A but do not show if it also matches B\",\n> while what you want to say is \"I want to paint A in positive color and\n> paint B in negative color, and I want to get a canonical notation to do\n> so\", it is spelled with rev-parse, not for-each-ref, like this:\n> \n> \trev-parse A ^B\n\nThat's not what I want; see above.\n\n> In other words,\n> \n> \tgit rev-list $(git rev-parse A ^B)\n> \n> would be the equivalent to \"git rev-list A ^B\".\n> \n> Maybe you are troubled that there are multiple concepts of negation, which\n> ultimately comes from the undeniable fact that for-each-ref and rev-parse\n> operate on entities in different concept domain (refnames and objects)?\n> And if we decide to use \"^\", then these two different concepts of negation\n> are both expressed with the same operator \"prefix ^\", leading to\n> confusion?\n\nNot only that, but also that both concepts of negation are interesting\nand useful within \"git rev-list\", and therefore we should make them\n*combinable*.\n\nTo be very explicit, I advocate:\n\n1. Implement an explicit syntax for \"do not include references matching\nthis pattern in a list of references\".  Implement this syntax in\nfor-each-ref; something like\n\n    --with-ref=PATTERN / --without-ref=PATTERN\n    --with-branch=PATTERN / --without-branch=PATTERN\n    --with-tag=PATTERN / --without-tag=PATTERN\n    --with-remote=PATTERN / --without-remote=PATTERN\n\nThe point of having multiple with/without pairs would be that the first\nwould match full refnames explicitly (i.e., the pattern would usually\nstart with \"refs/\"), whereas the other pairs would implicitly prepend\n\"refs/heads/\", \"refs/tags/\", or \"refs/remotes/\", respectively, to the\npattern for convenience.  There should also be an \"--all\" option that is\nequivalent to \"--with-ref=**\".\n\nThe output from for-each-ref would essentially be a *list of positive\nreferences* matching the criteria.  In other words,\n\"--without-branch=foo\" would cause \"refs/heads/foo\" to be *excluded*\nfrom the output altogether, *not* included as \"^refs/heads/foo\".\n\nThe order of the options should be significant, with the last matching\npattern winning.\n\n2. The pattern matching of refnames should be like fnmatch, with the\naddition of \"**\" as a wildcard meaning \"any characters, including '/'\".\n\n3. Other reference-listing commands should take the same options as\nappropriate; for example, \"git branch --list\" would take\n--with(out)?-branch and --with(out)?-remote (and maybe\n--with(out)?-ref); \"git tag --list\" would take --with(out)?-tag (and\nmaybe --with(out)?-ref), etc.\n\n4. The *exact same options* should be added to rev-list, and would\neffectively be expanded into a list of positive references; e.g.,\n\n    git rev-list --with-branch=A --with-branch=B --without-branch=C\n\nwould be equivalent to\n\n    git rev-list $(git for-each-ref --format='%(refname)'\n--with-branch=A --with-branch=B --without-branch=C)\n\nIf A, B, and C happen to be branch names rather than patterns, the above\nwould be equivalent to\n\n    git rev-list refs/heads/A refs/heads/B\n\nNote that this *differs* (in a useful way!) from\n\n    git rev-list refs/heads/A refs/heads/B --not refs/heads/C\n\nor\n\n    git rev-list refs/heads/A refs/heads/B ^refs/heads/C\n\nwhich are useful in other scenarios and whose meanings we would of\ncourse retain.\n\nIf \"--not\" is used in git-rev-list, it would demarcate groups of options\nthat are passed separately to for-each-ref; for example,\n\n    git rev-list --all --with-branch=A --without-branch=B \\\n           --not --with-branch=C --without-branch=D\n\nwould be equivalent to\n\n    git rev-list $(git for-each-ref --format='%(refname)' --all\n--with-branch=A --without-branch=B)\\\n           --not $(git for-each-ref --format='%(refname)'\n--with-branch=C --without-branch=D)\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184561","messageId":"7v4nuvghfk.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"4F38D9D4.5000203@alum.mit.edu","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-13T10:23:59Z","receivedAt":"2012-02-13T10:23:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> On 02/13/2012 07:37 AM, Junio C Hamano wrote:\n>> Michael Haggerty <mhagger@alum.mit.edu> writes:\n>> \n>>> Of *course* they operate on different namespaces.  But part of the way\n>>> that revisions are selected using rev-list is by *selecting or excluding\n>>> refnames* from which it should crawl.\n>> \n>> I am appalled if that is truly the understanding of yours, after having\n>> taken more than a few patches from you to fairly core parts of Git.\n>> \n>> \"rev-list A ^B\" does not say \"include A and exclude B from which rev-list\n>> should crawl\" AT ALL.  We _actively_ crawl from both A and B.  It is that\n>> what are reachable from B is painted in a color different from the color\n>> in which we paint what are reachable from A.\n>\n> Please read my emails more carefully before insulting me.\n> ...\n> o---o---o---*  A\n>      \\   \\\n>       \\   o---o  C\n>        \\\n>         *---*  B\n>\n> ... vs ...\n>\n> *---*---*---*  A\n>      \\   \\\n>       \\   o---o  C\n>        \\\n>         *---*  B\n>\n> I argue that this is a useful selection.\n\nThen why were you so against the addition of \"negation\" to for-each-ref?\n\nIf you want \"I want histories reaching A and B\", just say \"rev-list A B\",\nwithout adding useless \"er, I do not want histories reaching C in the\noutput, but I do not want commits reachable from C to be excluded from the\noutput either\" by mentioning C. Learn to shut your mouth and not talk\nabout irrelevant \"C\" in such a case, and you will do just fine.\n\nEspecially, re-read your first message where you said that between\n\n    git rev-list A B ^C\n\nand\n\n    git rev-list $(git for-each-ref A B ^C)\n\n\"consistency suggests should do the same\".  Should the consistency also\nsuggest that\n\n    git rev-list $(git rev-parse A B ^C)\n\ndo the same?  That is a total bullshit that can only come from somebody\nwho does not understand the distinction between pattern matching in\nrefnames vs set operation over commit DAG.\n\nHaving said all that, if your argument against using \"^\" as negation for\nfor-each-ref *were* with something like this from the beginning:\n\n    git rev-list --all --exclude-refs=refs/tags/v\\*\n\nit would have been very different. I would wholeheartedly buy the\nconsistency argument that says\n\n    git for-each-ref --exclude-refs=refs/tags/v\\*\n\nought to give all refs (only because for-each-ref \"all\" is implied) except\nfor the tagged tips, and\n\n    git log --all --exclude-refs=refs/tags/v\\*\n\nshould be the notation to produce consistently the same result as\n\n    git log $(git for-each-ref --format='%(objectname)' --exclude-refs=refs/tags/v\\*)\n\nbut if we used \"^\" as negated match in for-each-ref argument, we would\nclose the door to give such consistency to log family of commands later.\n\nBut that wasn't what you said.  Why should I get accused of not guessing\nwhat you meant to say but you clearly didn't, and in addition blamed for\ninsulting merely for pointing out the idiocy in what you said?\n\nNo. *YOU* go back and re-read your message more carefully.\n"},{"id":"184567","messageId":"4F391F5C.1000400@alum.mit.edu","threadId":"29583","inReplyTo":"7v4nuvghfk.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-02-13T14:34:04Z","receivedAt":"2012-02-13T14:34:04Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/13/2012 11:23 AM, Junio C Hamano wrote:\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n>> On 02/13/2012 07:37 AM, Junio C Hamano wrote:\n>>> Michael Haggerty <mhagger@alum.mit.edu> writes:\n>>>\n>>>> Of *course* they operate on different namespaces.  But part of the way\n>>>> that revisions are selected using rev-list is by *selecting or excluding\n>>>> refnames* from which it should crawl.\n>>>\n>>> I am appalled if that is truly the understanding of yours, after having\n>>> taken more than a few patches from you to fairly core parts of Git.\n>>>\n>>> \"rev-list A ^B\" does not say \"include A and exclude B from which rev-list\n>>> should crawl\" AT ALL.  We _actively_ crawl from both A and B.  It is that\n>>> what are reachable from B is painted in a color different from the color\n>>> in which we paint what are reachable from A.\n>>\n>> Please read my emails more carefully before insulting me.\n>> ...\n>> o---o---o---*  A\n>>      \\   \\\n>>       \\   o---o  C\n>>        \\\n>>         *---*  B\n>>\n>> ... vs ...\n>>\n>> *---*---*---*  A\n>>      \\   \\\n>>       \\   o---o  C\n>>        \\\n>>         *---*  B\n>>\n>> I argue that this is a useful selection.\n> \n> Then why were you so against the addition of \"negation\" to for-each-ref?\n\nI'm not against it.  I just think it should be spelled differently.\n\n> If you want \"I want histories reaching A and B\", just say \"rev-list A B\",\n> without adding useless \"er, I do not want histories reaching C in the\n> output, but I do not want commits reachable from C to be excluded from the\n> output either\" by mentioning C. Learn to shut your mouth and not talk\n> about irrelevant \"C\" in such a case, and you will do just fine.\n\nThat's fine if we're talking about single references.  But it does not\ngeneralize to patterns, like my example\n\n    gitk --with-branch='refs/heads/*' \\\n         --with-branch='remotes/gitster/*' \\\n         --without-branch='remotes/gitster/*/**' \\\n         --with-branch='remotes/gitster/mh/*'\n\nIf these options were supported, I could store this set of arguments as\na \"view\" in gitk and have it load automatically.  It would continue to\nwork even as you add and delete branches from your repository.  Listing\nthe branches explicitly would be fragile.  Currently I would have to\nwrite a script wrapper around gitk that invokes multiple git commands\nand filters the results using grep or something.  (At least I don't know\na better way.)  Even if for-each-ref were taught to exclude branches, I\ndon't believe it is possible to use arbitrary shell commands to build a\ngitk view.\n\n> Especially, re-read your first message where you said that between\n> \n>     git rev-list A B ^C\n> \n> and\n> \n>     git rev-list $(git for-each-ref A B ^C)\n> \n> \"consistency suggests should do the same\".\n\nI should have connected the dots better: consistency suggests they\nshould do the same, but they obviously cannot.  Moreover, it would be\nnice if the two types of exclusion could be combined in single commands,\nin which case consistency is mandatory.  Therefore, let's spell the\nfor-each-ref option another way that *can* be made consistent across\ncommands.\n\n> Having said all that, if your argument against using \"^\" as negation for\n> for-each-ref *were* with something like this from the beginning:\n> \n>     git rev-list --all --exclude-refs=refs/tags/v\\*\n> \n> it would have been very different. I would wholeheartedly buy the\n> consistency argument that says\n> \n>     git for-each-ref --exclude-refs=refs/tags/v\\*\n> \n> ought to give all refs (only because for-each-ref \"all\" is implied) except\n> for the tagged tips, and\n> \n>     git log --all --exclude-refs=refs/tags/v\\*\n> \n> should be the notation to produce consistently the same result as\n> \n>     git log $(git for-each-ref --format='%(objectname)' --exclude-refs=refs/tags/v\\*)\n> \n> but if we used \"^\" as negated match in for-each-ref argument, we would\n> close the door to give such consistency to log family of commands later.\n\nThat *has* been exactly my argument from the beginning [1].  I\ncautiously hope that we are now talking about the same thing, even if it\nis not yet clear whether we agree on a conclusion.\n\nI think this would be an interesting project, but I won't have time to\nwork on it in the near future.  My first priority is to get the\nhierarchical-refs patches rebased on top of the removal of extra refs\nand do some more rationalization in that area.\n\nMichael\n\n[1] I don't see where anything I've written is inconsistent with your\nphrasing of the argument.  But fine, let's just be happy that the\nmiscommunication now seems to be cleared up.\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"184572","messageId":"20120213162943.GF4903@tgrennan-laptop","threadId":"29583","inReplyTo":"7vzkcpkkbd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-13T16:29:43Z","receivedAt":"2012-02-13T16:29:43Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Sat, Feb 11, 2012 at 03:43:34PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> Yes, I should have stated that this emphasized containment over\n>> efficiency.  If instead we stipulate that the caller must list exclusion\n>> patterns before others, this could simply be:\n>\n>No.\n>\n>You have to pre-parse and rearrange the pattern[] list *only once* before\n>matching them against dozens of refs, so instead of forcing the callers do\n>anything funky, you give a function that gets a pattern[] list and returns\n>something that can be efficiently used by the match_pattern() function,\n>and have the caller pass that thing, not the original pattern[] list, to\n>the match_pattern() function.\n\nHmm, I'm not communicating very well; this is exactly what I meant by,\n\n>> Of course I'd add a with_exclusions_first() before the\n>> respective ref iterator.\n\n-- \nTomG\n\n\nOn Sat, Feb 11, 2012 at 12:06:56AM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> +int refname_match_patterns(const char **patterns, const char *refname)\n>> +{\n>> +\tint given_match_pattern = 0, had_match = 0;\n>> +\n>> +\tfor (; *patterns; patterns++)\n>> +\t\tif (**patterns != '!') {\n>> +\t\t\tgiven_match_pattern = 1;\n>> +\t\t\tif (!fnmatch(*patterns, refname, 0))\n>> +\t\t\t\thad_match = 1;\n>> +\t\t} else if (!fnmatch(*patterns+1, refname, 0))\n>> +\t\t\treturn 0;\n>> +\treturn given_match_pattern ? had_match : 1;\n>> +}\n>\n>This, while its semantics seem sane, is highly inefficient when you have\n>many patterns, and you will be calling this to filter dozens of refs.  And\n>it can trivially improved by first pre-parsing the pattern[] array.\n>\n> * If you know the patterns do not have any negative entry, you can return\n>   true upon seeing the first match. Because you do not pre-parse the\n>   pattern[] array, this loop does not know if there is any negative one,\n>   and has to scan it always all the way.\n>\n> * If you arrange the pattern[] array so that it has negative ones early,\n>   again, you can return false upon seeing the first hit with a negative\n>   one. If your input has negative ones at the end, the loop ends up\n>   scanning all the way, noting the positive matches, only to discard upon\n>   seeing the negative match at the end.\n>\n>That is why I said Nguyen's idea of reusing pathspec matching logic\n>somewhat attractive, even though I think it has downsides (the exact\n>matching logic for pathspec is more similar to that of for-each-ref\n>and very different from branch/tag).\n\nYes, I should have stated that this emphasized containment over\nefficiency.  If instead we stipulate that the caller must list exclusion\npatterns before others, this could simply be:\n\nint match_pattern(const char **patterns, const char *refname)\n{\n\tif (*patterns)\n\t\treturn 1;\n\tfor (; *patterns && **patterns == '!'; patterns++)\n\t\tif (!fnmatch(*patterns+1, refname, 0))\n\t\t\treturn 0;\n\tfor (; *patterns; patterns++)\n\t\tif (!fnmatch(*patterns, refname, 0))\n\t\t\treturn 1;\n\treturn 0;\n}\n\nOf course I'd add a with_exclusions_first() before the\nrespective ref iterator.\n\n-- \nTomG\n"},{"id":"184576","messageId":"20120213172754.GG4903@tgrennan-laptop","threadId":"29583","inReplyTo":"4F3898F8.2000201@alum.mit.edu","subject":"Re: [PATCHv2 1/4] refs: add common refname_match_patterns()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-13T17:27:54Z","receivedAt":"2012-02-13T17:27:54Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Mon, Feb 13, 2012 at 06:00:40AM +0100, Michael Haggerty wrote:\n>On 02/11/2012 08:17 PM, Tom Grennan wrote:\n>> Yes, I didn't explicitly state that the precedence is the order written\n>> and in correctly described the first case. How about?\n>> \n>> /**\n>>  * Returns in highest to lowest precedence:\n>>  *   1 with an empty patterns list\n>>  *   0 if refname fnmatch()es any ^ prefaced pattern\n>>  *   1 if refname fnmatch()es any other pattern\n>>  *   0 otherwise\n>>  */\n>\n>Much better; thanks.\n>\n>Please note that this choice of semantics limits its power.  For\n>example, if the rule were instead (like with gitattributes(5)) \"if more\n>than one pattern matches a refname, a later pattern overrides an earlier\n>pattern\", then one could do things like\n>\n>    refs/remotes/*/* !refs/remotes/gitster/* refs/remotes/gitster/master\n>\n>to include specific references within a hierarchy that is otherwise\n>excluded.\n>\n>However, since rev-list apparently uses a rule more like the one that\n>you are proposing, it might be better to be consistent than to choose a\n>different convention.\n\nHmm, I think it's important to have same respective result in each of\nthese case's,\n\n  $ git tag -l | grep v1.7.8.*\n  $ git tag -l v1.7.8*\n\n  $ git tag -l | grep -v .*-rc*\n  $ git tag -l ^*-rc*\n\n  $ git tag -l v1.7.8* | grep -v .*-rc*\n  $ git tag -l v1.7.8* ^*-rc*\n  $ git tag -l ^*-rc* v1.7.8*\n\nWhat I propose is somewhat analogous to gitignore's double negative,\n      *\tAn optional prefix !  which negates the pattern; any matching\n\tfile excluded by a previous pattern will become included again. If\n\ta negated pattern matches, this will override lower precedence\n\tpatterns sources.\n\nI still prefer \"^\" to \"!\" b/c A) it doesn't cause the noted regressions;\nand B) doesn't need command quoting.  I'd accept the counter proposals\nof --exclude or --with[out][-TYPE] but frankly, that's more\ncode/documentation churn (\"less code is always better\"[TM]) and worse,\nmore crap to type on the command line:\n\n  $ git --with-tags v1.7.8* --without-tags '*-rc*' tag -l v1.7.8* \nor\n  $ git tag -l --exclude '*-rc*' v1.7.8*\nvs.\n  $ git tag -l v1.7.8* ^*-rc*\n\n-- \nTomG\n"},{"id":"184600","messageId":"7vaa4meat5.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"4F391F5C.1000400@alum.mit.edu","subject":"Re: [RFC/PATCH] tag: make list exclude !<pattern>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-13T20:29:58Z","receivedAt":"2012-02-13T20:29:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n>> Having said all that, if your argument against using \"^\" as negation for\n>> for-each-ref *were* with something like this from the beginning:\n>> \n>>     git rev-list --all --exclude-refs=refs/tags/v\\*\n>> \n>> it would have been very different. I would wholeheartedly buy the\n>> consistency argument that says\n>> \n>>     git for-each-ref --exclude-refs=refs/tags/v\\*\n>> \n>> ought to give all refs (only because for-each-ref \"all\" is implied) except\n>> for the tagged tips, and\n>> \n>>     git log --all --exclude-refs=refs/tags/v\\*\n>> \n>> should be the notation to produce consistently the same result as\n>> \n>>     git log $(git for-each-ref --format='%(objectname)' --exclude-refs=refs/tags/v\\*)\n>> \n>> but if we used \"^\" as negated match in for-each-ref argument, we would\n>> close the door to give such consistency to log family of commands later.\n>\n> That *has* been exactly my argument from the beginning [1].\n\nWell, if the only thing you say is \"rev-list A B ^C\" and you are expecting\nthat your reader to substitute A with any dashed option like --all, --not\nor --stdin, I would have to say you are expecting too much.  I wouldn't\neven think of substituting A with $(git for-each-ref refs/heads/) in such\nan example.\n\n> I cautiously hope that we are now talking about the same thing, even if it\n> is not yet clear whether we agree on a conclusion.\n\nI think we are on the same page now.  Given that we seem to have settled\nfor the recent \"find in the paths that pathspec matches, but exclude\nmatches from paths that match these patterns\" topic by Albert Yale to\ntentatively use separate --exclude [*1*] command line option instead of\nmixing the negatives to the usual list of positives at the UI level, it\nappears to me that the most sensible way forward would be to expose the\nnegative match to the UI level is to introduce a similar --exclude-refs on\nthe command line.\n\nThat would eventually allow us to say something like [*2*]:\n\n\tgit log --all \\\n            --exclude-refs=refs/heads/experimental/* \\\n            --exclude-paths=compat/ \\\n\t    --since=30.days \\\n            -- '*.c'\n\nto ask for recent changes to all C sources outside the compat/ area for\neverything except for the experimental topics.\n\n\n[Footnote]\n\n*1* It might be better to spell this as --exclude-paths, though, if we are\ngoing to call this other exclude-refs-by-pattern --exclude-refs.  The\nlonger names would not bother us with the help of parse-options, and the\ncommands that need to support both, namely the commands in the log family,\nneed to allow users to be explicit which exclusion they want anyway, and\nhaving --exclude vs --exclude-refs as options that work on different\ndimensions look asymmetric.\n\n*2* \"something like\" includes using a convenience short-hand on this\ncommand line such as \"--branches --exclude-branches=experimental/*\"\ninstead of \"--all --exclude-refs=...\", but I consider that is icing on the\ncake after the first step to define the overall structure settles, so I\nwould prefer not to go into the tangential details.\n"},{"id":"185128","messageId":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"20120211190856.GB4903@tgrennan-laptop","subject":"[PATCHv3 0/5] Re: tag: make list exclude !<pattern>","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:45Z","receivedAt":"2012-02-22T01:28:45Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"It has taken me a while to get back to this; the following series rebase\nand rework my proposed \"!<pattern>\" feature.  The first patch extracts\nmatch_pattern() from builtin/tag.c and updates this to replace similar\nfunctions in builtin/{branch,for-each-ref,ls-remote}.c\n\nThe second patch uses the OPT_CALLBACK wrapper on the recently added\n\"--points-at\" option of git-tag.  I should have implemented it this way\nto begin with but I missed Jeff King's suggestion within that thread.\n\nThe remaining patches add \"--exclude <pattern>\" options (vs.\n\"!<pattern>\") to: git-tag, git-branch, and git-for-each-ref.\n\nFor example,\n  $ git tag -l --exclude \"*-rc?\" \"v1.7.8*\"\n  $ git branch -r --exclude \\*HEAD\n  $ git for-each-ref --format=\"%(refname)\" --exclude \"*HEAD\"\n\trefs/remotes/origin\n\nInstead of,\n  $ git tag -l \"!*-rc?\" \"v1.7.8*\"\n  $ git branch -r \"!*HEAD\"\n  $ git for-each-ref --format=\"%(refname)\" \"!*HEAD\" refs/remotes/origin\n\nNote that I haven't yet added an \"--exclude\" feature to git-ls-remote\nbecause I think that I should first update its option parsing.\n\nThanks,\nTom Grennan (5):\n  refs: add match_pattern()\n  tag --points-at option wrapper\n  tag --exclude option\n  branch --exclude option\n  for-each-ref --exclude option\n\n Documentation/git-branch.txt       |    7 ++++-\n Documentation/git-for-each-ref.txt |    7 ++++-\n Documentation/git-tag.txt          |    6 +++-\n builtin/branch.c                   |   30 ++++++++-----------\n builtin/for-each-ref.c             |   27 +++++------------\n builtin/ls-remote.c                |   12 ++------\n builtin/tag.c                      |   35 ++++++++++------------\n refs.c                             |   36 +++++++++++++++++++++++\n refs.h                             |   12 ++++++++\n t/t3200-branch.sh                  |   23 +++++++++++++++\n t/t6300-for-each-ref.sh            |   11 +++++++\n t/t7004-tag.sh                     |   56 ++++++++++++++++++++++++++++++++++++\n 12 files changed, 195 insertions(+), 67 deletions(-)\n\n-- \n1.7.8\n"},{"id":"185130","messageId":"1329874130-16818-2-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv3 1/5] refs: add match_pattern()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:46Z","receivedAt":"2012-02-22T01:28:46Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Used-by: git-branch, git-for-each-ref, git-ls-remote, and git-tag\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n builtin/branch.c       |   16 ++--------------\n builtin/for-each-ref.c |   21 ++-------------------\n builtin/ls-remote.c    |   12 +++---------\n builtin/tag.c          |   13 +------------\n refs.c                 |   36 ++++++++++++++++++++++++++++++++++++\n refs.h                 |   12 ++++++++++++\n 6 files changed, 56 insertions(+), 54 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex cb17bc3..e46ed58 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -266,18 +266,6 @@ struct append_ref_cb {\n \tint ret;\n };\n \n-static int match_patterns(const char **pattern, const char *refname)\n-{\n-\tif (!*pattern)\n-\t\treturn 1; /* no pattern always matches */\n-\twhile (*pattern) {\n-\t\tif (!fnmatch(*pattern, refname, 0))\n-\t\t\treturn 1;\n-\t\tpattern++;\n-\t}\n-\treturn 0;\n-}\n-\n static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data)\n {\n \tstruct append_ref_cb *cb = (struct append_ref_cb *)(cb_data);\n@@ -312,7 +300,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,\n \tif ((kind & ref_list->kinds) == 0)\n \t\treturn 0;\n \n-\tif (!match_patterns(cb->pattern, refname))\n+\tif (!match_pattern(refname, cb->pattern, NULL, 0))\n \t\treturn 0;\n \n \tcommit = NULL;\n@@ -542,7 +530,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);\n \n \tdetached = (detached && (kinds & REF_LOCAL_BRANCH));\n-\tif (detached && match_patterns(pattern, \"HEAD\"))\n+\tif (detached && match_pattern(\"HEAD\", pattern, NULL, 0))\n \t\tshow_detached(&ref_list);\n \n \tfor (i = 0; i < ref_list.index; i++) {\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex b01d76a..bd6a114 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -781,25 +781,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f\n \tstruct refinfo *ref;\n \tint cnt;\n \n-\tif (*cb->grab_pattern) {\n-\t\tconst char **pattern;\n-\t\tint namelen = strlen(refname);\n-\t\tfor (pattern = cb->grab_pattern; *pattern; pattern++) {\n-\t\t\tconst char *p = *pattern;\n-\t\t\tint plen = strlen(p);\n-\n-\t\t\tif ((plen <= namelen) &&\n-\t\t\t    !strncmp(refname, p, plen) &&\n-\t\t\t    (refname[plen] == '\\0' ||\n-\t\t\t     refname[plen] == '/' ||\n-\t\t\t     p[plen-1] == '/'))\n-\t\t\t\tbreak;\n-\t\t\tif (!fnmatch(p, refname, FNM_PATHNAME))\n-\t\t\t\tbreak;\n-\t\t}\n-\t\tif (!*pattern)\n-\t\t\treturn 0;\n-\t}\n+\tif (!match_pattern(refname, cb->grab_pattern, NULL, FNM_PATHNAME))\n+\t\treturn 0;\n \n \t/*\n \t * We do not open the object yet; sort may only need refname\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 41c88a9..29f2b38 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -2,6 +2,7 @@\n #include \"cache.h\"\n #include \"transport.h\"\n #include \"remote.h\"\n+#include \"refs.h\"\n \n static const char ls_remote_usage[] =\n \"git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>]\\n\"\n@@ -13,19 +14,12 @@ static const char ls_remote_usage[] =\n  */\n static int tail_match(const char **pattern, const char *path)\n {\n-\tconst char *p;\n \tchar pathbuf[PATH_MAX];\n \n-\tif (!pattern)\n-\t\treturn 1; /* no restriction */\n-\n \tif (snprintf(pathbuf, sizeof(pathbuf), \"/%s\", path) > sizeof(pathbuf))\n \t\treturn error(\"insanely long ref %.*s...\", 20, path);\n-\twhile ((p = *(pattern++)) != NULL) {\n-\t\tif (!fnmatch(p, pathbuf, 0))\n-\t\t\treturn 1;\n-\t}\n-\treturn 0;\n+\n+\treturn match_pattern(pathbuf, pattern, NULL, 0);\n }\n \n int cmd_ls_remote(int argc, const char **argv, const char *prefix)\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex fe7e5e5..9dcd7d2 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -34,17 +34,6 @@ struct tag_filter {\n \n static struct sha1_array points_at;\n \n-static int match_pattern(const char **patterns, const char *ref)\n-{\n-\t/* no pattern means match everything */\n-\tif (!*patterns)\n-\t\treturn 1;\n-\tfor (; *patterns; patterns++)\n-\t\tif (!fnmatch(*patterns, ref, 0))\n-\t\t\treturn 1;\n-\treturn 0;\n-}\n-\n static const unsigned char *match_points_at(const char *refname,\n \t\t\t\t\t    const unsigned char *sha1)\n {\n@@ -149,7 +138,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n {\n \tstruct tag_filter *filter = cb_data;\n \n-\tif (match_pattern(filter->patterns, refname)) {\n+\tif (match_pattern(refname, filter->patterns, NULL, 0)) {\n \t\tif (filter->with_commit) {\n \t\t\tstruct commit *commit;\n \ndiff --git a/refs.c b/refs.c\nindex c9f6835..0c50e81 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -3,6 +3,7 @@\n #include \"object.h\"\n #include \"tag.h\"\n #include \"dir.h\"\n+#include \"string-list.h\"\n \n /* ISSYMREF=0x01, ISPACKED=0x02 and ISBROKEN=0x04 are public interfaces */\n #define REF_KNOWS_PEELED 0x10\n@@ -2127,3 +2128,38 @@ char *shorten_unambiguous_ref(const char *refname, int strict)\n \tfree(short_name);\n \treturn xstrdup(refname);\n }\n+\n+static int match_path(const char *name, const char *pattern, int nlen)\n+{\n+\tint plen = strlen(pattern);\n+\n+\treturn ((plen <= nlen) &&\n+\t\t!strncmp(name, pattern, plen) &&\n+\t\t(name[plen] == '\\0' ||\n+\t\t name[plen] == '/' ||\n+\t\t pattern[plen-1] == '/'));\n+}\n+\n+int match_pattern(const char *name, const char **match,\n+\t\t  struct string_list *exclude, int flags)\n+{\n+\tint nlen = strlen(name);\n+\n+\tif (exclude) {\n+\t\tstruct string_list_item *x;\n+\t\tfor_each_string_list_item(x, exclude) {\n+\t\t\tif (!fnmatch(x->string, name, 0))\n+\t\t\t\treturn 0;\n+\t\t}\n+\t}\n+\tif (!match || !*match)\n+\t\treturn 1;\n+\tfor (; *match; match++) {\n+\t\tif (flags == FNM_PATHNAME)\n+\t\t\tif (match_path(name, *match, nlen))\n+\t\t\t\treturn 1;\n+\t\tif (!fnmatch(*match, name, flags))\n+\t\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\ndiff --git a/refs.h b/refs.h\nindex 33202b0..dd059d8 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -144,4 +144,16 @@ int update_ref(const char *action, const char *refname,\n \t\tconst unsigned char *sha1, const unsigned char *oldval,\n \t\tint flags, enum action_on_err onerr);\n \n+/*\n+ * match_pattern() - compares a name with pattern match and ignore lists\n+ * This returns in highest to lowest precedence:\n+ *    0 if <name> fnmatch() an <exclude> pattern\n+ *    1\tif <match> is NULL or empty\n+ *    1\tif <flags> is FNM_PATHNAME and <name> is an exact match of a listed\n+ *\tpattern upto and including a trailing '/'\n+ *    1 <name> fnmatch() a <match> pattern\n+ *    0 otherwise\n+ */\n+int match_pattern(const char *name, const char **match, struct string_list *exclude, int flags);\n+\n #endif /* REFS_H */\n-- \n1.7.8\n"},{"id":"185133","messageId":"1329874130-16818-3-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv3 2/5] tag --points-at option wrapper","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:47Z","receivedAt":"2012-02-22T01:28:47Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Use the OPT_CALLBACK wrapper with \"--points-at\" instead of an\nOPTION_CALLBACK block.\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n builtin/tag.c |    7 +++----\n 1 files changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 9dcd7d2..4a016d5 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -456,10 +456,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\t\tPARSE_OPT_LASTARG_DEFAULT,\n \t\t\tparse_opt_with_commit, (intptr_t)\"HEAD\",\n \t\t},\n-\t\t{\n-\t\t\tOPTION_CALLBACK, 0, \"points-at\", NULL, \"object\",\n-\t\t\t\"print only tags of the object\", 0, parse_opt_points_at\n-\t\t},\n+\t\tOPT_CALLBACK(0, \"points-at\", NULL, \"object\",\n+\t\t\t     \"print only tags of the object\",\n+\t\t\t     parse_opt_points_at),\n \t\tOPT_END()\n \t};\n \n-- \n1.7.8\n"},{"id":"185129","messageId":"1329874130-16818-4-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv3 3/5] tag --exclude option","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:48Z","receivedAt":"2012-02-22T01:28:48Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Example,\n  $ git tag -l --exclude \"*-rc?\" \"v1.7.8*\"\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n\nWhich is equivalent to,\n  $ git tag -l \"v1.7.8*\" | grep -v \\\\-rc.\n  v1.7.8\n  v1.7.8.1\n  v1.7.8.2\n  v1.7.8.3\n  v1.7.8.4\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n Documentation/git-tag.txt |    6 ++++-\n builtin/tag.c             |   17 ++++++++++---\n t/t7004-tag.sh            |   56 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 74 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\nindex 8d32b9a..470bd80 100644\n--- a/Documentation/git-tag.txt\n+++ b/Documentation/git-tag.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n \t<tagname> [<commit> | <object>]\n 'git tag' -d <tagname>...\n 'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]\n-\t[<pattern>...]\n+\t[--exclude <pattern>] [<pattern>...]\n 'git tag' -v <tagname>...\n \n DESCRIPTION\n@@ -90,6 +90,10 @@ OPTIONS\n --points-at <object>::\n \tOnly list tags of the given object.\n \n+--exclude <pattern>::\n+\tDon't list tags matching the given pattern.  This has precedence\n+\tover any other match pattern arguments.\n+\n -m <msg>::\n --message=<msg>::\n \tUse the given tag message (instead of prompting).\ndiff --git a/builtin/tag.c b/builtin/tag.c\nindex 4a016d5..547f97d 100644\n--- a/builtin/tag.c\n+++ b/builtin/tag.c\n@@ -21,7 +21,7 @@ static const char * const git_tag_usage[] = {\n \t\"git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]\",\n \t\"git tag -d <tagname>...\",\n \t\"git tag -l [-n[<num>]] [--contains <commit>] [--points-at <object>] \"\n-\t\t\"\\n\\t\\t[<pattern>...]\",\n+\t\t\"\\n\\t\\t[--exclude <pattern>] [<pattern>...]\",\n \t\"git tag -v <tagname>...\",\n \tNULL\n };\n@@ -30,6 +30,7 @@ struct tag_filter {\n \tconst char **patterns;\n \tint lines;\n \tstruct commit_list *with_commit;\n+\tstruct string_list *exclude;\n };\n \n static struct sha1_array points_at;\n@@ -138,7 +139,7 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n {\n \tstruct tag_filter *filter = cb_data;\n \n-\tif (match_pattern(refname, filter->patterns, NULL, 0)) {\n+\tif (match_pattern(refname, filter->patterns, filter->exclude, 0)) {\n \t\tif (filter->with_commit) {\n \t\t\tstruct commit *commit;\n \n@@ -165,13 +166,15 @@ static int show_reference(const char *refname, const unsigned char *sha1,\n }\n \n static int list_tags(const char **patterns, int lines,\n-\t\t\tstruct commit_list *with_commit)\n+\t\t     struct commit_list *with_commit,\n+\t\t     struct string_list *exclude)\n {\n \tstruct tag_filter filter;\n \n \tfilter.patterns = patterns;\n \tfilter.lines = lines;\n \tfilter.with_commit = with_commit;\n+\tfilter.exclude = exclude;\n \n \tfor_each_tag_ref(show_reference, (void *) &filter);\n \n@@ -428,6 +431,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \tconst char *msgfile = NULL, *keyid = NULL;\n \tstruct msg_arg msg = { 0, STRBUF_INIT };\n \tstruct commit_list *with_commit = NULL;\n+\tstruct string_list exclude = STRING_LIST_INIT_NODUP;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('l', \"list\", &list, \"list tag names\"),\n \t\t{ OPTION_INTEGER, 'n', NULL, &lines, \"n\",\n@@ -459,6 +463,9 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tOPT_CALLBACK(0, \"points-at\", NULL, \"object\",\n \t\t\t     \"print only tags of the object\",\n \t\t\t     parse_opt_points_at),\n+\t\tOPT_CALLBACK(0, \"exclude\", &exclude, \"pattern\",\n+\t\t\t     \"ignore pattern matching tags\",\n+\t\t\t     parse_opt_string_list),\n \t\tOPT_END()\n \t};\n \n@@ -485,13 +492,15 @@ int cmd_tag(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(git_tag_usage, options);\n \tif (list)\n \t\treturn list_tags(argv, lines == -1 ? 0 : lines,\n-\t\t\t\t with_commit);\n+\t\t\t\t with_commit, &exclude);\n \tif (lines != -1)\n \t\tdie(_(\"-n option is only allowed with -l.\"));\n \tif (with_commit)\n \t\tdie(_(\"--contains option is only allowed with -l.\"));\n \tif (points_at.nr)\n \t\tdie(_(\"--points-at option is only allowed with -l.\"));\n+\tif (exclude.nr)\n+\t\tdie(_(\"--exclude option is only allowed with -l.\"));\n \tif (delete)\n \t\treturn for_each_tag_name(argv, delete_tag);\n \tif (verify)\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f8c247a..4f1cf48 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -82,6 +82,10 @@ test_expect_success \\\n \t'listing tags using a non-matching pattern should output nothing' \\\n \t'test `git tag -l xxx | wc -l` -eq 0'\n \n+test_expect_success \\\n+\t'listing tags excluding \"mytag\" should output nothing' \\\n+\t'test `git tag -l --exclude mytag | wc -l` -eq 0'\n+\n # special cases for creating tags:\n \n test_expect_success \\\n@@ -202,6 +206,15 @@ test_expect_success \\\n '\n \n cat >expect <<EOF\n+v0.2.1\n+EOF\n+test_expect_success \\\n+\t'listing tags with a suffix as pattern and prefix exclusion' '\n+\tgit tag -l --exclude \"v1.*\" \"*.1\" > actual &&\n+\ttest_cmp expect actual\n+'\n+\n+cat >expect <<EOF\n t210\n t211\n EOF\n@@ -212,6 +225,15 @@ test_expect_success \\\n '\n \n cat >expect <<EOF\n+t210\n+EOF\n+test_expect_success \\\n+\t'listing tags with a prefix as pattern and suffix exclusion' '\n+\tgit tag -l --exclude \"*1\" \"t21*\" > actual &&\n+\ttest_cmp expect actual\n+'\n+\n+cat >expect <<EOF\n a1\n EOF\n test_expect_success \\\n@@ -239,6 +261,15 @@ test_expect_success \\\n \ttest_cmp expect actual\n '\n \n+cat >expect <<EOF\n+v1.0.1\n+EOF\n+test_expect_success \\\n+\t'listing tags with ? in the pattern and exclusion' '\n+\tgit tag -l --exclude \"v1.?.3\" \"v1.?.?\" > actual &&\n+\ttest_cmp expect actual\n+'\n+\n >expect\n test_expect_success \\\n \t'listing tags using v.* should print nothing because none have v.' '\n@@ -263,6 +294,31 @@ test_expect_success 'tag -l can accept multiple patterns' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'tag -l can cancel exclusions' '\n+\tgit tag -l --exclude \"v*.3\" --no-exclude \"v1*\" \"v0*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+cat >expect <<EOF\n+v0.2.1\n+v1.0.1\n+EOF\n+test_expect_success 'tag -l can accept multiple patterns and exclusions' '\n+\tgit tag -l --exclude \"v*.3\" --exclude \"v1.0\" \"v1*\" \"v0*\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+cat >expect <<EOF\n+v0.2.1\n+v1.0.1\n+v1.1.3\n+EOF\n+test_expect_success \\\n+\t'tag -l can cancel then reapply exclusions' '\n+\tgit tag -l --exclude \"v*.3\" --no-exclude --exclude \"v1.0\" \\\n+\t\t\"v1*\" \"v0*\" >actual &&\n+\ttest_cmp expect actual\n+'\n # creating and verifying lightweight tags:\n \n test_expect_success \\\n-- \n1.7.8\n"},{"id":"185132","messageId":"1329874130-16818-5-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv3 4/5] branch --exclude option","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:49Z","receivedAt":"2012-02-22T01:28:49Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Example,\n  $ ./git-branch -r --exclude \\*HEAD\n  origin/maint\n  origin/master\n  origin/next\n  origin/pu\n  origin/todo\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n Documentation/git-branch.txt |    7 ++++++-\n builtin/branch.c             |   18 +++++++++++++-----\n t/t3200-branch.sh            |   23 +++++++++++++++++++++++\n 3 files changed, 42 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 0427e80..ef08872 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -10,7 +10,8 @@ SYNOPSIS\n [verse]\n 'git branch' [--color[=<when>] | --no-color] [-r | -a]\n \t[--list] [-v [--abbrev=<length> | --no-abbrev]]\n-\t[(--merged | --no-merged | --contains) [<commit>]] [<pattern>...]\n+\t[(--merged | --no-merged | --contains) [<commit>]]\n+\t[--exclude <pattern>] [<pattern>...]\n 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\n 'git branch' (-m | -M) [<oldbranch>] <newbranch>\n 'git branch' (-d | -D) [-r] <branchname>...\n@@ -166,6 +167,10 @@ start-point is either a local or remote-tracking branch.\n --contains <commit>::\n \tOnly list branches which contain the specified commit.\n \n+--exclude <pattern>::\n+\tDon't list branches matching the given pattern.  This has\n+\tprecedence over other match pattern arguments.\n+\n --merged [<commit>]::\n \tOnly list branches whose tips are reachable from the\n \tspecified commit (HEAD if not specified).\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex e46ed58..ec06f66 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -243,6 +243,7 @@ struct ref_list {\n \tint index, alloc, maxwidth, verbose, abbrev;\n \tstruct ref_item *list;\n \tstruct commit_list *with_commit;\n+\tstruct string_list *exclude;\n \tint kinds;\n };\n \n@@ -300,7 +301,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,\n \tif ((kind & ref_list->kinds) == 0)\n \t\treturn 0;\n \n-\tif (!match_pattern(refname, cb->pattern, NULL, 0))\n+\tif (!match_pattern(refname, cb->pattern, ref_list->exclude, 0))\n \t\treturn 0;\n \n \tcommit = NULL;\n@@ -498,7 +499,10 @@ static void show_detached(struct ref_list *ref_list)\n \t}\n }\n \n-static int print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit, const char **pattern)\n+static int print_ref_list(int kinds, int detached, int verbose, int abbrev,\n+\t\t\t  struct commit_list *with_commit,\n+\t\t\t  struct string_list *exclude,\n+\t\t\t  const char **pattern)\n {\n \tint i;\n \tstruct append_ref_cb cb;\n@@ -509,6 +513,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \tref_list.verbose = verbose;\n \tref_list.abbrev = abbrev;\n \tref_list.with_commit = with_commit;\n+\tref_list.exclude = exclude;\n \tif (merge_filter != NO_FILTER)\n \t\tinit_revisions(&ref_list.revs, NULL);\n \tcb.ref_list = &ref_list;\n@@ -530,7 +535,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);\n \n \tdetached = (detached && (kinds & REF_LOCAL_BRANCH));\n-\tif (detached && match_pattern(\"HEAD\", pattern, NULL, 0))\n+\tif (detached && match_pattern(\"HEAD\", pattern, exclude, 0))\n \t\tshow_detached(&ref_list);\n \n \tfor (i = 0; i < ref_list.index; i++) {\n@@ -665,7 +670,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tenum branch_track track;\n \tint kinds = REF_LOCAL_BRANCH;\n \tstruct commit_list *with_commit = NULL;\n-\n+\tstruct string_list exclude = STRING_LIST_INIT_NODUP;\n \tstruct option options[] = {\n \t\tOPT_GROUP(\"Generic options\"),\n \t\tOPT__VERBOSE(&verbose,\n@@ -689,6 +694,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\tPARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,\n \t\t\tparse_opt_with_commit, (intptr_t) \"HEAD\",\n \t\t},\n+\t\tOPT_CALLBACK(0, \"exclude\", &exclude, \"pattern\",\n+\t\t\t     \"ignorepattern matching branches\",\n+\t\t\t     parse_opt_string_list),\n \t\tOPT__ABBREV(&abbrev),\n \n \t\tOPT_GROUP(\"Specific git-branch actions:\"),\n@@ -753,7 +761,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\treturn delete_branches(argc, argv, delete > 1, kinds);\n \telse if (list)\n \t\treturn print_ref_list(kinds, detached, verbose, abbrev,\n-\t\t\t\t      with_commit, argv);\n+\t\t\t\t      with_commit, &exclude, argv);\n \telse if (edit_description) {\n \t\tconst char *branch_name;\n \t\tstruct strbuf branch_ref = STRBUF_INIT;\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd1aceb..8144bc8 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -160,6 +160,29 @@ test_expect_success 'git branch --list -d t should fail' '\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n+>expect\n+test_expect_success \\\n+\t'git branch --list --exclude \"t*\" \"t*\" should be empty' '\n+\tgit branch ta &&\n+\tgit branch tb &&\n+\tgit branch --list --exclude \"t*\" \"t*\" > actual &&\n+\tcmp expect actual\n+'\n+\n+cat >expect <<EOF\n+  ta\n+EOF\n+test_expect_success \\\n+\t'git branch --list --exclude \"tb\" \"t*\" should be \"ta\"' '\n+\tgit branch --list --exclude \"tb\" \"t*\" > actual &&\n+\tcmp expect actual\n+'\n+\n+test_expect_success \\\n+\t'git branch -d ta tb should succeed' '\n+\tgit branch -d ta tb\n+'\n+\n mv .git/config .git/config-saved\n \n test_expect_success 'git branch -m q q2 without config should succeed' '\n-- \n1.7.8\n"},{"id":"185131","messageId":"1329874130-16818-6-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1329874130-16818-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv3 5/5] for-each-ref --exclude option","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T01:28:50Z","receivedAt":"2012-02-22T01:28:50Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Example,\n  $ git for-each-ref --format=\"%(refname)\" refs/remotes/origin\n  refs/remotes/origin/HEAD\n  refs/remotes/origin/maint\n  refs/remotes/origin/master\n  refs/remotes/origin/next\n  refs/remotes/origin/pu\n  refs/remotes/origin/todo\n  $ ./git-for-each-ref --format=\"%(refname)\" --exclude \"*/HEAD\" refs/remotes/origin\n  refs/remotes/origin/maint\n  refs/remotes/origin/master\n  refs/remotes/origin/next\n  refs/remotes/origin/pu\n  refs/remotes/origin/todo\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n Documentation/git-for-each-ref.txt |    7 ++++++-\n builtin/for-each-ref.c             |    8 +++++++-\n t/t6300-for-each-ref.sh            |   11 +++++++++++\n 3 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt\nindex c872b88..5f19a8b 100644\n--- a/Documentation/git-for-each-ref.txt\n+++ b/Documentation/git-for-each-ref.txt\n@@ -9,7 +9,8 @@ SYNOPSIS\n --------\n [verse]\n 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]\n-\t\t   [(--sort=<key>)...] [--format=<format>] [<pattern>...]\n+\t\t   [(--sort=<key>)...] [--format=<format>]\n+\t\t   [--exclude=<pattern>] [<pattern>...]\n \n DESCRIPTION\n -----------\n@@ -47,6 +48,10 @@ OPTIONS\n \t`xx`; for example `%00` interpolates to `\\0` (NUL),\n \t`%09` to `\\t` (TAB) and `%0a` to `\\n` (LF).\n \n+--exclude <pattern>::\n+\tIgnore refs matching the given pattern.  This has precedence\n+\tover any other pattern match arguments.\n+\n <pattern>...::\n \tIf one or more patterns are given, only refs are shown that\n \tmatch against at least one pattern, either using fnmatch(3) or\ndiff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c\nindex bd6a114..783f59f 100644\n--- a/builtin/for-each-ref.c\n+++ b/builtin/for-each-ref.c\n@@ -91,6 +91,9 @@ static const char **used_atom;\n static cmp_type *used_atom_type;\n static int used_atom_cnt, sort_atom_limit, need_tagged, need_symref;\n \n+/* list of ref patterns and ref groups (i.e. foo/) to ignore */\n+static struct string_list exclude = STRING_LIST_INIT_NODUP;\n+\n /*\n  * Used to parse format string and sort specifiers\n  */\n@@ -781,7 +784,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f\n \tstruct refinfo *ref;\n \tint cnt;\n \n-\tif (!match_pattern(refname, cb->grab_pattern, NULL, FNM_PATHNAME))\n+\tif (!match_pattern(refname, cb->grab_pattern, &exclude, FNM_PATHNAME))\n \t\treturn 0;\n \n \t/*\n@@ -985,6 +988,9 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(  0 , \"format\", &format, \"format\", \"format to use for the output\"),\n \t\tOPT_CALLBACK(0 , \"sort\", sort_tail, \"key\",\n \t\t            \"field name to sort on\", &opt_parse_sort),\n+\t\tOPT_CALLBACK(0, \"exclude\", &exclude, \"pattern\",\n+\t\t\t     \"ignore pattern matching refs\",\n+\t\t\t     parse_opt_string_list),\n \t\tOPT_END(),\n \t};\n \ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 1721784..26df442 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -243,6 +243,17 @@ test_expect_success 'Verify descending sort' '\n '\n \n cat >expected <<\\EOF\n+refs/tags/testtag\n+refs/heads/master\n+EOF\n+\n+test_expect_success 'Verify exclusion with sort' '\n+\tgit for-each-ref --format=\"%(refname)\" --sort=-refname \\\n+\t\t--exclude \"*origin*\" >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+cat >expected <<\\EOF\n 'refs/heads/master'\n 'refs/remotes/origin/master'\n 'refs/tags/testtag'\n-- \n1.7.8\n"},{"id":"185149","messageId":"7vobsrbcny.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1329874130-16818-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv3 1/5] refs: add match_pattern()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-22T06:33:05Z","receivedAt":"2012-02-22T06:33:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> +static int match_path(const char *name, const char *pattern, int nlen)\n> +{\n> +\tint plen = strlen(pattern);\n> +\n> +\treturn ((plen <= nlen) &&\n> +\t\t!strncmp(name, pattern, plen) &&\n> +\t\t(name[plen] == '\\0' ||\n> +\t\t name[plen] == '/' ||\n> +\t\t pattern[plen-1] == '/'));\n> +}\n\nThis is a counterpart to the tail match found in ls-remote, so we would\nwant to call it with a name that makes it clear this is a leading path\nmatch not just \"path\" match.  Perhaps match_leading_path() or something.\n\n> +int match_pattern(const char *name, const char **match,\n> +\t\t  struct string_list *exclude, int flags)\n> +{\n> +\tint nlen = strlen(name);\n> +\n> +\tif (exclude) {\n> +\t\tstruct string_list_item *x;\n> +\t\tfor_each_string_list_item(x, exclude) {\n> +\t\t\tif (!fnmatch(x->string, name, 0))\n> +\t\t\t\treturn 0;\n> +\t\t}\n> +\t}\n> +\tif (!match || !*match)\n> +\t\treturn 1;\n> +\tfor (; *match; match++) {\n> +\t\tif (flags == FNM_PATHNAME)\n> +\t\t\tif (match_path(name, *match, nlen))\n> +\t\t\t\treturn 1;\n> +\t\tif (!fnmatch(*match, name, flags))\n> +\t\t\treturn 1;\n> +\t}\n> +\treturn 0;\n> +}\n\nAs an API for a consolidated and generic function, the design needs a bit\nmore improving, I would think.\n\n - The name match_pattern() was OK for a static function inside a single\n   file, but it is way too vague for a global function. This is to match\n   refnames, so I suspect there should at least be a string \"ref_\"\n   somewhere in its name.\n\n - You pass \"flags\" argument, so that later we _could_ enhance the\n   implementation to cover needs for new callers, but alas, it uses its\n   full bits to express only one \"do we do FNM_PATHNAME or not?\" bit of\n   information, so essentially \"flags\" does not give us any expandability.\n\n - Is it a sane assumption that a caller that asks FNM_PATHNAME will\n   always want match_path() semantics, too?  Aren't these two logically\n   independent?\n\n - Is it a sane assumption that a caller that gives an exclude list will\n   want neither FNM_PATHNAME semantics nor match_path() semantics?\n\n - Positive patterns are passed in \"const char **match\", and negative ones\n   are in \"struct string_list *\". Doesn't the inconsistency strike you as\n   strange?\n\nPerhaps like...\n\n#define REF_MATCH_LEADING       01\n#define REF_MATCH_TRAILING      02\n#define REF_MATCH_FNM_PATH      04\n\nstatic int match_one(const char *name, size_t namelen, const char *pattern,\n\t\tunsigned flags)\n{\n       \tif ((flags & REF_MATCH_LEADING) &&\n            match_leading_path(name, pattern, namelen))\n\t\treturn 1;\n       \tif ((flags & REF_MATCH_TRAILING) &&\n            match_trailing_path(name, pattern, namelen))\n\t\treturn 1;\n\tif (!fnmatch(pattern, name, \n\t\t     (flags & REF_MATCH_FNM_PATH) ? FNM_PATHNAME : 0))\n\t\treturn 1;\n\treturn 0;\n}\n\nint ref_match_pattern(const char *name,\n\t\tconst char **pattern, const char **exclude, unsigned flags)\n{\n\tsize_t namelen = strlen(name);\n        if (exclude) {\n\t\twhile (*exclude) {\n\t\t\tif (match_one(name, namelen, *exclude, flags))\n\t\t\t\treturn 0;\n\t\t\texclude++;\n\t\t}\n\t}\n        if (!pattern || !*pattern)\n        \treturn 1;\n\twhile (*pattern) {\n\t\tif (match_one(name, namelen, *pattern, flags))\n\t\t\treturn 1;\n\t\tpattern++;\n\t}\n        return 0;\n}\n\nand then the caller could do something like\n\n\tref_match_pattern(\"refs/heads/master\",\n        \t\t  [\"maste?\", NULL],\n                          [\"refs/heads/\", NULL],\n                          (REF_MATCH_FNM_PATH|REF_MATCH_LEADING));\n\nNote that the above \"ref_match_pattern()\" gives the same \"flags\" for the\ncall to match_one() for elements in both positive and negative array and\nit is very deliberate.  See review comment to [3/5] for the reasoning.\n\nThanks.\n"},{"id":"185148","messageId":"7vhayjbcna.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1329874130-16818-4-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv3 3/5] tag --exclude option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-22T06:33:29Z","receivedAt":"2012-02-22T06:33:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> Example,\n>   $ git tag -l --exclude \"*-rc?\" \"v1.7.8*\"\n>   v1.7.8\n>   v1.7.8.1\n>   v1.7.8.2\n>   v1.7.8.3\n>   v1.7.8.4\n>\n> Which is equivalent to,\n>   $ git tag -l \"v1.7.8*\" | grep -v \\\\-rc.\n>   v1.7.8\n>   v1.7.8.1\n>   v1.7.8.2\n>   v1.7.8.3\n>   v1.7.8.4\n>\n> Signed-off-by: Tom Grennan <tmgrennan@gmail.com>\n\nHaving an example is a good way to illustrate your explanation, but it is\nnot a substitution.  Could we have at least one real sentence to describe\nwhat the added option *does*?\n\nThis comment applies to all the patches in this series except for the\nsecond patch.\n\n> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\n> index 8d32b9a..470bd80 100644\n> --- a/Documentation/git-tag.txt\n> +++ b/Documentation/git-tag.txt\n> @@ -13,7 +13,7 @@ SYNOPSIS\n>  \t<tagname> [<commit> | <object>]\n>  'git tag' -d <tagname>...\n>  'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]\n> -\t[<pattern>...]\n> +\t[--exclude <pattern>] [<pattern>...]\n>  'git tag' -v <tagname>...\n>  \n>  DESCRIPTION\n> @@ -90,6 +90,10 @@ OPTIONS\n>  --points-at <object>::\n>  \tOnly list tags of the given object.\n>  \n> +--exclude <pattern>::\n> +\tDon't list tags matching the given pattern.  This has precedence\n> +\tover any other match pattern arguments.\n\nAs you do not specify what kind of pattern matching is done to this\nexclude pattern, it is important to use the same logic between positive\nand negative ones to give users a consistent UI.  Unfortunately we use\nfnmatch without FNM_PATHNAME for positive ones, so this exclude pattern\nneeds to follow the same semantics to reduce confusion.\n\nThis comment applies to all the patches in this series to add this option\nto existing commands that take the positive pattern.\n\n> @@ -202,6 +206,15 @@ test_expect_success \\\n>  '\n>  \n>  cat >expect <<EOF\n> +v0.2.1\n> +EOF\n> +test_expect_success \\\n> +\t'listing tags with a suffix as pattern and prefix exclusion' '\n> +\tgit tag -l --exclude \"v1.*\" \"*.1\" > actual &&\n> +\ttest_cmp expect actual\n> +'\n\nI know you are imitating the style of surrounding tests that is an older\nparts of this script, but it is an eyesore.  More modern tests are written\nlike this:\n\n\ttest_expect_success 'label for the test' '\n\t\tcat >expect <<-EOF &&\n                v0.2.1\n\t\tEOF\n\t        git tag -l ... >actual &&\n\t\ttest_cmp expect actual\n\t'\n\nto avoid unnecessary backslash on the first line, and have the preparation\nof test vectore _inside_ test_expect_success.  We would eventually want to\nupdate the older part to the newer style for consistency.\n\nTwo possible ways to go about this are (1) have a \"pure style\" patch at\nthe beginning to update older tests to a new style and then add new code\nand new test as a follow-up patch written in modern, or (2) add new code\nand new test in modern, and make a mental note to update the older ones\nafter the dust settles.  Adding new tests written in older style to a file\nthat already has mixed styles is the worst thing you can do.\n\nThis comment applies to all the patches in this series with tests.\n\nThanks.\n"},{"id":"185224","messageId":"20120222234733.GD2410@tgrennan-laptop","threadId":"29583","inReplyTo":"7vobsrbcny.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 1/5] refs: add match_pattern()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-22T23:47:33Z","receivedAt":"2012-02-22T23:47:33Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Tue, Feb 21, 2012 at 10:33:05PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> +static int match_path(const char *name, const char *pattern, int nlen)\n>> +{\n>> +\tint plen = strlen(pattern);\n>> +\n>> +\treturn ((plen <= nlen) &&\n>> +\t\t!strncmp(name, pattern, plen) &&\n>> +\t\t(name[plen] == '\\0' ||\n>> +\t\t name[plen] == '/' ||\n>> +\t\t pattern[plen-1] == '/'));\n>> +}\n>\n>This is a counterpart to the tail match found in ls-remote, so we would\n>want to call it with a name that makes it clear this is a leading path\n>match not just \"path\" match.  Perhaps match_leading_path() or something.\n\nOK\n\n>> +int match_pattern(const char *name, const char **match,\n>> +\t\t  struct string_list *exclude, int flags)\n>> +{\n>> +\tint nlen = strlen(name);\n>> +\n>> +\tif (exclude) {\n>> +\t\tstruct string_list_item *x;\n>> +\t\tfor_each_string_list_item(x, exclude) {\n>> +\t\t\tif (!fnmatch(x->string, name, 0))\n>> +\t\t\t\treturn 0;\n>> +\t\t}\n>> +\t}\n>> +\tif (!match || !*match)\n>> +\t\treturn 1;\n>> +\tfor (; *match; match++) {\n>> +\t\tif (flags == FNM_PATHNAME)\n>> +\t\t\tif (match_path(name, *match, nlen))\n>> +\t\t\t\treturn 1;\n>> +\t\tif (!fnmatch(*match, name, flags))\n>> +\t\t\treturn 1;\n>> +\t}\n>> +\treturn 0;\n>> +}\n>\n>As an API for a consolidated and generic function, the design needs a bit\n>more improving, I would think.\n>\n> - The name match_pattern() was OK for a static function inside a single\n>   file, but it is way too vague for a global function. This is to match\n>   refnames, so I suspect there should at least be a string \"ref_\"\n>   somewhere in its name.\n\nOK\n\n> - You pass \"flags\" argument, so that later we _could_ enhance the\n>   implementation to cover needs for new callers, but alas, it uses its\n>   full bits to express only one \"do we do FNM_PATHNAME or not?\" bit of\n>   information, so essentially \"flags\" does not give us any expandability.\n\nI agree.\n\n> - Is it a sane assumption that a caller that asks FNM_PATHNAME will\n>   always want match_path() semantics, too?  Aren't these two logically\n>   independent?\n\nYes, these should be ligically independent although the current use has\ncombined them.\n\n> - Is it a sane assumption that a caller that gives an exclude list will\n>   want neither FNM_PATHNAME semantics nor match_path() semantics?\n\nI'm not sure.  I tried using FNM_PATHNAME with both exclusion and match\npatterns of git-for-each-ref but I couldn't get it to do something like\nthis:\n\tgit for-each-ref ... --exclude '*HEAD' refs/remotes/\n\nI don't remember if this worked,\n\tgit for-each-ref ... --exclude HEAD refs/remotes/\n\nNow I see how an implicit TRAILING match would be useful,\n\tgit for-each-ref ... --exclude /HEAD refs/remotes/\n\nWhere git-for-each-ref uses this flag:\n\tREF_MATCH_LEADING | REF_MATCH_TRAILING | REF_MATCH_FNM_PATH\n\nI'll experiment with this more. \n\n> - Positive patterns are passed in \"const char **match\", and negative ones\n>   are in \"struct string_list *\". Doesn't the inconsistency strike you as\n>   strange?\n\nYes, I tried to minimize change but the conversion of argv's to\nstring_list's won't add that much.\n\n>Perhaps like...\n>\n>#define REF_MATCH_LEADING       01\n>#define REF_MATCH_TRAILING      02\n>#define REF_MATCH_FNM_PATH      04\n>\n>static int match_one(const char *name, size_t namelen, const char *pattern,\n>\t\tunsigned flags)\n>{\n>       \tif ((flags & REF_MATCH_LEADING) &&\n>            match_leading_path(name, pattern, namelen))\n>\t\treturn 1;\n>       \tif ((flags & REF_MATCH_TRAILING) &&\n>            match_trailing_path(name, pattern, namelen))\n>\t\treturn 1;\n>\tif (!fnmatch(pattern, name, \n>\t\t     (flags & REF_MATCH_FNM_PATH) ? FNM_PATHNAME : 0))\n>\t\treturn 1;\n>\treturn 0;\n>}\n>\n>int ref_match_pattern(const char *name,\n>\t\tconst char **pattern, const char **exclude, unsigned flags)\n>{\n>\tsize_t namelen = strlen(name);\n>        if (exclude) {\n>\t\twhile (*exclude) {\n>\t\t\tif (match_one(name, namelen, *exclude, flags))\n>\t\t\t\treturn 0;\n>\t\t\texclude++;\n>\t\t}\n>\t}\n>        if (!pattern || !*pattern)\n>        \treturn 1;\n>\twhile (*pattern) {\n>\t\tif (match_one(name, namelen, *pattern, flags))\n>\t\t\treturn 1;\n>\t\tpattern++;\n>\t}\n>        return 0;\n>}\n>\n>and then the caller could do something like\n>\n>\tref_match_pattern(\"refs/heads/master\",\n>        \t\t  [\"maste?\", NULL],\n>                          [\"refs/heads/\", NULL],\n>                          (REF_MATCH_FNM_PATH|REF_MATCH_LEADING));\n>\n>Note that the above \"ref_match_pattern()\" gives the same \"flags\" for the\n>call to match_one() for elements in both positive and negative array and\n>it is very deliberate.  See review comment to [3/5] for the reasoning.\n\nOK, I think that I understand, but please confirm, you'd expect no output in\nthe above example, right?\n\n-- \nTomG\n"},{"id":"185227","messageId":"7v62ey8ktp.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"20120222234733.GD2410@tgrennan-laptop","subject":"Re: [PATCHv3 1/5] refs: add match_pattern()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-23T00:17:22Z","receivedAt":"2012-02-23T00:17:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> Yes, I tried to minimize change but the conversion of argv's to\n> string_list's won't add that much.\n\nHow about _not_ using string_list?  After all, string_list is not just a\ncollection of strings, but is a table to hold strings with attributes.  I\nthought argv_array is more appropriate abstraction for the purpose of your\npatch.\n>>\tref_match_pattern(\"refs/heads/master\",\n>>        \t\t  [\"maste?\", NULL],\n>>                          [\"refs/heads/\", NULL],\n>>                          (REF_MATCH_FNM_PATH|REF_MATCH_LEADING));\n>>\n>>Note that the above \"ref_match_pattern()\" gives the same \"flags\" for the\n>>call to match_one() for elements in both positive and negative array and\n>>it is very deliberate.  See review comment to [3/5] for the reasoning.\n>\n> OK, I think that I understand, but please confirm, you'd expect no output in\n> the above example, right?\n\n\"maste?\" would match with FNM_PATHNAME with \"refs/heads/master\" but\nthe negative \"refs/heads/\" matches with it, so yeah, I expect that the\nfunction would return false.\n"},{"id":"185228","messageId":"20120223002215.GE2410@tgrennan-laptop","threadId":"29583","inReplyTo":"7vhayjbcna.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 3/5] tag --exclude option","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-23T00:22:15Z","receivedAt":"2012-02-23T00:22:15Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Tue, Feb 21, 2012 at 10:33:29PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> Example,\n>>   $ git tag -l --exclude \"*-rc?\" \"v1.7.8*\"\n>>   v1.7.8\n>>   v1.7.8.1\n>>   v1.7.8.2\n>>   v1.7.8.3\n>>   v1.7.8.4\n>>\n>> Which is equivalent to,\n>>   $ git tag -l \"v1.7.8*\" | grep -v \\\\-rc.\n>>   v1.7.8\n>>   v1.7.8.1\n>>   v1.7.8.2\n>>   v1.7.8.3\n>>   v1.7.8.4\n>>\n>> Signed-off-by: Tom Grennan <tmgrennan@gmail.com>\n>\n>Having an example is a good way to illustrate your explanation, but it is\n>not a substitution.  Could we have at least one real sentence to describe\n>what the added option *does*?\n>\n>This comment applies to all the patches in this series except for the\n>second patch.\n>\n\nOK, I'll add the \"exclude\" option description from the respective man pages.\n\n>> diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt\n>> index 8d32b9a..470bd80 100644\n>> --- a/Documentation/git-tag.txt\n>> +++ b/Documentation/git-tag.txt\n>> @@ -13,7 +13,7 @@ SYNOPSIS\n>>  \t<tagname> [<commit> | <object>]\n>>  'git tag' -d <tagname>...\n>>  'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]\n>> -\t[<pattern>...]\n>> +\t[--exclude <pattern>] [<pattern>...]\n>>  'git tag' -v <tagname>...\n>>  \n>>  DESCRIPTION\n>> @@ -90,6 +90,10 @@ OPTIONS\n>>  --points-at <object>::\n>>  \tOnly list tags of the given object.\n>>  \n>> +--exclude <pattern>::\n>> +\tDon't list tags matching the given pattern.  This has precedence\n>> +\tover any other match pattern arguments.\n>\n>As you do not specify what kind of pattern matching is done to this\n>exclude pattern, it is important to use the same logic between positive\n>and negative ones to give users a consistent UI.  Unfortunately we use\n>fnmatch without FNM_PATHNAME for positive ones, so this exclude pattern\n>needs to follow the same semantics to reduce confusion.\n>\n>This comment applies to all the patches in this series to add this option\n>to existing commands that take the positive pattern.\n\nOK, should I also describe the --no-exclude option?\n\n>> @@ -202,6 +206,15 @@ test_expect_success \\\n>>  '\n>>  \n>>  cat >expect <<EOF\n>> +v0.2.1\n>> +EOF\n>> +test_expect_success \\\n>> +\t'listing tags with a suffix as pattern and prefix exclusion' '\n>> +\tgit tag -l --exclude \"v1.*\" \"*.1\" > actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>\n>I know you are imitating the style of surrounding tests that is an older\n>parts of this script, but it is an eyesore.  More modern tests are written\n>like this:\n>\n>\ttest_expect_success 'label for the test' '\n>\t\tcat >expect <<-EOF &&\n>                v0.2.1\n>\t\tEOF\n>\t        git tag -l ... >actual &&\n>\t\ttest_cmp expect actual\n>\t'\n>\n>to avoid unnecessary backslash on the first line, and have the preparation\n>of test vectore _inside_ test_expect_success.  We would eventually want to\n>update the older part to the newer style for consistency.\n>\n>Two possible ways to go about this are (1) have a \"pure style\" patch at\n>the beginning to update older tests to a new style and then add new code\n>and new test as a follow-up patch written in modern, or (2) add new code\n>and new test in modern, and make a mental note to update the older ones\n>after the dust settles.  Adding new tests written in older style to a file\n>that already has mixed styles is the worst thing you can do.\n>\n>This comment applies to all the patches in this series with tests.\n\nI'd prefer, (1) precede each \"--exclude\" patch with a \"pure style\" patch\nto update the respective tests.  However, since this will result in a\nlot of conflict with concurrent development;  I'll separate the test\npatches from the code and documentation.  I'll then cycle on rebasing\nthe style and new test patches until the development of each is\nquiescent.\n\nThanks,\nTomG\n"},{"id":"185231","messageId":"20120223005932.GF2410@tgrennan-laptop","threadId":"29583","inReplyTo":"7v62ey8ktp.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv3 1/5] refs: add match_pattern()","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-02-23T00:59:32Z","receivedAt":"2012-02-23T00:59:32Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Wed, Feb 22, 2012 at 04:17:22PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> Yes, I tried to minimize change but the conversion of argv's to\n>> string_list's won't add that much.\n>\n>How about _not_ using string_list?  After all, string_list is not just a\n>collection of strings, but is a table to hold strings with attributes.  I\n>thought argv_array is more appropriate abstraction for the purpose of your\n>patch.\n\nOK, It looks like I should also add a common parse_opt_argv_array() to\nparse-options-cb.  Of course that would be in a separate, dependent\npatch.\n\n>>>\tref_match_pattern(\"refs/heads/master\",\n>>>        \t\t  [\"maste?\", NULL],\n>>>                          [\"refs/heads/\", NULL],\n>>>                          (REF_MATCH_FNM_PATH|REF_MATCH_LEADING));\n>>>\n>>>Note that the above \"ref_match_pattern()\" gives the same \"flags\" for the\n>>>call to match_one() for elements in both positive and negative array and\n>>>it is very deliberate.  See review comment to [3/5] for the reasoning.\n>>\n>> OK, I think that I understand, but please confirm, you'd expect no output in\n>> the above example, right?\n>\n>\"maste?\" would match with FNM_PATHNAME with \"refs/heads/master\" but\n>the negative \"refs/heads/\" matches with it, so yeah, I expect that the\n>function would return false.\n\nthanks, that's a good test case.\n\n-- \nTomG\n"},{"id":"185232","messageId":"7vty2i749v.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"20120223002215.GE2410@tgrennan-laptop","subject":"Re: [PATCHv3 3/5] tag --exclude option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-23T01:00:12Z","receivedAt":"2012-02-23T01:00:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> On Tue, Feb 21, 2012 at 10:33:29PM -0800, Junio C Hamano wrote:\n>\n>>As you do not specify what kind of pattern matching is done to this\n>>exclude pattern, it is important to use the same logic between positive\n>>and negative ones to give users a consistent UI.  Unfortunately we use\n>>fnmatch without FNM_PATHNAME for positive ones, so this exclude pattern\n>>needs to follow the same semantics to reduce confusion.\n>>\n>>This comment applies to all the patches in this series to add this option\n>>to existing commands that take the positive pattern.\n>\n> OK, should I also describe the --no-exclude option?\n\nIf you support it, yes.  What does it do?\n\n--no-exclude::\n\tCancels all the `--exclude` options given so far on the command line.\n\nperhaps?\n"},{"id":"185762","messageId":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"20120223002215.GE2410@tgrennan-laptop","subject":"[PATCH 0/5] modernize test style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:16Z","receivedAt":"2012-03-01T01:45:16Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n>On Tue, Feb 21, 2012 at 10:33:29PM -0800, Junio C Hamano wrote:\n>>I know you are imitating the style of surrounding tests that is an older\n>>parts of this script, but it is an eyesore.  More modern tests are written\n>>like this:\n>>\n>>\ttest_expect_success 'label for the test' '\n>>\t\tcat >expect <<-EOF &&\n>>                v0.2.1\n>>\t\tEOF\n>>\t        git tag -l ... >actual &&\n>>\t\ttest_cmp expect actual\n>>\t'\n>>\n>>to avoid unnecessary backslash on the first line, and have the preparation\n>>of test vectore _inside_ test_expect_success.  We would eventually want to\n>>update the older part to the newer style for consistency.\n>>\n>>Two possible ways to go about this are (1) have a \"pure style\" patch at\n>>the beginning to update older tests to a new style and then add new code\n>>and new test as a follow-up patch written in modern, or (2) add new code\n>>and new test in modern, and make a mental note to update the older ones\n>>after the dust settles.  Adding new tests written in older style to a file\n>>that already has mixed styles is the worst thing you can do.\n>>\n>>This comment applies to all the patches in this series with tests.\n>\n>I'd prefer, (1) precede each \"--exclude\" patch with a \"pure style\" patch\n>to update the respective tests.  However, since this will result in a\n>lot of conflict with concurrent development;  I'll separate the test\n>patches from the code and documentation.  I'll then cycle on rebasing\n>the style and new test patches until the development of each is\n>quiescent.\n\nPer request, the following series modernize the style of the respective\ntest scripts.  The common themes are:\n\t- Guard setup with test_expect_success\n\t- Single-quoted, tab prefaced test blocks of < 80 cols\n\t- Redirect unwanted output\n\t- Use a \"here\" filter for some expect generation\n\nI also used pipelines to validate expected results rather than temporary\nfiles, i.e.\n\tTEST | test_cmp expect -\nvs.\tTEST >actual && test_cmp expect actual\n\nSince the later three patches have a lot of whitespace change, I've included an\nalternate, PATCH-w series that filters these for more substantive review.\nHowever, even the filtered series is very large causing me to second guess\nwhether such style modernization should be pursued; so, I look forward to your\ninput.\n\nThanks,\nTom Grennan (5):\n  t6300 (for-each-ref): modernize style\n  t5512 (ls-remote): modernize style\n  t3200 (branch): modernize style\n  t0040 (parse-options): modernize style\n  t7004 (tag): modernize style\n\n t/t7004-tag.sh | 1680 ++++++++++++++++++++++++++------------------------------\n 1 files changed, 783 insertions(+), 897 deletions(-)\n\n-- \n1.7.8\n"},{"id":"185763","messageId":"1330566326-26075-2-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH 1/5] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:17Z","receivedAt":"2012-03-01T01:45:17Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t6300-for-each-ref.sh |  364 +++++++++++++++++++++++++----------------------\n 1 files changed, 191 insertions(+), 173 deletions(-)\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 1721784..12916b2 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -5,9 +5,17 @@\n \n test_description='for-each-ref test'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-gpg.sh\n \n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+\n # Mon Jul 3 15:18:43 2006 +0000\n datestamp=1151939923\n setdate_and_increment () {\n@@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '\n \tsetdate_and_increment &&\n \techo \"Using $datestamp\" > one &&\n \tgit add one &&\n-\tgit commit -m \"Initial\" &&\n+\tgit commit -q -m \"Initial\" &&\n \tsetdate_and_increment &&\n-\tgit tag -a -m \"Tagging at $datestamp\" testtag\n+\tquiet git tag -a -m \"Tagging at $datestamp\" testtag\n '\n \n test_expect_success 'Create upstream config' '\n@@ -115,261 +123,270 @@ test_atom tag contents 'Tagging at 1151939927\n '\n \n test_expect_success 'Check invalid atoms names are errors' '\n-\ttest_must_fail git for-each-ref --format=\"%(INVALID)\" refs/heads\n+\tsilent test_must_fail git for-each-ref --format=\"%(INVALID)\" refs/heads\n '\n \n test_expect_success 'Check format specifiers are ignored in naming date atoms' '\n-\tgit for-each-ref --format=\"%(authordate)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:default) %(authordate)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate) %(authordate:default)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:default) %(authordate:default)\" refs/heads\n+\tf1=\"%(authordate)\" &&\n+\tf2=\"%(authordate:default) %(authordate)\" &&\n+\tf3=\"%(authordate) %(authordate:default)\" &&\n+\tf4=\"%(authordate:default) %(authordate:default)\"\n+\tquiet git for-each-ref --format=\"$f1\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f2\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f3\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f4\" refs/heads\n '\n \n test_expect_success 'Check valid format specifiers for date fields' '\n-\tgit for-each-ref --format=\"%(authordate:default)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:relative)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:short)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:local)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:iso8601)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:rfc2822)\" refs/heads\n+\tquiet git for-each-ref --format=\"%(authordate:default)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:relative)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:short)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:local)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:iso8601)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:rfc2822)\" refs/heads\n '\n \n test_expect_success 'Check invalid format specifiers are errors' '\n-\ttest_must_fail git for-each-ref --format=\"%(authordate:INVALID)\" refs/heads\n+\th=\"%(authordate:INVALID)\" &&\n+\tsilent test_must_fail git for-each-ref --format=\"$h\" refs/heads\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n-'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n-EOF\n-\n test_expect_success 'Check unformatted date fields output' '\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate) %(authordate)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF &&\n+\t\t'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n+\t\t'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n+\tEOF\n+\t\"'\n+\th=\"%(refname) %(committerdate) %(authordate)\" &&\n+\tt=\"%(refname) %(taggerdate)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Check format \"default\" formatted date fields output' '\n-\tf=default &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\th=\"%(refname) %(committerdate:default) %(authordate:default)\" &&\n+\tt=\"%(refname) %(taggerdate:default)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-# Don't know how to do relative check because I can't know when this script\n-# is going to be run and can't fake the current time to git, and hence can't\n-# provide expected output.  Instead, I'll just make sure that \"relative\"\n-# doesn't exit in error\n-#\n-#cat >expected <<\\EOF\n-#\n-#EOF\n-#\n test_expect_success 'Check format \"relative\" date fields output' '\n-\tf=relative &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual\n+\t'\"\n+\t# Don't know how to do relative check because I can't know when this\n+\t# script is going to be run and can't fake the current time to git,\n+\t# and hence can't provide expected output.  Instead, I'll just make\n+\t# sure that 'relative' doesn't exit in error\n+\t\"'\n+\th=\"%(refname) %(committerdate:relative) %(authordate:relative)\" &&\n+\tt=\"%(refname) %(taggerdate:relative)\" &&\n+\tquiet git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\tquiet git for-each-ref --shell --format=\"$t\" refs/tags\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' '2006-07-03' '2006-07-03'\n-'refs/tags/testtag' '2006-07-03'\n-EOF\n-\n test_expect_success 'Check format \"short\" date fields output' '\n-\tf=short &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF\n+\t\t'refs/heads/master' '2006-07-03' '2006-07-03'\n+\t\t'refs/tags/testtag' '2006-07-03'\n+\tEOF\n+\t\"'\n+\th=\"%(refname) %(committerdate:short) %(authordate:short)\" &&\n+\tt=\"%(refname) %(taggerdate:short)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n-'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n-EOF\n-\n test_expect_success 'Check format \"local\" date fields output' '\n-\tf=local &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF\n+\t\t'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n+\t\t'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n+\tEOF\n+\t\"'\n+\th=\"%(refname) %(committerdate:local) %(authordate:local)\" &&\n+\tt=\"%(refname) %(taggerdate:local)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n-'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n-EOF\n-\n test_expect_success 'Check format \"iso8601\" date fields output' '\n-\tf=iso8601 &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF\n+\t\t'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n+\t\t'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n+\tEOF\n+\t\"'\n+\th=\"%(refname) %(committerdate:iso8601) %(authordate:iso8601)\" &&\n+\tt=\"%(refname) %(taggerdate:iso8601)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n-'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n-EOF\n-\n test_expect_success 'Check format \"rfc2822\" date fields output' '\n-\tf=rfc2822 &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF\n+\t\t'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n+\t\t'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n+\tEOF\n+\t\"'\n+\th=\"%(refname) %(committerdate:rfc2822) %(authordate:rfc2822)\" &&\n+\tt=\"%(refname) %(taggerdate:rfc2822)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-refs/heads/master\n-refs/remotes/origin/master\n-refs/tags/testtag\n-EOF\n-\n test_expect_success 'Verify ascending sort' '\n-\tgit for-each-ref --format=\"%(refname)\" --sort=refname >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\trefs/heads/master\n+\t\trefs/remotes/origin/master\n+\t\trefs/tags/testtag\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --sort=refname |\n+\t\ttest_cmp expect -\n '\n \n-\n-cat >expected <<\\EOF\n-refs/tags/testtag\n-refs/remotes/origin/master\n-refs/heads/master\n-EOF\n-\n test_expect_success 'Verify descending sort' '\n-\tgit for-each-ref --format=\"%(refname)\" --sort=-refname >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\trefs/tags/testtag\n+\t\trefs/remotes/origin/master\n+\t\trefs/heads/master\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname)\" --sort=-refname |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master'\n-'refs/remotes/origin/master'\n-'refs/tags/testtag'\n-EOF\n-\n test_expect_success 'Quoting style: shell' '\n-\tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\t'\"\n+\tcat >expect <<-EOF\n+\t\t'refs/heads/master'\n+\t\t'refs/remotes/origin/master'\n+\t\t'refs/tags/testtag'\n+\tEOF\n+\t\"'\n+\tgit for-each-ref --shell --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Quoting style: perl' '\n-\tgit for-each-ref --perl --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --perl --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Quoting style: python' '\n-\tgit for-each-ref --python --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --python --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-\"refs/heads/master\"\n-\"refs/remotes/origin/master\"\n-\"refs/tags/testtag\"\n-EOF\n-\n test_expect_success 'Quoting style: tcl' '\n-\tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\t\"refs/heads/master\"\n+\t\t\"refs/remotes/origin/master\"\n+\t\t\"refs/tags/testtag\"\n+\tEOF\n+\tgit for-each-ref --tcl --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n-for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n-\ttest_expect_success \"more than one quoting style: $i\" \"\n-\t\tgit for-each-ref $i 2>&1 | (read line &&\n-\t\tcase \\$line in\n-\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n-\t\t*) false\n-\t\tesac)\n-\t\"\n-done\n-\n-cat >expected <<\\EOF\n-master\n-testtag\n-EOF\n-\n+test_expect_success 'more than one quoting styles' '\n+\tcat >expect <<-EOF\n+\t\terror: more than one quoting style?\n+\tEOF\n+\tgit for-each-ref --perl --shell 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref -s --python 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref --python --tcl 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref --tcl --perl 2>&1 | head -n 1 |\n+\t\ttest_cmp expect -\n+'\n test_expect_success 'Check short refname format' '\n-\t(git for-each-ref --format=\"%(refname:short)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(refname:short)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\tmaster\n+\t\ttesttag\n+\tEOF\n+\tgit for-each-ref --format=\"%(refname:short)\" refs/heads refs/tags |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<EOF\n-origin/master\n-EOF\n-\n test_expect_success 'Check short upstream format' '\n-\tgit for-each-ref --format=\"%(upstream:short)\" refs/heads >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\torigin/master\n+\tEOF\n+\tgit for-each-ref --format=\"%(upstream:short)\" refs/heads |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<EOF\n-67a36f1\n-EOF\n-\n test_expect_success 'Check short objectname format' '\n-\tgit for-each-ref --format=\"%(objectname:short)\" refs/heads >actual &&\n-\ttest_cmp expected actual\n+\tcat >expect <<-EOF\n+\t\t67a36f1\n+\tEOF\n+\tgit for-each-ref --format=\"%(objectname:short)\" refs/heads |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Check for invalid refname format' '\n-\ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n+\tsilent test_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n \n-cat >expected <<\\EOF\n-heads/master\n-tags/master\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs (strict)' '\n+\tcat >expect <<-EOF\n+\t\theads/master\n+\t\ttags/master\n+\tEOF\n \tgit config --bool core.warnambiguousrefs true &&\n-\tgit checkout -b newtag &&\n+\tgit checkout -q -b newtag &&\n \techo \"Using $datestamp\" > one &&\n \tgit add one &&\n-\tgit commit -m \"Branch\" &&\n+\tgit commit -q -m \"Branch\" &&\n \tsetdate_and_increment &&\n-\tgit tag -m \"Tagging at $datestamp\" master &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n-\ttest_cmp expected actual\n+\tquiet git tag -m \"Tagging at $datestamp\" master &&\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/master refs/tags/master |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-heads/master\n-master\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs (loose)' '\n+\tcat >expect <<-EOF\n+\t\theads/master\n+\t\tmaster\n+\tEOF\n \tgit config --bool core.warnambiguousrefs false &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n-\ttest_cmp expected actual\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/master refs/tags/master |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n-heads/ambiguous\n-ambiguous\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n-\tgit checkout master &&\n+\tcat >expect <<-EOF\n+\t\theads/ambiguous\n+\t\tambiguous\n+\tEOF\n+\tgit checkout -q master &&\n \tgit tag ambiguous testtag^0 &&\n \tgit branch ambiguous testtag^0 &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/ambiguous refs/tags/ambiguous >actual &&\n-\ttest_cmp expected actual\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/ambiguous refs/tags/ambiguous |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'an unusual tag with an incomplete line' '\n-\n \tgit tag -m \"bogo\" bogo &&\n \tbogo=$(git cat-file tag bogo) &&\n \tbogo=$(printf \"%s\" \"$bogo\" | git mktag) &&\n \tgit tag -f bogo \"$bogo\" &&\n \tgit for-each-ref --format \"%(body)\" refs/tags/bogo\n-\n '\n \n test_expect_success 'create tag with subject and body content' '\n-\tcat >>msg <<-\\EOF &&\n+\tcat >msg <<-\\EOF &&\n \t\tthe subject line\n \n \t\tfirst body line\n@@ -395,8 +412,9 @@ test_expect_success 'create tag with multiline subject' '\n \t\tfirst body line\n \t\tsecond body line\n \tEOF\n-\tgit tag -F msg multiline\n+\tquiet git tag -F msg multiline\n '\n+\n test_atom refs/tags/multiline subject 'first subject line second subject line'\n test_atom refs/tags/multiline contents:subject 'first subject line second subject line'\n test_atom refs/tags/multiline body 'first body line\n@@ -417,9 +435,9 @@ test_expect_success GPG 'create signed tags' '\n \tgit tag -s -m \"\" signed-empty &&\n \tgit tag -s -m \"subject line\" signed-short &&\n \tcat >msg <<-\\EOF &&\n-\tsubject line\n+\t\tsubject line\n \n-\tbody contents\n+\t\tbody contents\n \tEOF\n \tgit tag -s -F msg signed-long\n '\n-- \n1.7.8\n"},{"id":"185769","messageId":"1330566326-26075-3-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH 2/5] t5512 (ls-remote): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:18Z","receivedAt":"2012-03-01T01:45:18Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t5512-ls-remote.sh |   33 ++++++++++++++++++++++-----------\n 1 files changed, 22 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 5c546c9..bbe650f 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -2,14 +2,22 @@\n \n test_description='git ls-remote'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n \n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+\n test_expect_success setup '\n \n \t>file &&\n \tgit add file &&\n \ttest_tick &&\n-\tgit commit -m initial &&\n+\tgit commit -q -m initial &&\n \tgit tag mark &&\n \tgit show-ref --tags -d | sed -e \"s/ /\t/\" >expected.tag &&\n \t(\n@@ -51,7 +59,7 @@ test_expect_success 'ls-remote self' '\n \n test_expect_success 'dies when no remote specified and no default remotes found' '\n \n-\ttest_must_fail git ls-remote\n+\tsilent test_must_fail git ls-remote\n \n '\n \n@@ -70,8 +78,8 @@ test_expect_success 'use \"origin\" when no remote specified' '\n \n test_expect_success 'suppress \"From <url>\" with -q' '\n \n-\tgit ls-remote -q 2>actual_err &&\n-\ttest_must_fail test_cmp exp_err actual_err\n+\tquiet git ls-remote -q 2>actual_err &&\n+\ttest_must_fail cmp -s exp_err actual_err\n \n '\n \n@@ -83,7 +91,7 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \t#\n \n \t# setup a new remote to differentiate from \"origin\"\n-\tgit clone . other.git &&\n+\tgit clone -q . other.git &&\n \t(\n \t\tcd other.git &&\n \t\techo \"$(git rev-parse HEAD)\tHEAD\"\n@@ -102,11 +110,13 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \n '\n \n-cat >exp <<EOF\n-fatal: 'refs*master' does not appear to be a git repository\n-fatal: The remote end hung up unexpectedly\n-EOF\n test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t'\"\n+\tcat >exp <<-EOF\n+\t\tfatal: 'refs*master' does not appear to be a git repository\n+\t\tfatal: The remote end hung up unexpectedly\n+\tEOF\n+\t\"'\n \t#\n \t# Do not expect \"git ls-remote <pattern>\" to work; ls-remote, correctly,\n \t# confuses <pattern> for <remote>. Although ugly, this behaviour is akin\n@@ -124,7 +134,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' '\n '\n \n test_expect_success 'die with non-2 for wrong repository even with --exit-code' '\n-\tgit ls-remote --exit-code ./no-such-repository ;# not &&\n+\tsilent git ls-remote --exit-code ./no-such-repository ;# not &&\n \tstatus=$? &&\n \ttest $status != 2 && test $status != 0\n '\n@@ -136,7 +146,8 @@ test_expect_success 'Report success even when nothing matches' '\n '\n \n test_expect_success 'Report no-match with --exit-code' '\n-\ttest_expect_code 2 git ls-remote --exit-code other.git \"refs/nsn/*\" >actual &&\n+\ttest_expect_code 2 git ls-remote --exit-code other.git \"refs/nsn/*\" \\\n+\t\t>actual &&\n \t>expect &&\n \ttest_cmp expect actual\n '\n-- \n1.7.8\n"},{"id":"185766","messageId":"1330566326-26075-4-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH 3/5] t3200 (branch): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:19Z","receivedAt":"2012-03-01T01:45:19Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n- Use a \"here\" filter for expect generation\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t3200-branch.sh |  593 +++++++++++++++++++++++++++--------------------------\n 1 files changed, 304 insertions(+), 289 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd1aceb..93c35cd 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -5,125 +5,132 @@\n \n test_description='git branch assorted tests'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n \n-test_expect_success \\\n-    'prepare a trivial repository' \\\n-    'echo Hello > A &&\n-     git update-index --add A &&\n-     git commit -m \"Initial commit.\" &&\n-     echo World >> A &&\n-     git update-index --add A &&\n-     git commit -m \"Second commit.\" &&\n-     HEAD=$(git rev-parse --verify HEAD)'\n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+here () { sed 's/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g' $@; }\n+\n+test_expect_success 'prepare a trivial repository' '\n+\techo Hello >A &&\n+\tgit update-index --add A &&\n+\tgit commit -q -m \"Initial commit.\" &&\n+\techo World >>A &&\n+\tgit update-index --add A &&\n+\tgit commit -q -m \"Second commit.\" &&\n+\tHEAD=$(git rev-parse --verify HEAD)\n+'\n \n-test_expect_success \\\n-    'git branch --help should not have created a bogus branch' '\n-     test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&\n-     test_path_is_missing .git/refs/heads/--help\n+test_expect_success 'git branch --help should not have created a bogus branch' '\n+\tsilent test_might_fail git branch --help </dev/null &&\n+\ttest_path_is_missing .git/refs/heads/--help\n '\n \n test_expect_success 'branch -h in broken repository' '\n-\tmkdir broken &&\n-\t(\n-\t\tcd broken &&\n-\t\tgit init &&\n-\t\t>.git/refs/heads/master &&\n-\t\ttest_expect_code 129 git branch -h >usage 2>&1\n-\t) &&\n-\tgrep \"[Uu]sage\" broken/usage\n-'\n-\n-test_expect_success \\\n-    'git branch abc should create a branch' \\\n-    'git branch abc && test_path_is_file .git/refs/heads/abc'\n-\n-test_expect_success \\\n-    'git branch a/b/c should create a branch' \\\n-    'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'\n-\n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-EOF\n-test_expect_success \\\n-    'git branch -l d/e/f should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git branch -l d/e/f &&\n-\t test_path_is_file .git/refs/heads/d/e/f &&\n-\t test_path_is_file .git/logs/refs/heads/d/e/f &&\n-\t test_cmp expect .git/logs/refs/heads/d/e/f'\n-\n-test_expect_success \\\n-    'git branch -d d/e/f should delete a branch and a log' \\\n-\t'git branch -d d/e/f &&\n-\t test_path_is_missing .git/refs/heads/d/e/f &&\n-\t test_path_is_missing .git/logs/refs/heads/d/e/f'\n-\n-test_expect_success \\\n-    'git branch j/k should work after branch j has been deleted' \\\n-       'git branch j &&\n-        git branch -d j &&\n-        git branch j/k'\n-\n-test_expect_success \\\n-    'git branch l should work after branch l/m has been deleted' \\\n-       'git branch l/m &&\n-        git branch -d l/m &&\n-        git branch l'\n-\n-test_expect_success \\\n-    'git branch -m dumps usage' \\\n-       'test_expect_code 129 git branch -m 2>err &&\n-\tgrep \"[Uu]sage: git branch\" err'\n-\n-test_expect_success \\\n-    'git branch -m m m/m should work' \\\n-       'git branch -l m &&\n-        git branch -m m m/m &&\n-\ttest_path_is_file .git/logs/refs/heads/m/m'\n-\n-test_expect_success \\\n-    'git branch -m n/n n should work' \\\n-       'git branch -l n/n &&\n+\tgit init -q broken &&\n+\ttest_when_finished rm -rf broken usage &&\n+\t>broken/.git/refs/heads/master &&\n+\t>usage 2>&1 test_expect_code 129 git --git-dir=broken/.git branch -h &&\n+\tgrep -q \"[Uu]sage\" usage\n+'\n+\n+test_expect_success 'git branch abc should create a branch' '\n+\tgit branch abc && test_path_is_file .git/refs/heads/abc\n+'\n+\n+test_expect_success 'git branch a/b/c should create a branch' '\n+\tgit branch a/b/c && test_path_is_file .git/refs/heads/a/b/c\n+'\n+\n+test_expect_success 'git branch -l d/e/f should create a branch and a log' '\n+\tid=\"$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\"\n+\tdate=\"1117150200 +0000\"\n+\tmsg=\"branch: Created from master\"\n+\there >expect <<-EOF\n+\t\t$_z40 $HEAD $id $date\\t$msg\n+\tEOF\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" git branch -l d/e/f &&\n+\ttest_path_is_file .git/refs/heads/d/e/f &&\n+\ttest_path_is_file .git/logs/refs/heads/d/e/f &&\n+\ttest_cmp expect .git/logs/refs/heads/d/e/f\n+'\n+\n+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '\n+\tquiet git branch -d d/e/f &&\n+\ttest_path_is_missing .git/refs/heads/d/e/f &&\n+\ttest_path_is_missing .git/logs/refs/heads/d/e/f\n+'\n+\n+test_expect_success 'git branch j/k should work after branch j has been deleted' '\n+\tgit branch j &&\n+\tquiet git branch -d j &&\n+\tgit branch j/k\n+'\n+\n+test_expect_success 'git branch l should work after branch l/m has been deleted' '\n+\tgit branch l/m &&\n+\tquiet git branch -d l/m &&\n+\tgit branch l\n+'\n+\n+test_expect_success 'git branch -m dumps usage' '\n+\ttest_expect_code 129 git branch -m 2>err &&\n+\tgrep -q \"[Uu]sage: git branch\" err\n+'\n+\n+test_expect_success 'git branch -m m m/m should work' '\n+\tgit branch -l m &&\n+\tgit branch -m m m/m &&\n+\ttest_path_is_file .git/logs/refs/heads/m/m\n+'\n+\n+test_expect_success 'git branch -m n/n n should work' '\n+\tgit branch -l n/n &&\n \tgit branch -m n/n n &&\n-\ttest_path_is_file .git/logs/refs/heads/n'\n+\ttest_path_is_file .git/logs/refs/heads/n\n+'\n \n test_expect_success 'git branch -m o/o o should fail when o/p exists' '\n \tgit branch o/o &&\n-        git branch o/p &&\n-\ttest_must_fail git branch -m o/o o\n+\tgit branch o/p &&\n+\tsilent test_must_fail git branch -m o/o o\n '\n \n test_expect_success 'git branch -m q r/q should fail when r exists' '\n \tgit branch q &&\n \tgit branch r &&\n-\ttest_must_fail git branch -m q r/q\n+\tsilent test_must_fail git branch -m q r/q\n '\n \n test_expect_success 'git branch -M foo bar should fail when bar is checked out' '\n \tgit branch bar &&\n-\tgit checkout -b foo &&\n-\ttest_must_fail git branch -M bar foo\n+\tgit checkout -q -b foo &&\n+\tsilent test_must_fail git branch -M bar foo\n '\n \n test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '\n-\tgit checkout -b baz &&\n+\tgit checkout -q -b baz &&\n \tgit branch bam &&\n \tgit branch -M baz bam\n '\n \n test_expect_success 'git branch -M master should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch -M master\n '\n \n test_expect_success 'git branch -M master master should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch -M master master\n '\n \n test_expect_success 'git branch -M master2 master2 should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch master2 &&\n \tgit branch -M master2 master2\n '\n@@ -131,7 +138,7 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch\n test_expect_success 'git branch -v -d t should work' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\tgit branch -v -d t &&\n+\tquiet git branch -v -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n@@ -141,188 +148,198 @@ test_expect_success 'git branch -v -m t s should work' '\n \tgit branch -v -m t s &&\n \ttest_path_is_missing .git/refs/heads/t &&\n \ttest_path_is_file .git/refs/heads/s &&\n-\tgit branch -d s\n+\tquiet git branch -d s\n '\n \n test_expect_success 'git branch -m -d t s should fail' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\ttest_must_fail git branch -m -d t s &&\n-\tgit branch -d t &&\n+\tsilent test_must_fail git branch -m -d t s &&\n+\tquiet git branch -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n test_expect_success 'git branch --list -d t should fail' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\ttest_must_fail git branch --list -d t &&\n-\tgit branch -d t &&\n+\tsilent test_must_fail git branch --list -d t &&\n+\tquiet git branch -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n-mv .git/config .git/config-saved\n-\n test_expect_success 'git branch -m q q2 without config should succeed' '\n+\tmv .git/config .git/config-saved &&\n+\ttest_when_finished mv .git/config-saved .git/config &&\n \tgit branch -m q q2 &&\n \tgit branch -m q2 q\n '\n \n-mv .git/config-saved .git/config\n-\n-git config branch.s/s.dummy Hello\n-\n-test_expect_success \\\n-    'git branch -m s/s s should work when s/t is deleted' \\\n-       'git branch -l s/s &&\n+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '\n+\tgit config branch.s/s.dummy Hello\n+\tgit branch -l s/s &&\n \ttest_path_is_file .git/logs/refs/heads/s/s &&\n-        git branch -l s/t &&\n+\tgit branch -l s/t &&\n \ttest_path_is_file .git/logs/refs/heads/s/t &&\n-        git branch -d s/t &&\n-        git branch -m s/s s &&\n-\ttest_path_is_file .git/logs/refs/heads/s'\n-\n-test_expect_success 'config information was renamed, too' \\\n-\t\"test $(git config branch.s.dummy) = Hello &&\n-\t test_must_fail git config branch.s/s/dummy\"\n+\tquiet git branch -d s/t &&\n+\tgit branch -m s/s s &&\n+\ttest_path_is_file .git/logs/refs/heads/s\n+'\n \n-test_expect_success 'renaming a symref is not allowed' \\\n+test_expect_success 'config information was renamed, too' '\n+\ttest $(git config branch.s.dummy) = Hello &&\n+\tsilent test_must_fail git config branch.s/s/dummy\n '\n+\n+test_expect_success 'renaming a symref is not allowed' '\n \tgit symbolic-ref refs/heads/master2 refs/heads/master &&\n-\ttest_must_fail git branch -m master2 master3 &&\n-\tgit symbolic-ref refs/heads/master2 &&\n+\tsilent test_must_fail git branch -m master2 master3 &&\n+\tquiet git symbolic-ref refs/heads/master2 &&\n \ttest_path_is_file .git/refs/heads/master &&\n \ttest_path_is_missing .git/refs/heads/master3\n '\n \n-test_expect_success SYMLINKS \\\n-    'git branch -m u v should fail when the reflog for u is a symlink' '\n-     git branch -l u &&\n-     mv .git/logs/refs/heads/u real-u &&\n-     ln -s real-u .git/logs/refs/heads/u &&\n-     test_must_fail git branch -m u v\n-'\n-\n-test_expect_success 'test tracking setup via --track' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my1 local/master &&\n-     test $(git config branch.my1.remote) = local &&\n-     test $(git config branch.my1.merge) = refs/heads/master'\n-\n-test_expect_success 'test tracking setup (non-wildcard, matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my4 local/master &&\n-     test $(git config branch.my4.remote) = local &&\n-     test $(git config branch.my4.merge) = refs/heads/master'\n-\n-test_expect_success 'test tracking setup (non-wildcard, not matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my5 local/master &&\n-     ! test \"$(git config branch.my5.remote)\" = local &&\n-     ! test \"$(git config branch.my5.merge)\" = refs/heads/master'\n-\n-test_expect_success 'test tracking setup via config' \\\n-    'git config branch.autosetupmerge true &&\n-     git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch my3 local/master &&\n-     test $(git config branch.my3.remote) = local &&\n-     test $(git config branch.my3.merge) = refs/heads/master'\n-\n-test_expect_success 'test overriding tracking setup via --no-track' \\\n-    'git config branch.autosetupmerge true &&\n-     git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --no-track my2 local/master &&\n-     git config branch.autosetupmerge false &&\n-     ! test \"$(git config branch.my2.remote)\" = local &&\n-     ! test \"$(git config branch.my2.merge)\" = refs/heads/master'\n-\n-test_expect_success 'no tracking without .fetch entries' \\\n-    'git config branch.autosetupmerge true &&\n-     git branch my6 s &&\n-     git config branch.automsetupmerge false &&\n-     test -z \"$(git config branch.my6.remote)\" &&\n-     test -z \"$(git config branch.my6.merge)\"'\n-\n-test_expect_success 'test tracking setup via --track but deeper' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n-     git branch --track my7 local/o/o &&\n-     test \"$(git config branch.my7.remote)\" = local &&\n-     test \"$(git config branch.my7.merge)\" = refs/heads/o/o'\n-\n-test_expect_success 'test deleting branch deletes branch config' \\\n-    'git branch -d my7 &&\n-     test -z \"$(git config branch.my7.remote)\" &&\n-     test -z \"$(git config branch.my7.merge)\"'\n-\n-test_expect_success 'test deleting branch without config' \\\n-    'git branch my7 s &&\n-     sha1=$(git rev-parse my7 | cut -c 1-7) &&\n-     echo \"Deleted branch my7 (was $sha1).\" >expect &&\n-     git branch -d my7 >actual 2>&1 &&\n-     test_i18ncmp expect actual'\n-\n-test_expect_success 'test --track without .fetch entries' \\\n-    'git branch --track my8 &&\n-     test \"$(git config branch.my8.remote)\" &&\n-     test \"$(git config branch.my8.merge)\"'\n-\n-test_expect_success \\\n-    'branch from non-branch HEAD w/autosetupmerge=always' \\\n-    'git config branch.autosetupmerge always &&\n-     git branch my9 HEAD^ &&\n-     git config branch.autosetupmerge false'\n-\n-test_expect_success \\\n-    'branch from non-branch HEAD w/--track causes failure' \\\n-    'test_must_fail git branch --track my10 HEAD^'\n-\n-test_expect_success \\\n-    'branch from tag w/--track causes failure' \\\n-    'git tag foobar &&\n-     test_must_fail git branch --track my11 foobar'\n+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '\n+\tgit branch -l u &&\n+\tmv .git/logs/refs/heads/u real-u &&\n+\tln -s real-u .git/logs/refs/heads/u &&\n+\tsilent test_must_fail git branch -m u v\n+'\n+\n+test_expect_success 'test tracking setup via --track' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track my1 local/master &&\n+\ttest $(git config branch.my1.remote) = local &&\n+\ttest $(git config branch.my1.merge) = refs/heads/master\n+'\n+\n+test_expect_success 'test tracking setup (non-wildcard, matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch \\\n+\t\trefs/heads/master:refs/remotes/local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tquiet git branch --track my4 local/master &&\n+\ttest $(git config branch.my4.remote) = local &&\n+\ttest $(git config branch.my4.merge) = refs/heads/master\n+'\n+\n+test_expect_success 'test tracking setup (non-wildcard, not matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tquiet git branch --track my5 local/master &&\n+\t! test \"$(git config branch.my5.remote)\" = local &&\n+\t! test \"$(git config branch.my5.merge)\" = refs/heads/master\n+'\n+\n+test_expect_success 'test tracking setup via config' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tquiet git branch my3 local/master &&\n+\ttest $(git config branch.my3.remote) = local &&\n+\ttest $(git config branch.my3.merge) = refs/heads/master\n+'\n+\n+test_expect_success 'test overriding tracking setup via --no-track' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch --no-track my2 local/master &&\n+\tgit config branch.autosetupmerge false &&\n+\t! test \"$(git config branch.my2.remote)\" = local &&\n+\t! test \"$(git config branch.my2.merge)\" = refs/heads/master\n+'\n+\n+test_expect_success 'no tracking without .fetch entries' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit branch my6 s &&\n+\tgit config branch.automsetupmerge false &&\n+\ttest -z \"$(git config branch.my6.remote)\" &&\n+\ttest -z \"$(git config branch.my6.merge)\"\n+'\n+\n+test_expect_success 'test tracking setup via --track but deeper' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n+\tquiet git branch --track my7 local/o/o &&\n+\ttest \"$(git config branch.my7.remote)\" = local &&\n+\ttest \"$(git config branch.my7.merge)\" = refs/heads/o/o\n+'\n+\n+test_expect_success 'test deleting branch deletes branch config' '\n+\tquiet git branch -d my7 &&\n+\ttest -z \"$(git config branch.my7.remote)\" &&\n+\ttest -z \"$(git config branch.my7.merge)\"\n+'\n+\n+test_expect_success 'test deleting branch without config' '\n+\tgit branch my7 s &&\n+\tsha1=$(git rev-parse my7 | cut -c 1-7) &&\n+\techo \"Deleted branch my7 (was $sha1).\" >expect &&\n+\tgit branch -d my7 >actual 2>&1 &&\n+\ttest_i18ncmp expect actual\n+'\n+\n+test_expect_success 'test --track without .fetch entries' '\n+\tquiet git branch --track my8 &&\n+\ttest \"$(git config branch.my8.remote)\" &&\n+\ttest \"$(git config branch.my8.merge)\"\n+'\n+\n+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '\n+\tgit config branch.autosetupmerge always &&\n+\tgit branch my9 HEAD^ &&\n+\tgit config branch.autosetupmerge false\n+'\n+\n+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '\n+\tsilent test_must_fail git branch --track my10 HEAD^\n+'\n+\n+test_expect_success 'branch from tag w/--track causes failure' '\n+\tgit tag foobar &&\n+\tsilent test_must_fail git branch --track my11 foobar\n+'\n \n # Keep this test last, as it changes the current branch\n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-EOF\n-test_expect_success \\\n-    'git checkout -b g/h/i -l should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git checkout -b g/h/i -l master &&\n-\t test_path_is_file .git/refs/heads/g/h/i &&\n-\t test_path_is_file .git/logs/refs/heads/g/h/i &&\n-\t test_cmp expect .git/logs/refs/heads/g/h/i'\n+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '\n+\tid=\"$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\"\n+\tdate=\"1117150200 +0000\"\n+\tmsg=\"branch: Created from master\"\n+\there >expect <<-EOF\n+\t\t$_z40 $HEAD $id $date\\t$msg\n+\tEOF\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\t\tgit checkout -q -b g/h/i -l master &&\n+\ttest_path_is_file .git/refs/heads/g/h/i &&\n+\ttest_path_is_file .git/logs/refs/heads/g/h/i &&\n+\ttest_cmp expect .git/logs/refs/heads/g/h/i\n+'\n \n test_expect_success 'checkout -b makes reflog by default' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit config --unset core.logAllRefUpdates &&\n-\tgit checkout -b alpha &&\n-\tgit rev-parse --verify alpha@{0}\n+\tgit checkout -q -b alpha &&\n+\tquiet git rev-parse --verify alpha@{0}\n '\n \n test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit config core.logAllRefUpdates false &&\n-\tgit checkout -b beta &&\n-\ttest_must_fail git rev-parse --verify beta@{0}\n+\tgit checkout -q -b beta &&\n+\tsilent test_must_fail git rev-parse --verify beta@{0}\n '\n \n test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '\n-\tgit checkout master &&\n-\tgit checkout -lb gamma &&\n+\tgit checkout -q master &&\n+\tgit checkout -q -lb gamma &&\n \tgit config --unset core.logAllRefUpdates &&\n-\tgit rev-parse --verify gamma@{0}\n+\tquiet git rev-parse --verify gamma@{0}\n '\n \n test_expect_success 'avoid ambiguous track' '\n@@ -331,7 +348,7 @@ test_expect_success 'avoid ambiguous track' '\n \tgit config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&\n \tgit config remote.ambi2.url lilili &&\n \tgit config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&\n-\tgit branch all1 master &&\n+\tsilent git branch all1 master &&\n \ttest -z \"$(git config branch.all1.merge)\"\n '\n \n@@ -339,9 +356,9 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase local &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase &&\n-\tgit branch --track myr1 mybase &&\n+\tquiet git branch --track myr1 mybase &&\n \ttest \"$(git config branch.myr1.remote)\" = . &&\n \ttest \"$(git config branch.myr1.merge)\" = refs/heads/mybase &&\n \ttest \"$(git config branch.myr1.rebase)\" = true\n@@ -351,9 +368,9 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase always &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase2 &&\n-\tgit branch --track myr2 mybase &&\n+\tquiet git branch --track myr2 mybase &&\n \ttest \"$(git config branch.myr2.remote)\" = . &&\n \ttest \"$(git config branch.myr2.merge)\" = refs/heads/mybase &&\n \ttest \"$(git config branch.myr2.rebase)\" = true\n@@ -363,9 +380,9 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase3 &&\n-\tgit branch --track myr3 mybase2 &&\n+\tquiet git branch --track myr3 mybase2 &&\n \ttest \"$(git config branch.myr3.remote)\" = . &&\n \ttest \"$(git config branch.myr3.merge)\" = refs/heads/mybase2 &&\n \t! test \"$(git config branch.myr3.rebase)\" = true\n@@ -375,9 +392,9 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase never &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase4 &&\n-\tgit branch --track myr4 mybase2 &&\n+\tquiet git branch --track myr4 mybase2 &&\n \ttest \"$(git config branch.myr4.remote)\" = . &&\n \ttest \"$(git config branch.myr4.merge)\" = refs/heads/mybase2 &&\n \t! test \"$(git config branch.myr4.rebase)\" = true\n@@ -387,8 +404,8 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase local &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr5 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr5 local/master &&\n \ttest \"$(git config branch.myr5.remote)\" = local &&\n \ttest \"$(git config branch.myr5.merge)\" = refs/heads/master &&\n \t! test \"$(git config branch.myr5.rebase)\" = true\n@@ -398,8 +415,8 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase never &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr6 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr6 local/master &&\n \ttest \"$(git config branch.myr6.remote)\" = local &&\n \ttest \"$(git config branch.myr6.merge)\" = refs/heads/master &&\n \t! test \"$(git config branch.myr6.rebase)\" = true\n@@ -409,8 +426,8 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr7 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr7 local/master &&\n \ttest \"$(git config branch.myr7.remote)\" = local &&\n \ttest \"$(git config branch.myr7.merge)\" = refs/heads/master &&\n \ttest \"$(git config branch.myr7.rebase)\" = true\n@@ -420,8 +437,8 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr8 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr8 local/master &&\n \ttest \"$(git config branch.myr8.remote)\" = local &&\n \ttest \"$(git config branch.myr8.merge)\" = refs/heads/master &&\n \ttest \"$(git config branch.myr8.rebase)\" = true\n@@ -431,8 +448,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '\n \tgit config --unset branch.autosetuprebase &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr9 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr9 local/master &&\n \ttest \"$(git config branch.myr9.remote)\" = local &&\n \ttest \"$(git config branch.myr9.merge)\" = refs/heads/master &&\n \ttest \"z$(git config branch.myr9.rebase)\" = z\n@@ -441,9 +458,9 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '\n test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase10 &&\n-\tgit branch --track myr10 mybase2 &&\n+\tquiet git branch --track myr10 mybase2 &&\n \ttest \"$(git config branch.myr10.remote)\" = . &&\n \ttest \"$(git config branch.myr10.merge)\" = refs/heads/mybase2 &&\n \ttest \"z$(git config branch.myr10.rebase)\" = z\n@@ -452,8 +469,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '\n test_expect_success 'autosetuprebase unconfigured on untracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr11 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr11 mybase2 &&\n \ttest \"z$(git config branch.myr11.remote)\" = z &&\n \ttest \"z$(git config branch.myr11.merge)\" = z &&\n \ttest \"z$(git config branch.myr11.rebase)\" = z\n@@ -462,8 +479,8 @@ test_expect_success 'autosetuprebase unconfigured on untracked local branch' '\n test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr12 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr12 local/master &&\n \ttest \"z$(git config branch.myr12.remote)\" = z &&\n \ttest \"z$(git config branch.myr12.merge)\" = z &&\n \ttest \"z$(git config branch.myr12.rebase)\" = z\n@@ -473,8 +490,8 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '\n \tgit config branch.autosetuprebase never &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr13 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr13 mybase2 &&\n \ttest \"z$(git config branch.myr13.remote)\" = z &&\n \ttest \"z$(git config branch.myr13.merge)\" = z &&\n \ttest \"z$(git config branch.myr13.rebase)\" = z\n@@ -484,8 +501,8 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '\n \tgit config branch.autosetuprebase local &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr14 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr14 mybase2 &&\n \ttest \"z$(git config branch.myr14.remote)\" = z &&\n \ttest \"z$(git config branch.myr14.merge)\" = z &&\n \ttest \"z$(git config branch.myr14.rebase)\" = z\n@@ -495,8 +512,8 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '\n \tgit config branch.autosetuprebase remote &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr15 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr15 mybase2 &&\n \ttest \"z$(git config branch.myr15.remote)\" = z &&\n \ttest \"z$(git config branch.myr15.merge)\" = z &&\n \ttest \"z$(git config branch.myr15.rebase)\" = z\n@@ -506,8 +523,8 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '\n \tgit config branch.autosetuprebase always &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr16 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr16 mybase2 &&\n \ttest \"z$(git config branch.myr16.remote)\" = z &&\n \ttest \"z$(git config branch.myr16.merge)\" = z &&\n \ttest \"z$(git config branch.myr16.rebase)\" = z\n@@ -517,8 +534,8 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '\n \tgit config branch.autosetuprebase never &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr17 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr17 local/master &&\n \ttest \"z$(git config branch.myr17.remote)\" = z &&\n \ttest \"z$(git config branch.myr17.merge)\" = z &&\n \ttest \"z$(git config branch.myr17.rebase)\" = z\n@@ -528,8 +545,8 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '\n \tgit config branch.autosetuprebase local &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr18 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr18 local/master &&\n \ttest \"z$(git config branch.myr18.remote)\" = z &&\n \ttest \"z$(git config branch.myr18.merge)\" = z &&\n \ttest \"z$(git config branch.myr18.rebase)\" = z\n@@ -539,8 +556,8 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '\n \tgit config branch.autosetuprebase remote &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr19 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr19 local/master &&\n \ttest \"z$(git config branch.myr19.remote)\" = z &&\n \ttest \"z$(git config branch.myr19.merge)\" = z &&\n \ttest \"z$(git config branch.myr19.rebase)\" = z\n@@ -550,8 +567,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '\n \tgit config branch.autosetuprebase always &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr20 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr20 local/master &&\n \ttest \"z$(git config branch.myr20.remote)\" = z &&\n \ttest \"z$(git config branch.myr20.merge)\" = z &&\n \ttest \"z$(git config branch.myr20.rebase)\" = z\n@@ -559,8 +576,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '\n \n test_expect_success 'autosetuprebase always on detached HEAD' '\n \tgit config branch.autosetupmerge always &&\n-\ttest_when_finished git checkout master &&\n-\tgit checkout HEAD^0 &&\n+\ttest_when_finished git checkout -q master &&\n+\tgit checkout -q HEAD^0 &&\n \tgit branch my11 &&\n \ttest -z \"$(git config branch.my11.remote)\" &&\n \ttest -z \"$(git config branch.my11.merge)\"\n@@ -568,20 +585,20 @@ test_expect_success 'autosetuprebase always on detached HEAD' '\n \n test_expect_success 'detect misconfigured autosetuprebase (bad value)' '\n \tgit config branch.autosetuprebase garbage &&\n-\ttest_must_fail git branch\n+\tsilent test_must_fail git branch\n '\n \n test_expect_success 'detect misconfigured autosetuprebase (no value)' '\n \tgit config --unset branch.autosetuprebase &&\n \techo \"[branch] autosetuprebase\" >> .git/config &&\n-\ttest_must_fail git branch &&\n+\tsilent test_must_fail git branch &&\n \tgit config --unset branch.autosetuprebase\n '\n \n test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '\n-\tgit checkout my9 &&\n+\tgit checkout -q my9 &&\n \tgit config --unset branch.my8.merge &&\n-\ttest_must_fail git branch -d my8\n+\tsilent test_must_fail git branch -d my8\n '\n \n test_expect_success 'attempt to delete a branch merged to its base' '\n@@ -589,32 +606,30 @@ test_expect_success 'attempt to delete a branch merged to its base' '\n \t# we would not have allowed deleting my8 that is not merged\n \t# to my9, but it is set to track master that already has my8\n \tgit config branch.my8.merge refs/heads/master &&\n-\tgit branch -d my8\n+\tsilent git branch -d my8\n '\n \n test_expect_success 'attempt to delete a branch merged to its base' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \techo Third >>A &&\n-\tgit commit -m \"Third commit\" A &&\n-\tgit branch -t my10 my9 &&\n-\tgit branch -f my10 HEAD^ &&\n+\tgit commit -q -m \"Third commit\" A &&\n+\tquiet git branch -t my10 my9 &&\n+\tquiet git branch -f my10 HEAD^ &&\n \t# we are on master which is at the third commit, and my10\n \t# is behind us, so traditionally we would have allowed deleting\n \t# it; but my10 is set to track my9 that is further behind.\n-\ttest_must_fail git branch -d my10\n+\tsilent test_must_fail git branch -d my10\n '\n \n test_expect_success 'use set-upstream on the current branch' '\n-\tgit checkout master &&\n-\tgit --bare init myupstream.git &&\n-\tgit push myupstream.git master:refs/heads/frotz &&\n+\tgit checkout -q master &&\n+\tgit --bare init -q myupstream.git &&\n+\tgit push -q myupstream.git master:refs/heads/frotz &&\n \tgit remote add origin myupstream.git &&\n-\tgit fetch &&\n-\tgit branch --set-upstream master origin/frotz &&\n-\n+\tgit fetch -q &&\n+\tquiet git branch --set-upstream master origin/frotz &&\n \ttest \"z$(git config branch.master.remote)\" = \"zorigin\" &&\n \ttest \"z$(git config branch.master.merge)\" = \"zrefs/heads/frotz\"\n-\n '\n \n test_expect_success 'use --edit-description' '\n@@ -637,7 +652,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '\n \t(\n \t\tEDITOR=./editor &&\n \t\texport EDITOR &&\n-\t\ttest_must_fail git branch --edit-description no-such-branch\n+\t\tsilent test_must_fail git branch --edit-description no-such-branch\n \t)\n '\n \n@@ -645,11 +660,11 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '\n \twrite_script editor <<-\\EOF &&\n \t\techo \"New contents\" >\"$1\"\n \tEOF\n-\tgit checkout --orphan unborn &&\n+\tgit checkout -q --orphan unborn &&\n \t(\n \t\tEDITOR=./editor &&\n \t\texport EDITOR &&\n-\t\ttest_must_fail git branch --edit-description\n+\t\tsilent test_must_fail git branch --edit-description\n \t)\n '\n \n-- \n1.7.8\n"},{"id":"185770","messageId":"1330566326-26075-5-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH 4/5] t0040 (parse-options): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:20Z","receivedAt":"2012-03-01T01:45:20Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t0040-parse-options.sh |  519 ++++++++++++++++++++++------------------------\n 1 files changed, 245 insertions(+), 274 deletions(-)\n\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex a1e4616..6416d77 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -5,353 +5,324 @@\n \n test_description='our own option parser'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n \n-cat > expect << EOF\n-usage: test-parse-options <options>\n-\n-    -b, --boolean         get a boolean\n-    -4, --or4             bitwise-or boolean with ...0100\n-    --neg-or4             same as --no-or4\n-\n-    -i, --integer <n>     get a integer\n-    -j <n>                get a integer, too\n-    --set23               set integer to 23\n-    -t <time>             get timestamp of <time>\n-    -L, --length <str>    get length of <str>\n-    -F, --file <file>     set file to <file>\n-\n-String options\n-    -s, --string <string>\n-                          get a string\n-    --string2 <str>       get another string\n-    --st <st>             get another string (pervert ordering)\n-    -o <str>              get another string\n-    --default-string      set string to default\n-    --list <str>          add str to list\n-\n-Magic arguments\n-    --quux                means --quux\n-    -NUM                  set integer to NUM\n-    +                     same as -b\n-    --ambiguous           positive ambiguity\n-    --no-ambiguous        negative ambiguity\n-\n-Standard options\n-    --abbrev[=<n>]        use <n> digits to display SHA-1s\n-    -v, --verbose         be verbose\n-    -n, --dry-run         dry run\n-    -q, --quiet           be quiet\n-\n-EOF\n+silent () { \"$@\" >/dev/null 2>&1; }\n \n test_expect_success 'test help' '\n-\ttest_must_fail test-parse-options -h > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tsed -e \"s/^|//\" >expect <<-\\EOF &&\n+\t\t|usage: test-parse-options <options>\n+\n+\t\t|    -b, --boolean         get a boolean\n+\t\t|    -4, --or4             bitwise-or boolean with ...0100\n+\t\t|    --neg-or4             same as --no-or4\n+\n+\t\t|    -i, --integer <n>     get a integer\n+\t\t|    -j <n>                get a integer, too\n+\t\t|    --set23               set integer to 23\n+\t\t|    -t <time>             get timestamp of <time>\n+\t\t|    -L, --length <str>    get length of <str>\n+\t\t|    -F, --file <file>     set file to <file>\n+\n+\t\t|String options\n+\t\t|    -s, --string <string>\n+\t\t|                          get a string\n+\t\t|    --string2 <str>       get another string\n+\t\t|    --st <st>             get another string (pervert ordering)\n+\t\t|    -o <str>              get another string\n+\t\t|    --default-string      set string to default\n+\t\t|    --list <str>          add str to list\n+\n+\t\t|Magic arguments\n+\t\t|    --quux                means --quux\n+\t\t|    -NUM                  set integer to NUM\n+\t\t|    +                     same as -b\n+\t\t|    --ambiguous           positive ambiguity\n+\t\t|    --no-ambiguous        negative ambiguity\n+\n+\t\t|Standard options\n+\t\t|    --abbrev[=<n>]        use <n> digits to display SHA-1s\n+\t\t|    -v, --verbose         be verbose\n+\t\t|    -n, --dry-run         dry run\n+\t\t|    -q, --quiet           be quiet\n+\n+\tEOF\n+\tcp expect expect.err\n+\ttest_must_fail test-parse-options -h 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-mv expect expect.err\n-\n-cat > expect << EOF\n-boolean: 2\n-integer: 1729\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 2\n-quiet: no\n-dry run: yes\n-file: prefix/my.file\n-EOF\n-\n test_expect_success 'short options' '\n-\ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \\\n-\t> output 2> output.err &&\n-\ttest_cmp expect output &&\n-\ttest ! -s output.err\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 2\n+\t\tinteger: 1729\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 2\n+\t\tquiet: no\n+\t\tdry run: yes\n+\t\tfile: prefix/my.file\n+\tEOF\n+\ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect << EOF\n-boolean: 2\n-integer: 1729\n-timestamp: 0\n-string: 321\n-abbrev: 10\n-verbose: 2\n-quiet: no\n-dry run: no\n-file: prefix/fi.le\n-EOF\n-\n test_expect_success 'long options' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 2\n+\t\tinteger: 1729\n+\t\ttimestamp: 0\n+\t\tstring: 321\n+\t\tabbrev: 10\n+\t\tverbose: 2\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: prefix/fi.le\n+\tEOF\n \ttest-parse-options --boolean --integer 1729 --boolean --string2=321 \\\n-\t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\\\n-\t\t--obsolete > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le \\\n+\t\t--obsolete 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'missing required value' '\n-\ttest-parse-options -s;\n-\ttest $? = 129 &&\n-\ttest-parse-options --string;\n-\ttest $? = 129 &&\n-\ttest-parse-options --file;\n-\ttest $? = 129\n+\tsilent test_expect_code 129 test-parse-options -s &&\n+\tsilent test_expect_code 129 test-parse-options --string &&\n+\tsilent test_expect_code 129 test-parse-options --file\n '\n \n-cat > expect << EOF\n-boolean: 1\n-integer: 13\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-arg 00: a1\n-arg 01: b1\n-arg 02: --boolean\n-EOF\n-\n test_expect_success 'intermingled arguments' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 1\n+\t\tinteger: 13\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: a1\n+\t\targ 01: b1\n+\t\targ 02: --boolean\n+\tEOF\n \ttest-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \\\n-\t\t> output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\t\t2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect << EOF\n-boolean: 0\n-integer: 2\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'unambiguously abbreviated option' '\n-\ttest-parse-options --int 2 --boolean --no-bo > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 2\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --int 2 --boolean --no-bo 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'unambiguously abbreviated option with \"=\"' '\n-\ttest-parse-options --int=2 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --int=2 2>err | test_cmp expect -&&\n+\ttest ! -s err\n '\n \n test_expect_success 'ambiguously abbreviated option' '\n-\ttest-parse-options --strin 123;\n-\ttest $? = 129\n+\tsilent test_expect_code 129 test-parse-options --strin 123\n '\n \n-cat > expect << EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n-\ttest-parse-options --st 123 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --st 123 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > typo.err << EOF\n-error: did you mean \\`--boolean\\` (with two dashes ?)\n-EOF\n-\n test_expect_success 'detect possible typos' '\n-\ttest_must_fail test-parse-options -boolean > output 2> output.err &&\n-\ttest ! -s output &&\n-\ttest_cmp typo.err output.err\n+\tcat >typo.err <<-\\EOF &&\n+\t\terror: did you mean `--boolean` (with two dashes ?)\n+\tEOF\n+\t>expect\n+\ttest_must_fail test-parse-options -boolean 2>err | test_cmp expect - &&\n+\ttest_cmp typo.err err\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-arg 00: --quux\n-EOF\n-\n test_expect_success 'keep some options as arguments' '\n-\ttest-parse-options --quux > output 2> output.err &&\n-        test ! -s output.err &&\n-        test_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: --quux\n+\tEOF\n+\ttest-parse-options --quux 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 1\n-string: default\n-abbrev: 7\n-verbose: 0\n-quiet: yes\n-dry run: no\n-file: (not set)\n-arg 00: foo\n-EOF\n-\n test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n-\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" --default-string \\\n-\t\tfoo -q > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 1\n+\t\tstring: default\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: yes\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: foo\n+\tEOF\n+\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" \\\n+\t\t--default-string foo -q 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n-Callback: \"four\", 0\n-boolean: 5\n-integer: 4\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n-\ttest-parse-options --length=four -b -4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tCallback: \"four\", 0\n+\t\tboolean: 5\n+\t\tinteger: 4\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --length=four -b -4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n-Callback: \"not set\", 1\n-EOF\n-\n test_expect_success 'OPT_CALLBACK() and callback errors work' '\n-\ttest_must_fail test-parse-options --no-length > output 2> output.err &&\n-\ttest_cmp expect output &&\n-\ttest_cmp expect.err output.err\n+\tcat >expect <<-\\EOF &&\n+\t\tCallback: \"not set\", 1\n+\tEOF\n+\ttest_must_fail test-parse-options --no-length 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest_cmp expect.err err\n '\n \n-cat > expect <<EOF\n-boolean: 1\n-integer: 23\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 1\n+\t\tinteger: 23\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --set23 -bbbbb --no-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --set23 -bbbbb --neg-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n-boolean: 6\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_BIT() works' '\n-\ttest-parse-options -bb --or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 6\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options -bb --or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_NEGBIT() works' '\n-\ttest-parse-options -bb --no-neg-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options -bb --no-neg-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '\n-\ttest-parse-options + + + + + + > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options + + + + + + 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 12345\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n \n test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n-\ttest-parse-options -12345 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 12345\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options -12345 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat >expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n-\ttest-parse-options --no-ambig >output 2>output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --no-ambig 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat >>expect <<'EOF'\n-list: foo\n-list: bar\n-list: baz\n-EOF\n test_expect_success '--list keeps list of strings' '\n-\ttest-parse-options --list foo --list=bar --list=baz >output &&\n-\ttest_cmp expect output\n+\tcat >>expect <<-\\EOF &&\n+\t\tlist: foo\n+\t\tlist: bar\n+\t\tlist: baz\n+\tEOF\n+\ttest-parse-options --list foo --list=bar --list=baz | test_cmp expect -\n '\n \n test_expect_success '--no-list resets list' '\n-\ttest-parse-options --list=other --list=irrelevant --list=options \\\n-\t\t--no-list --list=foo --list=bar --list=baz >output &&\n-\ttest_cmp expect output\n+\ttest-parse-options --list=other --list=irrelevant \\\n+\t\t--list=options --no-list --list=foo --list=bar --list=baz |\n+\t\ttest_cmp expect -\n '\n \n test_done\n-- \n1.7.8\n"},{"id":"185772","messageId":"1330566326-26075-6-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH 5/5] t7004 (tag): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:21Z","receivedAt":"2012-03-01T01:45:21Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n- Use a \"here\" filter for expect generation\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t7004-tag.sh | 1680 ++++++++++++++++++++++++++------------------------------\n 1 files changed, 783 insertions(+), 897 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f8c247a..6704046 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -7,15 +7,37 @@ test_description='git tag\n \n Tests for operations with tags.'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-gpg.sh\n \n-# creating and listing lightweight tags:\n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+here () { sed 's/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g' $@; }\n \n tag_exists () {\n \tgit show-ref --quiet --verify refs/tags/\"$1\"\n }\n \n+gen_header () { # name, object, type, time\n+\tcat <<-EOF &&\n+\t\tobject $2\n+\t\ttype $3\n+\t\ttag $1\n+\t\ttagger C O Mitter <committer@example.com> $4 -0700\n+\n+\tEOF\n+\there\n+}\n+\n+get_header () {\n+\tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n+}\n+\n # todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success 'listing all tags in an empty tree should succeed' '\n \tgit tag -l &&\n@@ -27,36 +49,38 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '\n \ttest `git tag | wc -l` -eq 0\n '\n \n-test_expect_success 'looking for a tag in an empty tree should fail' \\\n-\t'! (tag_exists mytag)'\n+test_expect_success 'looking for a tag in an empty tree should fail' '\n+\t! tag_exists mytag\n+'\n \n test_expect_success 'creating a tag in an empty tree should fail' '\n-\ttest_must_fail git tag mynotag &&\n+\tsilent test_must_fail git tag mynotag &&\n \t! tag_exists mynotag\n '\n \n test_expect_success 'creating a tag for HEAD in an empty tree should fail' '\n-\ttest_must_fail git tag mytaghead HEAD &&\n+\tsilent test_must_fail git tag mytaghead HEAD &&\n \t! tag_exists mytaghead\n '\n \n test_expect_success 'creating a tag for an unknown revision should fail' '\n-\ttest_must_fail git tag mytagnorev aaaaaaaaaaa &&\n+\tsilent test_must_fail git tag mytagnorev aaaaaaaaaaa &&\n \t! tag_exists mytagnorev\n '\n \n-# commit used in the tests, test_tick is also called here to freeze the date:\n test_expect_success 'creating a tag using default HEAD should succeed' '\n+\t# commit used in the tests\n+\t# test_tick is also called here to freeze the date:\n \ttest_tick &&\n-\techo foo >foo &&\n+\techo >foo foo &&\n \tgit add foo &&\n-\tgit commit -m Foo &&\n+\tgit commit -q -m Foo &&\n \tgit tag mytag\n '\n \n test_expect_success 'listing all tags if one exists should succeed' '\n-\tgit tag -l &&\n-\tgit tag\n+\tquiet git tag -l &&\n+\tquiet git tag\n '\n \n test_expect_success 'listing all tags if one exists should output that tag' '\n@@ -66,36 +90,36 @@ test_expect_success 'listing all tags if one exists should output that tag' '\n \n # pattern matching:\n \n-test_expect_success 'listing a tag using a matching pattern should succeed' \\\n-\t'git tag -l mytag'\n+test_expect_success 'listing a tag using a matching pattern should succeed' '\n+\tquiet git tag -l mytag\n+'\n \n-test_expect_success \\\n-\t'listing a tag using a matching pattern should output that tag' \\\n-\t'test `git tag -l mytag` = mytag'\n+test_expect_success 'listing a tag using a matching pattern should output that tag' '\n+\ttest `git tag -l mytag` = mytag\n+'\n \n # todo: git tag -l now returns always zero, when fixed, change this test\n-test_expect_success \\\n-\t'listing tags using a non-matching pattern should suceed' \\\n-\t'git tag -l xxx'\n+test_expect_success 'listing tags using a non-matching pattern should suceed' '\n+\tgit tag -l xxx\n+'\n \n-test_expect_success \\\n-\t'listing tags using a non-matching pattern should output nothing' \\\n-\t'test `git tag -l xxx | wc -l` -eq 0'\n+test_expect_success 'listing tags using a non-matching pattern should output nothing' '\n+\ttest `git tag -l xxx | wc -l` -eq 0\n+'\n \n # special cases for creating tags:\n \n-test_expect_success \\\n-\t'trying to create a tag with the name of one existing should fail' \\\n-\t'test_must_fail git tag mytag'\n+test_expect_success 'trying to create a tag with the name of one existing should fail' '\n+\tsilent test_must_fail git tag mytag\n+'\n \n-test_expect_success \\\n-\t'trying to create a tag with a non-valid name should fail' '\n+test_expect_success 'trying to create a tag with a non-valid name should fail' '\n \ttest `git tag -l | wc -l` -eq 1 &&\n-\ttest_must_fail git tag \"\" &&\n-\ttest_must_fail git tag .othertag &&\n-\ttest_must_fail git tag \"other tag\" &&\n-\ttest_must_fail git tag \"othertag^\" &&\n-\ttest_must_fail git tag \"other~tag\" &&\n+\tsilent test_must_fail git tag \"\" &&\n+\tsilent test_must_fail git tag .othertag &&\n+\tsilent test_must_fail git tag \"other tag\" &&\n+\tsilent test_must_fail git tag \"othertag^\" &&\n+\tsilent test_must_fail git tag \"other~tag\" &&\n \ttest `git tag -l | wc -l` -eq 1\n '\n \n@@ -108,62 +132,59 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '\n \n test_expect_success 'trying to delete an unknown tag should fail' '\n \t! tag_exists unknown-tag &&\n-\ttest_must_fail git tag -d unknown-tag\n+\tsilent test_must_fail git tag -d unknown-tag\n '\n \n-cat >expect <<EOF\n-myhead\n-mytag\n-EOF\n-test_expect_success \\\n-\t'trying to delete tags without params should succeed and do nothing' '\n-\tgit tag -l > actual && test_cmp expect actual &&\n+test_expect_success 'trying to delete tags without params should succeed and do nothing' '\n+\tcat >expect <<-EOF &&\n+\t\tmyhead\n+\t\tmytag\n+\tEOF\n+\tgit tag -l | test_cmp expect - &&\n \tgit tag -d &&\n-\tgit tag -l > actual && test_cmp expect actual\n+\tgit tag -l | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'deleting two existing tags in one command should succeed' '\n+test_expect_success 'deleting two existing tags in one command should succeed' '\n \ttag_exists mytag &&\n \ttag_exists myhead &&\n-\tgit tag -d mytag myhead &&\n+\tquiet git tag -d mytag myhead &&\n \t! tag_exists mytag &&\n \t! tag_exists myhead\n '\n \n-test_expect_success \\\n-\t'creating a tag with the name of another deleted one should succeed' '\n+test_expect_success 'creating a tag with the name of another deleted one should succeed' '\n \t! tag_exists mytag &&\n \tgit tag mytag &&\n \ttag_exists mytag\n '\n \n-test_expect_success \\\n-\t'trying to delete two tags, existing and not, should fail in the 2nd' '\n+test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' '\n \ttag_exists mytag &&\n \t! tag_exists myhead &&\n-\ttest_must_fail git tag -d mytag anothertag &&\n+\tsilent test_must_fail git tag -d mytag anothertag &&\n \t! tag_exists mytag &&\n \t! tag_exists myhead\n '\n \n-test_expect_success 'trying to delete an already deleted tag should fail' \\\n-\t'test_must_fail git tag -d mytag'\n+test_expect_success 'trying to delete an already deleted tag should fail' '\n+\tsilent test_must_fail git tag -d mytag\n+'\n \n # listing various tags with pattern matching:\n \n-cat >expect <<EOF\n-a1\n-aa1\n-cba\n-t210\n-t211\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-EOF\n test_expect_success 'listing all tags should print them ordered' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\t\taa1\n+\t\tcba\n+\t\tt210\n+\t\tt211\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n \tgit tag v1.0.1 &&\n \tgit tag t211 &&\n \tgit tag aa1 &&\n@@ -173,561 +194,486 @@ test_expect_success 'listing all tags should print them ordered' '\n \tgit tag a1 &&\n \tgit tag v1.0 &&\n \tgit tag t210 &&\n-\tgit tag -l > actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l | test_cmp expect - &&\n+\tgit tag | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-a1\n-aa1\n-cba\n-EOF\n-test_expect_success \\\n-\t'listing tags with substring as pattern must print those matching' '\n-\trm *a* &&\n-\tgit tag -l \"*a*\" > current &&\n-\ttest_cmp expect current\n-'\n-\n-cat >expect <<EOF\n-v0.2.1\n-v1.0.1\n-EOF\n-test_expect_success \\\n-\t'listing tags with a suffix as pattern must print those matching' '\n-\tgit tag -l \"*.1\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags with substring as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\t\taa1\n+\t\tcba\n+\tEOF\n+\tgit tag -l \"*a*\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-t210\n-t211\n-EOF\n-test_expect_success \\\n-\t'listing tags with a prefix as pattern must print those matching' '\n-\tgit tag -l \"t21*\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags with a suffix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0.1\n+\tEOF\n+\tgit tag -l \"*.1\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-a1\n-EOF\n-test_expect_success \\\n-\t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l a1 > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags with a prefix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n+\t\tt210\n+\t\tt211\n+\tEOF\n+\tgit tag -l \"t21*\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-v1.0\n-EOF\n-test_expect_success \\\n-\t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l v1.0 > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\tEOF\n+\tgit tag -l a1 | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-v1.0.1\n-v1.1.3\n-EOF\n-test_expect_success \\\n-\t'listing tags with ? in the pattern should print those matching' '\n-\tgit tag -l \"v1.?.?\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n+\t\tv1.0\n+\tEOF\n+\tgit tag -l v1.0 | test_cmp expect -\n '\n \n->expect\n-test_expect_success \\\n-\t'listing tags using v.* should print nothing because none have v.' '\n-\tgit tag -l \"v.*\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags with ? in the pattern should print those matching' '\n+\tcat >expect <<-EOF &&\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n+\tgit tag -l \"v1.?.?\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-EOF\n-test_expect_success \\\n-\t'listing tags using v* should print only those having v' '\n-\tgit tag -l \"v*\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags using v.* should print nothing because none have v.' '\n+\t>expect &&\n+\tgit tag -l \"v.*\" | test_cmp expect -\n+'\n+\n+test_expect_success 'listing tags using v* should print only those having v' '\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n+\tgit tag -l \"v*\" | test_cmp expect -\n '\n \n test_expect_success 'tag -l can accept multiple patterns' '\n-\tgit tag -l \"v1*\" \"v0*\" >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"v1*\" \"v0*\" | test_cmp expect -\n '\n \n # creating and verifying lightweight tags:\n \n-test_expect_success \\\n-\t'a non-annotated tag created without parameters should point to HEAD' '\n+test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '\n \tgit tag non-annotated-tag &&\n \ttest $(git cat-file -t non-annotated-tag) = commit &&\n \ttest $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)\n '\n \n-test_expect_success 'trying to verify an unknown tag should fail' \\\n-\t'test_must_fail git tag -v unknown-tag'\n+test_expect_success 'trying to verify an unknown tag should fail' '\n+\tsilent test_must_fail git tag -v unknown-tag\n+'\n \n-test_expect_success \\\n-\t'trying to verify a non-annotated and non-signed tag should fail' \\\n-\t'test_must_fail git tag -v non-annotated-tag'\n+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' '\n+\tsilent test_must_fail git tag -v non-annotated-tag\n+'\n \n-test_expect_success \\\n-\t'trying to verify many non-annotated or unknown tags, should fail' \\\n-\t'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'\n+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' '\n+\tsilent test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2\n+'\n \n # creating annotated tags:\n \n-get_tag_msg () {\n-\tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n-}\n-\n-# run test_tick before committing always gives the time in that timezone\n-get_tag_header () {\n-cat <<EOF\n-object $2\n-type $3\n-tag $1\n-tagger C O Mitter <committer@example.com> $4 -0700\n-\n-EOF\n-}\n-\n-commit=$(git rev-parse HEAD)\n-time=$test_tick\n-\n-get_tag_header annotated-tag $commit commit $time >expect\n-echo \"A message\" >>expect\n-test_expect_success \\\n-\t'creating an annotated tag with -m message should succeed' '\n-\tgit tag -m \"A message\" annotated-tag &&\n-\tget_tag_msg annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating an annotated tag with -m message should succeed' '\n+\tcommit=$(git rev-parse HEAD) &&\n+\ttime=$test_tick &&\n+\tname=\"annotated-tag\" &&\n+\tmsg=\"A message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n+\tEOF\n+\tgit tag -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >msgfile <<EOF\n-Another message\n-in a file.\n-EOF\n-get_tag_header file-annotated-tag $commit commit $time >expect\n-cat msgfile >>expect\n-test_expect_success \\\n-\t'creating an annotated tag with -F messagefile should succeed' '\n-\tgit tag -F msgfile file-annotated-tag &&\n-\tget_tag_msg file-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating an annotated tag with -F messagefile should succeed' '\n+\tname=\"file-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tAnother message\n+\t\tin a file.\n+\tEOF\n+\ttail -n 2 expect >msgfile &&\n+\tgit tag -F msgfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >inputmsg <<EOF\n-A message from the\n-standard input\n-EOF\n-get_tag_header stdin-annotated-tag $commit commit $time >expect\n-cat inputmsg >>expect\n test_expect_success 'creating an annotated tag with -F - should succeed' '\n-\tgit tag -F - stdin-annotated-tag <inputmsg &&\n-\tget_tag_msg stdin-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\tname=\"stdin-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA message from the\n+\t\tstandard input\n+\tEOF\n+\ttail -n 2 expect | git tag -F - $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'trying to create a tag with a non-existing -F file should fail' '\n+test_expect_success 'trying to create a tag with a non-existing -F file should fail' '\n \t! test -f nonexistingfile &&\n \t! tag_exists notag &&\n-\ttest_must_fail git tag -F nonexistingfile notag &&\n+\tsilent test_must_fail git tag -F nonexistingfile notag &&\n \t! tag_exists notag\n '\n \n-test_expect_success \\\n-\t'trying to create tags giving both -m or -F options should fail' '\n-\techo \"message file 1\" >msgfile1 &&\n-\techo \"message file 2\" >msgfile2 &&\n+test_expect_success 'trying to create tags giving both -m or -F options should fail' '\n+\techo >msgfile1 \"message file 1\" &&\n+\techo >msgfile2 \"message file 2\" &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -m \"message 1\" -F msgfile1 msgtag &&\n+\tsilent test_must_fail git tag -m \"message 1\" -F msgfile1 msgtag &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -F msgfile1 -m \"message 1\" msgtag &&\n+\tsilent test_must_fail git tag -F msgfile1 -m \"message 1\" msgtag &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -m \"message 1\" -F msgfile1 \\\n+\tsilent test_must_fail git tag -m \"message 1\" -F msgfile1 \\\n \t\t-m \"message 2\" msgtag &&\n \t! tag_exists msgtag\n '\n \n # blank and empty messages:\n \n-get_tag_header empty-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with an empty -m message should succeed' '\n-\tgit tag -m \"\" empty-annotated-tag &&\n-\tget_tag_msg empty-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with an empty -m message should succeed' '\n+\tname=\"empty-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -m \"\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n->emptyfile\n-get_tag_header emptyfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with an empty -F messagefile should succeed' '\n-\tgit tag -F emptyfile emptyfile-annotated-tag &&\n-\tget_tag_msg emptyfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with an empty -F messagefile should succeed' '\n+\t>emptyfile &&\n+\tname=\"emptyfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F emptyfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' >blanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>blanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>blanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>blanksfile\n-get_tag_header blanks-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-Leading blank lines\n+test_expect_success 'extra blanks in the message for an annotated tag should be removed' '\n+\there >blanksfile <<-\\EOF &&\n \n-Repeated blank lines\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n \n-Trailing spaces\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n \n-Trailing blank lines\n-EOF\n-test_expect_success \\\n-\t'extra blanks in the message for an annotated tag should be removed' '\n-\tgit tag -F blanksfile blanks-annotated-tag &&\n-\tget_tag_msg blanks-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tname=\"blanks-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\tLeading blank lines\n+\n+\t\tRepeated blank lines\n+\n+\t\tTrailing spaces\n+\n+\t\tTrailing blank lines\n+\tEOF\n+\tgit tag -F blanksfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header blank-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with blank -m message with spaces should succeed' '\n-\tgit tag -m \"     \" blank-annotated-tag &&\n-\tget_tag_msg blank-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with blank -m message with spaces should succeed' '\n+\tname=\"blank-annotated-tag\" &&\n+\tgen_header $name $commit commit $time </dev/null >expect &&\n+\tgit tag -m \"     \" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-echo '     ' >blankfile\n-echo ''      >>blankfile\n-echo '  '    >>blankfile\n-get_tag_header blankfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with blank -F messagefile with spaces should succeed' '\n-\tgit tag -F blankfile blankfile-annotated-tag &&\n-\tget_tag_msg blankfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' '\n+\there >blankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tname=\"blankfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F blankfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '      ' >blanknonlfile\n-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with -F file of spaces and no newline should succeed' '\n-\tgit tag -F blanknonlfile blanknonlfile-annotated-tag &&\n-\tget_tag_msg blanknonlfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' '\n+\tprintf >blanknonlfile \"      \" &&\n+\tname=\"blanknonlfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F blanknonlfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n # messages with commented lines:\n \n-cat >commentsfile <<EOF\n-# A comment\n+test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' '\n+\tcat >commentsfile <<-EOF &&\n+\t\t# A comment\n \n-############\n-The message.\n-############\n-One line.\n+\t\t############\n+\t\tThe message.\n+\t\t############\n+\t\tOne line.\n \n \n-# commented lines\n-# commented lines\n+\t\t# commented lines\n+\t\t# commented lines\n \n-Another line.\n-# comments\n+\t\tAnother line.\n+\t\t# comments\n \n-Last line.\n-EOF\n-get_tag_header comments-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-The message.\n-One line.\n+\t\tLast line.\n+\tEOF\n+\tname=\"comments-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\tThe message.\n+\t\tOne line.\n \n-Another line.\n+\t\tAnother line.\n \n-Last line.\n-EOF\n-test_expect_success \\\n-\t'creating a tag using a -F messagefile with #comments should succeed' '\n-\tgit tag -F commentsfile comments-annotated-tag &&\n-\tget_tag_msg comments-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\t\tLast line.\n+\tEOF\n+\tgit tag -F commentsfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header comment-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with a #comment in the -m message should succeed' '\n-\tgit tag -m \"#comment\" comment-annotated-tag &&\n-\tget_tag_msg comment-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with a #comment in the -m message should succeed' '\n+\tname=\"comment-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect </dev/null &&\n+\tgit tag -m \"#comment\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-echo '#comment' >commentfile\n-echo ''         >>commentfile\n-echo '####'     >>commentfile\n-get_tag_header commentfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with #comments in the -F messagefile should succeed' '\n-\tgit tag -F commentfile commentfile-annotated-tag &&\n-\tget_tag_msg commentfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' '\n+\tcat >commentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tname=\"commentfile-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect </dev/null &&\n+\tgit tag -F commentfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '#comment' >commentnonlfile\n-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with a file of #comment and no newline should succeed' '\n-\tgit tag -F commentnonlfile commentnonlfile-annotated-tag &&\n-\tget_tag_msg commentnonlfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with a file of #comment and no newline should succeed' '\n+\tprintf >commentnonlfile \"#comment\" &&\n+\tname=\"commentnonlfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F commentnonlfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n # listing messages for annotated non-signed tags:\n \n-test_expect_success \\\n-\t'listing the one-line message of a non-signed tag should succeed' '\n+test_expect_success 'listing the one-line message of a non-signed tag should succeed' '\n \tgit tag -m \"A msg\" tag-one-line &&\n \n-\techo \"tag-one-line\" >expect &&\n-\tgit tag -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\n-\techo \"tag-one-line    A msg\" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l tag-one-line >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-one-line\" &&\n+\tgit tag -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-one-line | test_cmp expect - &&\n+\n+\techo >expect \"tag-one-line    A msg\" &&\n+\tgit tag -n1 -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-one-line | test_cmp expect - &&\n+\tgit tag -n2 -l tag-one-line | test_cmp expect - &&\n+\tgit tag -n999 -l tag-one-line | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'listing the zero-lines message of a non-signed tag should succeed' '\n+test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' '\n \tgit tag -m \"\" tag-zero-lines &&\n \n-\techo \"tag-zero-lines\" >expect &&\n-\tgit tag -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\n-\techo \"tag-zero-lines  \" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-zero-lines\" &&\n+\tgit tag -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-zero-lines | test_cmp expect - &&\n+\n+\techo >expect \"tag-zero-lines  \" &&\n+\tgit tag -n1 -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-zero-lines | test_cmp expect - &&\n+\tgit tag -n2 -l tag-zero-lines | test_cmp expect - &&\n+\tgit tag -n999 -l tag-zero-lines | test_cmp expect -\n '\n \n-echo 'tag line one' >annotagmsg\n-echo 'tag line two' >>annotagmsg\n-echo 'tag line three' >>annotagmsg\n-test_expect_success \\\n-\t'listing many message lines of a non-signed tag should succeed' '\n+test_expect_success 'listing many message lines of a non-signed tag should succeed' '\n+\tcat >annotagmsg <<-EOF &&\n+\t\ttag line one\n+\t\ttag line two\n+\t\ttag line three\n+\tEOF\n \tgit tag -F annotagmsg tag-lines &&\n-\n \techo \"tag-lines\" >expect &&\n-\tgit tag -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-lines | test_cmp expect - &&\n \n \techo \"tag-lines       tag line one\" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n1 -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-lines | test_cmp expect - &&\n \n \techo \"    tag line two\" >>expect &&\n-\tgit tag -n2 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n2 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n2 -l tag-lines | test_cmp expect - &&\n \n \techo \"    tag line three\" >>expect &&\n-\tgit tag -n3 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n3 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l tag-lines >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n3 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n3 -l tag-lines | test_cmp expect - &&\n+\tgit tag -n4 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n4 -l tag-lines | test_cmp expect - &&\n+\tgit tag -n99 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n99 -l tag-lines | test_cmp expect -\n '\n \n test_expect_success 'annotations for blobs are empty' '\n-\tblob=$(git hash-object -w --stdin <<-\\EOF\n-\tBlob paragraph 1.\n+\tblob=$(git hash-object -w --stdin <<-EOF\n+\t\tBlob paragraph 1.\n \n-\tBlob paragraph 2.\n+\t\tBlob paragraph 2.\n \tEOF\n \t) &&\n \tgit tag tag-blob $blob &&\n-\techo \"tag-blob        \" >expect &&\n-\tgit tag -n1 -l tag-blob >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-blob        \" &&\n+\tgit tag -n1 -l tag-blob | test_cmp expect -\n '\n \n # trying to verify annotated non-signed tags:\n \n-test_expect_success GPG \\\n-\t'trying to verify an annotated non-signed tag should fail' '\n+test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' '\n \ttag_exists annotated-tag &&\n-\ttest_must_fail git tag -v annotated-tag\n+\tsilent test_must_fail git tag -v annotated-tag\n '\n \n-test_expect_success GPG \\\n-\t'trying to verify a file-annotated non-signed tag should fail' '\n+test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' '\n \ttag_exists file-annotated-tag &&\n-\ttest_must_fail git tag -v file-annotated-tag\n+\tsilent test_must_fail git tag -v file-annotated-tag\n '\n \n-test_expect_success GPG \\\n-\t'trying to verify two annotated non-signed tags should fail' '\n+test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' '\n \ttag_exists annotated-tag file-annotated-tag &&\n-\ttest_must_fail git tag -v annotated-tag file-annotated-tag\n+\tsilent test_must_fail git tag -v annotated-tag file-annotated-tag\n '\n \n # creating and verifying signed tags:\n \n-get_tag_header signed-tag $commit commit $time >expect\n-echo 'A signed tag message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'creating a signed tag with -m message should succeed' '\n-\tgit tag -s -m \"A signed tag message\" signed-tag &&\n-\tget_tag_msg signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tname=\"signed-tag\" &&\n+\tmsg=\"A signed tag message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header u-signed-tag $commit commit $time >expect\n-echo 'Another message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'sign with a given key id' '\n-\n-\tgit tag -u committer@example.com -m \"Another message\" u-signed-tag &&\n-\tget_tag_msg u-signed-tag >actual &&\n-\ttest_cmp expect actual\n-\n+\tname=\"u-signed-tag\" &&\n+\tmsg=\"Another message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -u committer@example.com -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n test_expect_success GPG 'sign with an unknown id (1)' '\n-\n-\ttest_must_fail git tag -u author@example.com \\\n+\tsilent test_must_fail git tag -u author@example.com \\\n \t\t-m \"Another message\" o-signed-tag\n-\n '\n \n test_expect_success GPG 'sign with an unknown id (2)' '\n-\n-\ttest_must_fail git tag -u DEADBEEF -m \"Another message\" o-signed-tag\n-\n+\tsilent test_must_fail git tag -u DEADBEEF -m \"Another message\" o-signed-tag\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n-test -n \"$1\" && exec >\"$1\"\n-echo A signed tag message\n-echo from a fake editor.\n-EOF\n-chmod +x fakeeditor\n-\n-get_tag_header implied-sign $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-u implies signed tag' '\n-\tGIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&\n-\tget_tag_msg implied-sign >actual &&\n-\ttest_cmp expect actual\n+\tcat <<-\\EOF | write_script fakeeditor &&\n+\t\ttest -n \"$1\" && exec >\"$1\"\n+\t\techo A signed tag message\n+\t\techo from a fake editor.\n+\tEOF\n+\tname=\"implied-signed\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tGIT_EDITOR=./fakeeditor git tag -u CDDE430D $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >sigmsgfile <<EOF\n-Another signed tag\n-message in a file.\n-EOF\n-get_tag_header file-signed-tag $commit commit $time >expect\n-cat sigmsgfile >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with -F messagefile should succeed' '\n-\tgit tag -s -F sigmsgfile file-signed-tag &&\n-\tget_tag_msg file-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' '\n+\tname=\"file-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tAnother signed tag\n+\t\tmessage in a file.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\ttail -n 3 expect | head -n 2 >sigmsgfile\n+\tgit tag -s -F sigmsgfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >siginputmsg <<EOF\n-A signed tag message from\n-the standard input\n-EOF\n-get_tag_header stdin-signed-tag $commit commit $time >expect\n-cat siginputmsg >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n-\tgit tag -s -F - stdin-signed-tag <siginputmsg &&\n-\tget_tag_msg stdin-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tname=\"stdin-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA signed tag message from\n+\t\tthe standard input\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\ttail -n 3 expect | head -n 2 | git tag -s -F - $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header implied-annotate $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-s implies annotated tag' '\n-\tGIT_EDITOR=./fakeeditor git tag -s implied-annotate &&\n-\tget_tag_msg implied-annotate >actual &&\n-\ttest_cmp expect actual\n+\tname=\"implied-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tGIT_EDITOR=./fakeeditor git tag -s $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'trying to create a signed tag with non-existing -F file should fail' '\n+test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' '\n \t! test -f nonexistingfile &&\n \t! tag_exists nosigtag &&\n-\ttest_must_fail git tag -s -F nonexistingfile nosigtag &&\n+\tsilent test_must_fail git tag -s -F nonexistingfile nosigtag &&\n \t! tag_exists nosigtag\n '\n \n-test_expect_success GPG 'verifying a signed tag should succeed' \\\n-\t'git tag -v signed-tag'\n+test_expect_success GPG 'verifying a signed tag should succeed' '\n+\tsilent git tag -v signed-tag\n+'\n \n-test_expect_success GPG 'verifying two signed tags in one command should succeed' \\\n-\t'git tag -v signed-tag file-signed-tag'\n+test_expect_success GPG 'verifying two signed tags in one command should succeed' '\n+\tsilent git tag -v signed-tag file-signed-tag\n+'\n \n-test_expect_success GPG \\\n-\t'verifying many signed and non-signed tags should fail' '\n-\ttest_must_fail git tag -v signed-tag annotated-tag &&\n-\ttest_must_fail git tag -v file-annotated-tag file-signed-tag &&\n-\ttest_must_fail git tag -v annotated-tag \\\n+test_expect_success GPG 'verifying many signed and non-signed tags should fail' '\n+\tsilent test_must_fail git tag -v signed-tag annotated-tag &&\n+\tsilent test_must_fail git tag -v file-annotated-tag file-signed-tag &&\n+\tsilent test_must_fail git tag -v annotated-tag \\\n \t\tfile-signed-tag file-annotated-tag &&\n-\ttest_must_fail git tag -v signed-tag annotated-tag file-signed-tag\n+\tsilent test_must_fail git tag -v signed-tag \\\n+\t\tannotated-tag file-signed-tag\n '\n \n test_expect_success GPG 'verifying a forged tag should fail' '\n@@ -735,405 +681,374 @@ test_expect_success GPG 'verifying a forged tag should fail' '\n \t\tsed -e \"s/signed-tag/forged-tag/\" |\n \t\tgit mktag) &&\n \tgit tag forged-tag $forged &&\n-\ttest_must_fail git tag -v forged-tag\n+\tsilent test_must_fail git tag -v forged-tag\n '\n \n # blank and empty messages for signed tags:\n \n-get_tag_header empty-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with an empty -m message should succeed' '\n-\tgit tag -s -m \"\" empty-signed-tag &&\n-\tget_tag_msg empty-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v empty-signed-tag\n-'\n-\n->sigemptyfile\n-get_tag_header emptyfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with an empty -F messagefile should succeed' '\n-\tgit tag -s -F sigemptyfile emptyfile-signed-tag &&\n-\tget_tag_msg emptyfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v emptyfile-signed-tag\n-'\n-\n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' > sigblanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>sigblanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>sigblanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>sigblanksfile\n-get_tag_header blanks-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-Leading blank lines\n-\n-Repeated blank lines\n-\n-Trailing spaces\n-\n-Trailing blank lines\n-EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'extra blanks in the message for a signed tag should be removed' '\n-\tgit tag -s -F sigblanksfile blanks-signed-tag &&\n-\tget_tag_msg blanks-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blanks-signed-tag\n-'\n-\n-get_tag_header blank-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a blank -m message should succeed' '\n-\tgit tag -s -m \"     \" blank-signed-tag &&\n-\tget_tag_msg blank-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blank-signed-tag\n-'\n-\n-echo '     ' >sigblankfile\n-echo ''      >>sigblankfile\n-echo '  '    >>sigblankfile\n-get_tag_header blankfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with blank -F file with spaces should succeed' '\n-\tgit tag -s -F sigblankfile blankfile-signed-tag &&\n-\tget_tag_msg blankfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blankfile-signed-tag\n-'\n-\n-printf '      ' >sigblanknonlfile\n-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with spaces and no newline should succeed' '\n-\tgit tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&\n-\tget_tag_msg blanknonlfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v signed-tag\n+test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' '\n+\tname=\"empty-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"\" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' '\n+\t>sigemptyfile &&\n+\tname=\"emptyfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigemptyfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' '\n+\there >sigblanksfile <<-\\EOF &&\n+\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n+\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n+\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tname=\"blanks-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\tLeading blank lines\n+\n+\t\tRepeated blank lines\n+\n+\t\tTrailing spaces\n+\n+\t\tTrailing blank lines\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblanksfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' '\n+\tname=\"blank-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"     \" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' '\n+\there >sigblankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tname=\"blankfile-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblankfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' '\n+\tprintf >sigblanknonlfile \"      \" &&\n+\tname=\"blanknonlfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblanknonlfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n '\n \n # messages with commented lines for signed tags:\n \n-cat >sigcommentsfile <<EOF\n-# A comment\n-\n-############\n-The message.\n-############\n-One line.\n-\n-\n-# commented lines\n-# commented lines\n-\n-Another line.\n-# comments\n-\n-Last line.\n-EOF\n-get_tag_header comments-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-The message.\n-One line.\n-\n-Another line.\n-\n-Last line.\n-EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a -F file with #comments should succeed' '\n-\tgit tag -s -F sigcommentsfile comments-signed-tag &&\n-\tget_tag_msg comments-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v comments-signed-tag\n-'\n-\n-get_tag_header comment-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with #commented -m message should succeed' '\n-\tgit tag -s -m \"#comment\" comment-signed-tag &&\n-\tget_tag_msg comment-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v comment-signed-tag\n-'\n-\n-echo '#comment' >sigcommentfile\n-echo ''         >>sigcommentfile\n-echo '####'     >>sigcommentfile\n-get_tag_header commentfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with #commented -F messagefile should succeed' '\n-\tgit tag -s -F sigcommentfile commentfile-signed-tag &&\n-\tget_tag_msg commentfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v commentfile-signed-tag\n-'\n-\n-printf '#comment' >sigcommentnonlfile\n-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a #comment and no newline should succeed' '\n-\tgit tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&\n-\tget_tag_msg commentnonlfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v commentnonlfile-signed-tag\n+test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' '\n+\tcat >sigcommentsfile <<-EOF &&\n+\t\t# A comment\n+\n+\t\t############\n+\t\tThe message.\n+\t\t############\n+\t\tOne line.\n+\n+\n+\t\t# commented lines\n+\t\t# commented lines\n+\n+\t\tAnother line.\n+\t\t# comments\n+\n+\t\tLast line.\n+\tEOF\n+\tname=\"comments-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tThe message.\n+\t\tOne line.\n+\n+\t\tAnother line.\n+\n+\t\tLast line.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentsfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' '\n+\tname=\"comment-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"#comment\" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' '\n+\tcat >sigcommentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tname=\"commentfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' '\n+\tprintf \"#comment\" >sigcommentnonlfile &&\n+\tname=\"commentnonlfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentnonlfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n '\n \n # listing messages for signed tags:\n \n-test_expect_success GPG \\\n-\t'listing the one-line message of a signed tag should succeed' '\n+test_expect_success GPG 'listing the one-line message of a signed tag should succeed' '\n \tgit tag -s -m \"A message line signed\" stag-one-line &&\n \n \techo \"stag-one-line\" >expect &&\n-\tgit tag -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-one-line | test_cmp expect - &&\n \n \techo \"stag-one-line   A message line signed\" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l stag-one-line >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n1 -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-one-line | test_cmp expect - &&\n+\tgit tag -n2 -l stag-one-line | test_cmp expect - &&\n+\tgit tag -n999 -l stag-one-line | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'listing the zero-lines message of a signed tag should succeed' '\n+test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' '\n \tgit tag -s -m \"\" stag-zero-lines &&\n \n \techo \"stag-zero-lines\" >expect &&\n-\tgit tag -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-zero-lines | test_cmp expect - &&\n \n \techo \"stag-zero-lines \" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual\n-'\n-\n-echo 'stag line one' >sigtagmsg\n-echo 'stag line two' >>sigtagmsg\n-echo 'stag line three' >>sigtagmsg\n-test_expect_success GPG \\\n-\t'listing many message lines of a signed tag should succeed' '\n+\tgit tag -n1 -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n -l  | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-zero-lines | test_cmp expect - &&\n+\tgit tag -n2 -l stag-zero-lines | test_cmp expect - &&\n+\tgit tag -n999 -l stag-zero-lines | test_cmp expect -\n+'\n+\n+test_expect_success GPG 'listing many message lines of a signed tag should succeed' '\n+\tcat >sigtagmsg <<-EOF &&\n+\t\tstag line one\n+\t\tstag line two\n+\t\tstag line three\n+\tEOF\n \tgit tag -s -F sigtagmsg stag-lines &&\n \n \techo \"stag-lines\" >expect &&\n-\tgit tag -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-lines | test_cmp expect - &&\n \n \techo \"stag-lines      stag line one\" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n1 -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-lines | test_cmp expect - &&\n \n \techo \"    stag line two\" >>expect &&\n-\tgit tag -n2 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n2 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n2 -l stag-lines | test_cmp expect - &&\n \n \techo \"    stag line three\" >>expect &&\n-\tgit tag -n3 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n3 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l stag-lines >actual &&\n-\ttest_cmp expect actual\n-'\n-\n-# tags pointing to objects different from commits:\n-\n-tree=$(git rev-parse HEAD^{tree})\n-blob=$(git rev-parse HEAD:foo)\n-tag=$(git rev-parse signed-tag 2>/dev/null)\n-\n-get_tag_header tree-signed-tag $tree tree $time >expect\n-echo \"A message for a tree\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to a tree should succeed' '\n-\tgit tag -s -m \"A message for a tree\" tree-signed-tag HEAD^{tree} &&\n-\tget_tag_msg tree-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n3 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n3 -l stag-lines | test_cmp expect - &&\n+\tgit tag -n4 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n4 -l stag-lines | test_cmp expect - &&\n+\tgit tag -n99 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n99 -l stag-lines | test_cmp expect -\n+'\n+\n+\n+test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' '\n+\t# tags pointing to objects different from commits:\n+\ttree=$(git rev-parse HEAD^{tree}) &&\n+\tblob=$(git rev-parse HEAD:foo) &&\n+\ttag=$(git rev-parse signed-tag) &&\n+\tname=\"tree-signed-tag\" &&\n+\tmsg=\"A message for a tree\" &&\n+\tgen_header $name $tree tree $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name HEAD^{tree} &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header blob-signed-tag $blob blob $time >expect\n-echo \"A message for a blob\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to a blob should succeed' '\n-\tgit tag -s -m \"A message for a blob\" blob-signed-tag HEAD:foo &&\n-\tget_tag_msg blob-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' '\n+\tmsg=\"A message for a blob\" &&\n+\tname=\"blob-signed-tag\" &&\n+\tgen_header $name $blob blob $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name HEAD:foo &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header tag-signed-tag $tag tag $time >expect\n-echo \"A message for another tag\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to another tag should succeed' '\n-\tgit tag -s -m \"A message for another tag\" tag-signed-tag signed-tag &&\n-\tget_tag_msg tag-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' '\n+\tmsg=\"A message for another tag\" &&\n+\tname=\"tag-signed-tag\" &&\n+\tgen_header $name $tag tag $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name signed-tag &&\n+\tget_header $name | test_cmp expect -\n '\n \n # usage with rfc1991 signatures\n-echo \"rfc1991\" > gpghome/gpg.conf\n-get_tag_header rfc1991-signed-tag $commit commit $time >expect\n-echo \"RFC1991 signed tag\" >>expect\n-echo '-----BEGIN PGP MESSAGE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with rfc1991' '\n-\tgit tag -s -m \"RFC1991 signed tag\" rfc1991-signed-tag $commit &&\n-\tget_tag_msg rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag with rfc1991' '\n+\techo \"rfc1991\" >gpghome/gpg.conf &&\n+\tmsg=\"RFC1991 signed tag\" &&\n+\tname=\"rfc1991-signed-tag\"\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP MESSAGE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name $commit &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n-cp \"$1\" actual\n-EOF\n-chmod +x fakeeditor\n-\n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n+\tcat <<-\\EOF | write_script fakeeditor &&\n+\t\tcp \"$1\" actual\n+\tEOF\n \techo \"RFC1991 signed tag\" >expect &&\n-\tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n+\tGIT_EDITOR=./fakeeditor \\\n+\t\tquiet git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature' '\n-\tgit tag -v rfc1991-signed-tag\n+test_expect_success GPG 'verifying rfc1991 signature' '\n+\tsilent git tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature' '\n+test_expect_success GPG 'list tag with rfc1991 signature' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n-\tgit tag -l -n1 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n2 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n999 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n999 rfc1991-signed-tag | test_cmp expect -\n '\n \n-rm -f gpghome/gpg.conf\n-\n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature without --rfc1991' '\n-\tgit tag -v rfc1991-signed-tag\n+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '\n+\trm -f gpghome/gpg.conf &&\n+\tsilent git tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature without --rfc1991' '\n-\techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n-\tgit tag -l -n1 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n2 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n999 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '\n+\techo >expect \"rfc1991-signed-tag RFC1991 signed tag\" &&\n+\tgit tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n999 rfc1991-signed-tag | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n-\tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n+\tGIT_EDITOR=./fakeeditor \\\n+\t\tquiet git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-# try to sign with bad user.signingkey\n-git config user.signingkey BobTheMouse\n-test_expect_success GPG \\\n-\t'git tag -s fails if gpg is misconfigured' \\\n-\t'test_must_fail git tag -s -m tail tag-gpg-failure'\n-git config --unset user.signingkey\n-\n-# try to verify without gpg:\n+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '\n+\t# try to sign with bad user.signingkey\n+\tgit config user.signingkey BobTheMouse &&\n+\tsilent test_must_fail git tag -s -m tail tag-gpg-failure &&\n+\tgit config --unset user.signingkey\n+'\n \n-rm -rf gpghome\n-test_expect_success GPG \\\n-\t'verify signed tag fails when public key is not present' \\\n-\t'test_must_fail git tag -v signed-tag'\n+test_expect_success GPG 'verify signed tag fails when public key is not present' '\n+\t# try to verify without gpg:\n+\trm -rf gpghome &&\n+\tsilent test_must_fail git tag -v signed-tag\n+'\n \n-test_expect_success \\\n-\t'git tag -a fails if tag annotation is empty' '\n-\t! (GIT_EDITOR=cat git tag -a initial-comment)\n+test_expect_success 'git tag -a fails if tag annotation is empty' '\n+\t! (GIT_EDITOR=cat silent git tag -a initial-comment)\n '\n \n-test_expect_success \\\n-\t'message in editor has initial comment' '\n-\t! (GIT_EDITOR=cat git tag -a initial-comment > actual)\n+test_expect_success 'message in editor has initial comment' '\n+\t! (GIT_EDITOR=cat git tag -a initial-comment >actual 2>/dev/null)\n '\n \n test_expect_success 'message in editor has initial comment: first line' '\n \t# check the first line --- should be empty\n \techo >first.expect &&\n-\tsed -e 1q <actual >first.actual &&\n+\tsed -e 1q actual >first.actual &&\n \ttest_i18ncmp first.expect first.actual\n '\n \n-test_expect_success \\\n-\t'message in editor has initial comment: remainder' '\n+test_expect_success 'message in editor has initial comment: remainder' '\n \t# remove commented lines from the remainder -- should be empty\n \t>rest.expect\n \tsed -e 1d -e '/^#/d' <actual >rest.actual &&\n \ttest_cmp rest.expect rest.actual\n '\n \n-get_tag_header reuse $commit commit $time >expect\n-echo \"An annotation to be reused\" >> expect\n-test_expect_success \\\n-\t'overwriting an annoted tag should use its previous body' '\n-\tgit tag -a -m \"An annotation to be reused\" reuse &&\n-\tGIT_EDITOR=true git tag -f -a reuse &&\n-\tget_tag_msg reuse >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'overwriting an annoted tag should use its previous body' '\n+\tname=\"reuse\" &&\n+\tmsg=\"An annotation to be reused\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\treuse\n+\tEOF\n+\tgit tag -a -m \"$msg\" $name &&\n+\tGIT_EDITOR=true git tag -f -a -m \"reuse\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n test_expect_success 'filename for the message is relative to cwd' '\n@@ -1144,7 +1059,7 @@ test_expect_success 'filename for the message is relative to cwd' '\n \t\tcd subdir &&\n \t\tgit tag -a -F msgfile-5 tag-from-subdir\n \t) &&\n-\tgit cat-file tag tag-from-subdir | grep \"in sub directory\"\n+\tgit cat-file tag tag-from-subdir | grep -q \"in sub directory\"\n '\n \n test_expect_success 'filename for the message is relative to cwd' '\n@@ -1153,172 +1068,143 @@ test_expect_success 'filename for the message is relative to cwd' '\n \t\tcd subdir &&\n \t\tgit tag -a -F msgfile-6 tag-from-subdir-2\n \t) &&\n-\tgit cat-file tag tag-from-subdir-2 | grep \"in sub directory\"\n+\tgit cat-file tag tag-from-subdir-2 | grep -q \"in sub directory\"\n '\n \n-# create a few more commits to test --contains\n-\n-hash1=$(git rev-parse HEAD)\n-\n test_expect_success 'creating second commit and tag' '\n+\t# create a few more commits to test --contains\n+\thash1=$(git rev-parse HEAD) &&\n \techo foo-2.0 >foo &&\n \tgit add foo &&\n-\tgit commit -m second &&\n+\tgit commit -q -m second &&\n+\thash2=$(git rev-parse HEAD) &&\n \tgit tag v2.0\n '\n \n-hash2=$(git rev-parse HEAD)\n-\n test_expect_success 'creating third commit without tag' '\n \techo foo-dev >foo &&\n \tgit add foo &&\n-\tgit commit -m third\n+\tgit commit -q -m third &&\n+\thash3=$(git rev-parse HEAD)\n+'\n+\n+test_expect_success 'checking that first commit is in all tags (hash)' '\n+\t# simple linear checks of --contains\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\t\tv2.0\n+\tEOF\n+\tgit tag -l --contains $hash1 v* | test_cmp expect -\n '\n \n-hash3=$(git rev-parse HEAD)\n-\n-# simple linear checks of --continue\n-\n-cat > expected <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-v2.0\n-EOF\n-\n-test_expect_success 'checking that first commit is in all tags (hash)' \"\n-\tgit tag -l --contains $hash1 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-# other ways of specifying the commit\n-test_expect_success 'checking that first commit is in all tags (tag)' \"\n-\tgit tag -l --contains v1.0 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-test_expect_success 'checking that first commit is in all tags (relative)' \"\n-\tgit tag -l --contains HEAD~2 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-cat > expected <<EOF\n-v2.0\n-EOF\n-\n-test_expect_success 'checking that second commit only has one tag' \"\n-\tgit tag -l --contains $hash2 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that first commit is in all tags (tag)' '\n+\t# other ways of specifying the commit\n+\tgit tag -l --contains v1.0 v* | test_cmp expect -\n+'\n \n+test_expect_success 'checking that first commit is in all tags (relative)' '\n+\tgit tag -l --contains HEAD~2 v* | test_cmp expect -\n+'\n \n-cat > expected <<EOF\n-EOF\n+test_expect_success 'checking that second commit only has one tag' '\n+\tcat >expect <<-EOF &&\n+\t\tv2.0\n+\tEOF\n+\tgit tag -l --contains $hash2 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that third commit has no tags' \"\n-\tgit tag -l --contains $hash3 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that third commit has no tags' '\n+\t>expect\n+\tgit tag -l --contains $hash3 v* | test_cmp expect -\n+'\n \n # how about a simple merge?\n \n test_expect_success 'creating simple branch' '\n \tgit branch stable v2.0 &&\n-        git checkout stable &&\n-\techo foo-3.0 > foo &&\n-\tgit commit foo -m fourth &&\n+\tgit checkout -q stable &&\n+\techo foo-3.0 >foo &&\n+\tgit commit -q foo -m fourth &&\n+\thash4=$(git rev-parse HEAD) &&\n \tgit tag v3.0\n '\n \n-hash4=$(git rev-parse HEAD)\n-\n-cat > expected <<EOF\n-v3.0\n-EOF\n-\n-test_expect_success 'checking that branch head only has one tag' \"\n-\tgit tag -l --contains $hash4 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that branch head only has one tag' '\n+\tcat >expect <<-EOF &&\n+\t\tv3.0\n+\tEOF\n+\tgit tag -l --contains $hash4 v* | test_cmp expect -\n+'\n \n test_expect_success 'merging original branch into this branch' '\n-\tgit merge --strategy=ours master &&\n+\tgit merge -q --strategy=ours master &&\n         git tag v4.0\n '\n \n-cat > expected <<EOF\n-v4.0\n-EOF\n-\n-test_expect_success 'checking that original branch head has one tag now' \"\n-\tgit tag -l --contains $hash3 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-cat > expected <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-v2.0\n-v3.0\n-v4.0\n-EOF\n-\n-test_expect_success 'checking that initial commit is in all tags' \"\n-\tgit tag -l --contains $hash1 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that original branch head has one tag now' '\n+\tcat >expect <<-EOF &&\n+\t\tv4.0\n+\tEOF\n+\tgit tag -l --contains $hash3 v* | test_cmp expect -\n+'\n+\n+test_expect_success 'checking that initial commit is in all tags' '\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\t\tv2.0\n+\t\tv3.0\n+\t\tv4.0\n+\tEOF\n+\tgit tag -l --contains $hash1 v* | test_cmp expect -\n+'\n \n-# mixing modes and options:\n \n test_expect_success 'mixing incompatibles modes and options is forbidden' '\n-\ttest_must_fail git tag -a &&\n-\ttest_must_fail git tag -l -v &&\n-\ttest_must_fail git tag -n 100 &&\n-\ttest_must_fail git tag -l -m msg &&\n-\ttest_must_fail git tag -l -F some file &&\n-\ttest_must_fail git tag -v -s\n+\t# mixing modes and options:\n+\tsilent test_must_fail git tag -a &&\n+\tsilent test_must_fail git tag -l -v &&\n+\tsilent test_must_fail git tag -n 100 &&\n+\tsilent test_must_fail git tag -l -m msg &&\n+\tsilent test_must_fail git tag -l -F some file &&\n+\tsilent test_must_fail git tag -v -s &&\n+\tsilent test_must_fail git tag --points-at=v4.0 foo\n '\n \n # check points-at\n \n-test_expect_success '--points-at cannot be used in non-list mode' '\n-\ttest_must_fail git tag --points-at=v4.0 foo\n-'\n-\n test_expect_success '--points-at finds lightweight tags' '\n \techo v4.0 >expect &&\n-\tgit tag --points-at v4.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at v4.0 | test_cmp expect -\n '\n \n test_expect_success '--points-at finds annotated tags of commits' '\n \tgit tag -m \"v4.0, annotated\" annotated-v4.0 v4.0 &&\n \techo annotated-v4.0 >expect &&\n-\tgit tag -l --points-at v4.0 \"annotated*\" >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l --points-at v4.0 \"annotated*\" | test_cmp expect -\n '\n \n test_expect_success '--points-at finds annotated tags of tags' '\n \tgit tag -m \"describing the v4.0 tag object\" \\\n \t\tannotated-again-v4.0 annotated-v4.0 &&\n-\tcat >expect <<-\\EOF &&\n-\tannotated-again-v4.0\n-\tannotated-v4.0\n+\tcat >expect <<-EOF &&\n+\t\tannotated-again-v4.0\n+\t\tannotated-v4.0\n \tEOF\n-\tgit tag --points-at=annotated-v4.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at=annotated-v4.0 | test_cmp expect -\n '\n \n test_expect_success 'multiple --points-at are OR-ed together' '\n-\tcat >expect <<-\\EOF &&\n-\tv2.0\n-\tv3.0\n+\tcat >expect <<-EOF &&\n+\t\tv2.0\n+\t\tv3.0\n \tEOF\n-\tgit tag --points-at=v2.0 --points-at=v3.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at=v2.0 --points-at=v3.0 | test_cmp expect -\n '\n \n test_done\n-- \n1.7.8\n"},{"id":"185764","messageId":"1330566326-26075-7-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:22Z","receivedAt":"2012-03-01T01:45:22Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t6300-for-each-ref.sh |  296 +++++++++++++++++++++++++----------------------\n 1 files changed, 157 insertions(+), 139 deletions(-)\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 1721784..12916b2 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -5,9 +5,17 @@\n \n test_description='for-each-ref test'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-gpg.sh\n \n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+\n # Mon Jul 3 15:18:43 2006 +0000\n datestamp=1151939923\n setdate_and_increment () {\n@@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '\n \tsetdate_and_increment &&\n \techo \"Using $datestamp\" > one &&\n \tgit add one &&\n-\tgit commit -m \"Initial\" &&\n+\tgit commit -q -m \"Initial\" &&\n \tsetdate_and_increment &&\n-\tgit tag -a -m \"Tagging at $datestamp\" testtag\n+\tquiet git tag -a -m \"Tagging at $datestamp\" testtag\n '\n \n test_expect_success 'Create upstream config' '\n@@ -115,261 +123,270 @@ test_atom tag contents 'Tagging at 1151939927\n '\n \n test_expect_success 'Check invalid atoms names are errors' '\n-\ttest_must_fail git for-each-ref --format=\"%(INVALID)\" refs/heads\n+\tsilent test_must_fail git for-each-ref --format=\"%(INVALID)\" refs/heads\n '\n \n test_expect_success 'Check format specifiers are ignored in naming date atoms' '\n-\tgit for-each-ref --format=\"%(authordate)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:default) %(authordate)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate) %(authordate:default)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:default) %(authordate:default)\" refs/heads\n+\tf1=\"%(authordate)\" &&\n+\tf2=\"%(authordate:default) %(authordate)\" &&\n+\tf3=\"%(authordate) %(authordate:default)\" &&\n+\tf4=\"%(authordate:default) %(authordate:default)\"\n+\tquiet git for-each-ref --format=\"$f1\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f2\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f3\" refs/heads &&\n+\tquiet git for-each-ref --format=\"$f4\" refs/heads\n '\n \n test_expect_success 'Check valid format specifiers for date fields' '\n-\tgit for-each-ref --format=\"%(authordate:default)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:relative)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:short)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:local)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:iso8601)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(authordate:rfc2822)\" refs/heads\n+\tquiet git for-each-ref --format=\"%(authordate:default)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:relative)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:short)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:local)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:iso8601)\" refs/heads &&\n+\tquiet git for-each-ref --format=\"%(authordate:rfc2822)\" refs/heads\n '\n \n test_expect_success 'Check invalid format specifiers are errors' '\n-\ttest_must_fail git for-each-ref --format=\"%(authordate:INVALID)\" refs/heads\n+\th=\"%(authordate:INVALID)\" &&\n+\tsilent test_must_fail git for-each-ref --format=\"$h\" refs/heads\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check unformatted date fields output' '\n+\t'\"\n+\tcat >expect <<-EOF &&\n 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n EOF\n-\n-test_expect_success 'Check unformatted date fields output' '\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate) %(authordate)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\th=\"%(refname) %(committerdate) %(authordate)\" &&\n+\tt=\"%(refname) %(taggerdate)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Check format \"default\" formatted date fields output' '\n-\tf=default &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\th=\"%(refname) %(committerdate:default) %(authordate:default)\" &&\n+\tt=\"%(refname) %(taggerdate:default)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-# Don't know how to do relative check because I can't know when this script\n-# is going to be run and can't fake the current time to git, and hence can't\n-# provide expected output.  Instead, I'll just make sure that \"relative\"\n-# doesn't exit in error\n-#\n-#cat >expected <<\\EOF\n-#\n-#EOF\n-#\n test_expect_success 'Check format \"relative\" date fields output' '\n-\tf=relative &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual\n+\t'\"\n+\t# Don't know how to do relative check because I can't know when this\n+\t# script is going to be run and can't fake the current time to git,\n+\t# and hence can't provide expected output.  Instead, I'll just make\n+\t# sure that 'relative' doesn't exit in error\n+\t\"'\n+\th=\"%(refname) %(committerdate:relative) %(authordate:relative)\" &&\n+\tt=\"%(refname) %(taggerdate:relative)\" &&\n+\tquiet git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\tquiet git for-each-ref --shell --format=\"$t\" refs/tags\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"short\" date fields output' '\n+\t'\"\n+\tcat >expect <<-EOF\n 'refs/heads/master' '2006-07-03' '2006-07-03'\n 'refs/tags/testtag' '2006-07-03'\n EOF\n-\n-test_expect_success 'Check format \"short\" date fields output' '\n-\tf=short &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\th=\"%(refname) %(committerdate:short) %(authordate:short)\" &&\n+\tt=\"%(refname) %(taggerdate:short)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"local\" date fields output' '\n+\t'\"\n+\tcat >expect <<-EOF\n 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n EOF\n-\n-test_expect_success 'Check format \"local\" date fields output' '\n-\tf=local &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\th=\"%(refname) %(committerdate:local) %(authordate:local)\" &&\n+\tt=\"%(refname) %(taggerdate:local)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"iso8601\" date fields output' '\n+\t'\"\n+\tcat >expect <<-EOF\n 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n 'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n EOF\n-\n-test_expect_success 'Check format \"iso8601\" date fields output' '\n-\tf=iso8601 &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\th=\"%(refname) %(committerdate:iso8601) %(authordate:iso8601)\" &&\n+\tt=\"%(refname) %(taggerdate:iso8601)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"rfc2822\" date fields output' '\n+\t'\"\n+\tcat >expect <<-EOF\n 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n EOF\n-\n-test_expect_success 'Check format \"rfc2822\" date fields output' '\n-\tf=rfc2822 &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\th=\"%(refname) %(committerdate:rfc2822) %(authordate:rfc2822)\" &&\n+\tt=\"%(refname) %(taggerdate:rfc2822)\" &&\n+\t(git for-each-ref --shell --format=\"$h\" refs/heads &&\n+\t git for-each-ref --shell --format=\"$t\" refs/tags) |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Verify ascending sort' '\n+\tcat >expect <<-EOF\n refs/heads/master\n refs/remotes/origin/master\n refs/tags/testtag\n EOF\n-\n-test_expect_success 'Verify ascending sort' '\n-\tgit for-each-ref --format=\"%(refname)\" --sort=refname >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --format=\"%(refname)\" --sort=refname |\n+\t\ttest_cmp expect -\n '\n \n-\n-cat >expected <<\\EOF\n+test_expect_success 'Verify descending sort' '\n+\tcat >expect <<-EOF\n refs/tags/testtag\n refs/remotes/origin/master\n refs/heads/master\n EOF\n-\n-test_expect_success 'Verify descending sort' '\n-\tgit for-each-ref --format=\"%(refname)\" --sort=-refname >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --format=\"%(refname)\" --sort=-refname |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Quoting style: shell' '\n+\t'\"\n+\tcat >expect <<-EOF\n 'refs/heads/master'\n 'refs/remotes/origin/master'\n 'refs/tags/testtag'\n EOF\n-\n-test_expect_success 'Quoting style: shell' '\n-\tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\t\"'\n+\tgit for-each-ref --shell --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Quoting style: perl' '\n-\tgit for-each-ref --perl --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --perl --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Quoting style: python' '\n-\tgit for-each-ref --python --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --python --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Quoting style: tcl' '\n+\tcat >expect <<-EOF\n \"refs/heads/master\"\n \"refs/remotes/origin/master\"\n \"refs/tags/testtag\"\n EOF\n-\n-test_expect_success 'Quoting style: tcl' '\n-\tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --tcl --format=\"%(refname)\" |\n+\t\ttest_cmp expect -\n '\n \n-for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n-\ttest_expect_success \"more than one quoting style: $i\" \"\n-\t\tgit for-each-ref $i 2>&1 | (read line &&\n-\t\tcase \\$line in\n-\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n-\t\t*) false\n-\t\tesac)\n-\t\"\n-done\n-\n-cat >expected <<\\EOF\n+test_expect_success 'more than one quoting styles' '\n+\tcat >expect <<-EOF\n+\t\terror: more than one quoting style?\n+\tEOF\n+\tgit for-each-ref --perl --shell 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref -s --python 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref --python --tcl 2>&1 | head -n 1 |\n+\t\ttest_cmp expect - &&\n+\tgit for-each-ref --tcl --perl 2>&1 | head -n 1 |\n+\t\ttest_cmp expect -\n+'\n+test_expect_success 'Check short refname format' '\n+\tcat >expect <<-EOF\n master\n testtag\n EOF\n-\n-test_expect_success 'Check short refname format' '\n-\t(git for-each-ref --format=\"%(refname:short)\" refs/heads &&\n-\tgit for-each-ref --format=\"%(refname:short)\" refs/tags) >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --format=\"%(refname:short)\" refs/heads refs/tags |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<EOF\n+test_expect_success 'Check short upstream format' '\n+\tcat >expect <<-EOF\n origin/master\n EOF\n-\n-test_expect_success 'Check short upstream format' '\n-\tgit for-each-ref --format=\"%(upstream:short)\" refs/heads >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --format=\"%(upstream:short)\" refs/heads |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<EOF\n+test_expect_success 'Check short objectname format' '\n+\tcat >expect <<-EOF\n 67a36f1\n EOF\n-\n-test_expect_success 'Check short objectname format' '\n-\tgit for-each-ref --format=\"%(objectname:short)\" refs/heads >actual &&\n-\ttest_cmp expected actual\n+\tgit for-each-ref --format=\"%(objectname:short)\" refs/heads |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'Check for invalid refname format' '\n-\ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n+\tsilent test_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs (strict)' '\n+\tcat >expect <<-EOF\n heads/master\n tags/master\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs (strict)' '\n \tgit config --bool core.warnambiguousrefs true &&\n-\tgit checkout -b newtag &&\n+\tgit checkout -q -b newtag &&\n \techo \"Using $datestamp\" > one &&\n \tgit add one &&\n-\tgit commit -m \"Branch\" &&\n+\tgit commit -q -m \"Branch\" &&\n \tsetdate_and_increment &&\n-\tgit tag -m \"Tagging at $datestamp\" master &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n-\ttest_cmp expected actual\n+\tquiet git tag -m \"Tagging at $datestamp\" master &&\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/master refs/tags/master |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs (loose)' '\n+\tcat >expect <<-EOF\n heads/master\n master\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs (loose)' '\n \tgit config --bool core.warnambiguousrefs false &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n-\ttest_cmp expected actual\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/master refs/tags/master |\n+\t\ttest_cmp expect -\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n+\tcat >expect <<-EOF\n heads/ambiguous\n ambiguous\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit tag ambiguous testtag^0 &&\n \tgit branch ambiguous testtag^0 &&\n-\tgit for-each-ref --format \"%(refname:short)\" refs/heads/ambiguous refs/tags/ambiguous >actual &&\n-\ttest_cmp expected actual\n+\tf=\"%(refname:short)\" &&\n+\tgit for-each-ref --format \"$f\" refs/heads/ambiguous refs/tags/ambiguous |\n+\t\ttest_cmp expect -\n '\n \n test_expect_success 'an unusual tag with an incomplete line' '\n-\n \tgit tag -m \"bogo\" bogo &&\n \tbogo=$(git cat-file tag bogo) &&\n \tbogo=$(printf \"%s\" \"$bogo\" | git mktag) &&\n \tgit tag -f bogo \"$bogo\" &&\n \tgit for-each-ref --format \"%(body)\" refs/tags/bogo\n-\n '\n \n test_expect_success 'create tag with subject and body content' '\n-\tcat >>msg <<-\\EOF &&\n+\tcat >msg <<-\\EOF &&\n \t\tthe subject line\n \n \t\tfirst body line\n@@ -395,8 +412,9 @@ test_expect_success 'create tag with multiline subject' '\n \t\tfirst body line\n \t\tsecond body line\n \tEOF\n-\tgit tag -F msg multiline\n+\tquiet git tag -F msg multiline\n '\n+\n test_atom refs/tags/multiline subject 'first subject line second subject line'\n test_atom refs/tags/multiline contents:subject 'first subject line second subject line'\n test_atom refs/tags/multiline body 'first body line\n-- \n1.7.8\n"},{"id":"185765","messageId":"1330566326-26075-8-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH-w 102/105] t5512 (ls-remote): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:23Z","receivedAt":"2012-03-01T01:45:23Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t5512-ls-remote.sh |   29 ++++++++++++++++++++---------\n 1 files changed, 20 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 5c546c9..bbe650f 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -2,14 +2,22 @@\n \n test_description='git ls-remote'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n \n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+\n test_expect_success setup '\n \n \t>file &&\n \tgit add file &&\n \ttest_tick &&\n-\tgit commit -m initial &&\n+\tgit commit -q -m initial &&\n \tgit tag mark &&\n \tgit show-ref --tags -d | sed -e \"s/ /\t/\" >expected.tag &&\n \t(\n@@ -51,7 +59,7 @@ test_expect_success 'ls-remote self' '\n \n test_expect_success 'dies when no remote specified and no default remotes found' '\n \n-\ttest_must_fail git ls-remote\n+\tsilent test_must_fail git ls-remote\n \n '\n \n@@ -70,8 +78,8 @@ test_expect_success 'use \"origin\" when no remote specified' '\n \n test_expect_success 'suppress \"From <url>\" with -q' '\n \n-\tgit ls-remote -q 2>actual_err &&\n-\ttest_must_fail test_cmp exp_err actual_err\n+\tquiet git ls-remote -q 2>actual_err &&\n+\ttest_must_fail cmp -s exp_err actual_err\n \n '\n \n@@ -83,7 +91,7 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \t#\n \n \t# setup a new remote to differentiate from \"origin\"\n-\tgit clone . other.git &&\n+\tgit clone -q . other.git &&\n \t(\n \t\tcd other.git &&\n \t\techo \"$(git rev-parse HEAD)\tHEAD\"\n@@ -102,11 +110,13 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \n '\n \n-cat >exp <<EOF\n+test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t'\"\n+\tcat >exp <<-EOF\n fatal: 'refs*master' does not appear to be a git repository\n fatal: The remote end hung up unexpectedly\n EOF\n-test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t\"'\n \t#\n \t# Do not expect \"git ls-remote <pattern>\" to work; ls-remote, correctly,\n \t# confuses <pattern> for <remote>. Although ugly, this behaviour is akin\n@@ -124,7 +134,7 @@ test_expect_success 'confuses pattern as remote when no remote specified' '\n '\n \n test_expect_success 'die with non-2 for wrong repository even with --exit-code' '\n-\tgit ls-remote --exit-code ./no-such-repository ;# not &&\n+\tsilent git ls-remote --exit-code ./no-such-repository ;# not &&\n \tstatus=$? &&\n \ttest $status != 2 && test $status != 0\n '\n@@ -136,7 +146,8 @@ test_expect_success 'Report success even when nothing matches' '\n '\n \n test_expect_success 'Report no-match with --exit-code' '\n-\ttest_expect_code 2 git ls-remote --exit-code other.git \"refs/nsn/*\" >actual &&\n+\ttest_expect_code 2 git ls-remote --exit-code other.git \"refs/nsn/*\" \\\n+\t\t>actual &&\n \t>expect &&\n \ttest_cmp expect actual\n '\n-- \n1.7.8\n"},{"id":"185767","messageId":"1330566326-26075-9-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH-w 103/105] t3200 (branch): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:24Z","receivedAt":"2012-03-01T01:45:24Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n- Use a \"here\" filter for expect generation\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t3200-branch.sh |  457 +++++++++++++++++++++++++++--------------------------\n 1 files changed, 236 insertions(+), 221 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd1aceb..93c35cd 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -5,125 +5,132 @@\n \n test_description='git branch assorted tests'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n \n-test_expect_success \\\n-    'prepare a trivial repository' \\\n-    'echo Hello > A &&\n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+here () { sed 's/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g' $@; }\n+\n+test_expect_success 'prepare a trivial repository' '\n+\techo Hello >A &&\n      git update-index --add A &&\n-     git commit -m \"Initial commit.\" &&\n+\tgit commit -q -m \"Initial commit.\" &&\n      echo World >> A &&\n      git update-index --add A &&\n-     git commit -m \"Second commit.\" &&\n-     HEAD=$(git rev-parse --verify HEAD)'\n+\tgit commit -q -m \"Second commit.\" &&\n+\tHEAD=$(git rev-parse --verify HEAD)\n+'\n \n-test_expect_success \\\n-    'git branch --help should not have created a bogus branch' '\n-     test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&\n+test_expect_success 'git branch --help should not have created a bogus branch' '\n+\tsilent test_might_fail git branch --help </dev/null &&\n      test_path_is_missing .git/refs/heads/--help\n '\n \n test_expect_success 'branch -h in broken repository' '\n-\tmkdir broken &&\n-\t(\n-\t\tcd broken &&\n-\t\tgit init &&\n-\t\t>.git/refs/heads/master &&\n-\t\ttest_expect_code 129 git branch -h >usage 2>&1\n-\t) &&\n-\tgrep \"[Uu]sage\" broken/usage\n+\tgit init -q broken &&\n+\ttest_when_finished rm -rf broken usage &&\n+\t>broken/.git/refs/heads/master &&\n+\t>usage 2>&1 test_expect_code 129 git --git-dir=broken/.git branch -h &&\n+\tgrep -q \"[Uu]sage\" usage\n '\n \n-test_expect_success \\\n-    'git branch abc should create a branch' \\\n-    'git branch abc && test_path_is_file .git/refs/heads/abc'\n+test_expect_success 'git branch abc should create a branch' '\n+\tgit branch abc && test_path_is_file .git/refs/heads/abc\n+'\n \n-test_expect_success \\\n-    'git branch a/b/c should create a branch' \\\n-    'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'\n+test_expect_success 'git branch a/b/c should create a branch' '\n+\tgit branch a/b/c && test_path_is_file .git/refs/heads/a/b/c\n+'\n \n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n+test_expect_success 'git branch -l d/e/f should create a branch and a log' '\n+\tid=\"$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\"\n+\tdate=\"1117150200 +0000\"\n+\tmsg=\"branch: Created from master\"\n+\there >expect <<-EOF\n+\t\t$_z40 $HEAD $id $date\\t$msg\n EOF\n-test_expect_success \\\n-    'git branch -l d/e/f should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git branch -l d/e/f &&\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" git branch -l d/e/f &&\n \t test_path_is_file .git/refs/heads/d/e/f &&\n \t test_path_is_file .git/logs/refs/heads/d/e/f &&\n-\t test_cmp expect .git/logs/refs/heads/d/e/f'\n+\ttest_cmp expect .git/logs/refs/heads/d/e/f\n+'\n \n-test_expect_success \\\n-    'git branch -d d/e/f should delete a branch and a log' \\\n-\t'git branch -d d/e/f &&\n+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '\n+\tquiet git branch -d d/e/f &&\n \t test_path_is_missing .git/refs/heads/d/e/f &&\n-\t test_path_is_missing .git/logs/refs/heads/d/e/f'\n-\n-test_expect_success \\\n-    'git branch j/k should work after branch j has been deleted' \\\n-       'git branch j &&\n-        git branch -d j &&\n-        git branch j/k'\n-\n-test_expect_success \\\n-    'git branch l should work after branch l/m has been deleted' \\\n-       'git branch l/m &&\n-        git branch -d l/m &&\n-        git branch l'\n-\n-test_expect_success \\\n-    'git branch -m dumps usage' \\\n-       'test_expect_code 129 git branch -m 2>err &&\n-\tgrep \"[Uu]sage: git branch\" err'\n-\n-test_expect_success \\\n-    'git branch -m m m/m should work' \\\n-       'git branch -l m &&\n+\ttest_path_is_missing .git/logs/refs/heads/d/e/f\n+'\n+\n+test_expect_success 'git branch j/k should work after branch j has been deleted' '\n+\tgit branch j &&\n+\tquiet git branch -d j &&\n+\tgit branch j/k\n+'\n+\n+test_expect_success 'git branch l should work after branch l/m has been deleted' '\n+\tgit branch l/m &&\n+\tquiet git branch -d l/m &&\n+\tgit branch l\n+'\n+\n+test_expect_success 'git branch -m dumps usage' '\n+\ttest_expect_code 129 git branch -m 2>err &&\n+\tgrep -q \"[Uu]sage: git branch\" err\n+'\n+\n+test_expect_success 'git branch -m m m/m should work' '\n+\tgit branch -l m &&\n         git branch -m m m/m &&\n-\ttest_path_is_file .git/logs/refs/heads/m/m'\n+\ttest_path_is_file .git/logs/refs/heads/m/m\n+'\n \n-test_expect_success \\\n-    'git branch -m n/n n should work' \\\n-       'git branch -l n/n &&\n+test_expect_success 'git branch -m n/n n should work' '\n+\tgit branch -l n/n &&\n \tgit branch -m n/n n &&\n-\ttest_path_is_file .git/logs/refs/heads/n'\n+\ttest_path_is_file .git/logs/refs/heads/n\n+'\n \n test_expect_success 'git branch -m o/o o should fail when o/p exists' '\n \tgit branch o/o &&\n         git branch o/p &&\n-\ttest_must_fail git branch -m o/o o\n+\tsilent test_must_fail git branch -m o/o o\n '\n \n test_expect_success 'git branch -m q r/q should fail when r exists' '\n \tgit branch q &&\n \tgit branch r &&\n-\ttest_must_fail git branch -m q r/q\n+\tsilent test_must_fail git branch -m q r/q\n '\n \n test_expect_success 'git branch -M foo bar should fail when bar is checked out' '\n \tgit branch bar &&\n-\tgit checkout -b foo &&\n-\ttest_must_fail git branch -M bar foo\n+\tgit checkout -q -b foo &&\n+\tsilent test_must_fail git branch -M bar foo\n '\n \n test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '\n-\tgit checkout -b baz &&\n+\tgit checkout -q -b baz &&\n \tgit branch bam &&\n \tgit branch -M baz bam\n '\n \n test_expect_success 'git branch -M master should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch -M master\n '\n \n test_expect_success 'git branch -M master master should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch -M master master\n '\n \n test_expect_success 'git branch -M master2 master2 should work when master is checked out' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit branch master2 &&\n \tgit branch -M master2 master2\n '\n@@ -131,7 +138,7 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch\n test_expect_success 'git branch -v -d t should work' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\tgit branch -v -d t &&\n+\tquiet git branch -v -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n@@ -141,188 +148,198 @@ test_expect_success 'git branch -v -m t s should work' '\n \tgit branch -v -m t s &&\n \ttest_path_is_missing .git/refs/heads/t &&\n \ttest_path_is_file .git/refs/heads/s &&\n-\tgit branch -d s\n+\tquiet git branch -d s\n '\n \n test_expect_success 'git branch -m -d t s should fail' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\ttest_must_fail git branch -m -d t s &&\n-\tgit branch -d t &&\n+\tsilent test_must_fail git branch -m -d t s &&\n+\tquiet git branch -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n test_expect_success 'git branch --list -d t should fail' '\n \tgit branch t &&\n \ttest_path_is_file .git/refs/heads/t &&\n-\ttest_must_fail git branch --list -d t &&\n-\tgit branch -d t &&\n+\tsilent test_must_fail git branch --list -d t &&\n+\tquiet git branch -d t &&\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n-mv .git/config .git/config-saved\n-\n test_expect_success 'git branch -m q q2 without config should succeed' '\n+\tmv .git/config .git/config-saved &&\n+\ttest_when_finished mv .git/config-saved .git/config &&\n \tgit branch -m q q2 &&\n \tgit branch -m q2 q\n '\n \n-mv .git/config-saved .git/config\n-\n+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '\n git config branch.s/s.dummy Hello\n-\n-test_expect_success \\\n-    'git branch -m s/s s should work when s/t is deleted' \\\n-       'git branch -l s/s &&\n+\tgit branch -l s/s &&\n \ttest_path_is_file .git/logs/refs/heads/s/s &&\n         git branch -l s/t &&\n \ttest_path_is_file .git/logs/refs/heads/s/t &&\n-        git branch -d s/t &&\n+\tquiet git branch -d s/t &&\n         git branch -m s/s s &&\n-\ttest_path_is_file .git/logs/refs/heads/s'\n-\n-test_expect_success 'config information was renamed, too' \\\n-\t\"test $(git config branch.s.dummy) = Hello &&\n-\t test_must_fail git config branch.s/s/dummy\"\n+\ttest_path_is_file .git/logs/refs/heads/s\n+'\n \n-test_expect_success 'renaming a symref is not allowed' \\\n+test_expect_success 'config information was renamed, too' '\n+\ttest $(git config branch.s.dummy) = Hello &&\n+\tsilent test_must_fail git config branch.s/s/dummy\n '\n+\n+test_expect_success 'renaming a symref is not allowed' '\n \tgit symbolic-ref refs/heads/master2 refs/heads/master &&\n-\ttest_must_fail git branch -m master2 master3 &&\n-\tgit symbolic-ref refs/heads/master2 &&\n+\tsilent test_must_fail git branch -m master2 master3 &&\n+\tquiet git symbolic-ref refs/heads/master2 &&\n \ttest_path_is_file .git/refs/heads/master &&\n \ttest_path_is_missing .git/refs/heads/master3\n '\n \n-test_expect_success SYMLINKS \\\n-    'git branch -m u v should fail when the reflog for u is a symlink' '\n+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '\n      git branch -l u &&\n      mv .git/logs/refs/heads/u real-u &&\n      ln -s real-u .git/logs/refs/heads/u &&\n-     test_must_fail git branch -m u v\n+\tsilent test_must_fail git branch -m u v\n '\n \n-test_expect_success 'test tracking setup via --track' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup via --track' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my1 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track my1 local/master &&\n      test $(git config branch.my1.remote) = local &&\n-     test $(git config branch.my1.merge) = refs/heads/master'\n+\ttest $(git config branch.my1.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup (non-wildcard, matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&\n+test_expect_success 'test tracking setup (non-wildcard, matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch \\\n+\t\trefs/heads/master:refs/remotes/local/master &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my4 local/master &&\n+\tquiet git branch --track my4 local/master &&\n      test $(git config branch.my4.remote) = local &&\n-     test $(git config branch.my4.merge) = refs/heads/master'\n+\ttest $(git config branch.my4.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup (non-wildcard, not matching)' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup (non-wildcard, not matching)' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my5 local/master &&\n+\tquiet git branch --track my5 local/master &&\n      ! test \"$(git config branch.my5.remote)\" = local &&\n-     ! test \"$(git config branch.my5.merge)\" = refs/heads/master'\n+\t! test \"$(git config branch.my5.merge)\" = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup via config' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'test tracking setup via config' '\n+\tgit config branch.autosetupmerge true &&\n      git config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch my3 local/master &&\n+\tquiet git branch my3 local/master &&\n      test $(git config branch.my3.remote) = local &&\n-     test $(git config branch.my3.merge) = refs/heads/master'\n+\ttest $(git config branch.my3.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test overriding tracking setup via --no-track' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'test overriding tracking setup via --no-track' '\n+\tgit config branch.autosetupmerge true &&\n      git config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch --no-track my2 local/master &&\n      git config branch.autosetupmerge false &&\n      ! test \"$(git config branch.my2.remote)\" = local &&\n-     ! test \"$(git config branch.my2.merge)\" = refs/heads/master'\n+\t! test \"$(git config branch.my2.merge)\" = refs/heads/master\n+'\n \n-test_expect_success 'no tracking without .fetch entries' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'no tracking without .fetch entries' '\n+\tgit config branch.autosetupmerge true &&\n      git branch my6 s &&\n      git config branch.automsetupmerge false &&\n      test -z \"$(git config branch.my6.remote)\" &&\n-     test -z \"$(git config branch.my6.merge)\"'\n+\ttest -z \"$(git config branch.my6.merge)\"\n+'\n \n-test_expect_success 'test tracking setup via --track but deeper' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup via --track but deeper' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n-     git branch --track my7 local/o/o &&\n+\tquiet git branch --track my7 local/o/o &&\n      test \"$(git config branch.my7.remote)\" = local &&\n-     test \"$(git config branch.my7.merge)\" = refs/heads/o/o'\n+\ttest \"$(git config branch.my7.merge)\" = refs/heads/o/o\n+'\n \n-test_expect_success 'test deleting branch deletes branch config' \\\n-    'git branch -d my7 &&\n+test_expect_success 'test deleting branch deletes branch config' '\n+\tquiet git branch -d my7 &&\n      test -z \"$(git config branch.my7.remote)\" &&\n-     test -z \"$(git config branch.my7.merge)\"'\n+\ttest -z \"$(git config branch.my7.merge)\"\n+'\n \n-test_expect_success 'test deleting branch without config' \\\n-    'git branch my7 s &&\n+test_expect_success 'test deleting branch without config' '\n+\tgit branch my7 s &&\n      sha1=$(git rev-parse my7 | cut -c 1-7) &&\n      echo \"Deleted branch my7 (was $sha1).\" >expect &&\n      git branch -d my7 >actual 2>&1 &&\n-     test_i18ncmp expect actual'\n+\ttest_i18ncmp expect actual\n+'\n \n-test_expect_success 'test --track without .fetch entries' \\\n-    'git branch --track my8 &&\n+test_expect_success 'test --track without .fetch entries' '\n+\tquiet git branch --track my8 &&\n      test \"$(git config branch.my8.remote)\" &&\n-     test \"$(git config branch.my8.merge)\"'\n+\ttest \"$(git config branch.my8.merge)\"\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/autosetupmerge=always' \\\n-    'git config branch.autosetupmerge always &&\n+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '\n+\tgit config branch.autosetupmerge always &&\n      git branch my9 HEAD^ &&\n-     git config branch.autosetupmerge false'\n+\tgit config branch.autosetupmerge false\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/--track causes failure' \\\n-    'test_must_fail git branch --track my10 HEAD^'\n+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '\n+\tsilent test_must_fail git branch --track my10 HEAD^\n+'\n \n-test_expect_success \\\n-    'branch from tag w/--track causes failure' \\\n-    'git tag foobar &&\n-     test_must_fail git branch --track my11 foobar'\n+test_expect_success 'branch from tag w/--track causes failure' '\n+\tgit tag foobar &&\n+\tsilent test_must_fail git branch --track my11 foobar\n+'\n \n # Keep this test last, as it changes the current branch\n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '\n+\tid=\"$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>\"\n+\tdate=\"1117150200 +0000\"\n+\tmsg=\"branch: Created from master\"\n+\there >expect <<-EOF\n+\t\t$_z40 $HEAD $id $date\\t$msg\n EOF\n-test_expect_success \\\n-    'git checkout -b g/h/i -l should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git checkout -b g/h/i -l master &&\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\t\tgit checkout -q -b g/h/i -l master &&\n \t test_path_is_file .git/refs/heads/g/h/i &&\n \t test_path_is_file .git/logs/refs/heads/g/h/i &&\n-\t test_cmp expect .git/logs/refs/heads/g/h/i'\n+\ttest_cmp expect .git/logs/refs/heads/g/h/i\n+'\n \n test_expect_success 'checkout -b makes reflog by default' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit config --unset core.logAllRefUpdates &&\n-\tgit checkout -b alpha &&\n-\tgit rev-parse --verify alpha@{0}\n+\tgit checkout -q -b alpha &&\n+\tquiet git rev-parse --verify alpha@{0}\n '\n \n test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \tgit config core.logAllRefUpdates false &&\n-\tgit checkout -b beta &&\n-\ttest_must_fail git rev-parse --verify beta@{0}\n+\tgit checkout -q -b beta &&\n+\tsilent test_must_fail git rev-parse --verify beta@{0}\n '\n \n test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '\n-\tgit checkout master &&\n-\tgit checkout -lb gamma &&\n+\tgit checkout -q master &&\n+\tgit checkout -q -lb gamma &&\n \tgit config --unset core.logAllRefUpdates &&\n-\tgit rev-parse --verify gamma@{0}\n+\tquiet git rev-parse --verify gamma@{0}\n '\n \n test_expect_success 'avoid ambiguous track' '\n@@ -331,7 +348,7 @@ test_expect_success 'avoid ambiguous track' '\n \tgit config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&\n \tgit config remote.ambi2.url lilili &&\n \tgit config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&\n-\tgit branch all1 master &&\n+\tsilent git branch all1 master &&\n \ttest -z \"$(git config branch.all1.merge)\"\n '\n \n@@ -339,9 +356,9 @@ test_expect_success 'autosetuprebase local on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase local &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase &&\n-\tgit branch --track myr1 mybase &&\n+\tquiet git branch --track myr1 mybase &&\n \ttest \"$(git config branch.myr1.remote)\" = . &&\n \ttest \"$(git config branch.myr1.merge)\" = refs/heads/mybase &&\n \ttest \"$(git config branch.myr1.rebase)\" = true\n@@ -351,9 +368,9 @@ test_expect_success 'autosetuprebase always on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase always &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase2 &&\n-\tgit branch --track myr2 mybase &&\n+\tquiet git branch --track myr2 mybase &&\n \ttest \"$(git config branch.myr2.remote)\" = . &&\n \ttest \"$(git config branch.myr2.merge)\" = refs/heads/mybase &&\n \ttest \"$(git config branch.myr2.rebase)\" = true\n@@ -363,9 +380,9 @@ test_expect_success 'autosetuprebase remote on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase3 &&\n-\tgit branch --track myr3 mybase2 &&\n+\tquiet git branch --track myr3 mybase2 &&\n \ttest \"$(git config branch.myr3.remote)\" = . &&\n \ttest \"$(git config branch.myr3.merge)\" = refs/heads/mybase2 &&\n \t! test \"$(git config branch.myr3.rebase)\" = true\n@@ -375,9 +392,9 @@ test_expect_success 'autosetuprebase never on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase never &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase4 &&\n-\tgit branch --track myr4 mybase2 &&\n+\tquiet git branch --track myr4 mybase2 &&\n \ttest \"$(git config branch.myr4.remote)\" = . &&\n \ttest \"$(git config branch.myr4.merge)\" = refs/heads/mybase2 &&\n \t! test \"$(git config branch.myr4.rebase)\" = true\n@@ -387,8 +404,8 @@ test_expect_success 'autosetuprebase local on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase local &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr5 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr5 local/master &&\n \ttest \"$(git config branch.myr5.remote)\" = local &&\n \ttest \"$(git config branch.myr5.merge)\" = refs/heads/master &&\n \t! test \"$(git config branch.myr5.rebase)\" = true\n@@ -398,8 +415,8 @@ test_expect_success 'autosetuprebase never on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase never &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr6 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr6 local/master &&\n \ttest \"$(git config branch.myr6.remote)\" = local &&\n \ttest \"$(git config branch.myr6.merge)\" = refs/heads/master &&\n \t! test \"$(git config branch.myr6.rebase)\" = true\n@@ -409,8 +426,8 @@ test_expect_success 'autosetuprebase remote on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr7 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr7 local/master &&\n \ttest \"$(git config branch.myr7.remote)\" = local &&\n \ttest \"$(git config branch.myr7.merge)\" = refs/heads/master &&\n \ttest \"$(git config branch.myr7.rebase)\" = true\n@@ -420,8 +437,8 @@ test_expect_success 'autosetuprebase always on a tracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n \tgit config branch.autosetuprebase remote &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr8 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr8 local/master &&\n \ttest \"$(git config branch.myr8.remote)\" = local &&\n \ttest \"$(git config branch.myr8.merge)\" = refs/heads/master &&\n \ttest \"$(git config branch.myr8.rebase)\" = true\n@@ -431,8 +448,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '\n \tgit config --unset branch.autosetuprebase &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --track myr9 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --track myr9 local/master &&\n \ttest \"$(git config branch.myr9.remote)\" = local &&\n \ttest \"$(git config branch.myr9.merge)\" = refs/heads/master &&\n \ttest \"z$(git config branch.myr9.rebase)\" = z\n@@ -441,9 +458,9 @@ test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '\n test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n+\t(git show-ref -q refs/remotes/local/o || git fetch -q local) &&\n \tgit branch mybase10 &&\n-\tgit branch --track myr10 mybase2 &&\n+\tquiet git branch --track myr10 mybase2 &&\n \ttest \"$(git config branch.myr10.remote)\" = . &&\n \ttest \"$(git config branch.myr10.merge)\" = refs/heads/mybase2 &&\n \ttest \"z$(git config branch.myr10.rebase)\" = z\n@@ -452,8 +469,8 @@ test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '\n test_expect_success 'autosetuprebase unconfigured on untracked local branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr11 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr11 mybase2 &&\n \ttest \"z$(git config branch.myr11.remote)\" = z &&\n \ttest \"z$(git config branch.myr11.merge)\" = z &&\n \ttest \"z$(git config branch.myr11.rebase)\" = z\n@@ -462,8 +479,8 @@ test_expect_success 'autosetuprebase unconfigured on untracked local branch' '\n test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr12 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr12 local/master &&\n \ttest \"z$(git config branch.myr12.remote)\" = z &&\n \ttest \"z$(git config branch.myr12.merge)\" = z &&\n \ttest \"z$(git config branch.myr12.rebase)\" = z\n@@ -473,8 +490,8 @@ test_expect_success 'autosetuprebase never on an untracked local branch' '\n \tgit config branch.autosetuprebase never &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr13 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr13 mybase2 &&\n \ttest \"z$(git config branch.myr13.remote)\" = z &&\n \ttest \"z$(git config branch.myr13.merge)\" = z &&\n \ttest \"z$(git config branch.myr13.rebase)\" = z\n@@ -484,8 +501,8 @@ test_expect_success 'autosetuprebase local on an untracked local branch' '\n \tgit config branch.autosetuprebase local &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr14 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr14 mybase2 &&\n \ttest \"z$(git config branch.myr14.remote)\" = z &&\n \ttest \"z$(git config branch.myr14.merge)\" = z &&\n \ttest \"z$(git config branch.myr14.rebase)\" = z\n@@ -495,8 +512,8 @@ test_expect_success 'autosetuprebase remote on an untracked local branch' '\n \tgit config branch.autosetuprebase remote &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr15 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr15 mybase2 &&\n \ttest \"z$(git config branch.myr15.remote)\" = z &&\n \ttest \"z$(git config branch.myr15.merge)\" = z &&\n \ttest \"z$(git config branch.myr15.rebase)\" = z\n@@ -506,8 +523,8 @@ test_expect_success 'autosetuprebase always on an untracked local branch' '\n \tgit config branch.autosetuprebase always &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr16 mybase2 &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr16 mybase2 &&\n \ttest \"z$(git config branch.myr16.remote)\" = z &&\n \ttest \"z$(git config branch.myr16.merge)\" = z &&\n \ttest \"z$(git config branch.myr16.rebase)\" = z\n@@ -517,8 +534,8 @@ test_expect_success 'autosetuprebase never on an untracked remote branch' '\n \tgit config branch.autosetuprebase never &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr17 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr17 local/master &&\n \ttest \"z$(git config branch.myr17.remote)\" = z &&\n \ttest \"z$(git config branch.myr17.merge)\" = z &&\n \ttest \"z$(git config branch.myr17.rebase)\" = z\n@@ -528,8 +545,8 @@ test_expect_success 'autosetuprebase local on an untracked remote branch' '\n \tgit config branch.autosetuprebase local &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr18 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr18 local/master &&\n \ttest \"z$(git config branch.myr18.remote)\" = z &&\n \ttest \"z$(git config branch.myr18.merge)\" = z &&\n \ttest \"z$(git config branch.myr18.rebase)\" = z\n@@ -539,8 +556,8 @@ test_expect_success 'autosetuprebase remote on an untracked remote branch' '\n \tgit config branch.autosetuprebase remote &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr19 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr19 local/master &&\n \ttest \"z$(git config branch.myr19.remote)\" = z &&\n \ttest \"z$(git config branch.myr19.merge)\" = z &&\n \ttest \"z$(git config branch.myr19.rebase)\" = z\n@@ -550,8 +567,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '\n \tgit config branch.autosetuprebase always &&\n \tgit config remote.local.url . &&\n \tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n-\tgit branch --no-track myr20 local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch -q local) &&\n+\tquiet git branch --no-track myr20 local/master &&\n \ttest \"z$(git config branch.myr20.remote)\" = z &&\n \ttest \"z$(git config branch.myr20.merge)\" = z &&\n \ttest \"z$(git config branch.myr20.rebase)\" = z\n@@ -559,8 +576,8 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '\n \n test_expect_success 'autosetuprebase always on detached HEAD' '\n \tgit config branch.autosetupmerge always &&\n-\ttest_when_finished git checkout master &&\n-\tgit checkout HEAD^0 &&\n+\ttest_when_finished git checkout -q master &&\n+\tgit checkout -q HEAD^0 &&\n \tgit branch my11 &&\n \ttest -z \"$(git config branch.my11.remote)\" &&\n \ttest -z \"$(git config branch.my11.merge)\"\n@@ -568,20 +585,20 @@ test_expect_success 'autosetuprebase always on detached HEAD' '\n \n test_expect_success 'detect misconfigured autosetuprebase (bad value)' '\n \tgit config branch.autosetuprebase garbage &&\n-\ttest_must_fail git branch\n+\tsilent test_must_fail git branch\n '\n \n test_expect_success 'detect misconfigured autosetuprebase (no value)' '\n \tgit config --unset branch.autosetuprebase &&\n \techo \"[branch] autosetuprebase\" >> .git/config &&\n-\ttest_must_fail git branch &&\n+\tsilent test_must_fail git branch &&\n \tgit config --unset branch.autosetuprebase\n '\n \n test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '\n-\tgit checkout my9 &&\n+\tgit checkout -q my9 &&\n \tgit config --unset branch.my8.merge &&\n-\ttest_must_fail git branch -d my8\n+\tsilent test_must_fail git branch -d my8\n '\n \n test_expect_success 'attempt to delete a branch merged to its base' '\n@@ -589,32 +606,30 @@ test_expect_success 'attempt to delete a branch merged to its base' '\n \t# we would not have allowed deleting my8 that is not merged\n \t# to my9, but it is set to track master that already has my8\n \tgit config branch.my8.merge refs/heads/master &&\n-\tgit branch -d my8\n+\tsilent git branch -d my8\n '\n \n test_expect_success 'attempt to delete a branch merged to its base' '\n-\tgit checkout master &&\n+\tgit checkout -q master &&\n \techo Third >>A &&\n-\tgit commit -m \"Third commit\" A &&\n-\tgit branch -t my10 my9 &&\n-\tgit branch -f my10 HEAD^ &&\n+\tgit commit -q -m \"Third commit\" A &&\n+\tquiet git branch -t my10 my9 &&\n+\tquiet git branch -f my10 HEAD^ &&\n \t# we are on master which is at the third commit, and my10\n \t# is behind us, so traditionally we would have allowed deleting\n \t# it; but my10 is set to track my9 that is further behind.\n-\ttest_must_fail git branch -d my10\n+\tsilent test_must_fail git branch -d my10\n '\n \n test_expect_success 'use set-upstream on the current branch' '\n-\tgit checkout master &&\n-\tgit --bare init myupstream.git &&\n-\tgit push myupstream.git master:refs/heads/frotz &&\n+\tgit checkout -q master &&\n+\tgit --bare init -q myupstream.git &&\n+\tgit push -q myupstream.git master:refs/heads/frotz &&\n \tgit remote add origin myupstream.git &&\n-\tgit fetch &&\n-\tgit branch --set-upstream master origin/frotz &&\n-\n+\tgit fetch -q &&\n+\tquiet git branch --set-upstream master origin/frotz &&\n \ttest \"z$(git config branch.master.remote)\" = \"zorigin\" &&\n \ttest \"z$(git config branch.master.merge)\" = \"zrefs/heads/frotz\"\n-\n '\n \n test_expect_success 'use --edit-description' '\n@@ -637,7 +652,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '\n \t(\n \t\tEDITOR=./editor &&\n \t\texport EDITOR &&\n-\t\ttest_must_fail git branch --edit-description no-such-branch\n+\t\tsilent test_must_fail git branch --edit-description no-such-branch\n \t)\n '\n \n@@ -645,11 +660,11 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '\n \twrite_script editor <<-\\EOF &&\n \t\techo \"New contents\" >\"$1\"\n \tEOF\n-\tgit checkout --orphan unborn &&\n+\tgit checkout -q --orphan unborn &&\n \t(\n \t\tEDITOR=./editor &&\n \t\texport EDITOR &&\n-\t\ttest_must_fail git branch --edit-description\n+\t\tsilent test_must_fail git branch --edit-description\n \t)\n '\n \n-- \n1.7.8\n"},{"id":"185768","messageId":"1330566326-26075-10-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH-w 104/105] t0040 (parse-options): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:25Z","receivedAt":"2012-03-01T01:45:25Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t0040-parse-options.sh |  283 +++++++++++++++++++++-------------------------\n 1 files changed, 127 insertions(+), 156 deletions(-)\n\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex a1e4616..6416d77 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -5,55 +5,60 @@\n \n test_description='our own option parser'\n \n-. ./test-lib.sh\n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n \n-cat > expect << EOF\n-usage: test-parse-options <options>\n-\n-    -b, --boolean         get a boolean\n-    -4, --or4             bitwise-or boolean with ...0100\n-    --neg-or4             same as --no-or4\n-\n-    -i, --integer <n>     get a integer\n-    -j <n>                get a integer, too\n-    --set23               set integer to 23\n-    -t <time>             get timestamp of <time>\n-    -L, --length <str>    get length of <str>\n-    -F, --file <file>     set file to <file>\n-\n-String options\n-    -s, --string <string>\n-                          get a string\n-    --string2 <str>       get another string\n-    --st <st>             get another string (pervert ordering)\n-    -o <str>              get another string\n-    --default-string      set string to default\n-    --list <str>          add str to list\n-\n-Magic arguments\n-    --quux                means --quux\n-    -NUM                  set integer to NUM\n-    +                     same as -b\n-    --ambiguous           positive ambiguity\n-    --no-ambiguous        negative ambiguity\n-\n-Standard options\n-    --abbrev[=<n>]        use <n> digits to display SHA-1s\n-    -v, --verbose         be verbose\n-    -n, --dry-run         dry run\n-    -q, --quiet           be quiet\n+. ./test-lib.sh\n \n-EOF\n+silent () { \"$@\" >/dev/null 2>&1; }\n \n test_expect_success 'test help' '\n-\ttest_must_fail test-parse-options -h > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n-'\n+\tsed -e \"s/^|//\" >expect <<-\\EOF &&\n+\t\t|usage: test-parse-options <options>\n+\n+\t\t|    -b, --boolean         get a boolean\n+\t\t|    -4, --or4             bitwise-or boolean with ...0100\n+\t\t|    --neg-or4             same as --no-or4\n+\n+\t\t|    -i, --integer <n>     get a integer\n+\t\t|    -j <n>                get a integer, too\n+\t\t|    --set23               set integer to 23\n+\t\t|    -t <time>             get timestamp of <time>\n+\t\t|    -L, --length <str>    get length of <str>\n+\t\t|    -F, --file <file>     set file to <file>\n+\n+\t\t|String options\n+\t\t|    -s, --string <string>\n+\t\t|                          get a string\n+\t\t|    --string2 <str>       get another string\n+\t\t|    --st <st>             get another string (pervert ordering)\n+\t\t|    -o <str>              get another string\n+\t\t|    --default-string      set string to default\n+\t\t|    --list <str>          add str to list\n+\n+\t\t|Magic arguments\n+\t\t|    --quux                means --quux\n+\t\t|    -NUM                  set integer to NUM\n+\t\t|    +                     same as -b\n+\t\t|    --ambiguous           positive ambiguity\n+\t\t|    --no-ambiguous        negative ambiguity\n+\n+\t\t|Standard options\n+\t\t|    --abbrev[=<n>]        use <n> digits to display SHA-1s\n+\t\t|    -v, --verbose         be verbose\n+\t\t|    -n, --dry-run         dry run\n+\t\t|    -q, --quiet           be quiet\n \n-mv expect expect.err\n+\tEOF\n+\tcp expect expect.err\n+\ttest_must_fail test-parse-options -h 2>err | test_cmp expect - &&\n+\ttest ! -s err\n+'\n \n-cat > expect << EOF\n+test_expect_success 'short options' '\n+\tcat >expect <<-\\EOF &&\n boolean: 2\n integer: 1729\n timestamp: 0\n@@ -64,15 +69,13 @@ quiet: no\n dry run: yes\n file: prefix/my.file\n EOF\n-\n-test_expect_success 'short options' '\n-\ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \\\n-\t> output 2> output.err &&\n-\ttest_cmp expect output &&\n-\ttest ! -s output.err\n+\ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect << EOF\n+test_expect_success 'long options' '\n+\tcat >expect <<-\\EOF &&\n boolean: 2\n integer: 1729\n timestamp: 0\n@@ -83,25 +86,20 @@ quiet: no\n dry run: no\n file: prefix/fi.le\n EOF\n-\n-test_expect_success 'long options' '\n \ttest-parse-options --boolean --integer 1729 --boolean --string2=321 \\\n \t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\\\n-\t\t--obsolete > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\t\t--obsolete 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'missing required value' '\n-\ttest-parse-options -s;\n-\ttest $? = 129 &&\n-\ttest-parse-options --string;\n-\ttest $? = 129 &&\n-\ttest-parse-options --file;\n-\ttest $? = 129\n+\tsilent test_expect_code 129 test-parse-options -s &&\n+\tsilent test_expect_code 129 test-parse-options --string &&\n+\tsilent test_expect_code 129 test-parse-options --file\n '\n \n-cat > expect << EOF\n+test_expect_success 'intermingled arguments' '\n+\tcat >expect <<-\\EOF &&\n boolean: 1\n integer: 13\n timestamp: 0\n@@ -115,15 +113,13 @@ arg 00: a1\n arg 01: b1\n arg 02: --boolean\n EOF\n-\n-test_expect_success 'intermingled arguments' '\n \ttest-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \\\n-\t\t> output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\t\t2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect << EOF\n+test_expect_success 'unambiguously abbreviated option' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 2\n timestamp: 0\n@@ -134,25 +130,22 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'unambiguously abbreviated option' '\n-\ttest-parse-options --int 2 --boolean --no-bo > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --int 2 --boolean --no-bo 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'unambiguously abbreviated option with \"=\"' '\n-\ttest-parse-options --int=2 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --int=2 2>err | test_cmp expect -&&\n+\ttest ! -s err\n '\n \n test_expect_success 'ambiguously abbreviated option' '\n-\ttest-parse-options --strin 123;\n-\ttest $? = 129\n+\tsilent test_expect_code 129 test-parse-options --strin 123\n '\n \n-cat > expect << EOF\n+test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -163,24 +156,21 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n-\ttest-parse-options --st 123 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --st 123 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > typo.err << EOF\n-error: did you mean \\`--boolean\\` (with two dashes ?)\n-EOF\n-\n test_expect_success 'detect possible typos' '\n-\ttest_must_fail test-parse-options -boolean > output 2> output.err &&\n-\ttest ! -s output &&\n-\ttest_cmp typo.err output.err\n+\tcat >typo.err <<-\\EOF &&\n+\t\terror: did you mean `--boolean` (with two dashes ?)\n+\tEOF\n+\t>expect\n+\ttest_must_fail test-parse-options -boolean 2>err | test_cmp expect - &&\n+\ttest_cmp typo.err err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'keep some options as arguments' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -192,14 +182,12 @@ dry run: no\n file: (not set)\n arg 00: --quux\n EOF\n-\n-test_expect_success 'keep some options as arguments' '\n-\ttest-parse-options --quux > output 2> output.err &&\n-        test ! -s output.err &&\n-        test_cmp expect output\n+\ttest-parse-options --quux 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 1\n@@ -211,15 +199,13 @@ dry run: no\n file: (not set)\n arg 00: foo\n EOF\n-\n-test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n-\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" --default-string \\\n-\t\tfoo -q > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" \\\n+\t\t--default-string foo -q 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n+\tcat >expect <<-\\EOF &&\n Callback: \"four\", 0\n boolean: 5\n integer: 4\n@@ -231,24 +217,21 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n-\ttest-parse-options --length=four -b -4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --length=four -b -4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_CALLBACK() and callback errors work' '\n+\tcat >expect <<-\\EOF &&\n Callback: \"not set\", 1\n EOF\n-\n-test_expect_success 'OPT_CALLBACK() and callback errors work' '\n-\ttest_must_fail test-parse-options --no-length > output 2> output.err &&\n-\ttest_cmp expect output &&\n-\ttest_cmp expect.err output.err\n+\ttest_must_fail test-parse-options --no-length 2>err |\n+\t\ttest_cmp expect - &&\n+\ttest_cmp expect.err err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n+\tcat >expect <<-\\EOF &&\n boolean: 1\n integer: 23\n timestamp: 0\n@@ -259,20 +242,17 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --set23 -bbbbb --no-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --set23 -bbbbb --neg-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_BIT() works' '\n+\tcat >expect <<-\\EOF &&\n boolean: 6\n integer: 0\n timestamp: 0\n@@ -283,26 +263,23 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_BIT() works' '\n-\ttest-parse-options -bb --or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options -bb --or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_NEGBIT() works' '\n-\ttest-parse-options -bb --no-neg-or4 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options -bb --no-neg-or4 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '\n-\ttest-parse-options + + + + + + > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options + + + + + + 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat > expect <<EOF\n+\n+test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 12345\n timestamp: 0\n@@ -313,14 +290,12 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n-\ttest-parse-options -12345 > output 2> output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options -12345 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat >expect <<EOF\n+test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -331,27 +306,23 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n-\ttest-parse-options --no-ambig >output 2>output.err &&\n-\ttest ! -s output.err &&\n-\ttest_cmp expect output\n+\ttest-parse-options --no-ambig 2>err | test_cmp expect - &&\n+\ttest ! -s err\n '\n \n-cat >>expect <<'EOF'\n+test_expect_success '--list keeps list of strings' '\n+\tcat >>expect <<-\\EOF &&\n list: foo\n list: bar\n list: baz\n EOF\n-test_expect_success '--list keeps list of strings' '\n-\ttest-parse-options --list foo --list=bar --list=baz >output &&\n-\ttest_cmp expect output\n+\ttest-parse-options --list foo --list=bar --list=baz | test_cmp expect -\n '\n \n test_expect_success '--no-list resets list' '\n-\ttest-parse-options --list=other --list=irrelevant --list=options \\\n-\t\t--no-list --list=foo --list=bar --list=baz >output &&\n-\ttest_cmp expect output\n+\ttest-parse-options --list=other --list=irrelevant \\\n+\t\t--list=options --no-list --list=foo --list=bar --list=baz |\n+\t\ttest_cmp expect -\n '\n \n test_done\n-- \n1.7.8\n"},{"id":"185771","messageId":"1330566326-26075-11-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCH-w 105/105] t7004 (tag): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T01:45:26Z","receivedAt":"2012-03-01T01:45:26Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks of < 80 cols\n- Redirect unwanted output\n- Use a \"here\" filter for expect generation\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t7004-tag.sh | 1400 ++++++++++++++++++++++++++------------------------------\n 1 files changed, 643 insertions(+), 757 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f8c247a..6704046 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -7,15 +7,37 @@ test_description='git tag\n \n Tests for operations with tags.'\n \n+if ! test -r test-lib.sh ; then\n+\t(cd ${0%/*} && ./${0##*/} $@)\n+\texit $?\n+fi\n+\n . ./test-lib.sh\n . \"$TEST_DIRECTORY\"/lib-gpg.sh\n \n-# creating and listing lightweight tags:\n+quiet () { \"$@\" >/dev/null; }\n+silent () { \"$@\" >/dev/null 2>&1; }\n+here () { sed 's/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g' $@; }\n \n tag_exists () {\n \tgit show-ref --quiet --verify refs/tags/\"$1\"\n }\n \n+gen_header () { # name, object, type, time\n+\tcat <<-EOF &&\n+\t\tobject $2\n+\t\ttype $3\n+\t\ttag $1\n+\t\ttagger C O Mitter <committer@example.com> $4 -0700\n+\n+\tEOF\n+\there\n+}\n+\n+get_header () {\n+\tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n+}\n+\n # todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success 'listing all tags in an empty tree should succeed' '\n \tgit tag -l &&\n@@ -27,36 +49,38 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '\n \ttest `git tag | wc -l` -eq 0\n '\n \n-test_expect_success 'looking for a tag in an empty tree should fail' \\\n-\t'! (tag_exists mytag)'\n+test_expect_success 'looking for a tag in an empty tree should fail' '\n+\t! tag_exists mytag\n+'\n \n test_expect_success 'creating a tag in an empty tree should fail' '\n-\ttest_must_fail git tag mynotag &&\n+\tsilent test_must_fail git tag mynotag &&\n \t! tag_exists mynotag\n '\n \n test_expect_success 'creating a tag for HEAD in an empty tree should fail' '\n-\ttest_must_fail git tag mytaghead HEAD &&\n+\tsilent test_must_fail git tag mytaghead HEAD &&\n \t! tag_exists mytaghead\n '\n \n test_expect_success 'creating a tag for an unknown revision should fail' '\n-\ttest_must_fail git tag mytagnorev aaaaaaaaaaa &&\n+\tsilent test_must_fail git tag mytagnorev aaaaaaaaaaa &&\n \t! tag_exists mytagnorev\n '\n \n-# commit used in the tests, test_tick is also called here to freeze the date:\n test_expect_success 'creating a tag using default HEAD should succeed' '\n+\t# commit used in the tests\n+\t# test_tick is also called here to freeze the date:\n \ttest_tick &&\n-\techo foo >foo &&\n+\techo >foo foo &&\n \tgit add foo &&\n-\tgit commit -m Foo &&\n+\tgit commit -q -m Foo &&\n \tgit tag mytag\n '\n \n test_expect_success 'listing all tags if one exists should succeed' '\n-\tgit tag -l &&\n-\tgit tag\n+\tquiet git tag -l &&\n+\tquiet git tag\n '\n \n test_expect_success 'listing all tags if one exists should output that tag' '\n@@ -66,36 +90,36 @@ test_expect_success 'listing all tags if one exists should output that tag' '\n \n # pattern matching:\n \n-test_expect_success 'listing a tag using a matching pattern should succeed' \\\n-\t'git tag -l mytag'\n+test_expect_success 'listing a tag using a matching pattern should succeed' '\n+\tquiet git tag -l mytag\n+'\n \n-test_expect_success \\\n-\t'listing a tag using a matching pattern should output that tag' \\\n-\t'test `git tag -l mytag` = mytag'\n+test_expect_success 'listing a tag using a matching pattern should output that tag' '\n+\ttest `git tag -l mytag` = mytag\n+'\n \n # todo: git tag -l now returns always zero, when fixed, change this test\n-test_expect_success \\\n-\t'listing tags using a non-matching pattern should suceed' \\\n-\t'git tag -l xxx'\n+test_expect_success 'listing tags using a non-matching pattern should suceed' '\n+\tgit tag -l xxx\n+'\n \n-test_expect_success \\\n-\t'listing tags using a non-matching pattern should output nothing' \\\n-\t'test `git tag -l xxx | wc -l` -eq 0'\n+test_expect_success 'listing tags using a non-matching pattern should output nothing' '\n+\ttest `git tag -l xxx | wc -l` -eq 0\n+'\n \n # special cases for creating tags:\n \n-test_expect_success \\\n-\t'trying to create a tag with the name of one existing should fail' \\\n-\t'test_must_fail git tag mytag'\n+test_expect_success 'trying to create a tag with the name of one existing should fail' '\n+\tsilent test_must_fail git tag mytag\n+'\n \n-test_expect_success \\\n-\t'trying to create a tag with a non-valid name should fail' '\n+test_expect_success 'trying to create a tag with a non-valid name should fail' '\n \ttest `git tag -l | wc -l` -eq 1 &&\n-\ttest_must_fail git tag \"\" &&\n-\ttest_must_fail git tag .othertag &&\n-\ttest_must_fail git tag \"other tag\" &&\n-\ttest_must_fail git tag \"othertag^\" &&\n-\ttest_must_fail git tag \"other~tag\" &&\n+\tsilent test_must_fail git tag \"\" &&\n+\tsilent test_must_fail git tag .othertag &&\n+\tsilent test_must_fail git tag \"other tag\" &&\n+\tsilent test_must_fail git tag \"othertag^\" &&\n+\tsilent test_must_fail git tag \"other~tag\" &&\n \ttest `git tag -l | wc -l` -eq 1\n '\n \n@@ -108,51 +132,49 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '\n \n test_expect_success 'trying to delete an unknown tag should fail' '\n \t! tag_exists unknown-tag &&\n-\ttest_must_fail git tag -d unknown-tag\n+\tsilent test_must_fail git tag -d unknown-tag\n '\n \n-cat >expect <<EOF\n+test_expect_success 'trying to delete tags without params should succeed and do nothing' '\n+\tcat >expect <<-EOF &&\n myhead\n mytag\n EOF\n-test_expect_success \\\n-\t'trying to delete tags without params should succeed and do nothing' '\n-\tgit tag -l > actual && test_cmp expect actual &&\n+\tgit tag -l | test_cmp expect - &&\n \tgit tag -d &&\n-\tgit tag -l > actual && test_cmp expect actual\n+\tgit tag -l | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'deleting two existing tags in one command should succeed' '\n+test_expect_success 'deleting two existing tags in one command should succeed' '\n \ttag_exists mytag &&\n \ttag_exists myhead &&\n-\tgit tag -d mytag myhead &&\n+\tquiet git tag -d mytag myhead &&\n \t! tag_exists mytag &&\n \t! tag_exists myhead\n '\n \n-test_expect_success \\\n-\t'creating a tag with the name of another deleted one should succeed' '\n+test_expect_success 'creating a tag with the name of another deleted one should succeed' '\n \t! tag_exists mytag &&\n \tgit tag mytag &&\n \ttag_exists mytag\n '\n \n-test_expect_success \\\n-\t'trying to delete two tags, existing and not, should fail in the 2nd' '\n+test_expect_success 'trying to delete two tags, existing and not, should fail in the 2nd' '\n \ttag_exists mytag &&\n \t! tag_exists myhead &&\n-\ttest_must_fail git tag -d mytag anothertag &&\n+\tsilent test_must_fail git tag -d mytag anothertag &&\n \t! tag_exists mytag &&\n \t! tag_exists myhead\n '\n \n-test_expect_success 'trying to delete an already deleted tag should fail' \\\n-\t'test_must_fail git tag -d mytag'\n+test_expect_success 'trying to delete an already deleted tag should fail' '\n+\tsilent test_must_fail git tag -d mytag\n+'\n \n # listing various tags with pattern matching:\n \n-cat >expect <<EOF\n+test_expect_success 'listing all tags should print them ordered' '\n+\tcat >expect <<-EOF &&\n a1\n aa1\n cba\n@@ -163,7 +185,6 @@ v1.0\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success 'listing all tags should print them ordered' '\n \tgit tag v1.0.1 &&\n \tgit tag t211 &&\n \tgit tag aa1 &&\n@@ -173,217 +194,189 @@ test_expect_success 'listing all tags should print them ordered' '\n \tgit tag a1 &&\n \tgit tag v1.0 &&\n \tgit tag t210 &&\n-\tgit tag -l > actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l | test_cmp expect - &&\n+\tgit tag | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags with substring as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n a1\n aa1\n cba\n EOF\n-test_expect_success \\\n-\t'listing tags with substring as pattern must print those matching' '\n-\trm *a* &&\n-\tgit tag -l \"*a*\" > current &&\n-\ttest_cmp expect current\n+\tgit tag -l \"*a*\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags with a suffix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0.1\n EOF\n-test_expect_success \\\n-\t'listing tags with a suffix as pattern must print those matching' '\n-\tgit tag -l \"*.1\" > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"*.1\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags with a prefix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n t210\n t211\n EOF\n-test_expect_success \\\n-\t'listing tags with a prefix as pattern must print those matching' '\n-\tgit tag -l \"t21*\" > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"t21*\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n a1\n EOF\n-test_expect_success \\\n-\t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l a1 > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l a1 | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n v1.0\n EOF\n-test_expect_success \\\n-\t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l v1.0 > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l v1.0 | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags with ? in the pattern should print those matching' '\n+\tcat >expect <<-EOF &&\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success \\\n-\t'listing tags with ? in the pattern should print those matching' '\n-\tgit tag -l \"v1.?.?\" > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"v1.?.?\" | test_cmp expect -\n '\n \n->expect\n-test_expect_success \\\n-\t'listing tags using v.* should print nothing because none have v.' '\n-\tgit tag -l \"v.*\" > actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'listing tags using v.* should print nothing because none have v.' '\n+\t>expect &&\n+\tgit tag -l \"v.*\" | test_cmp expect -\n '\n \n-cat >expect <<EOF\n+test_expect_success 'listing tags using v* should print only those having v' '\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success \\\n-\t'listing tags using v* should print only those having v' '\n-\tgit tag -l \"v*\" > actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"v*\" | test_cmp expect -\n '\n \n test_expect_success 'tag -l can accept multiple patterns' '\n-\tgit tag -l \"v1*\" \"v0*\" >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l \"v1*\" \"v0*\" | test_cmp expect -\n '\n \n # creating and verifying lightweight tags:\n \n-test_expect_success \\\n-\t'a non-annotated tag created without parameters should point to HEAD' '\n+test_expect_success 'a non-annotated tag created without parameters should point to HEAD' '\n \tgit tag non-annotated-tag &&\n \ttest $(git cat-file -t non-annotated-tag) = commit &&\n \ttest $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)\n '\n \n-test_expect_success 'trying to verify an unknown tag should fail' \\\n-\t'test_must_fail git tag -v unknown-tag'\n+test_expect_success 'trying to verify an unknown tag should fail' '\n+\tsilent test_must_fail git tag -v unknown-tag\n+'\n \n-test_expect_success \\\n-\t'trying to verify a non-annotated and non-signed tag should fail' \\\n-\t'test_must_fail git tag -v non-annotated-tag'\n+test_expect_success 'trying to verify a non-annotated and non-signed tag should fail' '\n+\tsilent test_must_fail git tag -v non-annotated-tag\n+'\n \n-test_expect_success \\\n-\t'trying to verify many non-annotated or unknown tags, should fail' \\\n-\t'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'\n+test_expect_success 'trying to verify many non-annotated or unknown tags, should fail' '\n+\tsilent test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2\n+'\n \n # creating annotated tags:\n \n-get_tag_msg () {\n-\tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n-}\n-\n-# run test_tick before committing always gives the time in that timezone\n-get_tag_header () {\n-cat <<EOF\n-object $2\n-type $3\n-tag $1\n-tagger C O Mitter <committer@example.com> $4 -0700\n-\n+test_expect_success 'creating an annotated tag with -m message should succeed' '\n+\tcommit=$(git rev-parse HEAD) &&\n+\ttime=$test_tick &&\n+\tname=\"annotated-tag\" &&\n+\tmsg=\"A message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n EOF\n-}\n-\n-commit=$(git rev-parse HEAD)\n-time=$test_tick\n-\n-get_tag_header annotated-tag $commit commit $time >expect\n-echo \"A message\" >>expect\n-test_expect_success \\\n-\t'creating an annotated tag with -m message should succeed' '\n-\tgit tag -m \"A message\" annotated-tag &&\n-\tget_tag_msg annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >msgfile <<EOF\n+test_expect_success 'creating an annotated tag with -F messagefile should succeed' '\n+\tname=\"file-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n Another message\n in a file.\n EOF\n-get_tag_header file-annotated-tag $commit commit $time >expect\n-cat msgfile >>expect\n-test_expect_success \\\n-\t'creating an annotated tag with -F messagefile should succeed' '\n-\tgit tag -F msgfile file-annotated-tag &&\n-\tget_tag_msg file-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\ttail -n 2 expect >msgfile &&\n+\tgit tag -F msgfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >inputmsg <<EOF\n+test_expect_success 'creating an annotated tag with -F - should succeed' '\n+\tname=\"stdin-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n A message from the\n standard input\n EOF\n-get_tag_header stdin-annotated-tag $commit commit $time >expect\n-cat inputmsg >>expect\n-test_expect_success 'creating an annotated tag with -F - should succeed' '\n-\tgit tag -F - stdin-annotated-tag <inputmsg &&\n-\tget_tag_msg stdin-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\ttail -n 2 expect | git tag -F - $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'trying to create a tag with a non-existing -F file should fail' '\n+test_expect_success 'trying to create a tag with a non-existing -F file should fail' '\n \t! test -f nonexistingfile &&\n \t! tag_exists notag &&\n-\ttest_must_fail git tag -F nonexistingfile notag &&\n+\tsilent test_must_fail git tag -F nonexistingfile notag &&\n \t! tag_exists notag\n '\n \n-test_expect_success \\\n-\t'trying to create tags giving both -m or -F options should fail' '\n-\techo \"message file 1\" >msgfile1 &&\n-\techo \"message file 2\" >msgfile2 &&\n+test_expect_success 'trying to create tags giving both -m or -F options should fail' '\n+\techo >msgfile1 \"message file 1\" &&\n+\techo >msgfile2 \"message file 2\" &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -m \"message 1\" -F msgfile1 msgtag &&\n+\tsilent test_must_fail git tag -m \"message 1\" -F msgfile1 msgtag &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -F msgfile1 -m \"message 1\" msgtag &&\n+\tsilent test_must_fail git tag -F msgfile1 -m \"message 1\" msgtag &&\n \t! tag_exists msgtag &&\n-\ttest_must_fail git tag -m \"message 1\" -F msgfile1 \\\n+\tsilent test_must_fail git tag -m \"message 1\" -F msgfile1 \\\n \t\t-m \"message 2\" msgtag &&\n \t! tag_exists msgtag\n '\n \n # blank and empty messages:\n \n-get_tag_header empty-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with an empty -m message should succeed' '\n-\tgit tag -m \"\" empty-annotated-tag &&\n-\tget_tag_msg empty-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with an empty -m message should succeed' '\n+\tname=\"empty-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -m \"\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n->emptyfile\n-get_tag_header emptyfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with an empty -F messagefile should succeed' '\n-\tgit tag -F emptyfile emptyfile-annotated-tag &&\n-\tget_tag_msg emptyfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with an empty -F messagefile should succeed' '\n+\t>emptyfile &&\n+\tname=\"emptyfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F emptyfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' >blanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>blanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>blanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>blanksfile\n-get_tag_header blanks-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+test_expect_success 'extra blanks in the message for an annotated tag should be removed' '\n+\there >blanksfile <<-\\EOF &&\n+\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n+\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n+\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tname=\"blanks-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n Leading blank lines\n \n Repeated blank lines\n@@ -392,44 +385,41 @@ Trailing spaces\n \n Trailing blank lines\n EOF\n-test_expect_success \\\n-\t'extra blanks in the message for an annotated tag should be removed' '\n-\tgit tag -F blanksfile blanks-annotated-tag &&\n-\tget_tag_msg blanks-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -F blanksfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header blank-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with blank -m message with spaces should succeed' '\n-\tgit tag -m \"     \" blank-annotated-tag &&\n-\tget_tag_msg blank-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with blank -m message with spaces should succeed' '\n+\tname=\"blank-annotated-tag\" &&\n+\tgen_header $name $commit commit $time </dev/null >expect &&\n+\tgit tag -m \"     \" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-echo '     ' >blankfile\n-echo ''      >>blankfile\n-echo '  '    >>blankfile\n-get_tag_header blankfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with blank -F messagefile with spaces should succeed' '\n-\tgit tag -F blankfile blankfile-annotated-tag &&\n-\tget_tag_msg blankfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with blank -F messagefile with spaces should succeed' '\n+\there >blankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tname=\"blankfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F blankfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '      ' >blanknonlfile\n-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with -F file of spaces and no newline should succeed' '\n-\tgit tag -F blanknonlfile blanknonlfile-annotated-tag &&\n-\tget_tag_msg blanknonlfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with -F file of spaces and no newline should succeed' '\n+\tprintf >blanknonlfile \"      \" &&\n+\tname=\"blanknonlfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F blanknonlfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n # messages with commented lines:\n \n-cat >commentsfile <<EOF\n+test_expect_success 'creating a tag using a -F messagefile with #comments should succeed' '\n+\tcat >commentsfile <<-EOF &&\n # A comment\n \n ############\n@@ -446,8 +436,8 @@ Another line.\n \n Last line.\n EOF\n-get_tag_header comments-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+\tname=\"comments-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n The message.\n One line.\n \n@@ -455,279 +445,235 @@ Another line.\n \n Last line.\n EOF\n-test_expect_success \\\n-\t'creating a tag using a -F messagefile with #comments should succeed' '\n-\tgit tag -F commentsfile comments-annotated-tag &&\n-\tget_tag_msg comments-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -F commentsfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header comment-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with a #comment in the -m message should succeed' '\n-\tgit tag -m \"#comment\" comment-annotated-tag &&\n-\tget_tag_msg comment-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with a #comment in the -m message should succeed' '\n+\tname=\"comment-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect </dev/null &&\n+\tgit tag -m \"#comment\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-echo '#comment' >commentfile\n-echo ''         >>commentfile\n-echo '####'     >>commentfile\n-get_tag_header commentfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with #comments in the -F messagefile should succeed' '\n-\tgit tag -F commentfile commentfile-annotated-tag &&\n-\tget_tag_msg commentfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with #comments in the -F messagefile should succeed' '\n+\tcat >commentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tname=\"commentfile-annotated-tag\" &&\n+\tgen_header $name $commit commit $time >expect </dev/null &&\n+\tgit tag -F commentfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-printf '#comment' >commentnonlfile\n-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect\n-test_expect_success \\\n-\t'creating a tag with a file of #comment and no newline should succeed' '\n-\tgit tag -F commentnonlfile commentnonlfile-annotated-tag &&\n-\tget_tag_msg commentnonlfile-annotated-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'creating a tag with a file of #comment and no newline should succeed' '\n+\tprintf >commentnonlfile \"#comment\" &&\n+\tname=\"commentnonlfile-annotated-tag\" &&\n+\tgen_header >expect $name $commit commit $time </dev/null &&\n+\tgit tag -F commentnonlfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n # listing messages for annotated non-signed tags:\n \n-test_expect_success \\\n-\t'listing the one-line message of a non-signed tag should succeed' '\n+test_expect_success 'listing the one-line message of a non-signed tag should succeed' '\n \tgit tag -m \"A msg\" tag-one-line &&\n \n-\techo \"tag-one-line\" >expect &&\n-\tgit tag -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\n-\techo \"tag-one-line    A msg\" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l tag-one-line >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-one-line\" &&\n+\tgit tag -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-one-line | test_cmp expect - &&\n+\n+\techo >expect \"tag-one-line    A msg\" &&\n+\tgit tag -n1 -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-one-line\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-one-line | test_cmp expect - &&\n+\tgit tag -n2 -l tag-one-line | test_cmp expect - &&\n+\tgit tag -n999 -l tag-one-line | test_cmp expect -\n '\n \n-test_expect_success \\\n-\t'listing the zero-lines message of a non-signed tag should succeed' '\n+test_expect_success 'listing the zero-lines message of a non-signed tag should succeed' '\n \tgit tag -m \"\" tag-zero-lines &&\n \n-\techo \"tag-zero-lines\" >expect &&\n-\tgit tag -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\n-\techo \"tag-zero-lines  \" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l tag-zero-lines >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-zero-lines\" &&\n+\tgit tag -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-zero-lines | test_cmp expect - &&\n+\n+\techo >expect \"tag-zero-lines  \" &&\n+\tgit tag -n1 -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-zero-lines | test_cmp expect - &&\n+\tgit tag -n2 -l tag-zero-lines | test_cmp expect - &&\n+\tgit tag -n999 -l tag-zero-lines | test_cmp expect -\n '\n \n-echo 'tag line one' >annotagmsg\n-echo 'tag line two' >>annotagmsg\n-echo 'tag line three' >>annotagmsg\n-test_expect_success \\\n-\t'listing many message lines of a non-signed tag should succeed' '\n+test_expect_success 'listing many message lines of a non-signed tag should succeed' '\n+\tcat >annotagmsg <<-EOF &&\n+\t\ttag line one\n+\t\ttag line two\n+\t\ttag line three\n+\tEOF\n \tgit tag -F annotagmsg tag-lines &&\n-\n \techo \"tag-lines\" >expect &&\n-\tgit tag -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l tag-lines | test_cmp expect - &&\n \n \techo \"tag-lines       tag line one\" >expect &&\n-\tgit tag -n1 -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^tag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n1 -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^tag-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l tag-lines | test_cmp expect - &&\n \n \techo \"    tag line two\" >>expect &&\n-\tgit tag -n2 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n2 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n2 -l tag-lines | test_cmp expect - &&\n \n \techo \"    tag line three\" >>expect &&\n-\tgit tag -n3 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n3 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l tag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l | grep \"^ *tag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l tag-lines >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n3 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n3 -l tag-lines | test_cmp expect - &&\n+\tgit tag -n4 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n4 -l tag-lines | test_cmp expect - &&\n+\tgit tag -n99 -l | grep \"^.*tag.line\" | test_cmp expect - &&\n+\tgit tag -n99 -l tag-lines | test_cmp expect -\n '\n \n test_expect_success 'annotations for blobs are empty' '\n-\tblob=$(git hash-object -w --stdin <<-\\EOF\n+\tblob=$(git hash-object -w --stdin <<-EOF\n \tBlob paragraph 1.\n \n \tBlob paragraph 2.\n \tEOF\n \t) &&\n \tgit tag tag-blob $blob &&\n-\techo \"tag-blob        \" >expect &&\n-\tgit tag -n1 -l tag-blob >actual &&\n-\ttest_cmp expect actual\n+\techo >expect \"tag-blob        \" &&\n+\tgit tag -n1 -l tag-blob | test_cmp expect -\n '\n \n # trying to verify annotated non-signed tags:\n \n-test_expect_success GPG \\\n-\t'trying to verify an annotated non-signed tag should fail' '\n+test_expect_success GPG 'trying to verify an annotated non-signed tag should fail' '\n \ttag_exists annotated-tag &&\n-\ttest_must_fail git tag -v annotated-tag\n+\tsilent test_must_fail git tag -v annotated-tag\n '\n \n-test_expect_success GPG \\\n-\t'trying to verify a file-annotated non-signed tag should fail' '\n+test_expect_success GPG 'trying to verify a file-annotated non-signed tag should fail' '\n \ttag_exists file-annotated-tag &&\n-\ttest_must_fail git tag -v file-annotated-tag\n+\tsilent test_must_fail git tag -v file-annotated-tag\n '\n \n-test_expect_success GPG \\\n-\t'trying to verify two annotated non-signed tags should fail' '\n+test_expect_success GPG 'trying to verify two annotated non-signed tags should fail' '\n \ttag_exists annotated-tag file-annotated-tag &&\n-\ttest_must_fail git tag -v annotated-tag file-annotated-tag\n+\tsilent test_must_fail git tag -v annotated-tag file-annotated-tag\n '\n \n # creating and verifying signed tags:\n \n-get_tag_header signed-tag $commit commit $time >expect\n-echo 'A signed tag message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'creating a signed tag with -m message should succeed' '\n-\tgit tag -s -m \"A signed tag message\" signed-tag &&\n-\tget_tag_msg signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tname=\"signed-tag\" &&\n+\tmsg=\"A signed tag message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header u-signed-tag $commit commit $time >expect\n-echo 'Another message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'sign with a given key id' '\n-\n-\tgit tag -u committer@example.com -m \"Another message\" u-signed-tag &&\n-\tget_tag_msg u-signed-tag >actual &&\n-\ttest_cmp expect actual\n-\n+\tname=\"u-signed-tag\" &&\n+\tmsg=\"Another message\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -u committer@example.com -m \"$msg\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n test_expect_success GPG 'sign with an unknown id (1)' '\n-\n-\ttest_must_fail git tag -u author@example.com \\\n+\tsilent test_must_fail git tag -u author@example.com \\\n \t\t-m \"Another message\" o-signed-tag\n-\n '\n \n test_expect_success GPG 'sign with an unknown id (2)' '\n-\n-\ttest_must_fail git tag -u DEADBEEF -m \"Another message\" o-signed-tag\n-\n+\tsilent test_must_fail git tag -u DEADBEEF -m \"Another message\" o-signed-tag\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n+test_expect_success GPG '-u implies signed tag' '\n+\tcat <<-\\EOF | write_script fakeeditor &&\n test -n \"$1\" && exec >\"$1\"\n echo A signed tag message\n echo from a fake editor.\n EOF\n-chmod +x fakeeditor\n-\n-get_tag_header implied-sign $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG '-u implies signed tag' '\n-\tGIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&\n-\tget_tag_msg implied-sign >actual &&\n-\ttest_cmp expect actual\n+\tname=\"implied-signed\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tGIT_EDITOR=./fakeeditor git tag -u CDDE430D $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >sigmsgfile <<EOF\n+test_expect_success GPG 'creating a signed tag with -F messagefile should succeed' '\n+\tname=\"file-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n Another signed tag\n message in a file.\n+\t\t-----BEGIN PGP SIGNATURE-----\n EOF\n-get_tag_header file-signed-tag $commit commit $time >expect\n-cat sigmsgfile >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with -F messagefile should succeed' '\n-\tgit tag -s -F sigmsgfile file-signed-tag &&\n-\tget_tag_msg file-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\ttail -n 3 expect | head -n 2 >sigmsgfile\n+\tgit tag -s -F sigmsgfile $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >siginputmsg <<EOF\n+test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n+\tname=\"stdin-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n A signed tag message from\n the standard input\n+\t\t-----BEGIN PGP SIGNATURE-----\n EOF\n-get_tag_header stdin-signed-tag $commit commit $time >expect\n-cat siginputmsg >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n-\tgit tag -s -F - stdin-signed-tag <siginputmsg &&\n-\tget_tag_msg stdin-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\ttail -n 3 expect | head -n 2 | git tag -s -F - $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header implied-annotate $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-s implies annotated tag' '\n-\tGIT_EDITOR=./fakeeditor git tag -s implied-annotate &&\n-\tget_tag_msg implied-annotate >actual &&\n-\ttest_cmp expect actual\n+\tname=\"implied-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tGIT_EDITOR=./fakeeditor git tag -s $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'trying to create a signed tag with non-existing -F file should fail' '\n+test_expect_success GPG 'trying to create a signed tag with non-existing -F file should fail' '\n \t! test -f nonexistingfile &&\n \t! tag_exists nosigtag &&\n-\ttest_must_fail git tag -s -F nonexistingfile nosigtag &&\n+\tsilent test_must_fail git tag -s -F nonexistingfile nosigtag &&\n \t! tag_exists nosigtag\n '\n \n-test_expect_success GPG 'verifying a signed tag should succeed' \\\n-\t'git tag -v signed-tag'\n+test_expect_success GPG 'verifying a signed tag should succeed' '\n+\tsilent git tag -v signed-tag\n+'\n \n-test_expect_success GPG 'verifying two signed tags in one command should succeed' \\\n-\t'git tag -v signed-tag file-signed-tag'\n+test_expect_success GPG 'verifying two signed tags in one command should succeed' '\n+\tsilent git tag -v signed-tag file-signed-tag\n+'\n \n-test_expect_success GPG \\\n-\t'verifying many signed and non-signed tags should fail' '\n-\ttest_must_fail git tag -v signed-tag annotated-tag &&\n-\ttest_must_fail git tag -v file-annotated-tag file-signed-tag &&\n-\ttest_must_fail git tag -v annotated-tag \\\n+test_expect_success GPG 'verifying many signed and non-signed tags should fail' '\n+\tsilent test_must_fail git tag -v signed-tag annotated-tag &&\n+\tsilent test_must_fail git tag -v file-annotated-tag file-signed-tag &&\n+\tsilent test_must_fail git tag -v annotated-tag \\\n \t\tfile-signed-tag file-annotated-tag &&\n-\ttest_must_fail git tag -v signed-tag annotated-tag file-signed-tag\n+\tsilent test_must_fail git tag -v signed-tag \\\n+\t\tannotated-tag file-signed-tag\n '\n \n test_expect_success GPG 'verifying a forged tag should fail' '\n@@ -735,38 +681,53 @@ test_expect_success GPG 'verifying a forged tag should fail' '\n \t\tsed -e \"s/signed-tag/forged-tag/\" |\n \t\tgit mktag) &&\n \tgit tag forged-tag $forged &&\n-\ttest_must_fail git tag -v forged-tag\n+\tsilent test_must_fail git tag -v forged-tag\n '\n \n # blank and empty messages for signed tags:\n \n-get_tag_header empty-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with an empty -m message should succeed' '\n-\tgit tag -s -m \"\" empty-signed-tag &&\n-\tget_tag_msg empty-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v empty-signed-tag\n-'\n-\n->sigemptyfile\n-get_tag_header emptyfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with an empty -F messagefile should succeed' '\n-\tgit tag -s -F sigemptyfile emptyfile-signed-tag &&\n-\tget_tag_msg emptyfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v emptyfile-signed-tag\n-'\n-\n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' > sigblanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>sigblanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>sigblanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>sigblanksfile\n-get_tag_header blanks-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+test_expect_success GPG 'creating a signed tag with an empty -m message should succeed' '\n+\tname=\"empty-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"\" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with an empty -F messagefile should succeed' '\n+\t>sigemptyfile &&\n+\tname=\"emptyfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigemptyfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'extra blanks in the message for a signed tag should be removed' '\n+\there >sigblanksfile <<-\\EOF &&\n+\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n+\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n+\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tname=\"blanks-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n Leading blank lines\n \n Repeated blank lines\n@@ -774,53 +735,53 @@ Repeated blank lines\n Trailing spaces\n \n Trailing blank lines\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblanksfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with a blank -m message should succeed' '\n+\tname=\"blank-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'extra blanks in the message for a signed tag should be removed' '\n-\tgit tag -s -F sigblanksfile blanks-signed-tag &&\n-\tget_tag_msg blanks-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blanks-signed-tag\n-'\n-\n-get_tag_header blank-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a blank -m message should succeed' '\n-\tgit tag -s -m \"     \" blank-signed-tag &&\n-\tget_tag_msg blank-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blank-signed-tag\n-'\n-\n-echo '     ' >sigblankfile\n-echo ''      >>sigblankfile\n-echo '  '    >>sigblankfile\n-get_tag_header blankfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with blank -F file with spaces should succeed' '\n-\tgit tag -s -F sigblankfile blankfile-signed-tag &&\n-\tget_tag_msg blankfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v blankfile-signed-tag\n-'\n-\n-printf '      ' >sigblanknonlfile\n-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with spaces and no newline should succeed' '\n-\tgit tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&\n-\tget_tag_msg blanknonlfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v signed-tag\n+\tgit tag -s -m \"     \" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with blank -F file with spaces should succeed' '\n+\there >sigblankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tname=\"blankfile-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblankfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with spaces and no newline should succeed' '\n+\tprintf >sigblanknonlfile \"      \" &&\n+\tname=\"blanknonlfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigblanknonlfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n '\n \n # messages with commented lines for signed tags:\n \n-cat >sigcommentsfile <<EOF\n+test_expect_success GPG 'creating a signed tag with a -F file with #comments should succeed' '\n+\tcat >sigcommentsfile <<-EOF &&\n # A comment\n \n ############\n@@ -837,303 +798,257 @@ Another line.\n \n Last line.\n EOF\n-get_tag_header comments-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+\tname=\"comments-signed-tag\" &&\n+\tgen_header >expect $name $commit commit $time <<-EOF &&\n The message.\n One line.\n \n Another line.\n \n Last line.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentsfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with #commented -m message should succeed' '\n+\tname=\"comment-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"#comment\" $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with #commented -F messagefile should succeed' '\n+\tcat >sigcommentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a -F file with #comments should succeed' '\n-\tgit tag -s -F sigcommentsfile comments-signed-tag &&\n-\tget_tag_msg comments-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v comments-signed-tag\n-'\n-\n-get_tag_header comment-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with #commented -m message should succeed' '\n-\tgit tag -s -m \"#comment\" comment-signed-tag &&\n-\tget_tag_msg comment-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v comment-signed-tag\n-'\n-\n-echo '#comment' >sigcommentfile\n-echo ''         >>sigcommentfile\n-echo '####'     >>sigcommentfile\n-get_tag_header commentfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with #commented -F messagefile should succeed' '\n-\tgit tag -s -F sigcommentfile commentfile-signed-tag &&\n-\tget_tag_msg commentfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v commentfile-signed-tag\n-'\n-\n-printf '#comment' >sigcommentnonlfile\n-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a #comment and no newline should succeed' '\n-\tgit tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&\n-\tget_tag_msg commentnonlfile-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -v commentnonlfile-signed-tag\n+\tname=\"commentfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n+'\n+\n+test_expect_success GPG 'creating a signed tag with a #comment and no newline should succeed' '\n+\tprintf \"#comment\" >sigcommentnonlfile &&\n+\tname=\"commentnonlfile-signed-tag\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -F sigcommentnonlfile $name &&\n+\tget_header $name | test_cmp expect - &&\n+\tsilent git tag -v $name\n '\n \n # listing messages for signed tags:\n \n-test_expect_success GPG \\\n-\t'listing the one-line message of a signed tag should succeed' '\n+test_expect_success GPG 'listing the one-line message of a signed tag should succeed' '\n \tgit tag -s -m \"A message line signed\" stag-one-line &&\n \n \techo \"stag-one-line\" >expect &&\n-\tgit tag -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-one-line | test_cmp expect - &&\n \n \techo \"stag-one-line   A message line signed\" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-one-line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-one-line >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l stag-one-line >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n1 -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^stag-one-line\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-one-line | test_cmp expect - &&\n+\tgit tag -n2 -l stag-one-line | test_cmp expect - &&\n+\tgit tag -n999 -l stag-one-line | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'listing the zero-lines message of a signed tag should succeed' '\n+test_expect_success GPG 'listing the zero-lines message of a signed tag should succeed' '\n \tgit tag -s -m \"\" stag-zero-lines &&\n \n \techo \"stag-zero-lines\" >expect &&\n-\tgit tag -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-zero-lines | test_cmp expect - &&\n \n \techo \"stag-zero-lines \" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-zero-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n999 -l stag-zero-lines >actual &&\n-\ttest_cmp expect actual\n-'\n-\n-echo 'stag line one' >sigtagmsg\n-echo 'stag line two' >>sigtagmsg\n-echo 'stag line three' >>sigtagmsg\n-test_expect_success GPG \\\n-\t'listing many message lines of a signed tag should succeed' '\n+\tgit tag -n1 -l | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n -l  | grep \"^stag-zero-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-zero-lines | test_cmp expect - &&\n+\tgit tag -n2 -l stag-zero-lines | test_cmp expect - &&\n+\tgit tag -n999 -l stag-zero-lines | test_cmp expect -\n+'\n+\n+test_expect_success GPG 'listing many message lines of a signed tag should succeed' '\n+\tcat >sigtagmsg <<-EOF &&\n+\t\tstag line one\n+\t\tstag line two\n+\t\tstag line three\n+\tEOF\n \tgit tag -s -F sigtagmsg stag-lines &&\n \n \techo \"stag-lines\" >expect &&\n-\tgit tag -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n0 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n0 -l stag-lines | test_cmp expect - &&\n \n \techo \"stag-lines      stag line one\" >expect &&\n-\tgit tag -n1 -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n -l | grep \"^stag-lines\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n1 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n1 -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n -l | grep \"^stag-lines\" | test_cmp expect - &&\n+\tgit tag -n1 -l stag-lines | test_cmp expect - &&\n \n \techo \"    stag line two\" >>expect &&\n-\tgit tag -n2 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n2 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n+\tgit tag -n2 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n2 -l stag-lines | test_cmp expect - &&\n \n \techo \"    stag line three\" >>expect &&\n-\tgit tag -n3 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n3 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n4 -l stag-lines >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l | grep \"^ *stag.line\" >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -n99 -l stag-lines >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -n3 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n3 -l stag-lines | test_cmp expect - &&\n+\tgit tag -n4 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n4 -l stag-lines | test_cmp expect - &&\n+\tgit tag -n99 -l | grep \"^.*stag.line\" | test_cmp expect - &&\n+\tgit tag -n99 -l stag-lines | test_cmp expect -\n '\n \n-# tags pointing to objects different from commits:\n \n-tree=$(git rev-parse HEAD^{tree})\n-blob=$(git rev-parse HEAD:foo)\n-tag=$(git rev-parse signed-tag 2>/dev/null)\n-\n-get_tag_header tree-signed-tag $tree tree $time >expect\n-echo \"A message for a tree\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to a tree should succeed' '\n-\tgit tag -s -m \"A message for a tree\" tree-signed-tag HEAD^{tree} &&\n-\tget_tag_msg tree-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag pointing to a tree should succeed' '\n+\t# tags pointing to objects different from commits:\n+\ttree=$(git rev-parse HEAD^{tree}) &&\n+\tblob=$(git rev-parse HEAD:foo) &&\n+\ttag=$(git rev-parse signed-tag) &&\n+\tname=\"tree-signed-tag\" &&\n+\tmsg=\"A message for a tree\" &&\n+\tgen_header $name $tree tree $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name HEAD^{tree} &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header blob-signed-tag $blob blob $time >expect\n-echo \"A message for a blob\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to a blob should succeed' '\n-\tgit tag -s -m \"A message for a blob\" blob-signed-tag HEAD:foo &&\n-\tget_tag_msg blob-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag pointing to a blob should succeed' '\n+\tmsg=\"A message for a blob\" &&\n+\tname=\"blob-signed-tag\" &&\n+\tgen_header $name $blob blob $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name HEAD:foo &&\n+\tget_header $name | test_cmp expect -\n '\n \n-get_tag_header tag-signed-tag $tag tag $time >expect\n-echo \"A message for another tag\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag pointing to another tag should succeed' '\n-\tgit tag -s -m \"A message for another tag\" tag-signed-tag signed-tag &&\n-\tget_tag_msg tag-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag pointing to another tag should succeed' '\n+\tmsg=\"A message for another tag\" &&\n+\tname=\"tag-signed-tag\" &&\n+\tgen_header $name $tag tag $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name signed-tag &&\n+\tget_header $name | test_cmp expect -\n '\n \n # usage with rfc1991 signatures\n-echo \"rfc1991\" > gpghome/gpg.conf\n-get_tag_header rfc1991-signed-tag $commit commit $time >expect\n-echo \"RFC1991 signed tag\" >>expect\n-echo '-----BEGIN PGP MESSAGE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with rfc1991' '\n-\tgit tag -s -m \"RFC1991 signed tag\" rfc1991-signed-tag $commit &&\n-\tget_tag_msg rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'creating a signed tag with rfc1991' '\n+\techo \"rfc1991\" >gpghome/gpg.conf &&\n+\tmsg=\"RFC1991 signed tag\" &&\n+\tname=\"rfc1991-signed-tag\"\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\t$msg\n+\t\t-----BEGIN PGP MESSAGE-----\n+\tEOF\n+\tgit tag -s -m \"$msg\" $name $commit &&\n+\tget_header $name | test_cmp expect -\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n+\tcat <<-\\EOF | write_script fakeeditor &&\n cp \"$1\" actual\n EOF\n-chmod +x fakeeditor\n-\n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n-\tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n+\tGIT_EDITOR=./fakeeditor \\\n+\t\tquiet git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature' '\n-\tgit tag -v rfc1991-signed-tag\n+test_expect_success GPG 'verifying rfc1991 signature' '\n+\tsilent git tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature' '\n+test_expect_success GPG 'list tag with rfc1991 signature' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n-\tgit tag -l -n1 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n2 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n999 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n999 rfc1991-signed-tag | test_cmp expect -\n '\n \n-rm -f gpghome/gpg.conf\n-\n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature without --rfc1991' '\n-\tgit tag -v rfc1991-signed-tag\n+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '\n+\trm -f gpghome/gpg.conf &&\n+\tsilent git tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature without --rfc1991' '\n-\techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n-\tgit tag -l -n1 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n2 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual &&\n-\tgit tag -l -n999 rfc1991-signed-tag >actual &&\n-\ttest_cmp expect actual\n+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '\n+\techo >expect \"rfc1991-signed-tag RFC1991 signed tag\" &&\n+\tgit tag -l -n1 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n2 rfc1991-signed-tag | test_cmp expect - &&\n+\tgit tag -l -n999 rfc1991-signed-tag | test_cmp expect -\n '\n \n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n-\tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n+\tGIT_EDITOR=./fakeeditor \\\n+\t\tquiet git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '\n # try to sign with bad user.signingkey\n-git config user.signingkey BobTheMouse\n-test_expect_success GPG \\\n-\t'git tag -s fails if gpg is misconfigured' \\\n-\t'test_must_fail git tag -s -m tail tag-gpg-failure'\n+\tgit config user.signingkey BobTheMouse &&\n+\tsilent test_must_fail git tag -s -m tail tag-gpg-failure &&\n git config --unset user.signingkey\n+'\n \n+test_expect_success GPG 'verify signed tag fails when public key is not present' '\n # try to verify without gpg:\n+\trm -rf gpghome &&\n+\tsilent test_must_fail git tag -v signed-tag\n+'\n \n-rm -rf gpghome\n-test_expect_success GPG \\\n-\t'verify signed tag fails when public key is not present' \\\n-\t'test_must_fail git tag -v signed-tag'\n-\n-test_expect_success \\\n-\t'git tag -a fails if tag annotation is empty' '\n-\t! (GIT_EDITOR=cat git tag -a initial-comment)\n+test_expect_success 'git tag -a fails if tag annotation is empty' '\n+\t! (GIT_EDITOR=cat silent git tag -a initial-comment)\n '\n \n-test_expect_success \\\n-\t'message in editor has initial comment' '\n-\t! (GIT_EDITOR=cat git tag -a initial-comment > actual)\n+test_expect_success 'message in editor has initial comment' '\n+\t! (GIT_EDITOR=cat git tag -a initial-comment >actual 2>/dev/null)\n '\n \n test_expect_success 'message in editor has initial comment: first line' '\n \t# check the first line --- should be empty\n \techo >first.expect &&\n-\tsed -e 1q <actual >first.actual &&\n+\tsed -e 1q actual >first.actual &&\n \ttest_i18ncmp first.expect first.actual\n '\n \n-test_expect_success \\\n-\t'message in editor has initial comment: remainder' '\n+test_expect_success 'message in editor has initial comment: remainder' '\n \t# remove commented lines from the remainder -- should be empty\n \t>rest.expect\n \tsed -e 1d -e '/^#/d' <actual >rest.actual &&\n \ttest_cmp rest.expect rest.actual\n '\n \n-get_tag_header reuse $commit commit $time >expect\n-echo \"An annotation to be reused\" >> expect\n-test_expect_success \\\n-\t'overwriting an annoted tag should use its previous body' '\n-\tgit tag -a -m \"An annotation to be reused\" reuse &&\n-\tGIT_EDITOR=true git tag -f -a reuse &&\n-\tget_tag_msg reuse >actual &&\n-\ttest_cmp expect actual\n+test_expect_success 'overwriting an annoted tag should use its previous body' '\n+\tname=\"reuse\" &&\n+\tmsg=\"An annotation to be reused\" &&\n+\tgen_header $name $commit commit $time >expect <<-EOF &&\n+\t\treuse\n+\tEOF\n+\tgit tag -a -m \"$msg\" $name &&\n+\tGIT_EDITOR=true git tag -f -a -m \"reuse\" $name &&\n+\tget_header $name | test_cmp expect -\n '\n \n test_expect_success 'filename for the message is relative to cwd' '\n@@ -1144,7 +1059,7 @@ test_expect_success 'filename for the message is relative to cwd' '\n \t\tcd subdir &&\n \t\tgit tag -a -F msgfile-5 tag-from-subdir\n \t) &&\n-\tgit cat-file tag tag-from-subdir | grep \"in sub directory\"\n+\tgit cat-file tag tag-from-subdir | grep -q \"in sub directory\"\n '\n \n test_expect_success 'filename for the message is relative to cwd' '\n@@ -1153,110 +1068,91 @@ test_expect_success 'filename for the message is relative to cwd' '\n \t\tcd subdir &&\n \t\tgit tag -a -F msgfile-6 tag-from-subdir-2\n \t) &&\n-\tgit cat-file tag tag-from-subdir-2 | grep \"in sub directory\"\n+\tgit cat-file tag tag-from-subdir-2 | grep -q \"in sub directory\"\n '\n \n-# create a few more commits to test --contains\n-\n-hash1=$(git rev-parse HEAD)\n-\n test_expect_success 'creating second commit and tag' '\n+\t# create a few more commits to test --contains\n+\thash1=$(git rev-parse HEAD) &&\n \techo foo-2.0 >foo &&\n \tgit add foo &&\n-\tgit commit -m second &&\n+\tgit commit -q -m second &&\n+\thash2=$(git rev-parse HEAD) &&\n \tgit tag v2.0\n '\n \n-hash2=$(git rev-parse HEAD)\n-\n test_expect_success 'creating third commit without tag' '\n \techo foo-dev >foo &&\n \tgit add foo &&\n-\tgit commit -m third\n-'\n-\n+\tgit commit -q -m third &&\n hash3=$(git rev-parse HEAD)\n+'\n \n-# simple linear checks of --continue\n-\n-cat > expected <<EOF\n+test_expect_success 'checking that first commit is in all tags (hash)' '\n+\t# simple linear checks of --contains\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n v1.1.3\n v2.0\n EOF\n+\tgit tag -l --contains $hash1 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that first commit is in all tags (hash)' \"\n-\tgit tag -l --contains $hash1 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n+test_expect_success 'checking that first commit is in all tags (tag)' '\n # other ways of specifying the commit\n-test_expect_success 'checking that first commit is in all tags (tag)' \"\n-\tgit tag -l --contains v1.0 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+\tgit tag -l --contains v1.0 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that first commit is in all tags (relative)' \"\n-\tgit tag -l --contains HEAD~2 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that first commit is in all tags (relative)' '\n+\tgit tag -l --contains HEAD~2 v* | test_cmp expect -\n+'\n \n-cat > expected <<EOF\n+test_expect_success 'checking that second commit only has one tag' '\n+\tcat >expect <<-EOF &&\n v2.0\n EOF\n+\tgit tag -l --contains $hash2 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that second commit only has one tag' \"\n-\tgit tag -l --contains $hash2 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-\n-cat > expected <<EOF\n-EOF\n-\n-test_expect_success 'checking that third commit has no tags' \"\n-\tgit tag -l --contains $hash3 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+test_expect_success 'checking that third commit has no tags' '\n+\t>expect\n+\tgit tag -l --contains $hash3 v* | test_cmp expect -\n+'\n \n # how about a simple merge?\n \n test_expect_success 'creating simple branch' '\n \tgit branch stable v2.0 &&\n-        git checkout stable &&\n+\tgit checkout -q stable &&\n \techo foo-3.0 > foo &&\n-\tgit commit foo -m fourth &&\n+\tgit commit -q foo -m fourth &&\n+\thash4=$(git rev-parse HEAD) &&\n \tgit tag v3.0\n '\n \n-hash4=$(git rev-parse HEAD)\n-\n-cat > expected <<EOF\n+test_expect_success 'checking that branch head only has one tag' '\n+\tcat >expect <<-EOF &&\n v3.0\n EOF\n-\n-test_expect_success 'checking that branch head only has one tag' \"\n-\tgit tag -l --contains $hash4 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n+\tgit tag -l --contains $hash4 v* | test_cmp expect -\n+'\n \n test_expect_success 'merging original branch into this branch' '\n-\tgit merge --strategy=ours master &&\n+\tgit merge -q --strategy=ours master &&\n         git tag v4.0\n '\n \n-cat > expected <<EOF\n+test_expect_success 'checking that original branch head has one tag now' '\n+\tcat >expect <<-EOF &&\n v4.0\n EOF\n+\tgit tag -l --contains $hash3 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that original branch head has one tag now' \"\n-\tgit tag -l --contains $hash3 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-cat > expected <<EOF\n+test_expect_success 'checking that initial commit is in all tags' '\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n@@ -1265,60 +1161,50 @@ v2.0\n v3.0\n v4.0\n EOF\n+\tgit tag -l --contains $hash1 v* | test_cmp expect -\n+'\n \n-test_expect_success 'checking that initial commit is in all tags' \"\n-\tgit tag -l --contains $hash1 v* >actual &&\n-\ttest_cmp expected actual\n-\"\n-\n-# mixing modes and options:\n \n test_expect_success 'mixing incompatibles modes and options is forbidden' '\n-\ttest_must_fail git tag -a &&\n-\ttest_must_fail git tag -l -v &&\n-\ttest_must_fail git tag -n 100 &&\n-\ttest_must_fail git tag -l -m msg &&\n-\ttest_must_fail git tag -l -F some file &&\n-\ttest_must_fail git tag -v -s\n+\t# mixing modes and options:\n+\tsilent test_must_fail git tag -a &&\n+\tsilent test_must_fail git tag -l -v &&\n+\tsilent test_must_fail git tag -n 100 &&\n+\tsilent test_must_fail git tag -l -m msg &&\n+\tsilent test_must_fail git tag -l -F some file &&\n+\tsilent test_must_fail git tag -v -s &&\n+\tsilent test_must_fail git tag --points-at=v4.0 foo\n '\n \n # check points-at\n \n-test_expect_success '--points-at cannot be used in non-list mode' '\n-\ttest_must_fail git tag --points-at=v4.0 foo\n-'\n-\n test_expect_success '--points-at finds lightweight tags' '\n \techo v4.0 >expect &&\n-\tgit tag --points-at v4.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at v4.0 | test_cmp expect -\n '\n \n test_expect_success '--points-at finds annotated tags of commits' '\n \tgit tag -m \"v4.0, annotated\" annotated-v4.0 v4.0 &&\n \techo annotated-v4.0 >expect &&\n-\tgit tag -l --points-at v4.0 \"annotated*\" >actual &&\n-\ttest_cmp expect actual\n+\tgit tag -l --points-at v4.0 \"annotated*\" | test_cmp expect -\n '\n \n test_expect_success '--points-at finds annotated tags of tags' '\n \tgit tag -m \"describing the v4.0 tag object\" \\\n \t\tannotated-again-v4.0 annotated-v4.0 &&\n-\tcat >expect <<-\\EOF &&\n+\tcat >expect <<-EOF &&\n \tannotated-again-v4.0\n \tannotated-v4.0\n \tEOF\n-\tgit tag --points-at=annotated-v4.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at=annotated-v4.0 | test_cmp expect -\n '\n \n test_expect_success 'multiple --points-at are OR-ed together' '\n-\tcat >expect <<-\\EOF &&\n+\tcat >expect <<-EOF &&\n \tv2.0\n \tv3.0\n \tEOF\n-\tgit tag --points-at=v2.0 --points-at=v3.0 >actual &&\n-\ttest_cmp expect actual\n+\tgit tag --points-at=v2.0 --points-at=v3.0 | test_cmp expect -\n '\n \n test_done\n-- \n1.7.8\n"},{"id":"185773","messageId":"7v62epqd9a.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1330566326-26075-7-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-01T02:13:53Z","receivedAt":"2012-03-01T02:13:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> +if ! test -r test-lib.sh ; then\n> +\t(cd ${0%/*} && ./${0##*/} $@)\n> +\texit $?\n> +fi\n\nNot very nice; why is this an improvement?\n\n>  . ./test-lib.sh\n>  . \"$TEST_DIRECTORY\"/lib-gpg.sh\n>  \n> +quiet () { \"$@\" >/dev/null; }\n> +silent () { \"$@\" >/dev/null 2>&1; }\n\nNot nice, either.\n\n>  # Mon Jul 3 15:18:43 2006 +0000\n>  datestamp=1151939923\n>  setdate_and_increment () {\n> @@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '\n>  \tsetdate_and_increment &&\n>  \techo \"Using $datestamp\" > one &&\n>  \tgit add one &&\n> -\tgit commit -m \"Initial\" &&\n> +\tgit commit -q -m \"Initial\" &&\n>  \tsetdate_and_increment &&\n> -\tgit tag -a -m \"Tagging at $datestamp\" testtag\n> +\tquiet git tag -a -m \"Tagging at $datestamp\" testtag\n\nWhy? Why? Why?\n\n\tcd t && sh ./t1234-frotz.sh\n\nwould be silent enough and suppressing the output from the commands like\nthis patch does makes it _harder_ for people to debug their changes to the\nscript with\n\n\tsh ./t1234-frotz.sh -v\n\nMost of the change in this patch does nothing to do with \"modernize style\".\n"},{"id":"185779","messageId":"20120301032053.GD2572@tgrennan-laptop","threadId":"29583","inReplyTo":"7v62epqd9a.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T03:20:53Z","receivedAt":"2012-03-01T03:20:53Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Wed, Feb 29, 2012 at 06:13:53PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> +if ! test -r test-lib.sh ; then\n>> +\t(cd ${0%/*} && ./${0##*/} $@)\n>> +\texit $?\n>> +fi\n>\n>Not very nice; why is this an improvement?\n\nI liked being able to,\n\tt/t1234-frotz.sh [-q|-v]\nin addition to,\n\tcd t && sh ./t1234-frotz.sh\n\n>>  . ./test-lib.sh\n>>  . \"$TEST_DIRECTORY\"/lib-gpg.sh\n>>  \n>> +quiet () { \"$@\" >/dev/null; }\n>> +silent () { \"$@\" >/dev/null 2>&1; }\n>\n>Not nice, either.\n\n\"Not nice\" b/c they're on one line?\nI like simple things compressed so I quickly glance pass them.\nSort of forest through the trees.\n\n>>  # Mon Jul 3 15:18:43 2006 +0000\n>>  datestamp=1151939923\n>>  setdate_and_increment () {\n>> @@ -22,9 +30,9 @@ test_expect_success 'Create sample commit with known timestamp' '\n>>  \tsetdate_and_increment &&\n>>  \techo \"Using $datestamp\" > one &&\n>>  \tgit add one &&\n>> -\tgit commit -m \"Initial\" &&\n>> +\tgit commit -q -m \"Initial\" &&\n>>  \tsetdate_and_increment &&\n>> -\tgit tag -a -m \"Tagging at $datestamp\" testtag\n>> +\tquiet git tag -a -m \"Tagging at $datestamp\" testtag\n>\n>Why? Why? Why?\n>\n>\tcd t && sh ./t1234-frotz.sh\n>\n>would be silent enough and suppressing the output from the commands like\n>this patch does makes it _harder_ for people to debug their changes to the\n>script with\n>\n>\tsh ./t1234-frotz.sh -v\n\nHmm, I found the noise distracting.  For example, w/o redirecting\nstderr, most of the test_must_fail puke as expected.  If it's expected,\nwhy show it?  BTW since it's a different stream, to get the error near\nthe exec log one has to:\n\n\tsh ./t1234-frotz.sh -v |& less\n\nOtherwise it's challenging to separate the expected vs unexpected failures.\n\nMost of the \"quiet's\"  are with git-tag and git-branch.  I'd prefer\n--quiet and --silent options to these commands like git-init, git-commit, etc.\n\n>Most of the change in this patch does nothing to do with \"modernize style\".\n\nIt's trivial to remove these \"quiet\" and \"silent\", but to me that's the\nonly value added by these patches.  More seriously, the remaining\nmodernization still seems much larger than its value.\n\n-- \nTomG\n"},{"id":"185780","messageId":"7vty29ovcd.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"20120301032053.GD2572@tgrennan-laptop","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-01T03:26:10Z","receivedAt":"2012-03-01T03:26:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> It's trivial to remove these \"quiet\" and \"silent\", but to me that's the\n> only value added by these patches.  More seriously, the remaining\n> modernization still seems much larger than its value.\n\nDon't do that, then ;-).\n\nSome older scripts do redirect the output from the commands to /dev/null\nbut that dates back before we made the default reasonably silent, and in\n\"modern\" style we tend to keep them sent to their standard output to help\ndebuggability. These quiet/silent takes us to the prehistoric times.\n"},{"id":"185782","messageId":"20120301051010.GE2572@tgrennan-laptop","threadId":"29583","inReplyTo":"7vty29ovcd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T05:10:10Z","receivedAt":"2012-03-01T05:10:10Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>> It's trivial to remove these \"quiet\" and \"silent\", but to me that's the\n>> only value added by these patches.  More seriously, the remaining\n>> modernization still seems much larger than its value.\n>\n>Don't do that, then ;-).\n>\n>Some older scripts do redirect the output from the commands to /dev/null\n>but that dates back before we made the default reasonably silent, and in\n>\"modern\" style we tend to keep them sent to their standard output to help\n>debuggability. These quiet/silent takes us to the prehistoric times.\n\nHey! I am prehistoric:-)\n\nLike I said, I think there is currently a debug distraction with verbose\nmode.  However, rather than hiding expected failures and diverting other\noutput as I had, perhaps we should dup stderr to stdout in verbose mode\nso error messages show up near the logged invocation when piped through\na pager (i.e. mimic \"|&\").  With this, one can quickly scan past the\nnoise to focus on the broken cases.\n\n  exec 5>&1\n  exec 6<&0\n  if test \"$verbose\" = \"t\"\n  then\n- \texec 4>&2 3>&1\n+ \texec 4>&1 3>&1\n  else\n  \texec 4>/dev/null 3>/dev/null\n  fi\n\nFor example, try this w/ and w/o the above change.\n\t(cd t && ./t5512-ls-remote.sh) | less\n\nI still think git-branch and git-tag should have a -q option; better\nyet, the wrapper itself (i.e. git --quiet/--silent XXX).\n\n-- \nTomG\n"},{"id":"185789","messageId":"20120301055741.GF2572@tgrennan-laptop","threadId":"29583","inReplyTo":"20120301051010.GE2572@tgrennan-laptop","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T05:57:41Z","receivedAt":"2012-03-01T05:57:41Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Wed, Feb 29, 2012 at 09:10:10PM -0800, Tom Grennan wrote:\n>On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:\n>>Tom Grennan <tmgrennan@gmail.com> writes:\n>>\n>For example, try this w/ and w/o the above change.\n>\t(cd t && ./t5512-ls-remote.sh) | less\n\n\t(cd t && ./t5512-ls-remote.sh -v) | less\n\n-- \nTomG\n"},{"id":"185790","messageId":"4F4F1CD7.4060403@viscovery.net","threadId":"29583","inReplyTo":"1330566326-26075-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCH 1/5] t6300 (for-each-ref): modernize style","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-03-01T06:53:11Z","receivedAt":"2012-03-01T06:53:11Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 3/1/2012 2:45, schrieb Tom Grennan:\n> +\tgit for-each-ref --format=\"%(refname)\" --sort=refname |\n> +\t\ttest_cmp expect -\n\nDON'T DO THIS. It loses the exit code of the git invocation.\n\n(And it is contrary to my effort to move all test_cmp away from being used\nin a pipeline because I want to use a comparator tool that does not\nunderstand '-' as stdin.)\n\n-- Hannes\n"},{"id":"185793","messageId":"87zkc0ogz9.fsf@thomas.inf.ethz.ch","threadId":"29583","inReplyTo":"1330566326-26075-3-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCH 2/5] t5512 (ls-remote): modernize style","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-03-01T08:36:26Z","receivedAt":"2012-03-01T08:36:26Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n> - Redirect unwanted output\n[...]\n> -\tgit commit -m initial &&\n> +\tgit commit -q -m initial &&\n\nWhy?  When are you seeing the output, except with --verbose?  In the\nlatter case, isn't it useful to have as much output as possible?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"185794","messageId":"87ty28n244.fsf@thomas.inf.ethz.ch","threadId":"29583","inReplyTo":"20120301051010.GE2572@tgrennan-laptop","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-03-01T08:42:51Z","receivedAt":"2012-03-01T08:42:51Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"I sent out a reply to the same effect as Junio's longer one in this\nside-thread.  You can disregard that.  Sorry for not first reading the\nwhole thread.\n\nTom Grennan <tmgrennan@gmail.com> writes:\n\n> On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:\n>>Tom Grennan <tmgrennan@gmail.com> writes:\n>>\n>>> It's trivial to remove these \"quiet\" and \"silent\", but to me that's the\n>>> only value added by these patches.  More seriously, the remaining\n>>> modernization still seems much larger than its value.\n>>\n>>Don't do that, then ;-).\n>>\n>>Some older scripts do redirect the output from the commands to /dev/null\n>>but that dates back before we made the default reasonably silent, and in\n>>\"modern\" style we tend to keep them sent to their standard output to help\n>>debuggability. These quiet/silent takes us to the prehistoric times.\n>\n> Hey! I am prehistoric:-)\n>\n> Like I said, I think there is currently a debug distraction with verbose\n> mode.  However, rather than hiding expected failures and diverting other\n> output as I had, perhaps we should dup stderr to stdout in verbose mode\n> so error messages show up near the logged invocation when piped through\n> a pager (i.e. mimic \"|&\").  With this, one can quickly scan past the\n> noise to focus on the broken cases.\n\nIf you have trouble finding the broken case, you can run with -v -i.\n\nI also think you are making an argument for a different feature (which\ndoes not rob us of having all the debug output): test-lib.sh could\nperhaps redirect the test output to a file, and dump the file to stdout\nonly if the test failed.  Perhaps --verbose-failing or something like\nthat.\n\nOtherwise, your proposal is restricting us to having only an \"easily\nscannable\" amount of output per test, perhaps 5-15 lines.  Which I\npersonally think is an insane restriction for something that was\nintended for debugging in the first place.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"185821","messageId":"20120301154808.GG2572@tgrennan-laptop","threadId":"29583","inReplyTo":"87ty28n244.fsf@thomas.inf.ethz.ch","subject":"Re: [PATCH-w 101/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T15:48:08Z","receivedAt":"2012-03-01T15:48:08Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Thu, Mar 01, 2012 at 09:42:51AM +0100, Thomas Rast wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>> On Wed, Feb 29, 2012 at 07:26:10PM -0800, Junio C Hamano wrote:\n>>>Tom Grennan <tmgrennan@gmail.com> writes:\n>>>\n>> Like I said, I think there is currently a debug distraction with verbose\n>> mode.  However, rather than hiding expected failures and diverting other\n>> output as I had, perhaps we should dup stderr to stdout in verbose mode\n>> so error messages show up near the logged invocation when piped through\n>> a pager (i.e. mimic \"|&\").  With this, one can quickly scan past the\n>> noise to focus on the broken cases.\n>\n>If you have trouble finding the broken case, you can run with -v -i.\n>\n>I also think you are making an argument for a different feature (which\n>does not rob us of having all the debug output): test-lib.sh could\n>perhaps redirect the test output to a file, and dump the file to stdout\n>only if the test failed.  Perhaps --verbose-failing or something like\n>that.\n>\n>Otherwise, your proposal is restricting us to having only an \"easily\n>scannable\" amount of output per test, perhaps 5-15 lines.  Which I\n>personally think is an insane restriction for something that was\n>intended for debugging in the first place.\n\nOh, I hadn't tried -i with -v. This does mimic \"|&\".\n\t(cd t && ./t5512-ls-remote.sh -v -i) | less\n\t(cd t && ./t5512-ls-remote.sh -v) |& less\n\nSo, please ignore my suggestion.\n\nThanks,\nTomG\n"},{"id":"185822","messageId":"20120301155807.GH2572@tgrennan-laptop","threadId":"29583","inReplyTo":"4F4F1CD7.4060403@viscovery.net","subject":"Re: [PATCH 1/5] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-01T15:58:07Z","receivedAt":"2012-03-01T15:58:07Z","isPatch":true,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Thu, Mar 01, 2012 at 07:53:11AM +0100, Johannes Sixt wrote:\n>Am 3/1/2012 2:45, schrieb Tom Grennan:\n>> +\tgit for-each-ref --format=\"%(refname)\" --sort=refname |\n>> +\t\ttest_cmp expect -\n>\n>DON'T DO THIS. It loses the exit code of the git invocation.\n>\n>(And it is contrary to my effort to move all test_cmp away from being used\n>in a pipeline because I want to use a comparator tool that does not\n>understand '-' as stdin.)\n\nOK, with bash, one could get that from PIPESTATUS, but that doesn't help if\nyou're not using bash or desire a different comparator.\n\nThanks,\nTomG\n"},{"id":"185957","messageId":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330566326-26075-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 0/5] modernize test style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:32Z","receivedAt":"2012-03-03T02:15:32Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"I <tmgrennan@gmail.com> wrote:\n>Per request, the following series modernize the style of the respective\n>test scripts.  The common themes are:\n>\t- Guard setup with test_expect_success\n>\t- Single-quoted, tab prefaced test blocks of < 80 cols\n>\t- Redirect unwanted output\n>\t- Use a \"here\" filter for some expect generation\n>\n>I also used pipelines to validate expected results rather than temporary\n>files, i.e.\n>\tTEST | test_cmp expect -\n>vs.\tTEST >actual && test_cmp expect actual\n>\n>Since the later three patches have a lot of whitespace change, I've included an\n>alternate, PATCH-w series that filters these for more substantive review.\n>However, even the filtered series is very large causing me to second guess\n>whether such style modernization should be pursued; so, I look forward to your\n>input.\n\nThe following series is a much less ambitious modernization of these tests.\nThis version does NOT:\n\t- Support running with t/TEST.sh vs. (cd t && ./TEST.sh)\n\t- Redirect unwanted output\n\t- Pipeline test_cmp\n\t- Rewrite blocks to be less than 80 columns \n\nThis version DOES:\n\t- Guard setup with test_expect_success\n\t  (in one case, a shell loop was unwound to facilitate this)\n\t- Single-quoted, tab prefaced test blocks\n\t- >FILE instead of > FILE redirection style\n\t- Use a sed filter to process formatted whitespace test cases\n\nI've also included PATCHv2-w for review alternatives.\n\nThanks,\nTom Grennan (5):\n  t7004 (tag): modernize style\n  t5512 (ls-remote): modernize style\n  t3200 (branch): modernize style\n  t0040 (parse-options): modernize style\n  t6300 (for-each-ref): modernize style\n\n t/t7004-tag.sh |  828 ++++++++++++++++++++++++++++++--------------------------\n 1 files changed, 447 insertions(+), 381 deletions(-)\n\n-- \n1.7.8\n"},{"id":"185958","messageId":"1330740942-25130-2-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 1/5] t7004 (tag): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:33Z","receivedAt":"2012-03-03T02:15:33Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks\n- Use >FILE instead of > FILE\n- Use a \"here\" filter for generation of expect files with mixed tabs and\n  spaces\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t7004-tag.sh |  828 ++++++++++++++++++++++++++++++--------------------------\n 1 files changed, 447 insertions(+), 381 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f8c247a..f819f41 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -27,8 +27,9 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '\n \ttest `git tag | wc -l` -eq 0\n '\n \n-test_expect_success 'looking for a tag in an empty tree should fail' \\\n-\t'! (tag_exists mytag)'\n+test_expect_success 'looking for a tag in an empty tree should fail' '\n+\t! tag_exists mytag\n+'\n \n test_expect_success 'creating a tag in an empty tree should fail' '\n \ttest_must_fail git tag mynotag &&\n@@ -66,27 +67,32 @@ test_expect_success 'listing all tags if one exists should output that tag' '\n \n # pattern matching:\n \n-test_expect_success 'listing a tag using a matching pattern should succeed' \\\n-\t'git tag -l mytag'\n+test_expect_success 'listing a tag using a matching pattern should succeed' '\n+\tgit tag -l mytag\n+'\n \n test_expect_success \\\n-\t'listing a tag using a matching pattern should output that tag' \\\n-\t'test `git tag -l mytag` = mytag'\n+\t'listing a tag using a matching pattern should output that tag' '\n+\ttest `git tag -l mytag` = mytag\n+'\n \n # todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success \\\n-\t'listing tags using a non-matching pattern should suceed' \\\n-\t'git tag -l xxx'\n+\t'listing tags using a non-matching pattern should suceed' '\n+\tgit tag -l xxx\n+'\n \n test_expect_success \\\n-\t'listing tags using a non-matching pattern should output nothing' \\\n-\t'test `git tag -l xxx | wc -l` -eq 0'\n+\t'listing tags using a non-matching pattern should output nothing' '\n+\ttest `git tag -l xxx | wc -l` -eq 0\n+'\n \n # special cases for creating tags:\n \n test_expect_success \\\n-\t'trying to create a tag with the name of one existing should fail' \\\n-\t'test_must_fail git tag mytag'\n+\t'trying to create a tag with the name of one existing should fail' '\n+\ttest_must_fail git tag mytag\n+'\n \n test_expect_success \\\n \t'trying to create a tag with a non-valid name should fail' '\n@@ -111,15 +117,17 @@ test_expect_success 'trying to delete an unknown tag should fail' '\n \ttest_must_fail git tag -d unknown-tag\n '\n \n-cat >expect <<EOF\n-myhead\n-mytag\n-EOF\n test_expect_success \\\n \t'trying to delete tags without params should succeed and do nothing' '\n-\tgit tag -l > actual && test_cmp expect actual &&\n+\tcat >expect <<-EOF &&\n+\t\tmyhead\n+\t\tmytag\n+\tEOF\n+\tgit tag -l >actual &&\n+\ttest_cmp expect actual &&\n \tgit tag -d &&\n-\tgit tag -l > actual && test_cmp expect actual\n+\tgit tag -l >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success \\\n@@ -147,23 +155,25 @@ test_expect_success \\\n \t! tag_exists myhead\n '\n \n-test_expect_success 'trying to delete an already deleted tag should fail' \\\n-\t'test_must_fail git tag -d mytag'\n+test_expect_success \\\n+\t'trying to delete an already deleted tag should fail' '\n+\ttest_must_fail git tag -d mytag\n+'\n \n # listing various tags with pattern matching:\n \n-cat >expect <<EOF\n-a1\n-aa1\n-cba\n-t210\n-t211\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-EOF\n test_expect_success 'listing all tags should print them ordered' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\t\taa1\n+\t\tcba\n+\t\tt210\n+\t\tt211\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n \tgit tag v1.0.1 &&\n \tgit tag t211 &&\n \tgit tag aa1 &&\n@@ -173,88 +183,88 @@ test_expect_success 'listing all tags should print them ordered' '\n \tgit tag a1 &&\n \tgit tag v1.0 &&\n \tgit tag t210 &&\n-\tgit tag -l > actual &&\n+\tgit tag -l >actual &&\n \ttest_cmp expect actual &&\n-\tgit tag > actual &&\n+\tgit tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-a1\n-aa1\n-cba\n-EOF\n test_expect_success \\\n \t'listing tags with substring as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\t\taa1\n+\t\tcba\n+\tEOF\n \trm *a* &&\n-\tgit tag -l \"*a*\" > current &&\n+\tgit tag -l \"*a*\" >current &&\n \ttest_cmp expect current\n '\n \n-cat >expect <<EOF\n-v0.2.1\n-v1.0.1\n-EOF\n test_expect_success \\\n \t'listing tags with a suffix as pattern must print those matching' '\n-\tgit tag -l \"*.1\" > actual &&\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0.1\n+\tEOF\n+\tgit tag -l \"*.1\" >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-t210\n-t211\n-EOF\n test_expect_success \\\n \t'listing tags with a prefix as pattern must print those matching' '\n-\tgit tag -l \"t21*\" > actual &&\n+\tcat >expect <<-EOF &&\n+\t\tt210\n+\t\tt211\n+\tEOF\n+\tgit tag -l \"t21*\" >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-a1\n-EOF\n test_expect_success \\\n \t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l a1 > actual &&\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\tEOF\n+\tgit tag -l a1 >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-v1.0\n-EOF\n test_expect_success \\\n \t'listing tags using a name as pattern must print that one matching' '\n-\tgit tag -l v1.0 > actual &&\n+\tcat >expect <<-EOF &&\n+\t\tv1.0\n+\tEOF\n+\tgit tag -l v1.0 >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-v1.0.1\n-v1.1.3\n-EOF\n test_expect_success \\\n \t'listing tags with ? in the pattern should print those matching' '\n-\tgit tag -l \"v1.?.?\" > actual &&\n+\tcat >expect <<-EOF &&\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n+\tgit tag -l \"v1.?.?\" >actual &&\n \ttest_cmp expect actual\n '\n \n->expect\n test_expect_success \\\n \t'listing tags using v.* should print nothing because none have v.' '\n-\tgit tag -l \"v.*\" > actual &&\n+\t>expect &&\n+\tgit tag -l \"v.*\" >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-EOF\n test_expect_success \\\n \t'listing tags using v* should print only those having v' '\n-\tgit tag -l \"v*\" > actual &&\n+\tcat >expect <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\tEOF\n+\tgit tag -l \"v*\" >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -272,66 +282,73 @@ test_expect_success \\\n \ttest $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)\n '\n \n-test_expect_success 'trying to verify an unknown tag should fail' \\\n-\t'test_must_fail git tag -v unknown-tag'\n+test_expect_success 'trying to verify an unknown tag should fail' '\n+\ttest_must_fail git tag -v unknown-tag\n+'\n \n test_expect_success \\\n-\t'trying to verify a non-annotated and non-signed tag should fail' \\\n-\t'test_must_fail git tag -v non-annotated-tag'\n+\t'trying to verify a non-annotated and non-signed tag should fail' '\n+\ttest_must_fail git tag -v non-annotated-tag\n+'\n \n test_expect_success \\\n-\t'trying to verify many non-annotated or unknown tags, should fail' \\\n-\t'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'\n+\t'trying to verify many non-annotated or unknown tags, should fail' '\n+\ttest_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2\n+'\n \n # creating annotated tags:\n \n+here='s/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g'\n+\n get_tag_msg () {\n \tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n }\n \n # run test_tick before committing always gives the time in that timezone\n get_tag_header () {\n-cat <<EOF\n-object $2\n-type $3\n-tag $1\n-tagger C O Mitter <committer@example.com> $4 -0700\n+\t# name, object, type, time\n+\tcat <<-EOF &&\n+\t\tobject $2\n+\t\ttype $3\n+\t\ttag $1\n+\t\ttagger C O Mitter <committer@example.com> $4 -0700\n \n-EOF\n+\tEOF\n+\tsed -e \"$here\"\n }\n \n-commit=$(git rev-parse HEAD)\n-time=$test_tick\n-\n-get_tag_header annotated-tag $commit commit $time >expect\n-echo \"A message\" >>expect\n test_expect_success \\\n \t'creating an annotated tag with -m message should succeed' '\n+\tcommit=$(git rev-parse HEAD) &&\n+\ttime=$test_tick &&\n+\tget_tag_header annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tA message\n+\tEOF\n \tgit tag -m \"A message\" annotated-tag &&\n \tget_tag_msg annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >msgfile <<EOF\n-Another message\n-in a file.\n-EOF\n-get_tag_header file-annotated-tag $commit commit $time >expect\n-cat msgfile >>expect\n test_expect_success \\\n \t'creating an annotated tag with -F messagefile should succeed' '\n+\tcat >msgfile <<-EOF &&\n+\t\tA message from the\n+\t\tstandard input\n+\tEOF\n+\tget_tag_header file-annotated-tag $commit commit $time >expect <msgfile\n \tgit tag -F msgfile file-annotated-tag &&\n \tget_tag_msg file-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >inputmsg <<EOF\n-A message from the\n-standard input\n-EOF\n-get_tag_header stdin-annotated-tag $commit commit $time >expect\n-cat inputmsg >>expect\n test_expect_success 'creating an annotated tag with -F - should succeed' '\n+\tcat >inputmsg <<-EOF &&\n+\t\tA message from the\n+\t\tstandard input\n+\tEOF\n+\tget_tag_header stdin-annotated-tag $commit commit $time \\\n+\t\t>expect <inputmsg\n \tgit tag -F - stdin-annotated-tag <inputmsg &&\n \tget_tag_msg stdin-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -361,67 +378,87 @@ test_expect_success \\\n \n # blank and empty messages:\n \n-get_tag_header empty-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with an empty -m message should succeed' '\n+\t>emptyfile &&\n+\tget_tag_header empty-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -m \"\" empty-annotated-tag &&\n \tget_tag_msg empty-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n->emptyfile\n-get_tag_header emptyfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with an empty -F messagefile should succeed' '\n+\tget_tag_header emptyfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F emptyfile emptyfile-annotated-tag &&\n \tget_tag_msg emptyfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' >blanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>blanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>blanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>blanksfile\n-get_tag_header blanks-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-Leading blank lines\n+test_expect_success \\\n+\t'extra blanks in the message for an annotated tag should be removed' '\n+\tsed -e \"$here\" >blanksfile <<-\\EOF &&\n \n-Repeated blank lines\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n \n-Trailing spaces\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n \n-Trailing blank lines\n-EOF\n-test_expect_success \\\n-\t'extra blanks in the message for an annotated tag should be removed' '\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tget_tag_header blanks-annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tLeading blank lines\n+\n+\t\tRepeated blank lines\n+\n+\t\tTrailing spaces\n+\n+\t\tTrailing blank lines\n+\tEOF\n \tgit tag -F blanksfile blanks-annotated-tag &&\n \tget_tag_msg blanks-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header blank-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with blank -m message with spaces should succeed' '\n+\tget_tag_header blank-annotated-tag $commit commit $time >expect <emptyfile &&\n \tgit tag -m \"     \" blank-annotated-tag &&\n \tget_tag_msg blank-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-echo '     ' >blankfile\n-echo ''      >>blankfile\n-echo '  '    >>blankfile\n-get_tag_header blankfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with blank -F messagefile with spaces should succeed' '\n+\tsed -e \"$here\" >blankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tget_tag_header blankfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F blankfile blankfile-annotated-tag &&\n \tget_tag_msg blankfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '      ' >blanknonlfile\n-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with -F file of spaces and no newline should succeed' '\n+\tprintf \"      \" >blanknonlfile &&\n+\tget_tag_header blanknonlfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F blanknonlfile blanknonlfile-annotated-tag &&\n \tget_tag_msg blanknonlfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -429,62 +466,67 @@ test_expect_success \\\n \n # messages with commented lines:\n \n-cat >commentsfile <<EOF\n-# A comment\n+test_expect_success \\\n+\t'creating a tag using a -F messagefile with #comments should succeed' '\n+\tcat >commentsfile <<-EOF &&\n+\t\t# A comment\n \n-############\n-The message.\n-############\n-One line.\n+\t\t############\n+\t\tThe message.\n+\t\t############\n+\t\tOne line.\n \n \n-# commented lines\n-# commented lines\n+\t\t# commented lines\n+\t\t# commented lines\n \n-Another line.\n-# comments\n+\t\tAnother line.\n+\t\t# comments\n \n-Last line.\n-EOF\n-get_tag_header comments-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-The message.\n-One line.\n+\t\tLast line.\n+\tEOF\n+\tget_tag_header comments-annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tThe message.\n+\t\tOne line.\n \n-Another line.\n+\t\tAnother line.\n \n-Last line.\n-EOF\n-test_expect_success \\\n-\t'creating a tag using a -F messagefile with #comments should succeed' '\n+\t\tLast line.\n+\tEOF\n \tgit tag -F commentsfile comments-annotated-tag &&\n \tget_tag_msg comments-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header comment-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with a #comment in the -m message should succeed' '\n+\tget_tag_header comment-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -m \"#comment\" comment-annotated-tag &&\n \tget_tag_msg comment-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-echo '#comment' >commentfile\n-echo ''         >>commentfile\n-echo '####'     >>commentfile\n-get_tag_header commentfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with #comments in the -F messagefile should succeed' '\n+\tcat >commentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tget_tag_header commentfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F commentfile commentfile-annotated-tag &&\n \tget_tag_msg commentfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '#comment' >commentnonlfile\n-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with a file of #comment and no newline should succeed' '\n+\tprintf \"#comment\" >commentnonlfile &&\n+\tget_tag_header commentnonlfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F commentnonlfile commentnonlfile-annotated-tag &&\n \tget_tag_msg commentnonlfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -542,11 +584,13 @@ test_expect_success \\\n \ttest_cmp expect actual\n '\n \n-echo 'tag line one' >annotagmsg\n-echo 'tag line two' >>annotagmsg\n-echo 'tag line three' >>annotagmsg\n test_expect_success \\\n \t'listing many message lines of a non-signed tag should succeed' '\n+\tcat >annotagmsg <<-EOF &&\n+\t\ttag line one\n+\t\ttag line two\n+\t\ttag line three\n+\tEOF\n \tgit tag -F annotagmsg tag-lines &&\n \n \techo \"tag-lines\" >expect &&\n@@ -588,9 +632,9 @@ test_expect_success \\\n \n test_expect_success 'annotations for blobs are empty' '\n \tblob=$(git hash-object -w --stdin <<-\\EOF\n-\tBlob paragraph 1.\n+\t\tBlob paragraph 1.\n \n-\tBlob paragraph 2.\n+\t\tBlob paragraph 2.\n \tEOF\n \t) &&\n \tgit tag tag-blob $blob &&\n@@ -621,20 +665,22 @@ test_expect_success GPG \\\n \n # creating and verifying signed tags:\n \n-get_tag_header signed-tag $commit commit $time >expect\n-echo 'A signed tag message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG 'creating a signed tag with -m message should succeed' '\n+test_expect_success GPG \\\n+\t'creating a signed tag with -m message should succeed' '\n+\tget_tag_header signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A signed tag message\" signed-tag &&\n \tget_tag_msg signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header u-signed-tag $commit commit $time >expect\n-echo 'Another message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'sign with a given key id' '\n-\n+\tget_tag_header u-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tAnother message\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -u committer@example.com -m \"Another message\" u-signed-tag &&\n \tget_tag_msg u-signed-tag >actual &&\n \ttest_cmp expect actual\n@@ -654,54 +700,54 @@ test_expect_success GPG 'sign with an unknown id (2)' '\n \n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n-test -n \"$1\" && exec >\"$1\"\n-echo A signed tag message\n-echo from a fake editor.\n-EOF\n-chmod +x fakeeditor\n-\n-get_tag_header implied-sign $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-u implies signed tag' '\n+\twrite_script fakeeditor <<-\\EOF &&\n+\t\ttest -n \"$1\" && exec >\"$1\"\n+\t\techo A signed tag message\n+\t\techo from a fake editor.\n+\tEOF\n+\tget_tag_header implied-sign $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tGIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&\n \tget_tag_msg implied-sign >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >sigmsgfile <<EOF\n-Another signed tag\n-message in a file.\n-EOF\n-get_tag_header file-signed-tag $commit commit $time >expect\n-cat sigmsgfile >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with -F messagefile should succeed' '\n+\tcat >sigmsgfile <<-EOF\n+\t\tAnother signed tag\n+\t\tmessage in a file.\n+\tEOF\n+\tget_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile\n+\techo \"-----BEGIN PGP SIGNATURE-----\" >>expect\n \tgit tag -s -F sigmsgfile file-signed-tag &&\n \tget_tag_msg file-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >siginputmsg <<EOF\n-A signed tag message from\n-the standard input\n-EOF\n-get_tag_header stdin-signed-tag $commit commit $time >expect\n-cat siginputmsg >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n+\tcat >siginputmsg <<-EOF\n+\t\tA signed tag message from\n+\t\tthe standard input\n+\tEOF\n+\tget_tag_header stdin-signed-tag $commit commit $time \\\n+\t\t>expect <siginputmsg &&\n+\techo \"-----BEGIN PGP SIGNATURE-----\" >>expect\n \tgit tag -s -F - stdin-signed-tag <siginputmsg &&\n \tget_tag_msg stdin-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header implied-annotate $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-s implies annotated tag' '\n+\tget_tag_header implied-annotate $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tGIT_EDITOR=./fakeeditor git tag -s implied-annotate &&\n \tget_tag_msg implied-annotate >actual &&\n \ttest_cmp expect actual\n@@ -715,11 +761,14 @@ test_expect_success GPG \\\n \t! tag_exists nosigtag\n '\n \n-test_expect_success GPG 'verifying a signed tag should succeed' \\\n-\t'git tag -v signed-tag'\n+test_expect_success GPG 'verifying a signed tag should succeed' '\n+\tgit tag -v signed-tag\n+'\n \n-test_expect_success GPG 'verifying two signed tags in one command should succeed' \\\n-\t'git tag -v signed-tag file-signed-tag'\n+test_expect_success GPG \\\n+\t'verifying two signed tags in one command should succeed' '\n+\tgit tag -v signed-tag file-signed-tag\n+'\n \n test_expect_success GPG \\\n \t'verifying many signed and non-signed tags should fail' '\n@@ -740,149 +789,181 @@ test_expect_success GPG 'verifying a forged tag should fail' '\n \n # blank and empty messages for signed tags:\n \n-get_tag_header empty-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with an empty -m message should succeed' '\n+\tget_tag_header empty-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"\" empty-signed-tag &&\n \tget_tag_msg empty-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v empty-signed-tag\n '\n \n->sigemptyfile\n-get_tag_header emptyfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with an empty -F messagefile should succeed' '\n+\t>sigemptyfile &&\n+\tget_tag_header emptyfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigemptyfile emptyfile-signed-tag &&\n \tget_tag_msg emptyfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v emptyfile-signed-tag\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' > sigblanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>sigblanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>sigblanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>sigblanksfile\n-get_tag_header blanks-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-Leading blank lines\n+test_expect_success GPG \\\n+\t'extra blanks in the message for a signed tag should be removed' '\n+\tsed -e \"$here\" >sigblanksfile <<-\\EOF &&\n \n-Repeated blank lines\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n \n-Trailing spaces\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n \n-Trailing blank lines\n-EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'extra blanks in the message for a signed tag should be removed' '\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tget_tag_header blanks-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tLeading blank lines\n+\n+\t\tRepeated blank lines\n+\n+\t\tTrailing spaces\n+\n+\t\tTrailing blank lines\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigblanksfile blanks-signed-tag &&\n \tget_tag_msg blanks-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blanks-signed-tag\n '\n \n-get_tag_header blank-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with a blank -m message should succeed' '\n+\tget_tag_header blank-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"     \" blank-signed-tag &&\n \tget_tag_msg blank-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blank-signed-tag\n '\n \n-echo '     ' >sigblankfile\n-echo ''      >>sigblankfile\n-echo '  '    >>sigblankfile\n-get_tag_header blankfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with blank -F file with spaces should succeed' '\n+\tsed -e \"$here\" >sigblankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tget_tag_header blankfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigblankfile blankfile-signed-tag &&\n \tget_tag_msg blankfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blankfile-signed-tag\n '\n \n-printf '      ' >sigblanknonlfile\n-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with spaces and no newline should succeed' '\n+\tprintf >sigblanknonlfile \"      \" &&\n+\tget_tag_header blanknonlfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&\n \tget_tag_msg blanknonlfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n-\tgit tag -v signed-tag\n+\tgit tag -v blanknonlfile-signed-tag\n '\n \n # messages with commented lines for signed tags:\n \n-cat >sigcommentsfile <<EOF\n-# A comment\n+test_expect_success GPG \\\n+\t'creating a signed tag with a -F file with #comments should succeed' '\n+\tcat >sigcommentsfile <<-EOF &&\n+\t\t# A comment\n \n-############\n-The message.\n-############\n-One line.\n+\t\t############\n+\t\tThe message.\n+\t\t############\n+\t\tOne line.\n \n \n-# commented lines\n-# commented lines\n+\t\t# commented lines\n+\t\t# commented lines\n \n-Another line.\n-# comments\n+\t\tAnother line.\n+\t\t# comments\n \n-Last line.\n-EOF\n-get_tag_header comments-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n-The message.\n-One line.\n+\t\tLast line.\n+\tEOF\n+\tget_tag_header comments-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tThe message.\n+\t\tOne line.\n \n-Another line.\n+\t\tAnother line.\n \n-Last line.\n-EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a -F file with #comments should succeed' '\n+\t\tLast line.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigcommentsfile comments-signed-tag &&\n \tget_tag_msg comments-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v comments-signed-tag\n '\n \n-get_tag_header comment-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with #commented -m message should succeed' '\n+\tget_tag_header comment-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"#comment\" comment-signed-tag &&\n \tget_tag_msg comment-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v comment-signed-tag\n '\n \n-echo '#comment' >sigcommentfile\n-echo ''         >>sigcommentfile\n-echo '####'     >>sigcommentfile\n-get_tag_header commentfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with #commented -F messagefile should succeed' '\n+\tcat >sigcommentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tget_tag_header commentfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigcommentfile commentfile-signed-tag &&\n \tget_tag_msg commentfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v commentfile-signed-tag\n '\n \n-printf '#comment' >sigcommentnonlfile\n-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with a #comment and no newline should succeed' '\n+\tprintf \"#comment\" >sigcommentnonlfile &&\n+\tget_tag_header commentnonlfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&\n \tget_tag_msg commentnonlfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -941,11 +1022,13 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-echo 'stag line one' >sigtagmsg\n-echo 'stag line two' >>sigtagmsg\n-echo 'stag line three' >>sigtagmsg\n test_expect_success GPG \\\n \t'listing many message lines of a signed tag should succeed' '\n+\tcat >sigtagmsg <<-EOF &&\n+\t\tstag line one\n+\t\tstag line two\n+\t\tstag line three\n+\tEOF\n \tgit tag -s -F sigtagmsg stag-lines &&\n \n \techo \"stag-lines\" >expect &&\n@@ -987,72 +1070,68 @@ test_expect_success GPG \\\n \n # tags pointing to objects different from commits:\n \n-tree=$(git rev-parse HEAD^{tree})\n-blob=$(git rev-parse HEAD:foo)\n-tag=$(git rev-parse signed-tag 2>/dev/null)\n-\n-get_tag_header tree-signed-tag $tree tree $time >expect\n-echo \"A message for a tree\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to a tree should succeed' '\n+\ttree=$(git rev-parse HEAD^{tree}) &&\n+\tblob=$(git rev-parse HEAD:foo) &&\n+\ttag=$(git rev-parse signed-tag) &&\n+\tget_tag_header tree-signed-tag $tree tree $time >expect <<-EOF &&\n+\t\tA message for a tree\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for a tree\" tree-signed-tag HEAD^{tree} &&\n \tget_tag_msg tree-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header blob-signed-tag $blob blob $time >expect\n-echo \"A message for a blob\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to a blob should succeed' '\n+\tget_tag_header blob-signed-tag $blob blob $time >expect <<-EOF &&\n+\t\tA message for a blob\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for a blob\" blob-signed-tag HEAD:foo &&\n \tget_tag_msg blob-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header tag-signed-tag $tag tag $time >expect\n-echo \"A message for another tag\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to another tag should succeed' '\n+\tget_tag_header tag-signed-tag $tag tag $time >expect <<-EOF &&\n+\t\tA message for another tag\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for another tag\" tag-signed-tag signed-tag &&\n \tget_tag_msg tag-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n # usage with rfc1991 signatures\n-echo \"rfc1991\" > gpghome/gpg.conf\n-get_tag_header rfc1991-signed-tag $commit commit $time >expect\n-echo \"RFC1991 signed tag\" >>expect\n-echo '-----BEGIN PGP MESSAGE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with rfc1991' '\n+test_expect_success GPG 'creating a signed tag with rfc1991' '\n+\techo \"rfc1991\" >gpghome/gpg.conf &&\n+\tget_tag_header rfc1991-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tRFC1991 signed tag\n+\t\t-----BEGIN PGP MESSAGE-----\n+\tEOF\n \tgit tag -s -m \"RFC1991 signed tag\" rfc1991-signed-tag $commit &&\n \tget_tag_msg rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n-cp \"$1\" actual\n-EOF\n-chmod +x fakeeditor\n-\n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n+\twrite_script fakeeditor <<-\\EOF &&\n+\t\tcp \"$1\" actual\n+\tEOF\n \techo \"RFC1991 signed tag\" >expect &&\n \tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature' '\n+test_expect_success GPG 'verifying rfc1991 signature' '\n \tgit tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature' '\n+test_expect_success GPG 'list tag with rfc1991 signature' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n \tgit tag -l -n1 rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -1062,15 +1141,12 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-rm -f gpghome/gpg.conf\n-\n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature without --rfc1991' '\n+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '\n+\trm -f gpghome/gpg.conf &&\n \tgit tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature without --rfc1991' '\n+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n \tgit tag -l -n1 rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -1080,26 +1156,26 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n \tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-# try to sign with bad user.signingkey\n-git config user.signingkey BobTheMouse\n-test_expect_success GPG \\\n-\t'git tag -s fails if gpg is misconfigured' \\\n-\t'test_must_fail git tag -s -m tail tag-gpg-failure'\n-git config --unset user.signingkey\n+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '\n+\t# try to sign with bad user.signingkey\n+\tgit config user.signingkey BobTheMouse &&\n+\ttest_must_fail git tag -s -m tail tag-gpg-failure &&\n+\tgit config --unset user.signingkey\n+'\n \n # try to verify without gpg:\n \n-rm -rf gpghome\n test_expect_success GPG \\\n-\t'verify signed tag fails when public key is not present' \\\n-\t'test_must_fail git tag -v signed-tag'\n+\t'verify signed tag fails when public key is not present' '\n+\trm -rf gpghome &&\n+\ttest_must_fail git tag -v signed-tag\n+'\n \n test_expect_success \\\n \t'git tag -a fails if tag annotation is empty' '\n@@ -1108,7 +1184,7 @@ test_expect_success \\\n \n test_expect_success \\\n \t'message in editor has initial comment' '\n-\t! (GIT_EDITOR=cat git tag -a initial-comment > actual)\n+\t! (GIT_EDITOR=cat git tag -a initial-comment >actual)\n '\n \n test_expect_success 'message in editor has initial comment: first line' '\n@@ -1126,12 +1202,13 @@ test_expect_success \\\n \ttest_cmp rest.expect rest.actual\n '\n \n-get_tag_header reuse $commit commit $time >expect\n-echo \"An annotation to be reused\" >> expect\n test_expect_success \\\n \t'overwriting an annoted tag should use its previous body' '\n+\tget_tag_header reuse $commit commit $time >expect <<-EOF &&\n+\t\treuse\n+\tEOF\n \tgit tag -a -m \"An annotation to be reused\" reuse &&\n-\tGIT_EDITOR=true git tag -f -a reuse &&\n+\tGIT_EDITOR=true git tag -f -a -m \"reuse\" reuse &&\n \tget_tag_msg reuse >actual &&\n \ttest_cmp expect actual\n '\n@@ -1158,118 +1235,107 @@ test_expect_success 'filename for the message is relative to cwd' '\n \n # create a few more commits to test --contains\n \n-hash1=$(git rev-parse HEAD)\n-\n test_expect_success 'creating second commit and tag' '\n+\thash1=$(git rev-parse HEAD) &&\n \techo foo-2.0 >foo &&\n \tgit add foo &&\n \tgit commit -m second &&\n+\thash2=$(git rev-parse HEAD) &&\n \tgit tag v2.0\n '\n \n-hash2=$(git rev-parse HEAD)\n-\n test_expect_success 'creating third commit without tag' '\n \techo foo-dev >foo &&\n \tgit add foo &&\n-\tgit commit -m third\n+\tgit commit -m third &&\n+\thash3=$(git rev-parse HEAD)\n '\n \n-hash3=$(git rev-parse HEAD)\n-\n-# simple linear checks of --continue\n+# simple linear checks of --contains\n \n-cat > expected <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-v2.0\n-EOF\n-\n-test_expect_success 'checking that first commit is in all tags (hash)' \"\n+test_expect_success 'checking that first commit is in all tags (hash)' '\n+\tcat >expected <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\t\tv2.0\n+\tEOF\n \tgit tag -l --contains $hash1 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # other ways of specifying the commit\n-test_expect_success 'checking that first commit is in all tags (tag)' \"\n+test_expect_success 'checking that first commit is in all tags (tag)' '\n \tgit tag -l --contains v1.0 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n-test_expect_success 'checking that first commit is in all tags (relative)' \"\n+test_expect_success 'checking that first commit is in all tags (relative)' '\n \tgit tag -l --contains HEAD~2 v* >actual &&\n \ttest_cmp expected actual\n-\"\n-\n-cat > expected <<EOF\n-v2.0\n-EOF\n+'\n \n-test_expect_success 'checking that second commit only has one tag' \"\n+test_expect_success 'checking that second commit only has one tag' '\n+\tcat >expected <<-EOF &&\n+\t\tv2.0\n+\tEOF\n \tgit tag -l --contains $hash2 v* >actual &&\n \ttest_cmp expected actual\n-\"\n-\n-\n-cat > expected <<EOF\n-EOF\n+'\n \n-test_expect_success 'checking that third commit has no tags' \"\n+test_expect_success 'checking that third commit has no tags' '\n+\tcat >expected <<-EOF &&\n+\tEOF\n \tgit tag -l --contains $hash3 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # how about a simple merge?\n \n test_expect_success 'creating simple branch' '\n \tgit branch stable v2.0 &&\n-        git checkout stable &&\n-\techo foo-3.0 > foo &&\n+\tgit checkout stable &&\n+\techo foo-3.0 >foo &&\n \tgit commit foo -m fourth &&\n+\thash4=$(git rev-parse HEAD) &&\n \tgit tag v3.0\n '\n \n-hash4=$(git rev-parse HEAD)\n-\n-cat > expected <<EOF\n-v3.0\n-EOF\n-\n-test_expect_success 'checking that branch head only has one tag' \"\n+test_expect_success 'checking that branch head only has one tag' '\n+\tcat >expected <<-EOF &&\n+\t\tv3.0\n+\tEOF\n \tgit tag -l --contains $hash4 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n test_expect_success 'merging original branch into this branch' '\n \tgit merge --strategy=ours master &&\n-        git tag v4.0\n+\tgit tag v4.0\n '\n \n-cat > expected <<EOF\n-v4.0\n-EOF\n-\n-test_expect_success 'checking that original branch head has one tag now' \"\n+test_expect_success 'checking that original branch head has one tag now' '\n+\tcat >expected <<-EOF &&\n+\t\tv4.0\n+\tEOF\n \tgit tag -l --contains $hash3 v* >actual &&\n \ttest_cmp expected actual\n-\"\n-\n-cat > expected <<EOF\n-v0.2.1\n-v1.0\n-v1.0.1\n-v1.1.3\n-v2.0\n-v3.0\n-v4.0\n-EOF\n-\n-test_expect_success 'checking that initial commit is in all tags' \"\n+'\n+\n+test_expect_success 'checking that initial commit is in all tags' '\n+\tcat >expected <<-EOF &&\n+\t\tv0.2.1\n+\t\tv1.0\n+\t\tv1.0.1\n+\t\tv1.1.3\n+\t\tv2.0\n+\t\tv3.0\n+\t\tv4.0\n+\tEOF\n \tgit tag -l --contains $hash1 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # mixing modes and options:\n \n@@ -1305,8 +1371,8 @@ test_expect_success '--points-at finds annotated tags of tags' '\n \tgit tag -m \"describing the v4.0 tag object\" \\\n \t\tannotated-again-v4.0 annotated-v4.0 &&\n \tcat >expect <<-\\EOF &&\n-\tannotated-again-v4.0\n-\tannotated-v4.0\n+\t\tannotated-again-v4.0\n+\t\tannotated-v4.0\n \tEOF\n \tgit tag --points-at=annotated-v4.0 >actual &&\n \ttest_cmp expect actual\n@@ -1314,8 +1380,8 @@ test_expect_success '--points-at finds annotated tags of tags' '\n \n test_expect_success 'multiple --points-at are OR-ed together' '\n \tcat >expect <<-\\EOF &&\n-\tv2.0\n-\tv3.0\n+\t\tv2.0\n+\t\tv3.0\n \tEOF\n \tgit tag --points-at=v2.0 --points-at=v3.0 >actual &&\n \ttest_cmp expect actual\n-- \n1.7.8\n"},{"id":"185959","messageId":"1330740942-25130-3-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 2/5] t5512 (ls-remote): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:34Z","receivedAt":"2012-03-03T02:15:34Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Guard setup with test_expect_success\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t5512-ls-remote.sh |   10 ++++++----\n 1 files changed, 6 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 5c546c9..811dcc3 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -102,11 +102,13 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \n '\n \n-cat >exp <<EOF\n-fatal: 'refs*master' does not appear to be a git repository\n-fatal: The remote end hung up unexpectedly\n-EOF\n test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t'\"\n+\tcat >exp <<-EOF\n+\t\tfatal: 'refs*master' does not appear to be a git repository\n+\t\tfatal: The remote end hung up unexpectedly\n+\tEOF\n+\t\"'\n \t#\n \t# Do not expect \"git ls-remote <pattern>\" to work; ls-remote, correctly,\n \t# confuses <pattern> for <remote>. Although ugly, this behaviour is akin\n-- \n1.7.8\n"},{"id":"185964","messageId":"1330740942-25130-4-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 3/5] t3200 (branch): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:35Z","receivedAt":"2012-03-03T02:15:35Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t3200-branch.sh |  365 +++++++++++++++++++++++++++--------------------------\n 1 files changed, 186 insertions(+), 179 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd1aceb..7191b89 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -7,20 +7,20 @@ test_description='git branch assorted tests'\n \n . ./test-lib.sh\n \n-test_expect_success \\\n-    'prepare a trivial repository' \\\n-    'echo Hello > A &&\n-     git update-index --add A &&\n-     git commit -m \"Initial commit.\" &&\n-     echo World >> A &&\n-     git update-index --add A &&\n-     git commit -m \"Second commit.\" &&\n-     HEAD=$(git rev-parse --verify HEAD)'\n+test_expect_success 'prepare a trivial repository' '\n+\techo Hello >A &&\n+\tgit update-index --add A &&\n+\tgit commit -m \"Initial commit.\" &&\n+\techo World >>A &&\n+\tgit update-index --add A &&\n+\tgit commit -m \"Second commit.\" &&\n+\tHEAD=$(git rev-parse --verify HEAD)\n+'\n \n test_expect_success \\\n-    'git branch --help should not have created a bogus branch' '\n-     test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&\n-     test_path_is_missing .git/refs/heads/--help\n+\t'git branch --help should not have created a bogus branch' '\n+\ttest_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&\n+\ttest_path_is_missing .git/refs/heads/--help\n '\n \n test_expect_success 'branch -h in broken repository' '\n@@ -34,63 +34,63 @@ test_expect_success 'branch -h in broken repository' '\n \tgrep \"[Uu]sage\" broken/usage\n '\n \n-test_expect_success \\\n-    'git branch abc should create a branch' \\\n-    'git branch abc && test_path_is_file .git/refs/heads/abc'\n+test_expect_success 'git branch abc should create a branch' '\n+\tgit branch abc && test_path_is_file .git/refs/heads/abc\n+'\n \n-test_expect_success \\\n-    'git branch a/b/c should create a branch' \\\n-    'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'\n+test_expect_success 'git branch a/b/c should create a branch' '\n+\tgit branch a/b/c && test_path_is_file .git/refs/heads/a/b/c\n+'\n \n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-EOF\n-test_expect_success \\\n-    'git branch -l d/e/f should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git branch -l d/e/f &&\n-\t test_path_is_file .git/refs/heads/d/e/f &&\n-\t test_path_is_file .git/logs/refs/heads/d/e/f &&\n-\t test_cmp expect .git/logs/refs/heads/d/e/f'\n+test_expect_success 'git branch -l d/e/f should create a branch and a log' '\n+\tcat >expect <<-EOF\n+\t\t$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n+\tEOF\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\t\tgit branch -l d/e/f &&\n+\ttest_path_is_file .git/refs/heads/d/e/f &&\n+\ttest_path_is_file .git/logs/refs/heads/d/e/f &&\n+\ttest_cmp expect .git/logs/refs/heads/d/e/f\n+'\n \n-test_expect_success \\\n-    'git branch -d d/e/f should delete a branch and a log' \\\n-\t'git branch -d d/e/f &&\n-\t test_path_is_missing .git/refs/heads/d/e/f &&\n-\t test_path_is_missing .git/logs/refs/heads/d/e/f'\n+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '\n+\tgit branch -d d/e/f &&\n+\ttest_path_is_missing .git/refs/heads/d/e/f &&\n+\ttest_path_is_missing .git/logs/refs/heads/d/e/f\n+'\n \n-test_expect_success \\\n-    'git branch j/k should work after branch j has been deleted' \\\n-       'git branch j &&\n-        git branch -d j &&\n-        git branch j/k'\n+test_expect_success 'git branch j/k should work after branch j has been deleted' '\n+\tgit branch j &&\n+\tgit branch -d j &&\n+\tgit branch j/k\n+'\n \n-test_expect_success \\\n-    'git branch l should work after branch l/m has been deleted' \\\n-       'git branch l/m &&\n-        git branch -d l/m &&\n-        git branch l'\n+test_expect_success 'git branch l should work after branch l/m has been deleted' '\n+\tgit branch l/m &&\n+\tgit branch -d l/m &&\n+\tgit branch l\n+'\n \n-test_expect_success \\\n-    'git branch -m dumps usage' \\\n-       'test_expect_code 129 git branch -m 2>err &&\n-\tgrep \"[Uu]sage: git branch\" err'\n+test_expect_success 'git branch -m dumps usage' '\n+\ttest_expect_code 129 git branch -m 2>err &&\n+\tgrep \"[Uu]sage: git branch\" err\n+'\n \n-test_expect_success \\\n-    'git branch -m m m/m should work' \\\n-       'git branch -l m &&\n-        git branch -m m m/m &&\n-\ttest_path_is_file .git/logs/refs/heads/m/m'\n+test_expect_success 'git branch -m m m/m should work' '\n+\tgit branch -l m &&\n+\tgit branch -m m m/m &&\n+\ttest_path_is_file .git/logs/refs/heads/m/m\n+'\n \n-test_expect_success \\\n-    'git branch -m n/n n should work' \\\n-       'git branch -l n/n &&\n+test_expect_success 'git branch -m n/n n should work' '\n+\tgit branch -l n/n &&\n \tgit branch -m n/n n &&\n-\ttest_path_is_file .git/logs/refs/heads/n'\n+\ttest_path_is_file .git/logs/refs/heads/n\n+'\n \n test_expect_success 'git branch -m o/o o should fail when o/p exists' '\n \tgit branch o/o &&\n-        git branch o/p &&\n+\tgit branch o/p &&\n \ttest_must_fail git branch -m o/o o\n '\n \n@@ -160,33 +160,30 @@ test_expect_success 'git branch --list -d t should fail' '\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n-mv .git/config .git/config-saved\n-\n test_expect_success 'git branch -m q q2 without config should succeed' '\n+\tmv .git/config .git/config-saved &&\n+\ttest_when_finished mv .git/config-saved .git/config &&\n \tgit branch -m q q2 &&\n \tgit branch -m q2 q\n '\n \n-mv .git/config-saved .git/config\n-\n-git config branch.s/s.dummy Hello\n-\n-test_expect_success \\\n-    'git branch -m s/s s should work when s/t is deleted' \\\n-       'git branch -l s/s &&\n+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '\n+\tgit config branch.s/s.dummy Hello\n+\tgit branch -l s/s &&\n \ttest_path_is_file .git/logs/refs/heads/s/s &&\n-        git branch -l s/t &&\n+\tgit branch -l s/t &&\n \ttest_path_is_file .git/logs/refs/heads/s/t &&\n-        git branch -d s/t &&\n-        git branch -m s/s s &&\n-\ttest_path_is_file .git/logs/refs/heads/s'\n-\n-test_expect_success 'config information was renamed, too' \\\n-\t\"test $(git config branch.s.dummy) = Hello &&\n-\t test_must_fail git config branch.s/s/dummy\"\n+\tgit branch -d s/t &&\n+\tgit branch -m s/s s &&\n+\ttest_path_is_file .git/logs/refs/heads/s\n+'\n \n-test_expect_success 'renaming a symref is not allowed' \\\n+test_expect_success 'config information was renamed, too' '\n+\ttest $(git config branch.s.dummy) = Hello &&\n+\ttest_must_fail git config branch.s/s/dummy\n '\n+\n+test_expect_success 'renaming a symref is not allowed' '\n \tgit symbolic-ref refs/heads/master2 refs/heads/master &&\n \ttest_must_fail git branch -m master2 master3 &&\n \tgit symbolic-ref refs/heads/master2 &&\n@@ -194,115 +191,125 @@ test_expect_success 'renaming a symref is not allowed' \\\n \ttest_path_is_missing .git/refs/heads/master3\n '\n \n-test_expect_success SYMLINKS \\\n-    'git branch -m u v should fail when the reflog for u is a symlink' '\n-     git branch -l u &&\n-     mv .git/logs/refs/heads/u real-u &&\n-     ln -s real-u .git/logs/refs/heads/u &&\n-     test_must_fail git branch -m u v\n-'\n-\n-test_expect_success 'test tracking setup via --track' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my1 local/master &&\n-     test $(git config branch.my1.remote) = local &&\n-     test $(git config branch.my1.merge) = refs/heads/master'\n-\n-test_expect_success 'test tracking setup (non-wildcard, matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my4 local/master &&\n-     test $(git config branch.my4.remote) = local &&\n-     test $(git config branch.my4.merge) = refs/heads/master'\n-\n-test_expect_success 'test tracking setup (non-wildcard, not matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --track my5 local/master &&\n-     ! test \"$(git config branch.my5.remote)\" = local &&\n-     ! test \"$(git config branch.my5.merge)\" = refs/heads/master'\n-\n-test_expect_success 'test tracking setup via config' \\\n-    'git config branch.autosetupmerge true &&\n-     git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch my3 local/master &&\n-     test $(git config branch.my3.remote) = local &&\n-     test $(git config branch.my3.merge) = refs/heads/master'\n-\n-test_expect_success 'test overriding tracking setup via --no-track' \\\n-    'git config branch.autosetupmerge true &&\n-     git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/master || git fetch local) &&\n-     git branch --no-track my2 local/master &&\n-     git config branch.autosetupmerge false &&\n-     ! test \"$(git config branch.my2.remote)\" = local &&\n-     ! test \"$(git config branch.my2.merge)\" = refs/heads/master'\n-\n-test_expect_success 'no tracking without .fetch entries' \\\n-    'git config branch.autosetupmerge true &&\n-     git branch my6 s &&\n-     git config branch.automsetupmerge false &&\n-     test -z \"$(git config branch.my6.remote)\" &&\n-     test -z \"$(git config branch.my6.merge)\"'\n-\n-test_expect_success 'test tracking setup via --track but deeper' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n-     (git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n-     git branch --track my7 local/o/o &&\n-     test \"$(git config branch.my7.remote)\" = local &&\n-     test \"$(git config branch.my7.merge)\" = refs/heads/o/o'\n-\n-test_expect_success 'test deleting branch deletes branch config' \\\n-    'git branch -d my7 &&\n-     test -z \"$(git config branch.my7.remote)\" &&\n-     test -z \"$(git config branch.my7.merge)\"'\n-\n-test_expect_success 'test deleting branch without config' \\\n-    'git branch my7 s &&\n-     sha1=$(git rev-parse my7 | cut -c 1-7) &&\n-     echo \"Deleted branch my7 (was $sha1).\" >expect &&\n-     git branch -d my7 >actual 2>&1 &&\n-     test_i18ncmp expect actual'\n-\n-test_expect_success 'test --track without .fetch entries' \\\n-    'git branch --track my8 &&\n-     test \"$(git config branch.my8.remote)\" &&\n-     test \"$(git config branch.my8.merge)\"'\n+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '\n+\tgit branch -l u &&\n+\tmv .git/logs/refs/heads/u real-u &&\n+\tln -s real-u .git/logs/refs/heads/u &&\n+\ttest_must_fail git branch -m u v\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/autosetupmerge=always' \\\n-    'git config branch.autosetupmerge always &&\n-     git branch my9 HEAD^ &&\n-     git config branch.autosetupmerge false'\n+test_expect_success 'test tracking setup via --track' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch --track my1 local/master &&\n+\ttest $(git config branch.my1.remote) = local &&\n+\ttest $(git config branch.my1.merge) = refs/heads/master\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/--track causes failure' \\\n-    'test_must_fail git branch --track my10 HEAD^'\n+test_expect_success 'test tracking setup (non-wildcard, matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch \\\n+\t\trefs/heads/master:refs/remotes/local/master &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch --track my4 local/master &&\n+\ttest $(git config branch.my4.remote) = local &&\n+\ttest $(git config branch.my4.merge) = refs/heads/master\n+'\n \n-test_expect_success \\\n-    'branch from tag w/--track causes failure' \\\n-    'git tag foobar &&\n-     test_must_fail git branch --track my11 foobar'\n+test_expect_success 'test tracking setup (non-wildcard, not matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch --track my5 local/master &&\n+\t! test \"$(git config branch.my5.remote)\" = local &&\n+\t! test \"$(git config branch.my5.merge)\" = refs/heads/master\n+'\n+\n+test_expect_success 'test tracking setup via config' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch my3 local/master &&\n+\ttest $(git config branch.my3.remote) = local &&\n+\ttest $(git config branch.my3.merge) = refs/heads/master\n+'\n+\n+test_expect_success 'test overriding tracking setup via --no-track' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n+\tgit branch --no-track my2 local/master &&\n+\tgit config branch.autosetupmerge false &&\n+\t! test \"$(git config branch.my2.remote)\" = local &&\n+\t! test \"$(git config branch.my2.merge)\" = refs/heads/master\n+'\n+\n+test_expect_success 'no tracking without .fetch entries' '\n+\tgit config branch.autosetupmerge true &&\n+\tgit branch my6 s &&\n+\tgit config branch.automsetupmerge false &&\n+\ttest -z \"$(git config branch.my6.remote)\" &&\n+\ttest -z \"$(git config branch.my6.merge)\"\n+'\n+\n+test_expect_success 'test tracking setup via --track but deeper' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n+\t(git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n+\tgit branch --track my7 local/o/o &&\n+\ttest \"$(git config branch.my7.remote)\" = local &&\n+\ttest \"$(git config branch.my7.merge)\" = refs/heads/o/o\n+'\n+\n+test_expect_success 'test deleting branch deletes branch config' '\n+\tgit branch -d my7 &&\n+\ttest -z \"$(git config branch.my7.remote)\" &&\n+\ttest -z \"$(git config branch.my7.merge)\"\n+'\n+\n+test_expect_success 'test deleting branch without config' '\n+\tgit branch my7 s &&\n+\tsha1=$(git rev-parse my7 | cut -c 1-7) &&\n+\techo \"Deleted branch my7 (was $sha1).\" >expect &&\n+\tgit branch -d my7 >actual 2>&1 &&\n+\ttest_i18ncmp expect actual\n+'\n+\n+test_expect_success 'test --track without .fetch entries' '\n+\tgit branch --track my8 &&\n+\ttest \"$(git config branch.my8.remote)\" &&\n+\ttest \"$(git config branch.my8.merge)\"\n+'\n+\n+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '\n+\tgit config branch.autosetupmerge always &&\n+\tgit branch my9 HEAD^ &&\n+\tgit config branch.autosetupmerge false\n+'\n+\n+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '\n+\ttest_must_fail git branch --track my10 HEAD^\n+'\n+\n+test_expect_success 'branch from tag w/--track causes failure' '\n+\tgit tag foobar &&\n+\ttest_must_fail git branch --track my11 foobar\n+'\n \n # Keep this test last, as it changes the current branch\n-cat >expect <<EOF\n-$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-EOF\n-test_expect_success \\\n-    'git checkout -b g/h/i -l should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n-     git checkout -b g/h/i -l master &&\n-\t test_path_is_file .git/refs/heads/g/h/i &&\n-\t test_path_is_file .git/logs/refs/heads/g/h/i &&\n-\t test_cmp expect .git/logs/refs/heads/g/h/i'\n+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '\n+\tcat >expect <<-EOF\n+\t\t$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n+\tEOF\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\t\tgit checkout -b g/h/i -l master &&\n+\ttest_path_is_file .git/refs/heads/g/h/i &&\n+\ttest_path_is_file .git/logs/refs/heads/g/h/i &&\n+\ttest_cmp expect .git/logs/refs/heads/g/h/i\n+'\n \n test_expect_success 'checkout -b makes reflog by default' '\n \tgit checkout master &&\n-- \n1.7.8\n"},{"id":"185965","messageId":"1330740942-25130-5-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 4/5] t0040 (parse-options): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:36Z","receivedAt":"2012-03-03T02:15:36Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t0040-parse-options.sh |  438 ++++++++++++++++++++++------------------------\n 1 files changed, 212 insertions(+), 226 deletions(-)\n\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex a1e4616..4a0b991 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -7,87 +7,83 @@ test_description='our own option parser'\n \n . ./test-lib.sh\n \n-cat > expect << EOF\n-usage: test-parse-options <options>\n-\n-    -b, --boolean         get a boolean\n-    -4, --or4             bitwise-or boolean with ...0100\n-    --neg-or4             same as --no-or4\n-\n-    -i, --integer <n>     get a integer\n-    -j <n>                get a integer, too\n-    --set23               set integer to 23\n-    -t <time>             get timestamp of <time>\n-    -L, --length <str>    get length of <str>\n-    -F, --file <file>     set file to <file>\n-\n-String options\n-    -s, --string <string>\n-                          get a string\n-    --string2 <str>       get another string\n-    --st <st>             get another string (pervert ordering)\n-    -o <str>              get another string\n-    --default-string      set string to default\n-    --list <str>          add str to list\n-\n-Magic arguments\n-    --quux                means --quux\n-    -NUM                  set integer to NUM\n-    +                     same as -b\n-    --ambiguous           positive ambiguity\n-    --no-ambiguous        negative ambiguity\n-\n-Standard options\n-    --abbrev[=<n>]        use <n> digits to display SHA-1s\n-    -v, --verbose         be verbose\n-    -n, --dry-run         dry run\n-    -q, --quiet           be quiet\n-\n-EOF\n-\n test_expect_success 'test help' '\n-\ttest_must_fail test-parse-options -h > output 2> output.err &&\n+\tcat >expect <<-EOF &&\n+\t\tusage: test-parse-options <options>\n+\n+\t\t    -b, --boolean         get a boolean\n+\t\t    -4, --or4             bitwise-or boolean with ...0100\n+\t\t    --neg-or4             same as --no-or4\n+\n+\t\t    -i, --integer <n>     get a integer\n+\t\t    -j <n>                get a integer, too\n+\t\t    --set23               set integer to 23\n+\t\t    -t <time>             get timestamp of <time>\n+\t\t    -L, --length <str>    get length of <str>\n+\t\t    -F, --file <file>     set file to <file>\n+\n+\t\tString options\n+\t\t    -s, --string <string>\n+\t\t''                          get a string\n+\t\t    --string2 <str>       get another string\n+\t\t    --st <st>             get another string (pervert ordering)\n+\t\t    -o <str>              get another string\n+\t\t    --default-string      set string to default\n+\t\t    --list <str>          add str to list\n+\n+\t\tMagic arguments\n+\t\t    --quux                means --quux\n+\t\t    -NUM                  set integer to NUM\n+\t\t    +                     same as -b\n+\t\t    --ambiguous           positive ambiguity\n+\t\t    --no-ambiguous        negative ambiguity\n+\n+\t\tStandard options\n+\t\t    --abbrev[=<n>]        use <n> digits to display SHA-1s\n+\t\t    -v, --verbose         be verbose\n+\t\t    -n, --dry-run         dry run\n+\t\t    -q, --quiet           be quiet\n+\n+\tEOF\n+\tcp expect expect.err &&\n+\ttest_must_fail test-parse-options -h >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-mv expect expect.err\n-\n-cat > expect << EOF\n-boolean: 2\n-integer: 1729\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 2\n-quiet: no\n-dry run: yes\n-file: prefix/my.file\n-EOF\n-\n test_expect_success 'short options' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 2\n+\t\tinteger: 1729\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 2\n+\t\tquiet: no\n+\t\tdry run: yes\n+\t\tfile: prefix/my.file\n+\tEOF\n \ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \\\n-\t> output 2> output.err &&\n+\t\t>output 2>output.err &&\n \ttest_cmp expect output &&\n \ttest ! -s output.err\n '\n \n-cat > expect << EOF\n-boolean: 2\n-integer: 1729\n-timestamp: 0\n-string: 321\n-abbrev: 10\n-verbose: 2\n-quiet: no\n-dry run: no\n-file: prefix/fi.le\n-EOF\n-\n test_expect_success 'long options' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 2\n+\t\tinteger: 1729\n+\t\ttimestamp: 0\n+\t\tstring: 321\n+\t\tabbrev: 10\n+\t\tverbose: 2\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: prefix/fi.le\n+\tEOF\n \ttest-parse-options --boolean --integer 1729 --boolean --string2=321 \\\n-\t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\\\n-\t\t--obsolete > output 2> output.err &&\n+\t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le \\\n+\t\t--obsolete >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n@@ -101,48 +97,46 @@ test_expect_success 'missing required value' '\n \ttest $? = 129\n '\n \n-cat > expect << EOF\n-boolean: 1\n-integer: 13\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-arg 00: a1\n-arg 01: b1\n-arg 02: --boolean\n-EOF\n-\n test_expect_success 'intermingled arguments' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 1\n+\t\tinteger: 13\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: a1\n+\t\targ 01: b1\n+\t\targ 02: --boolean\n+\tEOF\n \ttest-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \\\n-\t\t> output 2> output.err &&\n+\t\t>output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect << EOF\n-boolean: 0\n-integer: 2\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'unambiguously abbreviated option' '\n-\ttest-parse-options --int 2 --boolean --no-bo > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 2\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --int 2 --boolean --no-bo >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n test_expect_success 'unambiguously abbreviated option with \"=\"' '\n-\ttest-parse-options --int=2 > output 2> output.err &&\n+\ttest-parse-options --int=2 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n@@ -152,198 +146,190 @@ test_expect_success 'ambiguously abbreviated option' '\n \ttest $? = 129\n '\n \n-cat > expect << EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: 123\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n-\ttest-parse-options --st 123 > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: 123\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --st 123 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > typo.err << EOF\n-error: did you mean \\`--boolean\\` (with two dashes ?)\n-EOF\n-\n test_expect_success 'detect possible typos' '\n-\ttest_must_fail test-parse-options -boolean > output 2> output.err &&\n-\ttest ! -s output &&\n-\ttest_cmp typo.err output.err\n+\tcat >typo.err <<-\\EOF &&\n+\t\terror: did you mean `--boolean` (with two dashes ?)\n+\tEOF\n+\t>expect\n+\ttest_must_fail test-parse-options -boolean >output 2>output.err &&\n+\ttest_cmp typo.err output.err &&\n+\ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-arg 00: --quux\n-EOF\n-\n test_expect_success 'keep some options as arguments' '\n-\ttest-parse-options --quux > output 2> output.err &&\n-        test ! -s output.err &&\n-        test_cmp expect output\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: --quux\n+\tEOF\n+\ttest-parse-options --quux >output 2>output.err &&\n+\ttest ! -s output.err &&\n+\ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 1\n-string: default\n-abbrev: 7\n-verbose: 0\n-quiet: yes\n-dry run: no\n-file: (not set)\n-arg 00: foo\n-EOF\n-\n test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n-\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" --default-string \\\n-\t\tfoo -q > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 1\n+\t\tstring: default\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: yes\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\t\targ 00: foo\n+\tEOF\n+\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" \\\n+\t\t--default-string foo -q >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-Callback: \"four\", 0\n-boolean: 5\n-integer: 4\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n-\ttest-parse-options --length=four -b -4 > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tCallback: \"four\", 0\n+\t\tboolean: 5\n+\t\tinteger: 4\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --length=four -b -4 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-Callback: \"not set\", 1\n-EOF\n-\n test_expect_success 'OPT_CALLBACK() and callback errors work' '\n-\ttest_must_fail test-parse-options --no-length > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tCallback: \"not set\", 1\n+\tEOF\n+\ttest_must_fail test-parse-options --no-length >output 2>output.err &&\n \ttest_cmp expect output &&\n \ttest_cmp expect.err output.err\n '\n \n-cat > expect <<EOF\n-boolean: 1\n-integer: 23\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 1\n+\t\tinteger: 23\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options --set23 -bbbbb --no-or4 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '\n-\ttest-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&\n+\ttest-parse-options --set23 -bbbbb --neg-or4 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-boolean: 6\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'OPT_BIT() works' '\n-\ttest-parse-options -bb --or4 > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 6\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options -bb --or4 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n test_expect_success 'OPT_NEGBIT() works' '\n-\ttest-parse-options -bb --no-neg-or4 > output 2> output.err &&\n+\ttest-parse-options -bb --no-neg-or4 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '\n-\ttest-parse-options + + + + + + > output 2> output.err &&\n+\ttest-parse-options + + + + + + >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n-boolean: 0\n-integer: 12345\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n \n test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n-\ttest-parse-options -12345 > output 2> output.err &&\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 12345\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n+\ttest-parse-options -12345 >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat >expect <<EOF\n-boolean: 0\n-integer: 0\n-timestamp: 0\n-string: (not set)\n-abbrev: 7\n-verbose: 0\n-quiet: no\n-dry run: no\n-file: (not set)\n-EOF\n-\n test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n+\tcat >expect <<-\\EOF &&\n+\t\tboolean: 0\n+\t\tinteger: 0\n+\t\ttimestamp: 0\n+\t\tstring: (not set)\n+\t\tabbrev: 7\n+\t\tverbose: 0\n+\t\tquiet: no\n+\t\tdry run: no\n+\t\tfile: (not set)\n+\tEOF\n \ttest-parse-options --no-ambig >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat >>expect <<'EOF'\n-list: foo\n-list: bar\n-list: baz\n-EOF\n test_expect_success '--list keeps list of strings' '\n+\tcat >>expect <<-\\EOF &&\n+\t\tlist: foo\n+\t\tlist: bar\n+\t\tlist: baz\n+\tEOF\n \ttest-parse-options --list foo --list=bar --list=baz >output &&\n \ttest_cmp expect output\n '\n-- \n1.7.8\n"},{"id":"185966","messageId":"1330740942-25130-6-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2 5/5] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:37Z","receivedAt":"2012-03-03T02:15:37Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Unwound one loop to stay within the test_expect_success guard\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t6300-for-each-ref.sh |  186 +++++++++++++++++++++++------------------------\n 1 files changed, 92 insertions(+), 94 deletions(-)\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 1721784..ebba7d1 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '\n \ttest_must_fail git for-each-ref --format=\"%(authordate:INVALID)\" refs/heads\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n-'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n-EOF\n-\n test_expect_success 'Check unformatted date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF &&\n+\t\t'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n+\t\t'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n+\tEOF\n+\t\"'\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate) %(authordate)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n@@ -171,84 +172,85 @@ test_expect_success 'Check format \"relative\" date fields output' '\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' '2006-07-03' '2006-07-03'\n-'refs/tags/testtag' '2006-07-03'\n-EOF\n-\n test_expect_success 'Check format \"short\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n+\t\t'refs/heads/master' '2006-07-03' '2006-07-03'\n+\t\t'refs/tags/testtag' '2006-07-03'\n+\tEOF\n+\t\"'\n \tf=short &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n-'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n-EOF\n-\n test_expect_success 'Check format \"local\" date fields output' '\n-\tf=local &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\t'\"\n+\tcat >expected <<-EOF\n+\t\t'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n+\t\t'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n+\tEOF\n+\t\"'\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:local) %(authordate:local)\" refs/heads &&\n+\t git for-each-ref --shell --format=\"%(refname) %(taggerdate:local)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n-'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n-EOF\n-\n test_expect_success 'Check format \"iso8601\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n+\t\t'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n+\t\t'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n+\tEOF\n+\t\"'\n \tf=iso8601 &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n-'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n-EOF\n-\n test_expect_success 'Check format \"rfc2822\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n+\t\t'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n+\t\t'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n+\tEOF\n+\t\"'\n \tf=rfc2822 &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-refs/heads/master\n-refs/remotes/origin/master\n-refs/tags/testtag\n-EOF\n-\n test_expect_success 'Verify ascending sort' '\n+\tcat >expected <<-EOF\n+\t\trefs/heads/master\n+\t\trefs/remotes/origin/master\n+\t\trefs/tags/testtag\n+\tEOF\n \tgit for-each-ref --format=\"%(refname)\" --sort=refname >actual &&\n \ttest_cmp expected actual\n '\n \n-\n-cat >expected <<\\EOF\n-refs/tags/testtag\n-refs/remotes/origin/master\n-refs/heads/master\n-EOF\n-\n test_expect_success 'Verify descending sort' '\n+\tcat >expected <<-EOF\n+\t\trefs/tags/testtag\n+\t\trefs/remotes/origin/master\n+\t\trefs/heads/master\n+\tEOF\n \tgit for-each-ref --format=\"%(refname)\" --sort=-refname >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-'refs/heads/master'\n-'refs/remotes/origin/master'\n-'refs/tags/testtag'\n-EOF\n-\n test_expect_success 'Quoting style: shell' '\n+\t'\"\n+\tcat >expected <<-EOF\n+\t\t'refs/heads/master'\n+\t\t'refs/remotes/origin/master'\n+\t\t'refs/tags/testtag'\n+\tEOF\n+\t\"'\n \tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n \ttest_cmp expected actual\n '\n@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-\"refs/heads/master\"\n-\"refs/remotes/origin/master\"\n-\"refs/tags/testtag\"\n-EOF\n-\n test_expect_success 'Quoting style: tcl' '\n+\tcat >expected <<-EOF\n+\t\t\"refs/heads/master\"\n+\t\t\"refs/remotes/origin/master\"\n+\t\t\"refs/tags/testtag\"\n+\tEOF\n \tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n \ttest_cmp expected actual\n '\n \n-for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n-\ttest_expect_success \"more than one quoting style: $i\" \"\n-\t\tgit for-each-ref $i 2>&1 | (read line &&\n-\t\tcase \\$line in\n-\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n-\t\t*) false\n-\t\tesac)\n-\t\"\n-done\n-\n-cat >expected <<\\EOF\n-master\n-testtag\n-EOF\n-\n+test_expect_success 'more than one quoting styles' '\n+\tcat >expected <<-EOF\n+\t\terror: more than one quoting style?\n+\tEOF\n+\tgit for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref -s --python 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual\n+'\n test_expect_success 'Check short refname format' '\n+\tcat >expected <<-EOF\n+\t\tmaster\n+\t\ttesttag\n+\tEOF\n \t(git for-each-ref --format=\"%(refname:short)\" refs/heads &&\n \tgit for-each-ref --format=\"%(refname:short)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<EOF\n-origin/master\n-EOF\n-\n test_expect_success 'Check short upstream format' '\n+\tcat >expected <<-EOF\n+\t\torigin/master\n+\tEOF\n \tgit for-each-ref --format=\"%(upstream:short)\" refs/heads >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<EOF\n-67a36f1\n-EOF\n-\n test_expect_success 'Check short objectname format' '\n+\tcat >expected <<-EOF\n+\t\t67a36f1\n+\tEOF\n \tgit for-each-ref --format=\"%(objectname:short)\" refs/heads >actual &&\n \ttest_cmp expected actual\n '\n@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '\n \ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n \n-cat >expected <<\\EOF\n-heads/master\n-tags/master\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs (strict)' '\n+\tcat >expected <<-EOF\n+\t\theads/master\n+\t\ttags/master\n+\tEOF\n \tgit config --bool core.warnambiguousrefs true &&\n \tgit checkout -b newtag &&\n \techo \"Using $datestamp\" > one &&\n@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-heads/master\n-master\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs (loose)' '\n+\tcat >expected <<-EOF\n+\t\theads/master\n+\t\tmaster\n+\tEOF\n \tgit config --bool core.warnambiguousrefs false &&\n \tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n-heads/ambiguous\n-ambiguous\n-EOF\n-\n test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n+\tcat >expected <<-EOF\n+\t\theads/ambiguous\n+\t\tambiguous\n+\tEOF\n \tgit checkout master &&\n \tgit tag ambiguous testtag^0 &&\n \tgit branch ambiguous testtag^0 &&\n@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '\n '\n \n test_expect_success 'create tag with subject and body content' '\n-\tcat >>msg <<-\\EOF &&\n+\tcat >msg <<-\\EOF &&\n \t\tthe subject line\n \n \t\tfirst body line\n@@ -417,9 +415,9 @@ test_expect_success GPG 'create signed tags' '\n \tgit tag -s -m \"\" signed-empty &&\n \tgit tag -s -m \"subject line\" signed-short &&\n \tcat >msg <<-\\EOF &&\n-\tsubject line\n+\t\tsubject line\n \n-\tbody contents\n+\t\tbody contents\n \tEOF\n \tgit tag -s -F msg signed-long\n '\n-- \n1.7.8\n"},{"id":"185962","messageId":"1330740942-25130-7-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2-w 101/105] t7004 (tag): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:38Z","receivedAt":"2012-03-03T02:15:38Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks\n- Use >FILE instead of > FILE\n- Use a \"here\" filter for generation of expect files with mixed tabs and\n  spaces\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t7004-tag.sh |  590 +++++++++++++++++++++++++++++++-------------------------\n 1 files changed, 328 insertions(+), 262 deletions(-)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex f8c247a..f819f41 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -27,8 +27,9 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '\n \ttest `git tag | wc -l` -eq 0\n '\n \n-test_expect_success 'looking for a tag in an empty tree should fail' \\\n-\t'! (tag_exists mytag)'\n+test_expect_success 'looking for a tag in an empty tree should fail' '\n+\t! tag_exists mytag\n+'\n \n test_expect_success 'creating a tag in an empty tree should fail' '\n \ttest_must_fail git tag mynotag &&\n@@ -66,27 +67,32 @@ test_expect_success 'listing all tags if one exists should output that tag' '\n \n # pattern matching:\n \n-test_expect_success 'listing a tag using a matching pattern should succeed' \\\n-\t'git tag -l mytag'\n+test_expect_success 'listing a tag using a matching pattern should succeed' '\n+\tgit tag -l mytag\n+'\n \n test_expect_success \\\n-\t'listing a tag using a matching pattern should output that tag' \\\n-\t'test `git tag -l mytag` = mytag'\n+\t'listing a tag using a matching pattern should output that tag' '\n+\ttest `git tag -l mytag` = mytag\n+'\n \n # todo: git tag -l now returns always zero, when fixed, change this test\n test_expect_success \\\n-\t'listing tags using a non-matching pattern should suceed' \\\n-\t'git tag -l xxx'\n+\t'listing tags using a non-matching pattern should suceed' '\n+\tgit tag -l xxx\n+'\n \n test_expect_success \\\n-\t'listing tags using a non-matching pattern should output nothing' \\\n-\t'test `git tag -l xxx | wc -l` -eq 0'\n+\t'listing tags using a non-matching pattern should output nothing' '\n+\ttest `git tag -l xxx | wc -l` -eq 0\n+'\n \n # special cases for creating tags:\n \n test_expect_success \\\n-\t'trying to create a tag with the name of one existing should fail' \\\n-\t'test_must_fail git tag mytag'\n+\t'trying to create a tag with the name of one existing should fail' '\n+\ttest_must_fail git tag mytag\n+'\n \n test_expect_success \\\n \t'trying to create a tag with a non-valid name should fail' '\n@@ -111,15 +117,17 @@ test_expect_success 'trying to delete an unknown tag should fail' '\n \ttest_must_fail git tag -d unknown-tag\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'trying to delete tags without params should succeed and do nothing' '\n+\tcat >expect <<-EOF &&\n myhead\n mytag\n EOF\n-test_expect_success \\\n-\t'trying to delete tags without params should succeed and do nothing' '\n-\tgit tag -l > actual && test_cmp expect actual &&\n+\tgit tag -l >actual &&\n+\ttest_cmp expect actual &&\n \tgit tag -d &&\n-\tgit tag -l > actual && test_cmp expect actual\n+\tgit tag -l >actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success \\\n@@ -147,12 +155,15 @@ test_expect_success \\\n \t! tag_exists myhead\n '\n \n-test_expect_success 'trying to delete an already deleted tag should fail' \\\n-\t'test_must_fail git tag -d mytag'\n+test_expect_success \\\n+\t'trying to delete an already deleted tag should fail' '\n+\ttest_must_fail git tag -d mytag\n+'\n \n # listing various tags with pattern matching:\n \n-cat >expect <<EOF\n+test_expect_success 'listing all tags should print them ordered' '\n+\tcat >expect <<-EOF &&\n a1\n aa1\n cba\n@@ -163,7 +174,6 @@ v1.0\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success 'listing all tags should print them ordered' '\n \tgit tag v1.0.1 &&\n \tgit tag t211 &&\n \tgit tag aa1 &&\n@@ -179,81 +189,81 @@ test_expect_success 'listing all tags should print them ordered' '\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'listing tags with substring as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n a1\n aa1\n cba\n EOF\n-test_expect_success \\\n-\t'listing tags with substring as pattern must print those matching' '\n \trm *a* &&\n \tgit tag -l \"*a*\" > current &&\n \ttest_cmp expect current\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'listing tags with a suffix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0.1\n EOF\n-test_expect_success \\\n-\t'listing tags with a suffix as pattern must print those matching' '\n \tgit tag -l \"*.1\" > actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'listing tags with a prefix as pattern must print those matching' '\n+\tcat >expect <<-EOF &&\n t210\n t211\n EOF\n-test_expect_success \\\n-\t'listing tags with a prefix as pattern must print those matching' '\n \tgit tag -l \"t21*\" > actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-a1\n-EOF\n test_expect_success \\\n \t'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n+\t\ta1\n+\tEOF\n \tgit tag -l a1 > actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n-v1.0\n-EOF\n test_expect_success \\\n \t'listing tags using a name as pattern must print that one matching' '\n+\tcat >expect <<-EOF &&\n+\t\tv1.0\n+\tEOF\n \tgit tag -l v1.0 > actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'listing tags with ? in the pattern should print those matching' '\n+\tcat >expect <<-EOF &&\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success \\\n-\t'listing tags with ? in the pattern should print those matching' '\n \tgit tag -l \"v1.?.?\" > actual &&\n \ttest_cmp expect actual\n '\n \n->expect\n test_expect_success \\\n \t'listing tags using v.* should print nothing because none have v.' '\n+\t>expect &&\n \tgit tag -l \"v.*\" > actual &&\n \ttest_cmp expect actual\n '\n \n-cat >expect <<EOF\n+test_expect_success \\\n+\t'listing tags using v* should print only those having v' '\n+\tcat >expect <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n v1.1.3\n EOF\n-test_expect_success \\\n-\t'listing tags using v* should print only those having v' '\n \tgit tag -l \"v*\" > actual &&\n \ttest_cmp expect actual\n '\n@@ -272,66 +282,73 @@ test_expect_success \\\n \ttest $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)\n '\n \n-test_expect_success 'trying to verify an unknown tag should fail' \\\n-\t'test_must_fail git tag -v unknown-tag'\n+test_expect_success 'trying to verify an unknown tag should fail' '\n+\ttest_must_fail git tag -v unknown-tag\n+'\n \n test_expect_success \\\n-\t'trying to verify a non-annotated and non-signed tag should fail' \\\n-\t'test_must_fail git tag -v non-annotated-tag'\n+\t'trying to verify a non-annotated and non-signed tag should fail' '\n+\ttest_must_fail git tag -v non-annotated-tag\n+'\n \n test_expect_success \\\n-\t'trying to verify many non-annotated or unknown tags, should fail' \\\n-\t'test_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2'\n+\t'trying to verify many non-annotated or unknown tags, should fail' '\n+\ttest_must_fail git tag -v unknown-tag1 non-annotated-tag unknown-tag2\n+'\n \n # creating annotated tags:\n \n+here='s/\\\\s/ /g; s/\\\\t/\\t/g; s/\\\\n/\\n/g'\n+\n get_tag_msg () {\n \tgit cat-file tag \"$1\" | sed -e \"/BEGIN PGP/q\"\n }\n \n # run test_tick before committing always gives the time in that timezone\n get_tag_header () {\n-cat <<EOF\n+\t# name, object, type, time\n+\tcat <<-EOF &&\n object $2\n type $3\n tag $1\n tagger C O Mitter <committer@example.com> $4 -0700\n \n EOF\n+\tsed -e \"$here\"\n }\n \n-commit=$(git rev-parse HEAD)\n-time=$test_tick\n-\n-get_tag_header annotated-tag $commit commit $time >expect\n-echo \"A message\" >>expect\n test_expect_success \\\n \t'creating an annotated tag with -m message should succeed' '\n+\tcommit=$(git rev-parse HEAD) &&\n+\ttime=$test_tick &&\n+\tget_tag_header annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\tA message\n+\tEOF\n \tgit tag -m \"A message\" annotated-tag &&\n \tget_tag_msg annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >msgfile <<EOF\n-Another message\n-in a file.\n-EOF\n-get_tag_header file-annotated-tag $commit commit $time >expect\n-cat msgfile >>expect\n test_expect_success \\\n \t'creating an annotated tag with -F messagefile should succeed' '\n+\tcat >msgfile <<-EOF &&\n+\t\tA message from the\n+\t\tstandard input\n+\tEOF\n+\tget_tag_header file-annotated-tag $commit commit $time >expect <msgfile\n \tgit tag -F msgfile file-annotated-tag &&\n \tget_tag_msg file-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >inputmsg <<EOF\n+test_expect_success 'creating an annotated tag with -F - should succeed' '\n+\tcat >inputmsg <<-EOF &&\n A message from the\n standard input\n EOF\n-get_tag_header stdin-annotated-tag $commit commit $time >expect\n-cat inputmsg >>expect\n-test_expect_success 'creating an annotated tag with -F - should succeed' '\n+\tget_tag_header stdin-annotated-tag $commit commit $time \\\n+\t\t>expect <inputmsg\n \tgit tag -F - stdin-annotated-tag <inputmsg &&\n \tget_tag_msg stdin-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -361,29 +378,47 @@ test_expect_success \\\n \n # blank and empty messages:\n \n-get_tag_header empty-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with an empty -m message should succeed' '\n+\t>emptyfile &&\n+\tget_tag_header empty-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -m \"\" empty-annotated-tag &&\n \tget_tag_msg empty-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n->emptyfile\n-get_tag_header emptyfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with an empty -F messagefile should succeed' '\n+\tget_tag_header emptyfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F emptyfile emptyfile-annotated-tag &&\n \tget_tag_msg emptyfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' >blanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>blanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>blanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>blanksfile\n-get_tag_header blanks-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+test_expect_success \\\n+\t'extra blanks in the message for an annotated tag should be removed' '\n+\tsed -e \"$here\" >blanksfile <<-\\EOF &&\n+\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n+\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n+\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tget_tag_header blanks-annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n Leading blank lines\n \n Repeated blank lines\n@@ -392,36 +427,38 @@ Trailing spaces\n \n Trailing blank lines\n EOF\n-test_expect_success \\\n-\t'extra blanks in the message for an annotated tag should be removed' '\n \tgit tag -F blanksfile blanks-annotated-tag &&\n \tget_tag_msg blanks-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header blank-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with blank -m message with spaces should succeed' '\n+\tget_tag_header blank-annotated-tag $commit commit $time >expect <emptyfile &&\n \tgit tag -m \"     \" blank-annotated-tag &&\n \tget_tag_msg blank-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-echo '     ' >blankfile\n-echo ''      >>blankfile\n-echo '  '    >>blankfile\n-get_tag_header blankfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with blank -F messagefile with spaces should succeed' '\n+\tsed -e \"$here\" >blankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tget_tag_header blankfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F blankfile blankfile-annotated-tag &&\n \tget_tag_msg blankfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '      ' >blanknonlfile\n-get_tag_header blanknonlfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with -F file of spaces and no newline should succeed' '\n+\tprintf \"      \" >blanknonlfile &&\n+\tget_tag_header blanknonlfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F blanknonlfile blanknonlfile-annotated-tag &&\n \tget_tag_msg blanknonlfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -429,7 +466,9 @@ test_expect_success \\\n \n # messages with commented lines:\n \n-cat >commentsfile <<EOF\n+test_expect_success \\\n+\t'creating a tag using a -F messagefile with #comments should succeed' '\n+\tcat >commentsfile <<-EOF &&\n # A comment\n \n ############\n@@ -446,8 +485,8 @@ Another line.\n \n Last line.\n EOF\n-get_tag_header comments-annotated-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+\tget_tag_header comments-annotated-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n The message.\n One line.\n \n@@ -455,36 +494,39 @@ Another line.\n \n Last line.\n EOF\n-test_expect_success \\\n-\t'creating a tag using a -F messagefile with #comments should succeed' '\n \tgit tag -F commentsfile comments-annotated-tag &&\n \tget_tag_msg comments-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header comment-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with a #comment in the -m message should succeed' '\n+\tget_tag_header comment-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -m \"#comment\" comment-annotated-tag &&\n \tget_tag_msg comment-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-echo '#comment' >commentfile\n-echo ''         >>commentfile\n-echo '####'     >>commentfile\n-get_tag_header commentfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with #comments in the -F messagefile should succeed' '\n+\tcat >commentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tget_tag_header commentfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F commentfile commentfile-annotated-tag &&\n \tget_tag_msg commentfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-printf '#comment' >commentnonlfile\n-get_tag_header commentnonlfile-annotated-tag $commit commit $time >expect\n test_expect_success \\\n \t'creating a tag with a file of #comment and no newline should succeed' '\n+\tprintf \"#comment\" >commentnonlfile &&\n+\tget_tag_header commentnonlfile-annotated-tag $commit commit $time \\\n+\t\t>expect <emptyfile &&\n \tgit tag -F commentnonlfile commentnonlfile-annotated-tag &&\n \tget_tag_msg commentnonlfile-annotated-tag >actual &&\n \ttest_cmp expect actual\n@@ -542,11 +584,13 @@ test_expect_success \\\n \ttest_cmp expect actual\n '\n \n-echo 'tag line one' >annotagmsg\n-echo 'tag line two' >>annotagmsg\n-echo 'tag line three' >>annotagmsg\n test_expect_success \\\n \t'listing many message lines of a non-signed tag should succeed' '\n+\tcat >annotagmsg <<-EOF &&\n+\t\ttag line one\n+\t\ttag line two\n+\t\ttag line three\n+\tEOF\n \tgit tag -F annotagmsg tag-lines &&\n \n \techo \"tag-lines\" >expect &&\n@@ -621,20 +665,22 @@ test_expect_success GPG \\\n \n # creating and verifying signed tags:\n \n-get_tag_header signed-tag $commit commit $time >expect\n-echo 'A signed tag message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG 'creating a signed tag with -m message should succeed' '\n+test_expect_success GPG \\\n+\t'creating a signed tag with -m message should succeed' '\n+\tget_tag_header signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A signed tag message\" signed-tag &&\n \tget_tag_msg signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header u-signed-tag $commit commit $time >expect\n-echo 'Another message' >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG 'sign with a given key id' '\n-\n+\tget_tag_header u-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tAnother message\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -u committer@example.com -m \"Another message\" u-signed-tag &&\n \tget_tag_msg u-signed-tag >actual &&\n \ttest_cmp expect actual\n@@ -654,54 +700,54 @@ test_expect_success GPG 'sign with an unknown id (2)' '\n \n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n+test_expect_success GPG '-u implies signed tag' '\n+\twrite_script fakeeditor <<-\\EOF &&\n test -n \"$1\" && exec >\"$1\"\n echo A signed tag message\n echo from a fake editor.\n EOF\n-chmod +x fakeeditor\n-\n-get_tag_header implied-sign $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG '-u implies signed tag' '\n+\tget_tag_header implied-sign $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tGIT_EDITOR=./fakeeditor git tag -u CDDE430D implied-sign &&\n \tget_tag_msg implied-sign >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >sigmsgfile <<EOF\n+test_expect_success GPG \\\n+\t'creating a signed tag with -F messagefile should succeed' '\n+\tcat >sigmsgfile <<-EOF\n Another signed tag\n message in a file.\n EOF\n-get_tag_header file-signed-tag $commit commit $time >expect\n-cat sigmsgfile >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with -F messagefile should succeed' '\n+\tget_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile\n+\techo \"-----BEGIN PGP SIGNATURE-----\" >>expect\n \tgit tag -s -F sigmsgfile file-signed-tag &&\n \tget_tag_msg file-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >siginputmsg <<EOF\n+test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n+\tcat >siginputmsg <<-EOF\n A signed tag message from\n the standard input\n EOF\n-get_tag_header stdin-signed-tag $commit commit $time >expect\n-cat siginputmsg >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG 'creating a signed tag with -F - should succeed' '\n+\tget_tag_header stdin-signed-tag $commit commit $time \\\n+\t\t>expect <siginputmsg &&\n+\techo \"-----BEGIN PGP SIGNATURE-----\" >>expect\n \tgit tag -s -F - stdin-signed-tag <siginputmsg &&\n \tget_tag_msg stdin-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header implied-annotate $commit commit $time >expect\n-./fakeeditor >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG '-s implies annotated tag' '\n+\tget_tag_header implied-annotate $commit commit $time >expect <<-EOF &&\n+\t\tA signed tag message\n+\t\tfrom a fake editor.\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tGIT_EDITOR=./fakeeditor git tag -s implied-annotate &&\n \tget_tag_msg implied-annotate >actual &&\n \ttest_cmp expect actual\n@@ -715,11 +761,14 @@ test_expect_success GPG \\\n \t! tag_exists nosigtag\n '\n \n-test_expect_success GPG 'verifying a signed tag should succeed' \\\n-\t'git tag -v signed-tag'\n+test_expect_success GPG 'verifying a signed tag should succeed' '\n+\tgit tag -v signed-tag\n+'\n \n-test_expect_success GPG 'verifying two signed tags in one command should succeed' \\\n-\t'git tag -v signed-tag file-signed-tag'\n+test_expect_success GPG \\\n+\t'verifying two signed tags in one command should succeed' '\n+\tgit tag -v signed-tag file-signed-tag\n+'\n \n test_expect_success GPG \\\n \t'verifying many signed and non-signed tags should fail' '\n@@ -740,33 +789,52 @@ test_expect_success GPG 'verifying a forged tag should fail' '\n \n # blank and empty messages for signed tags:\n \n-get_tag_header empty-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with an empty -m message should succeed' '\n+\tget_tag_header empty-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"\" empty-signed-tag &&\n \tget_tag_msg empty-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v empty-signed-tag\n '\n \n->sigemptyfile\n-get_tag_header emptyfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with an empty -F messagefile should succeed' '\n+\t>sigemptyfile &&\n+\tget_tag_header emptyfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigemptyfile emptyfile-signed-tag &&\n \tget_tag_msg emptyfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v emptyfile-signed-tag\n '\n \n-printf '\\n\\n  \\n\\t\\nLeading blank lines\\n' > sigblanksfile\n-printf '\\n\\t \\t  \\nRepeated blank lines\\n' >>sigblanksfile\n-printf '\\n\\n\\nTrailing spaces      \\t  \\n' >>sigblanksfile\n-printf '\\nTrailing blank lines\\n\\n\\t \\n\\n' >>sigblanksfile\n-get_tag_header blanks-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+test_expect_success GPG \\\n+\t'extra blanks in the message for a signed tag should be removed' '\n+\tsed -e \"$here\" >sigblanksfile <<-\\EOF &&\n+\n+\t\t\\s\\s\n+\t\t\\t\n+\t\tLeading blank lines\n+\n+\t\t\\t\\s\\t\\s\\s\n+\t\tRepeated blank lines\n+\n+\n+\n+\t\tTrailing spaces\\s\\s\\s\\s\\s\\s\\t\\s\\s\n+\n+\t\tTrailing blank lines\n+\n+\t\t\\t\\s\n+\n+\tEOF\n+\tget_tag_header blanks-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n Leading blank lines\n \n Repeated blank lines\n@@ -774,53 +842,61 @@ Repeated blank lines\n Trailing spaces\n \n Trailing blank lines\n+\t\t-----BEGIN PGP SIGNATURE-----\n EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'extra blanks in the message for a signed tag should be removed' '\n \tgit tag -s -F sigblanksfile blanks-signed-tag &&\n \tget_tag_msg blanks-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blanks-signed-tag\n '\n \n-get_tag_header blank-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with a blank -m message should succeed' '\n+\tget_tag_header blank-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"     \" blank-signed-tag &&\n \tget_tag_msg blank-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blank-signed-tag\n '\n \n-echo '     ' >sigblankfile\n-echo ''      >>sigblankfile\n-echo '  '    >>sigblankfile\n-get_tag_header blankfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with blank -F file with spaces should succeed' '\n+\tsed -e \"$here\" >sigblankfile <<-\\EOF &&\n+\t\t\\s\\s\\s\\s\\s\n+\n+\t\t\\s\\s\n+\tEOF\n+\tget_tag_header blankfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigblankfile blankfile-signed-tag &&\n \tget_tag_msg blankfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v blankfile-signed-tag\n '\n \n-printf '      ' >sigblanknonlfile\n-get_tag_header blanknonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with spaces and no newline should succeed' '\n+\tprintf >sigblanknonlfile \"      \" &&\n+\tget_tag_header blanknonlfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&\n \tget_tag_msg blanknonlfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n-\tgit tag -v signed-tag\n+\tgit tag -v blanknonlfile-signed-tag\n '\n \n # messages with commented lines for signed tags:\n \n-cat >sigcommentsfile <<EOF\n+test_expect_success GPG \\\n+\t'creating a signed tag with a -F file with #comments should succeed' '\n+\tcat >sigcommentsfile <<-EOF &&\n # A comment\n \n ############\n@@ -837,52 +913,57 @@ Another line.\n \n Last line.\n EOF\n-get_tag_header comments-signed-tag $commit commit $time >expect\n-cat >>expect <<EOF\n+\tget_tag_header comments-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n The message.\n One line.\n \n Another line.\n \n Last line.\n+\t\t-----BEGIN PGP SIGNATURE-----\n EOF\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with a -F file with #comments should succeed' '\n \tgit tag -s -F sigcommentsfile comments-signed-tag &&\n \tget_tag_msg comments-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v comments-signed-tag\n '\n \n-get_tag_header comment-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with #commented -m message should succeed' '\n+\tget_tag_header comment-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"#comment\" comment-signed-tag &&\n \tget_tag_msg comment-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v comment-signed-tag\n '\n \n-echo '#comment' >sigcommentfile\n-echo ''         >>sigcommentfile\n-echo '####'     >>sigcommentfile\n-get_tag_header commentfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with #commented -F messagefile should succeed' '\n+\tcat >sigcommentfile <<-EOF &&\n+\t\t#comment\n+\n+\t\t####\n+\tEOF\n+\tget_tag_header commentfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigcommentfile commentfile-signed-tag &&\n \tget_tag_msg commentfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n \tgit tag -v commentfile-signed-tag\n '\n \n-printf '#comment' >sigcommentnonlfile\n-get_tag_header commentnonlfile-signed-tag $commit commit $time >expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag with a #comment and no newline should succeed' '\n+\tprintf \"#comment\" >sigcommentnonlfile &&\n+\tget_tag_header commentnonlfile-signed-tag $commit commit $time \\\n+\t\t>expect <<-EOF &&\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&\n \tget_tag_msg commentnonlfile-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -941,11 +1022,13 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-echo 'stag line one' >sigtagmsg\n-echo 'stag line two' >>sigtagmsg\n-echo 'stag line three' >>sigtagmsg\n test_expect_success GPG \\\n \t'listing many message lines of a signed tag should succeed' '\n+\tcat >sigtagmsg <<-EOF &&\n+\t\tstag line one\n+\t\tstag line two\n+\t\tstag line three\n+\tEOF\n \tgit tag -s -F sigtagmsg stag-lines &&\n \n \techo \"stag-lines\" >expect &&\n@@ -987,72 +1070,68 @@ test_expect_success GPG \\\n \n # tags pointing to objects different from commits:\n \n-tree=$(git rev-parse HEAD^{tree})\n-blob=$(git rev-parse HEAD:foo)\n-tag=$(git rev-parse signed-tag 2>/dev/null)\n-\n-get_tag_header tree-signed-tag $tree tree $time >expect\n-echo \"A message for a tree\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to a tree should succeed' '\n+\ttree=$(git rev-parse HEAD^{tree}) &&\n+\tblob=$(git rev-parse HEAD:foo) &&\n+\ttag=$(git rev-parse signed-tag) &&\n+\tget_tag_header tree-signed-tag $tree tree $time >expect <<-EOF &&\n+\t\tA message for a tree\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for a tree\" tree-signed-tag HEAD^{tree} &&\n \tget_tag_msg tree-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header blob-signed-tag $blob blob $time >expect\n-echo \"A message for a blob\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to a blob should succeed' '\n+\tget_tag_header blob-signed-tag $blob blob $time >expect <<-EOF &&\n+\t\tA message for a blob\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for a blob\" blob-signed-tag HEAD:foo &&\n \tget_tag_msg blob-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-get_tag_header tag-signed-tag $tag tag $time >expect\n-echo \"A message for another tag\" >>expect\n-echo '-----BEGIN PGP SIGNATURE-----' >>expect\n test_expect_success GPG \\\n \t'creating a signed tag pointing to another tag should succeed' '\n+\tget_tag_header tag-signed-tag $tag tag $time >expect <<-EOF &&\n+\t\tA message for another tag\n+\t\t-----BEGIN PGP SIGNATURE-----\n+\tEOF\n \tgit tag -s -m \"A message for another tag\" tag-signed-tag signed-tag &&\n \tget_tag_msg tag-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n # usage with rfc1991 signatures\n-echo \"rfc1991\" > gpghome/gpg.conf\n-get_tag_header rfc1991-signed-tag $commit commit $time >expect\n-echo \"RFC1991 signed tag\" >>expect\n-echo '-----BEGIN PGP MESSAGE-----' >>expect\n-test_expect_success GPG \\\n-\t'creating a signed tag with rfc1991' '\n+test_expect_success GPG 'creating a signed tag with rfc1991' '\n+\techo \"rfc1991\" >gpghome/gpg.conf &&\n+\tget_tag_header rfc1991-signed-tag $commit commit $time >expect <<-EOF &&\n+\t\tRFC1991 signed tag\n+\t\t-----BEGIN PGP MESSAGE-----\n+\tEOF\n \tgit tag -s -m \"RFC1991 signed tag\" rfc1991-signed-tag $commit &&\n \tget_tag_msg rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual\n '\n \n-cat >fakeeditor <<'EOF'\n-#!/bin/sh\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n+\twrite_script fakeeditor <<-\\EOF &&\n cp \"$1\" actual\n EOF\n-chmod +x fakeeditor\n-\n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n \tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature' '\n+test_expect_success GPG 'verifying rfc1991 signature' '\n \tgit tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature' '\n+test_expect_success GPG 'list tag with rfc1991 signature' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n \tgit tag -l -n1 rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -1062,15 +1141,12 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-rm -f gpghome/gpg.conf\n-\n-test_expect_success GPG \\\n-\t'verifying rfc1991 signature without --rfc1991' '\n+test_expect_success GPG 'verifying rfc1991 signature without --rfc1991' '\n+\trm -f gpghome/gpg.conf &&\n \tgit tag -v rfc1991-signed-tag\n '\n \n-test_expect_success GPG \\\n-\t'list tag with rfc1991 signature without --rfc1991' '\n+test_expect_success GPG 'list tag with rfc1991 signature without --rfc1991' '\n \techo \"rfc1991-signed-tag RFC1991 signed tag\" >expect &&\n \tgit tag -l -n1 rfc1991-signed-tag >actual &&\n \ttest_cmp expect actual &&\n@@ -1080,26 +1156,26 @@ test_expect_success GPG \\\n \ttest_cmp expect actual\n '\n \n-test_expect_success GPG \\\n-\t'reediting a signed tag body omits signature' '\n+test_expect_success GPG 'reediting a signed tag body omits signature' '\n \techo \"RFC1991 signed tag\" >expect &&\n \tGIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success GPG 'git tag -s fails if gpg is misconfigured' '\n # try to sign with bad user.signingkey\n-git config user.signingkey BobTheMouse\n-test_expect_success GPG \\\n-\t'git tag -s fails if gpg is misconfigured' \\\n-\t'test_must_fail git tag -s -m tail tag-gpg-failure'\n+\tgit config user.signingkey BobTheMouse &&\n+\ttest_must_fail git tag -s -m tail tag-gpg-failure &&\n git config --unset user.signingkey\n+'\n \n # try to verify without gpg:\n \n-rm -rf gpghome\n test_expect_success GPG \\\n-\t'verify signed tag fails when public key is not present' \\\n-\t'test_must_fail git tag -v signed-tag'\n+\t'verify signed tag fails when public key is not present' '\n+\trm -rf gpghome &&\n+\ttest_must_fail git tag -v signed-tag\n+'\n \n test_expect_success \\\n \t'git tag -a fails if tag annotation is empty' '\n@@ -1126,12 +1202,13 @@ test_expect_success \\\n \ttest_cmp rest.expect rest.actual\n '\n \n-get_tag_header reuse $commit commit $time >expect\n-echo \"An annotation to be reused\" >> expect\n test_expect_success \\\n \t'overwriting an annoted tag should use its previous body' '\n+\tget_tag_header reuse $commit commit $time >expect <<-EOF &&\n+\t\treuse\n+\tEOF\n \tgit tag -a -m \"An annotation to be reused\" reuse &&\n-\tGIT_EDITOR=true git tag -f -a reuse &&\n+\tGIT_EDITOR=true git tag -f -a -m \"reuse\" reuse &&\n \tget_tag_msg reuse >actual &&\n \ttest_cmp expect actual\n '\n@@ -1158,68 +1235,61 @@ test_expect_success 'filename for the message is relative to cwd' '\n \n # create a few more commits to test --contains\n \n-hash1=$(git rev-parse HEAD)\n-\n test_expect_success 'creating second commit and tag' '\n+\thash1=$(git rev-parse HEAD) &&\n \techo foo-2.0 >foo &&\n \tgit add foo &&\n \tgit commit -m second &&\n+\thash2=$(git rev-parse HEAD) &&\n \tgit tag v2.0\n '\n \n-hash2=$(git rev-parse HEAD)\n-\n test_expect_success 'creating third commit without tag' '\n \techo foo-dev >foo &&\n \tgit add foo &&\n-\tgit commit -m third\n-'\n-\n+\tgit commit -m third &&\n hash3=$(git rev-parse HEAD)\n+'\n \n-# simple linear checks of --continue\n+# simple linear checks of --contains\n \n-cat > expected <<EOF\n+test_expect_success 'checking that first commit is in all tags (hash)' '\n+\tcat >expected <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n v1.1.3\n v2.0\n EOF\n-\n-test_expect_success 'checking that first commit is in all tags (hash)' \"\n \tgit tag -l --contains $hash1 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # other ways of specifying the commit\n-test_expect_success 'checking that first commit is in all tags (tag)' \"\n+test_expect_success 'checking that first commit is in all tags (tag)' '\n \tgit tag -l --contains v1.0 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n-test_expect_success 'checking that first commit is in all tags (relative)' \"\n+test_expect_success 'checking that first commit is in all tags (relative)' '\n \tgit tag -l --contains HEAD~2 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n-cat > expected <<EOF\n+test_expect_success 'checking that second commit only has one tag' '\n+\tcat >expected <<-EOF &&\n v2.0\n EOF\n-\n-test_expect_success 'checking that second commit only has one tag' \"\n \tgit tag -l --contains $hash2 v* >actual &&\n \ttest_cmp expected actual\n-\"\n-\n+'\n \n-cat > expected <<EOF\n+test_expect_success 'checking that third commit has no tags' '\n+\tcat >expected <<-EOF &&\n EOF\n-\n-test_expect_success 'checking that third commit has no tags' \"\n \tgit tag -l --contains $hash3 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # how about a simple merge?\n \n@@ -1228,35 +1298,33 @@ test_expect_success 'creating simple branch' '\n         git checkout stable &&\n \techo foo-3.0 > foo &&\n \tgit commit foo -m fourth &&\n+\thash4=$(git rev-parse HEAD) &&\n \tgit tag v3.0\n '\n \n-hash4=$(git rev-parse HEAD)\n-\n-cat > expected <<EOF\n+test_expect_success 'checking that branch head only has one tag' '\n+\tcat >expected <<-EOF &&\n v3.0\n EOF\n-\n-test_expect_success 'checking that branch head only has one tag' \"\n \tgit tag -l --contains $hash4 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n test_expect_success 'merging original branch into this branch' '\n \tgit merge --strategy=ours master &&\n         git tag v4.0\n '\n \n-cat > expected <<EOF\n+test_expect_success 'checking that original branch head has one tag now' '\n+\tcat >expected <<-EOF &&\n v4.0\n EOF\n-\n-test_expect_success 'checking that original branch head has one tag now' \"\n \tgit tag -l --contains $hash3 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n-cat > expected <<EOF\n+test_expect_success 'checking that initial commit is in all tags' '\n+\tcat >expected <<-EOF &&\n v0.2.1\n v1.0\n v1.0.1\n@@ -1265,11 +1333,9 @@ v2.0\n v3.0\n v4.0\n EOF\n-\n-test_expect_success 'checking that initial commit is in all tags' \"\n \tgit tag -l --contains $hash1 v* >actual &&\n \ttest_cmp expected actual\n-\"\n+'\n \n # mixing modes and options:\n \n-- \n1.7.8\n"},{"id":"185967","messageId":"1330740942-25130-8-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2-w 102/105] t5512 (ls-remote): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:39Z","receivedAt":"2012-03-03T02:15:39Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"Guard setup with test_expect_success\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t5512-ls-remote.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh\nindex 5c546c9..811dcc3 100755\n--- a/t/t5512-ls-remote.sh\n+++ b/t/t5512-ls-remote.sh\n@@ -102,11 +102,13 @@ test_expect_success 'use branch.<name>.remote if possible' '\n \n '\n \n-cat >exp <<EOF\n+test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t'\"\n+\tcat >exp <<-EOF\n fatal: 'refs*master' does not appear to be a git repository\n fatal: The remote end hung up unexpectedly\n EOF\n-test_expect_success 'confuses pattern as remote when no remote specified' '\n+\t\"'\n \t#\n \t# Do not expect \"git ls-remote <pattern>\" to work; ls-remote, correctly,\n \t# confuses <pattern> for <remote>. Although ugly, this behaviour is akin\n-- \n1.7.8\n"},{"id":"185961","messageId":"1330740942-25130-9-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2-w 103/105] t3200 (branch): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:40Z","receivedAt":"2012-03-03T02:15:40Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Single-quoted, tab prefaced test blocks\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t3200-branch.sh |  211 +++++++++++++++++++++++++++--------------------------\n 1 files changed, 109 insertions(+), 102 deletions(-)\n\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd1aceb..7191b89 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -7,15 +7,15 @@ test_description='git branch assorted tests'\n \n . ./test-lib.sh\n \n-test_expect_success \\\n-    'prepare a trivial repository' \\\n-    'echo Hello > A &&\n+test_expect_success 'prepare a trivial repository' '\n+\techo Hello >A &&\n      git update-index --add A &&\n      git commit -m \"Initial commit.\" &&\n      echo World >> A &&\n      git update-index --add A &&\n      git commit -m \"Second commit.\" &&\n-     HEAD=$(git rev-parse --verify HEAD)'\n+\tHEAD=$(git rev-parse --verify HEAD)\n+'\n \n test_expect_success \\\n     'git branch --help should not have created a bogus branch' '\n@@ -34,59 +34,59 @@ test_expect_success 'branch -h in broken repository' '\n \tgrep \"[Uu]sage\" broken/usage\n '\n \n-test_expect_success \\\n-    'git branch abc should create a branch' \\\n-    'git branch abc && test_path_is_file .git/refs/heads/abc'\n+test_expect_success 'git branch abc should create a branch' '\n+\tgit branch abc && test_path_is_file .git/refs/heads/abc\n+'\n \n-test_expect_success \\\n-    'git branch a/b/c should create a branch' \\\n-    'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'\n+test_expect_success 'git branch a/b/c should create a branch' '\n+\tgit branch a/b/c && test_path_is_file .git/refs/heads/a/b/c\n+'\n \n-cat >expect <<EOF\n+test_expect_success 'git branch -l d/e/f should create a branch and a log' '\n+\tcat >expect <<-EOF\n $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n EOF\n-test_expect_success \\\n-    'git branch -l d/e/f should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n      git branch -l d/e/f &&\n \t test_path_is_file .git/refs/heads/d/e/f &&\n \t test_path_is_file .git/logs/refs/heads/d/e/f &&\n-\t test_cmp expect .git/logs/refs/heads/d/e/f'\n+\ttest_cmp expect .git/logs/refs/heads/d/e/f\n+'\n \n-test_expect_success \\\n-    'git branch -d d/e/f should delete a branch and a log' \\\n-\t'git branch -d d/e/f &&\n+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '\n+\tgit branch -d d/e/f &&\n \t test_path_is_missing .git/refs/heads/d/e/f &&\n-\t test_path_is_missing .git/logs/refs/heads/d/e/f'\n+\ttest_path_is_missing .git/logs/refs/heads/d/e/f\n+'\n \n-test_expect_success \\\n-    'git branch j/k should work after branch j has been deleted' \\\n-       'git branch j &&\n+test_expect_success 'git branch j/k should work after branch j has been deleted' '\n+\tgit branch j &&\n         git branch -d j &&\n-        git branch j/k'\n+\tgit branch j/k\n+'\n \n-test_expect_success \\\n-    'git branch l should work after branch l/m has been deleted' \\\n-       'git branch l/m &&\n+test_expect_success 'git branch l should work after branch l/m has been deleted' '\n+\tgit branch l/m &&\n         git branch -d l/m &&\n-        git branch l'\n+\tgit branch l\n+'\n \n-test_expect_success \\\n-    'git branch -m dumps usage' \\\n-       'test_expect_code 129 git branch -m 2>err &&\n-\tgrep \"[Uu]sage: git branch\" err'\n+test_expect_success 'git branch -m dumps usage' '\n+\ttest_expect_code 129 git branch -m 2>err &&\n+\tgrep \"[Uu]sage: git branch\" err\n+'\n \n-test_expect_success \\\n-    'git branch -m m m/m should work' \\\n-       'git branch -l m &&\n+test_expect_success 'git branch -m m m/m should work' '\n+\tgit branch -l m &&\n         git branch -m m m/m &&\n-\ttest_path_is_file .git/logs/refs/heads/m/m'\n+\ttest_path_is_file .git/logs/refs/heads/m/m\n+'\n \n-test_expect_success \\\n-    'git branch -m n/n n should work' \\\n-       'git branch -l n/n &&\n+test_expect_success 'git branch -m n/n n should work' '\n+\tgit branch -l n/n &&\n \tgit branch -m n/n n &&\n-\ttest_path_is_file .git/logs/refs/heads/n'\n+\ttest_path_is_file .git/logs/refs/heads/n\n+'\n \n test_expect_success 'git branch -m o/o o should fail when o/p exists' '\n \tgit branch o/o &&\n@@ -160,33 +160,30 @@ test_expect_success 'git branch --list -d t should fail' '\n \ttest_path_is_missing .git/refs/heads/t\n '\n \n-mv .git/config .git/config-saved\n-\n test_expect_success 'git branch -m q q2 without config should succeed' '\n+\tmv .git/config .git/config-saved &&\n+\ttest_when_finished mv .git/config-saved .git/config &&\n \tgit branch -m q q2 &&\n \tgit branch -m q2 q\n '\n \n-mv .git/config-saved .git/config\n-\n+test_expect_success 'git branch -m s/s s should work when s/t is deleted' '\n git config branch.s/s.dummy Hello\n-\n-test_expect_success \\\n-    'git branch -m s/s s should work when s/t is deleted' \\\n-       'git branch -l s/s &&\n+\tgit branch -l s/s &&\n \ttest_path_is_file .git/logs/refs/heads/s/s &&\n         git branch -l s/t &&\n \ttest_path_is_file .git/logs/refs/heads/s/t &&\n         git branch -d s/t &&\n         git branch -m s/s s &&\n-\ttest_path_is_file .git/logs/refs/heads/s'\n-\n-test_expect_success 'config information was renamed, too' \\\n-\t\"test $(git config branch.s.dummy) = Hello &&\n-\t test_must_fail git config branch.s/s/dummy\"\n+\ttest_path_is_file .git/logs/refs/heads/s\n+'\n \n-test_expect_success 'renaming a symref is not allowed' \\\n+test_expect_success 'config information was renamed, too' '\n+\ttest $(git config branch.s.dummy) = Hello &&\n+\ttest_must_fail git config branch.s/s/dummy\n '\n+\n+test_expect_success 'renaming a symref is not allowed' '\n \tgit symbolic-ref refs/heads/master2 refs/heads/master &&\n \ttest_must_fail git branch -m master2 master3 &&\n \tgit symbolic-ref refs/heads/master2 &&\n@@ -194,115 +191,125 @@ test_expect_success 'renaming a symref is not allowed' \\\n \ttest_path_is_missing .git/refs/heads/master3\n '\n \n-test_expect_success SYMLINKS \\\n-    'git branch -m u v should fail when the reflog for u is a symlink' '\n+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '\n      git branch -l u &&\n      mv .git/logs/refs/heads/u real-u &&\n      ln -s real-u .git/logs/refs/heads/u &&\n      test_must_fail git branch -m u v\n '\n \n-test_expect_success 'test tracking setup via --track' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup via --track' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch --track my1 local/master &&\n      test $(git config branch.my1.remote) = local &&\n-     test $(git config branch.my1.merge) = refs/heads/master'\n+\ttest $(git config branch.my1.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup (non-wildcard, matching)' \\\n-    'git config remote.local.url . &&\n-     git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&\n+test_expect_success 'test tracking setup (non-wildcard, matching)' '\n+\tgit config remote.local.url . &&\n+\tgit config remote.local.fetch \\\n+\t\trefs/heads/master:refs/remotes/local/master &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch --track my4 local/master &&\n      test $(git config branch.my4.remote) = local &&\n-     test $(git config branch.my4.merge) = refs/heads/master'\n+\ttest $(git config branch.my4.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup (non-wildcard, not matching)' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup (non-wildcard, not matching)' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch --track my5 local/master &&\n      ! test \"$(git config branch.my5.remote)\" = local &&\n-     ! test \"$(git config branch.my5.merge)\" = refs/heads/master'\n+\t! test \"$(git config branch.my5.merge)\" = refs/heads/master\n+'\n \n-test_expect_success 'test tracking setup via config' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'test tracking setup via config' '\n+\tgit config branch.autosetupmerge true &&\n      git config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch my3 local/master &&\n      test $(git config branch.my3.remote) = local &&\n-     test $(git config branch.my3.merge) = refs/heads/master'\n+\ttest $(git config branch.my3.merge) = refs/heads/master\n+'\n \n-test_expect_success 'test overriding tracking setup via --no-track' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'test overriding tracking setup via --no-track' '\n+\tgit config branch.autosetupmerge true &&\n      git config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/master || git fetch local) &&\n      git branch --no-track my2 local/master &&\n      git config branch.autosetupmerge false &&\n      ! test \"$(git config branch.my2.remote)\" = local &&\n-     ! test \"$(git config branch.my2.merge)\" = refs/heads/master'\n+\t! test \"$(git config branch.my2.merge)\" = refs/heads/master\n+'\n \n-test_expect_success 'no tracking without .fetch entries' \\\n-    'git config branch.autosetupmerge true &&\n+test_expect_success 'no tracking without .fetch entries' '\n+\tgit config branch.autosetupmerge true &&\n      git branch my6 s &&\n      git config branch.automsetupmerge false &&\n      test -z \"$(git config branch.my6.remote)\" &&\n-     test -z \"$(git config branch.my6.merge)\"'\n+\ttest -z \"$(git config branch.my6.merge)\"\n+'\n \n-test_expect_success 'test tracking setup via --track but deeper' \\\n-    'git config remote.local.url . &&\n+test_expect_success 'test tracking setup via --track but deeper' '\n+\tgit config remote.local.url . &&\n      git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n      (git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n      git branch --track my7 local/o/o &&\n      test \"$(git config branch.my7.remote)\" = local &&\n-     test \"$(git config branch.my7.merge)\" = refs/heads/o/o'\n+\ttest \"$(git config branch.my7.merge)\" = refs/heads/o/o\n+'\n \n-test_expect_success 'test deleting branch deletes branch config' \\\n-    'git branch -d my7 &&\n+test_expect_success 'test deleting branch deletes branch config' '\n+\tgit branch -d my7 &&\n      test -z \"$(git config branch.my7.remote)\" &&\n-     test -z \"$(git config branch.my7.merge)\"'\n+\ttest -z \"$(git config branch.my7.merge)\"\n+'\n \n-test_expect_success 'test deleting branch without config' \\\n-    'git branch my7 s &&\n+test_expect_success 'test deleting branch without config' '\n+\tgit branch my7 s &&\n      sha1=$(git rev-parse my7 | cut -c 1-7) &&\n      echo \"Deleted branch my7 (was $sha1).\" >expect &&\n      git branch -d my7 >actual 2>&1 &&\n-     test_i18ncmp expect actual'\n+\ttest_i18ncmp expect actual\n+'\n \n-test_expect_success 'test --track without .fetch entries' \\\n-    'git branch --track my8 &&\n+test_expect_success 'test --track without .fetch entries' '\n+\tgit branch --track my8 &&\n      test \"$(git config branch.my8.remote)\" &&\n-     test \"$(git config branch.my8.merge)\"'\n+\ttest \"$(git config branch.my8.merge)\"\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/autosetupmerge=always' \\\n-    'git config branch.autosetupmerge always &&\n+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '\n+\tgit config branch.autosetupmerge always &&\n      git branch my9 HEAD^ &&\n-     git config branch.autosetupmerge false'\n+\tgit config branch.autosetupmerge false\n+'\n \n-test_expect_success \\\n-    'branch from non-branch HEAD w/--track causes failure' \\\n-    'test_must_fail git branch --track my10 HEAD^'\n+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '\n+\ttest_must_fail git branch --track my10 HEAD^\n+'\n \n-test_expect_success \\\n-    'branch from tag w/--track causes failure' \\\n-    'git tag foobar &&\n-     test_must_fail git branch --track my11 foobar'\n+test_expect_success 'branch from tag w/--track causes failure' '\n+\tgit tag foobar &&\n+\ttest_must_fail git branch --track my11 foobar\n+'\n \n # Keep this test last, as it changes the current branch\n-cat >expect <<EOF\n+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '\n+\tcat >expect <<-EOF\n $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n EOF\n-test_expect_success \\\n-    'git checkout -b g/h/i -l should create a branch and a log' \\\n-\t'GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n      git checkout -b g/h/i -l master &&\n \t test_path_is_file .git/refs/heads/g/h/i &&\n \t test_path_is_file .git/logs/refs/heads/g/h/i &&\n-\t test_cmp expect .git/logs/refs/heads/g/h/i'\n+\ttest_cmp expect .git/logs/refs/heads/g/h/i\n+'\n \n test_expect_success 'checkout -b makes reflog by default' '\n \tgit checkout master &&\n-- \n1.7.8\n"},{"id":"185963","messageId":"1330740942-25130-10-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2-w 104/105] t0040 (parse-options): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:41Z","receivedAt":"2012-03-03T02:15:41Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t0040-parse-options.sh |   96 +++++++++++++++++++--------------------------\n 1 files changed, 41 insertions(+), 55 deletions(-)\n\ndiff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh\nindex a1e4616..4a0b991 100755\n--- a/t/t0040-parse-options.sh\n+++ b/t/t0040-parse-options.sh\n@@ -7,7 +7,8 @@ test_description='our own option parser'\n \n . ./test-lib.sh\n \n-cat > expect << EOF\n+test_expect_success 'test help' '\n+\tcat >expect <<-EOF &&\n usage: test-parse-options <options>\n \n     -b, --boolean         get a boolean\n@@ -23,7 +24,7 @@ usage: test-parse-options <options>\n \n String options\n     -s, --string <string>\n-                          get a string\n+\t\t''                          get a string\n     --string2 <str>       get another string\n     --st <st>             get another string (pervert ordering)\n     -o <str>              get another string\n@@ -44,16 +45,14 @@ Standard options\n     -q, --quiet           be quiet\n \n EOF\n-\n-test_expect_success 'test help' '\n+\tcp expect expect.err &&\n \ttest_must_fail test-parse-options -h > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-mv expect expect.err\n-\n-cat > expect << EOF\n+test_expect_success 'short options' '\n+\tcat >expect <<-\\EOF &&\n boolean: 2\n integer: 1729\n timestamp: 0\n@@ -64,15 +63,14 @@ quiet: no\n dry run: yes\n file: prefix/my.file\n EOF\n-\n-test_expect_success 'short options' '\n \ttest-parse-options -s123 -b -i 1729 -b -vv -n -F my.file \\\n \t> output 2> output.err &&\n \ttest_cmp expect output &&\n \ttest ! -s output.err\n '\n \n-cat > expect << EOF\n+test_expect_success 'long options' '\n+\tcat >expect <<-\\EOF &&\n boolean: 2\n integer: 1729\n timestamp: 0\n@@ -83,8 +81,6 @@ quiet: no\n dry run: no\n file: prefix/fi.le\n EOF\n-\n-test_expect_success 'long options' '\n \ttest-parse-options --boolean --integer 1729 --boolean --string2=321 \\\n \t\t--verbose --verbose --no-dry-run --abbrev=10 --file fi.le\\\n \t\t--obsolete > output 2> output.err &&\n@@ -101,7 +97,8 @@ test_expect_success 'missing required value' '\n \ttest $? = 129\n '\n \n-cat > expect << EOF\n+test_expect_success 'intermingled arguments' '\n+\tcat >expect <<-\\EOF &&\n boolean: 1\n integer: 13\n timestamp: 0\n@@ -115,15 +112,14 @@ arg 00: a1\n arg 01: b1\n arg 02: --boolean\n EOF\n-\n-test_expect_success 'intermingled arguments' '\n \ttest-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \\\n \t\t> output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect << EOF\n+test_expect_success 'unambiguously abbreviated option' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 2\n timestamp: 0\n@@ -134,8 +130,6 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'unambiguously abbreviated option' '\n \ttest-parse-options --int 2 --boolean --no-bo > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n@@ -152,7 +146,8 @@ test_expect_success 'ambiguously abbreviated option' '\n \ttest $? = 129\n '\n \n-cat > expect << EOF\n+test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -163,24 +158,23 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'non ambiguous option (after two options it abbreviates)' '\n \ttest-parse-options --st 123 > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > typo.err << EOF\n-error: did you mean \\`--boolean\\` (with two dashes ?)\n-EOF\n-\n test_expect_success 'detect possible typos' '\n+\tcat >typo.err <<-\\EOF &&\n+\t\terror: did you mean `--boolean` (with two dashes ?)\n+\tEOF\n+\t>expect\n \ttest_must_fail test-parse-options -boolean > output 2> output.err &&\n-\ttest ! -s output &&\n-\ttest_cmp typo.err output.err\n+\ttest_cmp typo.err output.err &&\n+\ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n+test_expect_success 'keep some options as arguments' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -192,14 +186,13 @@ dry run: no\n file: (not set)\n arg 00: --quux\n EOF\n-\n-test_expect_success 'keep some options as arguments' '\n \ttest-parse-options --quux > output 2> output.err &&\n         test ! -s output.err &&\n         test_cmp expect output\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 1\n@@ -211,15 +204,14 @@ dry run: no\n file: (not set)\n arg 00: foo\n EOF\n-\n-test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '\n-\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" --default-string \\\n-\t\tfoo -q > output 2> output.err &&\n+\ttest-parse-options -t \"1970-01-01 00:00:01 +0000\" \\\n+\t\t--default-string foo -q >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n+\tcat >expect <<-\\EOF &&\n Callback: \"four\", 0\n boolean: 5\n integer: 4\n@@ -231,24 +223,22 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '\n \ttest-parse-options --length=four -b -4 > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_CALLBACK() and callback errors work' '\n+\tcat >expect <<-\\EOF &&\n Callback: \"not set\", 1\n EOF\n-\n-test_expect_success 'OPT_CALLBACK() and callback errors work' '\n \ttest_must_fail test-parse-options --no-length > output 2> output.err &&\n \ttest_cmp expect output &&\n \ttest_cmp expect.err output.err\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n+\tcat >expect <<-\\EOF &&\n boolean: 1\n integer: 23\n timestamp: 0\n@@ -259,8 +249,6 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '\n \ttest-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n@@ -272,7 +260,8 @@ test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n+test_expect_success 'OPT_BIT() works' '\n+\tcat >expect <<-\\EOF &&\n boolean: 6\n integer: 0\n timestamp: 0\n@@ -283,8 +272,6 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_BIT() works' '\n \ttest-parse-options -bb --or4 > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n@@ -302,7 +289,9 @@ test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '\n \ttest_cmp expect output\n '\n \n-cat > expect <<EOF\n+\n+test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 12345\n timestamp: 0\n@@ -313,14 +302,13 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'OPT_NUMBER_CALLBACK() works' '\n \ttest-parse-options -12345 > output 2> output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat >expect <<EOF\n+test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n+\tcat >expect <<-\\EOF &&\n boolean: 0\n integer: 0\n timestamp: 0\n@@ -331,19 +319,17 @@ quiet: no\n dry run: no\n file: (not set)\n EOF\n-\n-test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '\n \ttest-parse-options --no-ambig >output 2>output.err &&\n \ttest ! -s output.err &&\n \ttest_cmp expect output\n '\n \n-cat >>expect <<'EOF'\n+test_expect_success '--list keeps list of strings' '\n+\tcat >>expect <<-\\EOF &&\n list: foo\n list: bar\n list: baz\n EOF\n-test_expect_success '--list keeps list of strings' '\n \ttest-parse-options --list foo --list=bar --list=baz >output &&\n \ttest_cmp expect output\n '\n-- \n1.7.8\n"},{"id":"185960","messageId":"1330740942-25130-11-git-send-email-tmgrennan@gmail.com","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"[PATCHv2-w 105/105] t6300 (for-each-ref): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T02:15:42Z","receivedAt":"2012-03-03T02:15:42Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"- Guard setup with test_expect_success\n- Unwound one loop to stay within the test_expect_success guard\n\nSigned-off-by: Tom Grennan <tmgrennan@gmail.com>\n---\n t/t6300-for-each-ref.sh |  118 +++++++++++++++++++++++------------------------\n 1 files changed, 58 insertions(+), 60 deletions(-)\n\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex 1721784..ebba7d1 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -138,12 +138,13 @@ test_expect_success 'Check invalid format specifiers are errors' '\n \ttest_must_fail git for-each-ref --format=\"%(authordate:INVALID)\" refs/heads\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check unformatted date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF &&\n 'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n 'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\n EOF\n-\n-test_expect_success 'Check unformatted date fields output' '\n+\t\"'\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate) %(authordate)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n@@ -171,84 +172,85 @@ test_expect_success 'Check format \"relative\" date fields output' '\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"short\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n 'refs/heads/master' '2006-07-03' '2006-07-03'\n 'refs/tags/testtag' '2006-07-03'\n EOF\n-\n-test_expect_success 'Check format \"short\" date fields output' '\n+\t\"'\n \tf=short &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"local\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n 'refs/heads/master' 'Mon Jul 3 15:18:43 2006' 'Mon Jul 3 15:18:44 2006'\n 'refs/tags/testtag' 'Mon Jul 3 15:18:45 2006'\n EOF\n-\n-test_expect_success 'Check format \"local\" date fields output' '\n-\tf=local &&\n-\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n-\tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n+\t\"'\n+\t(git for-each-ref --shell --format=\"%(refname) %(committerdate:local) %(authordate:local)\" refs/heads &&\n+\t git for-each-ref --shell --format=\"%(refname) %(taggerdate:local)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"iso8601\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n 'refs/heads/master' '2006-07-03 17:18:43 +0200' '2006-07-03 17:18:44 +0200'\n 'refs/tags/testtag' '2006-07-03 17:18:45 +0200'\n EOF\n-\n-test_expect_success 'Check format \"iso8601\" date fields output' '\n+\t\"'\n \tf=iso8601 &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check format \"rfc2822\" date fields output' '\n+\t'\"\n+\tcat >expected <<-EOF\n 'refs/heads/master' 'Mon, 3 Jul 2006 17:18:43 +0200' 'Mon, 3 Jul 2006 17:18:44 +0200'\n 'refs/tags/testtag' 'Mon, 3 Jul 2006 17:18:45 +0200'\n EOF\n-\n-test_expect_success 'Check format \"rfc2822\" date fields output' '\n+\t\"'\n \tf=rfc2822 &&\n \t(git for-each-ref --shell --format=\"%(refname) %(committerdate:$f) %(authordate:$f)\" refs/heads &&\n \tgit for-each-ref --shell --format=\"%(refname) %(taggerdate:$f)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Verify ascending sort' '\n+\tcat >expected <<-EOF\n refs/heads/master\n refs/remotes/origin/master\n refs/tags/testtag\n EOF\n-\n-test_expect_success 'Verify ascending sort' '\n \tgit for-each-ref --format=\"%(refname)\" --sort=refname >actual &&\n \ttest_cmp expected actual\n '\n \n-\n-cat >expected <<\\EOF\n+test_expect_success 'Verify descending sort' '\n+\tcat >expected <<-EOF\n refs/tags/testtag\n refs/remotes/origin/master\n refs/heads/master\n EOF\n-\n-test_expect_success 'Verify descending sort' '\n \tgit for-each-ref --format=\"%(refname)\" --sort=-refname >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Quoting style: shell' '\n+\t'\"\n+\tcat >expected <<-EOF\n 'refs/heads/master'\n 'refs/remotes/origin/master'\n 'refs/tags/testtag'\n EOF\n-\n-test_expect_success 'Quoting style: shell' '\n+\t\"'\n \tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n \ttest_cmp expected actual\n '\n@@ -263,52 +265,51 @@ test_expect_success 'Quoting style: python' '\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Quoting style: tcl' '\n+\tcat >expected <<-EOF\n \"refs/heads/master\"\n \"refs/remotes/origin/master\"\n \"refs/tags/testtag\"\n EOF\n-\n-test_expect_success 'Quoting style: tcl' '\n \tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n \ttest_cmp expected actual\n '\n \n-for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n-\ttest_expect_success \"more than one quoting style: $i\" \"\n-\t\tgit for-each-ref $i 2>&1 | (read line &&\n-\t\tcase \\$line in\n-\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n-\t\t*) false\n-\t\tesac)\n-\t\"\n-done\n-\n-cat >expected <<\\EOF\n+test_expect_success 'more than one quoting styles' '\n+\tcat >expected <<-EOF\n+\t\terror: more than one quoting style?\n+\tEOF\n+\tgit for-each-ref --perl --shell 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref -s --python 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref --python --tcl 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual &&\n+\tgit for-each-ref --tcl --perl 2>&1 | head -n 1 >actual &&\n+\ttest_cmp expected actual\n+'\n+test_expect_success 'Check short refname format' '\n+\tcat >expected <<-EOF\n master\n testtag\n EOF\n-\n-test_expect_success 'Check short refname format' '\n \t(git for-each-ref --format=\"%(refname:short)\" refs/heads &&\n \tgit for-each-ref --format=\"%(refname:short)\" refs/tags) >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<EOF\n+test_expect_success 'Check short upstream format' '\n+\tcat >expected <<-EOF\n origin/master\n EOF\n-\n-test_expect_success 'Check short upstream format' '\n \tgit for-each-ref --format=\"%(upstream:short)\" refs/heads >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<EOF\n+test_expect_success 'Check short objectname format' '\n+\tcat >expected <<-EOF\n 67a36f1\n EOF\n-\n-test_expect_success 'Check short objectname format' '\n \tgit for-each-ref --format=\"%(objectname:short)\" refs/heads >actual &&\n \ttest_cmp expected actual\n '\n@@ -317,12 +318,11 @@ test_expect_success 'Check for invalid refname format' '\n \ttest_must_fail git for-each-ref --format=\"%(refname:INVALID)\"\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs (strict)' '\n+\tcat >expected <<-EOF\n heads/master\n tags/master\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs (strict)' '\n \tgit config --bool core.warnambiguousrefs true &&\n \tgit checkout -b newtag &&\n \techo \"Using $datestamp\" > one &&\n@@ -334,23 +334,21 @@ test_expect_success 'Check ambiguous head and tag refs (strict)' '\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs (loose)' '\n+\tcat >expected <<-EOF\n heads/master\n master\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs (loose)' '\n \tgit config --bool core.warnambiguousrefs false &&\n \tgit for-each-ref --format \"%(refname:short)\" refs/heads/master refs/tags/master >actual &&\n \ttest_cmp expected actual\n '\n \n-cat >expected <<\\EOF\n+test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n+\tcat >expected <<-EOF\n heads/ambiguous\n ambiguous\n EOF\n-\n-test_expect_success 'Check ambiguous head and tag refs II (loose)' '\n \tgit checkout master &&\n \tgit tag ambiguous testtag^0 &&\n \tgit branch ambiguous testtag^0 &&\n@@ -369,7 +367,7 @@ test_expect_success 'an unusual tag with an incomplete line' '\n '\n \n test_expect_success 'create tag with subject and body content' '\n-\tcat >>msg <<-\\EOF &&\n+\tcat >msg <<-\\EOF &&\n \t\tthe subject line\n \n \t\tfirst body line\n-- \n1.7.8\n"},{"id":"185978","messageId":"7vpqcu6rfd.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1330740942-25130-1-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv2 0/5] modernize test style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-03T08:04:54Z","receivedAt":"2012-03-03T08:04:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n>   t7004 (tag): modernize style\n>   t5512 (ls-remote): modernize style\n>   t3200 (branch): modernize style\n>   t0040 (parse-options): modernize style\n>   t6300 (for-each-ref): modernize style\n\nHmph.\n\nWe would want to keep/make the codebase uniformly conform to our style\nguide for longer term maintainability (this is not limited to the test\nscripts) but at the same time we would strongly want to avoid churning\npatches from interfering other patches that are still in flight that do\n\"real work\".\n\nThere are only two appropriate occasions for file-wide clean-up patches\nlike these:\n\n (1) The file has not been touched for quite some time, and it is not\n     expected to be touched for some time to come; or\n\n (2) You are going to do extensive work on the file for reasons other than\n     clean-up, and nobody else is working or expected to work in the same\n     area for some time to come (in other words, you _own_ the file), and\n     your real work will be easier to review if it is done _after_ such a\n     clean-up patch.\n\nLet's see how active these five files are:\n\n$ git diff --stat v1.7.9..pu --  t/t{7004,5512,3200,0040,6300}-*.sh\n t/t0040-parse-options.sh |   60 ++++++++++++++++++++++-\n t/t3200-branch.sh        |  122 ++++++++++++++++++++++++++++++++++++++++++++--\n t/t7004-tag.sh           |   96 ++++++++++++++++++++++++++++++++++++\n 3 files changed, 272 insertions(+), 6 deletions(-)\n\nGiven this, I do not want to take three of your 5 patches that touch these\nfiles at this point.  Please hold onto them and wait until topics that\ntouch these test scripts graduate to 'master', and then wait a bit more\nuntil some time passes without anybody touching them, before redoing the\nclean-up patches.\n\nOn the other hand, we can see that 5512 has been dormant for quite a\nwhile.  Note that the latter diff is against 3 cycles ago:\n\n$ git diff --stat v1.7.6..pu --  t/t{7004,5512,3200,0040,6300}-*.sh\n t/t0040-parse-options.sh |   79 +++++++++++++++-\n t/t3200-branch.sh        |  236 +++++++++++++++++++++++++++++++++++++++++-----\n t/t6300-for-each-ref.sh  |  101 +++++++++++++++++++-\n t/t7004-tag.sh           |  128 +++++++++++++++++++------\n 4 files changed, 490 insertions(+), 54 deletions(-)\n\nso 5512 and possibly 6300 may be worth reviewing.\n\nThanks.\n"},{"id":"185979","messageId":"7vipim6rf2.fsf@alter.siamese.dyndns.org","threadId":"29583","inReplyTo":"1330740942-25130-3-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv2 2/5] t5512 (ls-remote): modernize style","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-03T08:05:05Z","receivedAt":"2012-03-03T08:05:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tom Grennan <tmgrennan@gmail.com> writes:\n\n>  test_expect_success 'confuses pattern as remote when no remote specified' '\n> +\t'\"\n> +\tcat >exp <<-EOF\n> +\t\tfatal: 'refs*master' does not appear to be a git repository\n> +\t\tfatal: The remote end hung up unexpectedly\n> +\tEOF\n> +\t\"'\n\nPlease make it a habit to make your test script a cascade of &&, i.e.\n\n\t... remote specified' '\n\tcat >exp <<-\\EOF &&\n        fatal: '\\''refs*master'\\'' does not ...\n\t...\n        EOF\n\nNo need to resend; I'll fix it up locally.        \n\nThanks.\n"},{"id":"185996","messageId":"20120303173350.GL2572@tgrennan-laptop","threadId":"29583","inReplyTo":"7vipim6rf2.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 2/5] t5512 (ls-remote): modernize style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T17:33:50Z","receivedAt":"2012-03-03T17:33:50Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Sat, Mar 03, 2012 at 12:05:05AM -0800, Junio C Hamano wrote:\n>Tom Grennan <tmgrennan@gmail.com> writes:\n>\n>>  test_expect_success 'confuses pattern as remote when no remote specified' '\n>> +\t'\"\n>> +\tcat >exp <<-EOF\n>> +\t\tfatal: 'refs*master' does not appear to be a git repository\n>> +\t\tfatal: The remote end hung up unexpectedly\n>> +\tEOF\n>> +\t\"'\n>\n>Please make it a habit to make your test script a cascade of &&, i.e.\n>\n>\t... remote specified' '\n>\tcat >exp <<-\\EOF &&\n>        fatal: '\\''refs*master'\\'' does not ...\n>\t...\n>        EOF\n>\n>No need to resend; I'll fix it up locally.        \n>\n\nOops, I missed the && on that one.\n\nWhat about the quoting of t6300's,\n\ncat >expected <<\\EOF\n'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\n'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\nEOF\n\nDo you want it like this,\n\tcat >expected <<-EOF &&\n\t\t'\\''refs/heads/master'\\'' '\\''Mon Jul 3 17:18:43 2006 +0200'\\'' '\\''Mon Jul 3 17:18:44 2006 +0200'\\''\n\t\t'\\''refs/tags/testtag'\\'' '\\''Mon Jul 3 17:18:45 2006 +0200'\\''\n\tEOF\n\nor,\n\tcat >expected <<-EOF &&\n\t\t'\"'refs/heads/master' 'Mon Jul 3 17:18:43 2006 +0200' 'Mon Jul 3 17:18:44 2006 +0200'\"'\n\t\t'\"'refs/tags/testtag' 'Mon Jul 3 17:18:45 2006 +0200'\"'\n\tEOF\n\nor something else?\n\nThanks,\nTomG\n"},{"id":"185997","messageId":"20120303174206.GM2572@tgrennan-laptop","threadId":"29583","inReplyTo":"7vpqcu6rfd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 0/5] modernize test style","fromName":"Tom Grennan","fromEmail":"tmgrennan@gmail.com","sentAt":"2012-03-03T17:42:06Z","receivedAt":"2012-03-03T17:42:06Z","isPatch":false,"sender":{"key":"tmgrennan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/422771?v=4"},"body":"On Sat, Mar 03, 2012 at 12:04:54AM -0800, Junio C Hamano wrote:\n>\n>On the other hand, we can see that 5512 has been dormant for quite a\n>while.  Note that the latter diff is against 3 cycles ago:\n>\n>$ git diff --stat v1.7.6..pu --  t/t{7004,5512,3200,0040,6300}-*.sh\n> t/t0040-parse-options.sh |   79 +++++++++++++++-\n> t/t3200-branch.sh        |  236 +++++++++++++++++++++++++++++++++++++++++-----\n> t/t6300-for-each-ref.sh  |  101 +++++++++++++++++++-\n> t/t7004-tag.sh           |  128 +++++++++++++++++++------\n> 4 files changed, 490 insertions(+), 54 deletions(-)\n>\n>so 5512 and possibly 6300 may be worth reviewing.\n\nAck, I'll hold the others until each are quiescent for a few cycles.\n\nThanks.\nTomG\n"},{"id":"186013","messageId":"4F528DC8.7010102@kdbg.org","threadId":"29583","inReplyTo":"1330740942-25130-2-git-send-email-tmgrennan@gmail.com","subject":"Re: [PATCHv2 1/5] t7004 (tag): modernize style","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-03-03T21:31:52Z","receivedAt":"2012-03-03T21:31:52Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 03.03.2012 03:15, schrieb Tom Grennan:\n> -test_expect_success 'trying to delete an already deleted tag should fail' \\\n> -\t'test_must_fail git tag -d mytag'\n> +test_expect_success \\\n> +\t'trying to delete an already deleted tag should fail' '\n> +\ttest_must_fail git tag -d mytag\n> +'\n\nPersonally, I prefer lines with 80+ chars over lines broken with a\nbackslash. So, while I can understand that you do not always remove a\nbackslash to avoid churn, I think it is not warranted to *introduce* one\nto shorten a line below 80 chars. But that's really just a matter of taste.\n\n>  test_expect_success GPG \\\n>  \t'creating a signed tag with -F messagefile should succeed' '\n> +\tcat >sigmsgfile <<-EOF\n> +\t\tAnother signed tag\n> +\t\tmessage in a file.\n> +\tEOF\n> +\tget_tag_header file-signed-tag $commit commit $time >expect <sigmsgfile\n> +\techo \"-----BEGIN PGP SIGNATURE-----\" >>expect\n\n\nSeveral && missing here and later in the file.\n\nI stopped reading here. This is too much to read in one go. This should\nreally be broken into several parts. For example, you changed\nget_tag_header and added several <emptyfile redirections (which should\nbe /dev/null IMO); that has not a lot to do with \"modernize style\".\n\n>  \tgit tag -s -F sigmsgfile file-signed-tag &&\n>  \tget_tag_msg file-signed-tag >actual &&\n>  \ttest_cmp expect actual\n>  '\n\n-- Hannes\n"}]}