Code

update hook: redirect _both_ diagnostic lines to stderr upon tag failure
[git.git] / describe.c
index 324ca8965b9512de59b515cdcc29801022553d1d..f4029ee74e80305e9ec9e5793d2e12c07096f45a 100644 (file)
@@ -8,12 +8,12 @@
 static const char describe_usage[] =
 "git-describe [--all] [--tags] [--abbrev=<n>] <committish>*";
 
-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) {
@@ -53,7 +53,7 @@ static void add_to_known_names(const char *path,
        names = ++idx;
 }
 
-static int get_name(const char *path, const unsigned char *sha1)
+static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct commit *commit = lookup_commit_reference_gently(sha1, 1);
        struct object *object;
@@ -113,7 +113,7 @@ static void describe(const char *arg, int last_one)
 
        if (!initialized) {
                initialized = 1;
-               for_each_ref(get_name);
+               for_each_ref(get_name, NULL);
                qsort(name_array, names, sizeof(*name_array), compare_names);
        }
 
@@ -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) {