{"thread":{"id":"19602","subject":"[PATCH 2/2] document new flags","startedAt":"2009-05-30T01:39:14Z","lastAt":"2009-05-30T12:18:23Z","messageCount":4,"participants":["Jeff Epler","Jakub Narebski","Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"115066","messageId":"1243647555-25098-1-git-send-email-user@lamp","threadId":"19602","inReplyTo":null,"subject":"[PATCH 1/2] add new output-tuning flags to 'git cherry'","fromName":"Jeff Epler","fromEmail":"unpythonic.net@unpythonic.net","sentAt":"2009-05-30T01:39:14Z","receivedAt":"2009-05-30T01:39:14Z","isPatch":true,"sender":{"key":"unpythonic.net@unpythonic.net","avatar":null},"body":"From: Jeff Epler <jepler@unpythonic.net>\n\nThe new flags are:\n    -a or -##: abbreviate SHA1s to 7 or ## places\n    -r: reverse 'upstream' and 'head' (useful when on 'head' and wanting to\n        pick from 'upstream')\n    -d: only show \"+\" (doesn't have) patches\n    -D: only show \"-\" (does have) patches\n\nSigned-off-by: Jeff Epler <jepler@unpythonic.net>\n---\n builtin-log.c |   54 ++++++++++++++++++++++++++++++++++++++++++++----------\n 1 files changed, 44 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex f10cfeb..420f39e 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -1130,7 +1130,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n }\n \n static const char cherry_usage[] =\n-\"git cherry [-v] [<upstream> [<head> [<limit>]]]\";\n+\"git cherry [-v] [-a|-#] [-r] [-d|-D] [<upstream> [<head> [<limit>]]]\";\n int cmd_cherry(int argc, const char **argv, const char *prefix)\n {\n \tstruct rev_info revs;\n@@ -1142,9 +1142,29 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \tconst char *head = \"HEAD\";\n \tconst char *limit = NULL;\n \tint verbose = 0;\n+\tint reverse = 0;\n+\tint abbrev = 40;\n+\tint show_has = 0;\n+\tint show_hasnt = 0;\n+\n+\twhile(argc > 1 && argv[1][0] == '-')\n+\t{\n+\t\tif (!strcmp(argv[1], \"-v\")) {\n+\t\t\tverbose = 1;\n+\t\t} else if(!strcmp(argv[1], \"-a\")) {\n+\t\t\tabbrev = DEFAULT_ABBREV;\n+\t\t} else if(isdigit(argv[1][1])) {\n+\t\t\tabbrev = atoi(argv+1);\n+\t\t} else if(!strcmp(argv[1], \"-r\")) {\n+\t\t\treverse = 1;\n+\t\t} else if(!strcmp(argv[1], \"-d\")) {\n+\t\t\tshow_hasnt = 1;\n+\t\t} else if(!strcmp(argv[1], \"-D\")) {\n+\t\t\tshow_has = 1;\n+\t\t} else {\n+\t\t\tdie(\"unrecognized argument: %s\", argv[1]);\n+\t\t}\n \n-\tif (argc > 1 && !strcmp(argv[1], \"-v\")) {\n-\t\tverbose = 1;\n \t\targc--;\n \t\targv++;\n \t}\n@@ -1173,6 +1193,16 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\tupstream = current_branch->merge[0]->dst;\n \t}\n \n+\tif(reverse) {\n+\t\tconst char *temp = upstream;\n+\t\tupstream = head;\n+\t\thead = temp;\n+\t}\n+\n+\tif(!show_has && !show_hasnt) {\n+\t\tshow_has = show_hasnt = 1;\n+\t}\n+\n \tinit_revisions(&revs, prefix);\n \trevs.diff = 1;\n \trevs.combine_merges = 0;\n@@ -1207,27 +1237,31 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n \t\tcommit_list_insert(commit, &list);\n \t}\n \n-\twhile (list) {\n+\tfor (; list; list=list->next) {\n \t\tchar sign = '+';\n+\t\tint has;\n \n \t\tcommit = list->item;\n-\t\tif (has_commit_patch_id(commit, &ids))\n+\n+\t\tif ((has = has_commit_patch_id(commit, &ids))) {\n \t\t\tsign = '-';\n+\t\t\tif(!show_has) continue;\n+\t\t} else {\n+\t\t\tif(!show_hasnt) continue;\n+\t\t}\n \n \t\tif (verbose) {\n \t\t\tstruct strbuf buf = STRBUF_INIT;\n \t\t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n-\t\t\t                    &buf, 0, NULL, NULL, 0, 0);\n-\t\t\tprintf(\"%c %s %s\\n\", sign,\n+\t\t\t\t\t    &buf, 0, NULL, NULL, 0, 0);\n+\t\t\tprintf(\"%c %.*s %s\\n\", sign, abbrev,\n \t\t\t       sha1_to_hex(commit->object.sha1), buf.buf);\n \t\t\tstrbuf_release(&buf);\n \t\t}\n \t\telse {\n-\t\t\tprintf(\"%c %s\\n\", sign,\n+\t\t\tprintf(\"%c %.*s\\n\", sign, abbrev,\n \t\t\t       sha1_to_hex(commit->object.sha1));\n \t\t}\n-\n-\t\tlist = list->next;\n \t}\n \n \tfree_patch_ids(&ids);\n-- \n1.5.4.3\n"},{"id":"115065","messageId":"1243647555-25098-2-git-send-email-user@lamp","threadId":"19602","inReplyTo":"1243647555-25098-1-git-send-email-user@lamp","subject":"[PATCH 2/2] document new flags","fromName":"Jeff Epler","fromEmail":"unpythonic.net@unpythonic.net","sentAt":"2009-05-30T01:39:15Z","receivedAt":"2009-05-30T01:39:15Z","isPatch":true,"sender":{"key":"unpythonic.net@unpythonic.net","avatar":null},"body":"From: Jeff Epler <jepler@unpythonic.net>\n\nSigned-off-by: Jeff Epler <jepler@unpythonic.net>\n---\n Documentation/git-cherry.txt |   14 +++++++++++++-\n 1 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt\nindex 7deefda..100ed69 100644\n--- a/Documentation/git-cherry.txt\n+++ b/Documentation/git-cherry.txt\n@@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream\n \n SYNOPSIS\n --------\n-'git cherry' [-v] [<upstream> [<head> [<limit>]]]\n+'git cherry' [-v] [-a|-#] [-r] [-d|-D] [<upstream> [<head> [<limit>]]]\n \n DESCRIPTION\n -----------\n@@ -49,6 +49,18 @@ OPTIONS\n -v::\n \tVerbose.\n \n+-a|-#::\n+\tAbbreviate commit ids to the given number of characters, or 7 for -a\n+\n+-r::\n+\tSwap <upstream> and <head>\n+\n+-d::\n+\tOnly show commits that don't exist in upstream (\"+\" lines)\n+\n+-D::\n+\tOnly show commits that do exist in upstream (\"-\" lines)\n+\n <upstream>::\n \tUpstream branch to compare against.\n \tDefaults to the first tracked remote branch, if available.\n-- \n1.5.4.3\n"},{"id":"115071","messageId":"m38wkfatqc.fsf@localhost.localdomain","threadId":"19602","inReplyTo":"1243647555-25098-2-git-send-email-user@lamp","subject":"Re: [PATCH 2/2] document new flags","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-30T08:19:53Z","receivedAt":"2009-05-30T08:19:53Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jeff Epler <unpythonic.net@unpythonic.net> writes:\n\n> From: Jeff Epler <jepler@unpythonic.net>\n> \n> Signed-off-by: Jeff Epler <jepler@unpythonic.net>\n> ---\n>  Documentation/git-cherry.txt |   14 +++++++++++++-\n>  1 files changed, 13 insertions(+), 1 deletions(-)\n\nWhy split this patch in two? It is better to have new feature and\ndocumentation together, I think.\n \n> diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt\n> index 7deefda..100ed69 100644\n> --- a/Documentation/git-cherry.txt\n> +++ b/Documentation/git-cherry.txt\n> @@ -7,7 +7,7 @@ git-cherry - Find commits not merged upstream\n>  \n>  SYNOPSIS\n>  --------\n> -'git cherry' [-v] [<upstream> [<head> [<limit>]]]\n> +'git cherry' [-v] [-a|-#] [-r] [-d|-D] [<upstream> [<head> [<limit>]]]\n>  \n>  DESCRIPTION\n>  -----------\n> @@ -49,6 +49,18 @@ OPTIONS\n>  -v::\n>  \tVerbose.\n>  \n> +-a|-#::\n> +\tAbbreviate commit ids to the given number of characters, or 7 for -a\n> +\n\nWhy invent new convention, instead of using -<n> like git-log?\nWhy do not use --abbrev or --abbrev-commit? -<n> is used elsewhere\nto limit number of commits...\n\n> +-r::\n> +\tSwap <upstream> and <head>\n\nWhy not -R like in git-diff?\n\n> +\n> +-d::\n> +\tOnly show commits that don't exist in upstream (\"+\" lines)\n> +\n> +-D::\n> +\tOnly show commits that do exist in upstream (\"-\" lines)\n> +\n\nI'm not sure if -d/-D is the best name of this short option...\n\n>  <upstream>::\n>  \tUpstream branch to compare against.\n>  \tDefaults to the first tracked remote branch, if available.\n> -- \n> 1.5.4.3\n> \n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"115082","messageId":"4A21240F.8090902@drmicha.warpmail.net","threadId":"19602","inReplyTo":"1243647555-25098-1-git-send-email-user@lamp","subject":"Re: [PATCH 1/2] add new output-tuning flags to 'git cherry'","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-05-30T12:18:23Z","receivedAt":"2009-05-30T12:18:23Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Jeff Epler venit, vidit, dixit 30.05.2009 03:39:\n> From: Jeff Epler <jepler@unpythonic.net>\n\ngit cherry certainly could use a few enhancements. About the proposed\nones, I'm a bit doubtful, besides the issue of unusual option names\nwhich Jakub mentioned:\n\n> \n> The new flags are:\n>     -a or -##: abbreviate SHA1s to 7 or ## places\n>     -r: reverse 'upstream' and 'head' (useful when on 'head' and wanting to\n>         pick from 'upstream')\n\nWhat's wrong with using \"git cherry HEAD upstream\" in that case?\n\n>     -d: only show \"+\" (doesn't have) patches\n>     -D: only show \"-\" (does have) patches\n\nThose are a matter of \"git cherry <options> | egrep '^\\+' etc.\n\nSo I don't think the patch adds new functionality. If anything I would\nprobably suggest having --abbrev and leaving the others out.\n\nUseful new functionality would be:\n- Display the upstream commit name which has the same patch id.\n- Deal differently with a limit which is a predecessor of the merge-base.\n\n> \n> Signed-off-by: Jeff Epler <jepler@unpythonic.net>\n> ---\n>  builtin-log.c |   54 ++++++++++++++++++++++++++++++++++++++++++++----------\n>  1 files changed, 44 insertions(+), 10 deletions(-)\n> \n> diff --git a/builtin-log.c b/builtin-log.c\n> index f10cfeb..420f39e 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -1130,7 +1130,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)\n>  }\n>  \n>  static const char cherry_usage[] =\n> -\"git cherry [-v] [<upstream> [<head> [<limit>]]]\";\n> +\"git cherry [-v] [-a|-#] [-r] [-d|-D] [<upstream> [<head> [<limit>]]]\";\n>  int cmd_cherry(int argc, const char **argv, const char *prefix)\n>  {\n>  \tstruct rev_info revs;\n> @@ -1142,9 +1142,29 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n>  \tconst char *head = \"HEAD\";\n>  \tconst char *limit = NULL;\n>  \tint verbose = 0;\n> +\tint reverse = 0;\n> +\tint abbrev = 40;\n> +\tint show_has = 0;\n> +\tint show_hasnt = 0;\n> +\n> +\twhile(argc > 1 && argv[1][0] == '-')\n> +\t{\n> +\t\tif (!strcmp(argv[1], \"-v\")) {\n> +\t\t\tverbose = 1;\n> +\t\t} else if(!strcmp(argv[1], \"-a\")) {\n> +\t\t\tabbrev = DEFAULT_ABBREV;\n> +\t\t} else if(isdigit(argv[1][1])) {\n> +\t\t\tabbrev = atoi(argv+1);\n> +\t\t} else if(!strcmp(argv[1], \"-r\")) {\n> +\t\t\treverse = 1;\n> +\t\t} else if(!strcmp(argv[1], \"-d\")) {\n> +\t\t\tshow_hasnt = 1;\n> +\t\t} else if(!strcmp(argv[1], \"-D\")) {\n> +\t\t\tshow_has = 1;\n> +\t\t} else {\n> +\t\t\tdie(\"unrecognized argument: %s\", argv[1]);\n> +\t\t}\n>  \n> -\tif (argc > 1 && !strcmp(argv[1], \"-v\")) {\n> -\t\tverbose = 1;\n>  \t\targc--;\n>  \t\targv++;\n>  \t}\n> @@ -1173,6 +1193,16 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n>  \t\tupstream = current_branch->merge[0]->dst;\n>  \t}\n>  \n> +\tif(reverse) {\n> +\t\tconst char *temp = upstream;\n> +\t\tupstream = head;\n> +\t\thead = temp;\n> +\t}\n> +\n> +\tif(!show_has && !show_hasnt) {\n> +\t\tshow_has = show_hasnt = 1;\n> +\t}\n> +\n>  \tinit_revisions(&revs, prefix);\n>  \trevs.diff = 1;\n>  \trevs.combine_merges = 0;\n> @@ -1207,27 +1237,31 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)\n>  \t\tcommit_list_insert(commit, &list);\n>  \t}\n>  \n> -\twhile (list) {\n> +\tfor (; list; list=list->next) {\n>  \t\tchar sign = '+';\n> +\t\tint has;\n>  \n>  \t\tcommit = list->item;\n> -\t\tif (has_commit_patch_id(commit, &ids))\n> +\n> +\t\tif ((has = has_commit_patch_id(commit, &ids))) {\n>  \t\t\tsign = '-';\n> +\t\t\tif(!show_has) continue;\n> +\t\t} else {\n> +\t\t\tif(!show_hasnt) continue;\n> +\t\t}\n>  \n>  \t\tif (verbose) {\n>  \t\t\tstruct strbuf buf = STRBUF_INIT;\n>  \t\t\tpretty_print_commit(CMIT_FMT_ONELINE, commit,\n> -\t\t\t                    &buf, 0, NULL, NULL, 0, 0);\n> -\t\t\tprintf(\"%c %s %s\\n\", sign,\n> +\t\t\t\t\t    &buf, 0, NULL, NULL, 0, 0);\n> +\t\t\tprintf(\"%c %.*s %s\\n\", sign, abbrev,\n>  \t\t\t       sha1_to_hex(commit->object.sha1), buf.buf);\n>  \t\t\tstrbuf_release(&buf);\n>  \t\t}\n>  \t\telse {\n> -\t\t\tprintf(\"%c %s\\n\", sign,\n> +\t\t\tprintf(\"%c %.*s\\n\", sign, abbrev,\n>  \t\t\t       sha1_to_hex(commit->object.sha1));\n>  \t\t}\n> -\n> -\t\tlist = list->next;\n>  \t}\n>  \n>  \tfree_patch_ids(&ids);\n"}]}