From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Subject: [PATCH 1/2] git-describe: introduce --first-parent
Date: Tue, 11 Sep 2012 15:51:51 +0200 [thread overview]
Message-ID: <b5a771de4f84b6f6ae82b736c834d105aa98f87f.1347370970.git.git@drmicha.warpmail.net> (raw)
In-Reply-To: <cover.1347370970.git.git@drmicha.warpmail.net>
so that git-describe searches first-parent history only when looking for
a named commit. This is useful for describing commits by tags on their
"main" (first-parent) branch; for example, on git.git:
git describe 22ffc39
v1.7.2.3-223-g22ffc39
git describe --first-parent 22ffc39
v1.7.2-104-g22ffc39
git describe --contains --first-parent is forbidden because git name-rev
(which is called by that) favors first-parent transversal already,
although not strictly so.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
builtin/describe.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/builtin/describe.c b/builtin/describe.c
index 9fe11ed..aa60f5c 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -25,6 +25,7 @@ static int abbrev = -1; /* unspecified */
static int max_candidates = 10;
static struct hash_table names;
static int have_util;
+static int first_parent;
static const char *pattern;
static int always;
static const char *dirty;
@@ -336,7 +337,7 @@ static void describe(const char *arg, int last_one)
if (!(p->object.flags & SEEN))
commit_list_insert_by_date(p, &list);
p->object.flags |= c->object.flags;
- parents = parents->next;
+ parents = first_parent ? NULL : parents->next;
}
}
@@ -414,6 +415,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
N_("only consider tags matching <pattern>")),
OPT_BOOLEAN(0, "always", &always,
N_("show abbreviated commit object as fallback")),
+ OPT_BOOLEAN(0, "first-parent", &first_parent,
+ "follow first parents only"),
{OPTION_STRING, 0, "dirty", &dirty, N_("mark"),
N_("append <mark> on dirty working tree (default: \"-dirty\")"),
PARSE_OPT_OPTARG, NULL, (intptr_t) "-dirty"},
@@ -435,6 +438,9 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
if (longformat && abbrev == 0)
die(_("--long is incompatible with --abbrev=0"));
+ if (contains && first_parent)
+ die(_("--contains is incompatible with --first-parent"));
+
if (contains) {
const char **args = xmalloc((7 + argc) * sizeof(char *));
int i = 0;
--
1.7.12.463.gbd9d638
next prev parent reply other threads:[~2012-09-11 13:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 13:51 [PATCH 0/2] git describe --first-parent Michael J Gruber
2012-09-11 13:51 ` Michael J Gruber [this message]
2012-09-11 16:41 ` [PATCH 1/2] git-describe: introduce --first-parent Junio C Hamano
2012-09-11 13:51 ` [PATCH 2/2] describe: document and test --first-parent Michael J Gruber
2012-09-11 17:20 ` Junio C Hamano
2012-09-11 16:10 ` [PATCH 0/2] git describe --first-parent Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5a771de4f84b6f6ae82b736c834d105aa98f87f.1347370970.git.git@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).