From: exon@op5.se (Andreas Ericsson)
To: git@vger.kernel.org
Subject: [PATCH] git-describe: Show HEAD by default.
Date: Wed, 11 Jan 2006 21:33:12 +0100 (CET) [thread overview]
Message-ID: <20060111203312.5FEF25BEBD@nox.op5.se> (raw)
Signed-off-by: Andreas Ericsson <ae@op5.se>
---
describe.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
b3c6fee2b1dda213fe8439da2c14189abab9bdf7
diff --git a/describe.c b/describe.c
index a0180f5..fda4102 100644
--- a/describe.c
+++ b/describe.c
@@ -98,11 +98,20 @@ static int compare_names(const void *_a,
return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
}
-static void describe(struct commit *cmit)
+static void describe(const char *ref)
{
struct commit_list *list;
static int initialized = 0;
struct commit_name *n;
+ unsigned char sha1[20];
+ struct commit *cmit;
+
+ if (get_sha1(ref, sha1) < 0)
+ usage(describe_usage);
+
+ cmit = lookup_commit_reference(sha1);
+ if (!cmit)
+ usage(describe_usage);
if (!initialized) {
initialized = 1;
@@ -132,12 +141,10 @@ static void describe(struct commit *cmit
int main(int argc, char **argv)
{
- int i;
+ int i, desc = 0;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
- unsigned char sha1[20];
- struct commit *cmit;
if (!strcmp(arg, "--all")) {
all = 1;
@@ -153,12 +160,12 @@ int main(int argc, char **argv)
abbrev = DEFAULT_ABBREV;
continue;
}
- if (get_sha1(arg, sha1) < 0)
- usage(describe_usage);
- cmit = lookup_commit_reference(sha1);
- if (!cmit)
- usage(describe_usage);
- describe(cmit);
+ describe(arg);
+ desc++;
}
+
+ if (!desc)
+ describe("HEAD");
+
return 0;
}
--
1.1.0
reply other threads:[~2006-01-11 20:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060111203312.5FEF25BEBD@nox.op5.se \
--to=exon@op5.se \
--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).