{"thread":{"id":"31502","subject":"[PATCH 1/2] git-describe: introduce --first-parent","startedAt":"2012-09-11T13:51:50Z","lastAt":"2012-09-11T17:20:45Z","messageCount":6,"participants":["Michael J Gruber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"198776","messageId":"cover.1347370970.git.git@drmicha.warpmail.net","threadId":"31502","inReplyTo":null,"subject":"[PATCH 0/2] git describe --first-parent","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-09-11T13:51:50Z","receivedAt":"2012-09-11T13:51:50Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"While \"git describe\" behaves as documented, the notion of \"most recent tag\"\nis not really easy to grab, and it's not always the way you want to describe\na commit.\n\n\"--first-parent\" is the option which answers the question: Which is the\nmost recent tag on this branch which can be reached from this commit?\n(\"This branch\" being defined as \"--first-parent\" walk.)\n\nI had suggested this before, but the discussion veered off quite a bit:\nhttp://permalink.gmane.org/gmane.comp.version-control.git/156811\n\nNo need to discuss the way \"git describe\" behaves again ;)\n\nMichael J Gruber (2):\n  git-describe: introduce --first-parent\n  describe: document and test --first-parent\n\n Documentation/git-describe.txt | 16 +++++++++++++++-\n builtin/describe.c             |  8 +++++++-\n t/t6120-describe.sh            |  7 +++++++\n 3 files changed, 29 insertions(+), 2 deletions(-)\n\n-- \n1.7.12.463.gbd9d638\n"},{"id":"198775","messageId":"b5a771de4f84b6f6ae82b736c834d105aa98f87f.1347370970.git.git@drmicha.warpmail.net","threadId":"31502","inReplyTo":"cover.1347370970.git.git@drmicha.warpmail.net","subject":"[PATCH 1/2] git-describe: introduce --first-parent","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-09-11T13:51:51Z","receivedAt":"2012-09-11T13:51:51Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"so that git-describe searches first-parent history only when looking for\na named commit. This is useful for describing commits by tags on their\n\"main\" (first-parent) branch; for example, on git.git:\n\ngit describe 22ffc39\nv1.7.2.3-223-g22ffc39\n\ngit describe --first-parent 22ffc39\nv1.7.2-104-g22ffc39\n\ngit describe --contains --first-parent is forbidden because git name-rev\n(which is called by that) favors first-parent transversal already,\nalthough not strictly so.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n builtin/describe.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/describe.c b/builtin/describe.c\nindex 9fe11ed..aa60f5c 100644\n--- a/builtin/describe.c\n+++ b/builtin/describe.c\n@@ -25,6 +25,7 @@ static int abbrev = -1; /* unspecified */\n static int max_candidates = 10;\n static struct hash_table names;\n static int have_util;\n+static int first_parent;\n static const char *pattern;\n static int always;\n static const char *dirty;\n@@ -336,7 +337,7 @@ static void describe(const char *arg, int last_one)\n \t\t\tif (!(p->object.flags & SEEN))\n \t\t\t\tcommit_list_insert_by_date(p, &list);\n \t\t\tp->object.flags |= c->object.flags;\n-\t\t\tparents = parents->next;\n+\t\t\tparents = first_parent ? NULL : parents->next;\n \t\t}\n \t}\n \n@@ -414,6 +415,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \t\t\t   N_(\"only consider tags matching <pattern>\")),\n \t\tOPT_BOOLEAN(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n+\t\tOPT_BOOLEAN(0, \"first-parent\",     &first_parent,\n+\t\t\t   \"follow first parents only\"),\n \t\t{OPTION_STRING, 0, \"dirty\",  &dirty, N_(\"mark\"),\n \t\t\t   N_(\"append <mark> on dirty working tree (default: \\\"-dirty\\\")\"),\n \t\t PARSE_OPT_OPTARG, NULL, (intptr_t) \"-dirty\"},\n@@ -435,6 +438,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)\n \tif (longformat && abbrev == 0)\n \t\tdie(_(\"--long is incompatible with --abbrev=0\"));\n \n+\tif (contains && first_parent)\n+\t\tdie(_(\"--contains is incompatible with --first-parent\"));\n+\n \tif (contains) {\n \t\tconst char **args = xmalloc((7 + argc) * sizeof(char *));\n \t\tint i = 0;\n-- \n1.7.12.463.gbd9d638\n"},{"id":"198777","messageId":"a0f0cf4e9cf41577d01d728007250f78e18a9ac0.1347370970.git.git@drmicha.warpmail.net","threadId":"31502","inReplyTo":"cover.1347370970.git.git@drmicha.warpmail.net","subject":"[PATCH 2/2] describe: document and test --first-parent","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-09-11T13:51:52Z","receivedAt":"2012-09-11T13:51:52Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-describe.txt | 16 +++++++++++++++-\n t/t6120-describe.sh            |  7 +++++++\n 2 files changed, 22 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\nindex 72d6bb6..9fb5c84 100644\n--- a/Documentation/git-describe.txt\n+++ b/Documentation/git-describe.txt\n@@ -84,6 +84,10 @@ OPTIONS\n \tOnly consider tags matching the given pattern (can be used to avoid\n \tleaking private tags made from the repository).\n \n+--first-parent::\n+\tOnly consider tags which can be reached from '<committish>' by a first\n+\tparent walk, i.e. only those which are not on side branches.\n+\n --always::\n \tShow uniquely abbreviated commit object as fallback.\n \n@@ -129,6 +133,14 @@ closest tagname without any suffix:\n \t[torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2\n \ttags/v1.0.0\n \n+With --first-parent, tags on side branches are not considered:\n+\n+\t$ git describe v1.1.0^\n+\tv1.0.7-44-ge77f489\n+\n+\t$ git describe --first-parent v1.1.0^\n+\tv1.0.0-41-ge77f489\n+\n Note that the suffix you get if you type these commands today may be\n longer than what Linus saw above when he ran these commands, as your\n git repository may have new commits whose object names begin with\n@@ -148,7 +160,9 @@ is found, its name will be output and searching will stop.\n If an exact match was not found, 'git describe' will walk back\n through the commit history to locate an ancestor commit which\n has been tagged.  The ancestor's tag will be output along with an\n-abbreviation of the input committish's SHA1.\n+abbreviation of the input committish's SHA1.  With '--first-parent',\n+'git describe' will walk the history only along the first parent\n+of each commit.\n \n If multiple tags were found during the walk then the tag which\n has the fewest commits different from the input committish will be\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex f67aa6f..2524236 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -103,6 +103,13 @@ check_describe c-* --tags HEAD^^2\n check_describe B --tags HEAD^^2^\n check_describe e --tags HEAD^^^\n \n+check_describe R-* --first-parent HEAD\n+check_describe R-* --first-parent HEAD^\n+check_describe R-* --first-parent HEAD^^\n+check_describe B-* --first-parent HEAD^^2\n+check_describe B --first-parent HEAD^^2^\n+check_describe R-* --first-parent HEAD^^^\n+\n check_describe heads/master --all HEAD\n check_describe tags/c-* --all HEAD^\n check_describe tags/e --all HEAD^^^\n-- \n1.7.12.463.gbd9d638\n"},{"id":"198791","messageId":"7vwr00ilqj.fsf@alter.siamese.dyndns.org","threadId":"31502","inReplyTo":"cover.1347370970.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 0/2] git describe --first-parent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-11T16:10:28Z","receivedAt":"2012-09-11T16:10:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> While \"git describe\" behaves as documented, the notion of \"most recent tag\"\n> is not really easy to grab, and it's not always the way you want to describe\n> a commit.\n>\n> \"--first-parent\" is the option which answers the question: Which is the\n> most recent tag on this branch which can be reached from this commit?\n> (\"This branch\" being defined as \"--first-parent\" walk.)\n\nI see a confused message here.  If it is \"the\" option which answers,\nwhat is the question?  If the \"question\" is the only question people\nwould ask, you wouldn't make this an option, but update the default\nto do this, but you obviously did not want to do so, so there must\nbe cases where using this option is inappropirate and is not \"the\"\noption to answer the question the user wants to ask.\n\nAlso, how would this interact with \"--contains\"?  Should it and if\nso why?  If it shouldn't, why?\n"},{"id":"198794","messageId":"7voblcikap.fsf@alter.siamese.dyndns.org","threadId":"31502","inReplyTo":"b5a771de4f84b6f6ae82b736c834d105aa98f87f.1347370970.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 1/2] git-describe: introduce --first-parent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-11T16:41:34Z","receivedAt":"2012-09-11T16:41:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> so that git-describe searches first-parent history only when looking for\n\nPlease make sure your first paragraph of the log message start with\na full sentence, not an incomplete tail part of a sentence as if the\ntitle of the commit were repeated in front of it.\n\n> a named commit. This is useful for describing commits by tags on their\n> \"main\" (first-parent) branch; for example, on git.git:\n\nThis is useful only when the history does not have fast-forward\nmerges from a sideline; otherwise it will produce unexpected\nresults, no?\n\n> git describe 22ffc39\n> v1.7.2.3-223-g22ffc39\n>\n> git describe --first-parent 22ffc39\n> v1.7.2-104-g22ffc39\n\nThe output is wrong in that 22ffc39 is v1.7.2-336-g22ffc39, not 104.\nPutting an arbitrary number that can change depending on how the\ntraversal went will close the door to possible follow-up work on the\nrecent sha1-name-more series (0958a24^2, most importantly aa1dec9e)\nto prolong the shelf-life of describe output by filtering candidate\ncommits with reachability from the tag and the number of commits\nfrom the tag.\n\nIn any case, it is not clear to me if this is a useful example to\nhelp readers of this commit to understand why this new feature is\nuseful.  22ffc39 was created to mark that the work done for 1.7.2.x\nmaintenance track back then were all contained in the 'master' by\nmerging 'maint' when it was pointing at v1.7.2.3.  Saying the commit\nis newer than v1.7.2.3 gives more information than it is newer than\nv1.7.2, as by convention v1.7.2 must be older than v1.7.2.3, no?\n"},{"id":"198800","messageId":"7vy5kgh3wy.fsf@alter.siamese.dyndns.org","threadId":"31502","inReplyTo":"a0f0cf4e9cf41577d01d728007250f78e18a9ac0.1347370970.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 2/2] describe: document and test --first-parent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-09-11T17:20:45Z","receivedAt":"2012-09-11T17:20:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n>  Documentation/git-describe.txt | 16 +++++++++++++++-\n>  t/t6120-describe.sh            |  7 +++++++\n>  2 files changed, 22 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt\n> index 72d6bb6..9fb5c84 100644\n> --- a/Documentation/git-describe.txt\n> +++ b/Documentation/git-describe.txt\n> @@ -84,6 +84,10 @@ OPTIONS\n>  \tOnly consider tags matching the given pattern (can be used to avoid\n>  \tleaking private tags made from the repository).\n>  \n> +--first-parent::\n> +\tOnly consider tags which can be reached from '<committish>' by a first\n> +\tparent walk, i.e. only those which are not on side branches.\n> +\n\n[PATCH 1/2] says:\n\n    git describe --contains --first-parent is forbidden because git name-rev\n    (which is called by that) favors first-parent transversal already,\n    although not strictly so.\n\nbut the end-users won't read the log message, so something like that\nneed to be here, I guess.\n\nBut if \"name-rev\" does more-or-less first-parent anyway, perhaps\nsimply ignoring --first-parent when doing --contains may make more\nsense?\n"}]}