X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=describe.c;h=ab192f83ae27c5e0bf3f2a5f61684d0dc66deb32;hb=810799ecab6f9164401416988d9d79270315ba18;hp=8a9cd5d52c555330c512b977179ab030ccd28861;hpb=45f75a0167b4a4693f2c6005bf7db231ca91ecc8;p=git.git diff --git a/describe.c b/describe.c index 8a9cd5d52..ab192f83a 100644 --- a/describe.c +++ b/describe.c @@ -8,12 +8,12 @@ static const char describe_usage[] = "git-describe [--all] [--tags] [--abbrev=] *"; -static int all = 0; /* Default to annotated tags only */ -static int tags = 0; /* But allow any tags if --tags is specified */ +static int all; /* Default to annotated tags only */ +static int tags; /* But allow any tags if --tags is specified */ static int abbrev = DEFAULT_ABBREV; -static int names = 0, allocs = 0; +static int names, allocs; static struct commit_name { const struct commit *commit; int prio; /* annotated tag = 2, tag = 1, head = 0 */ @@ -42,7 +42,7 @@ static void add_to_known_names(const char *path, struct commit_name *name = xmalloc(sizeof(struct commit_name) + len); name->commit = commit; - name->prio = prio; + name->prio = prio; memcpy(name->path, path, len); idx = names; if (idx >= allocs) { @@ -67,7 +67,7 @@ static int get_name(const char *path, const unsigned char *sha1) * Otherwise only annotated tags are used. */ if (!strncmp(path, "refs/tags/", 10)) { - if (object->type == tag_type) + if (object->type == OBJ_TAG) prio = 2; else prio = 1; @@ -97,7 +97,7 @@ static int compare_names(const void *_a, const void *_b) return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; } -static void describe(char *arg, int last_one) +static void describe(const char *arg, int last_one) { unsigned char sha1[20]; struct commit *cmit; @@ -154,14 +154,16 @@ int main(int argc, char **argv) tags = 1; else if (!strncmp(arg, "--abbrev=", 9)) { abbrev = strtoul(arg + 9, NULL, 10); - if (abbrev < MINIMUM_ABBREV || 40 <= abbrev) + if (abbrev < MINIMUM_ABBREV || 40 < abbrev) abbrev = DEFAULT_ABBREV; } else usage(describe_usage); } - if (i == argc) + setup_git_directory(); + + if (argc <= i) describe("HEAD", 1); else while (i < argc) {