git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git describe is failing
@ 2009-10-22 14:47 Eugene Sajine
  2009-10-22 14:59 ` Mikael Magnusson
  2009-10-22 15:02 ` Thomas Rast
  0 siblings, 2 replies; 13+ messages in thread
From: Eugene Sajine @ 2009-10-22 14:47 UTC (permalink / raw
  To: git; +Cc: Eugene Sajine

Hi,

I have a test repo which I'm playing with. It has about 15 commits and
one branch only (master) and couple of tags. Somehow it got to a state
when

$ git describe

gives:

fatal: cannot describe 'SHA-1'

The command is working ok with my other repo. It doesn't seem that the
test repo is corrupted. I can commit, push and pull, see the history
with gitk... How can I check or repair it?

Thanks,
Eugene

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: git describe is failing
  2009-10-22 14:47 git describe is failing Eugene Sajine
@ 2009-10-22 14:59 ` Mikael Magnusson
  2009-10-22 15:02 ` Thomas Rast
  1 sibling, 0 replies; 13+ messages in thread
From: Mikael Magnusson @ 2009-10-22 14:59 UTC (permalink / raw
  To: Eugene Sajine; +Cc: git

2009/10/22 Eugene Sajine <euguess@gmail.com>:
> Hi,
>
> I have a test repo which I'm playing with. It has about 15 commits and
> one branch only (master) and couple of tags. Somehow it got to a state
> when
>
> $ git describe
>
> gives:
>
> fatal: cannot describe 'SHA-1'
>
> The command is working ok with my other repo. It doesn't seem that the
> test repo is corrupted. I can commit, push and pull, see the history
> with gitk... How can I check or repair it?
>
> Thanks,
> Eugene

Your tags are probably not annotated (lightweight tags), use git
describe --tags.

-- 
Mikael Magnusson

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: git describe is failing
  2009-10-22 14:47 git describe is failing Eugene Sajine
  2009-10-22 14:59 ` Mikael Magnusson
@ 2009-10-22 15:02 ` Thomas Rast
  2009-10-22 15:10   ` Eugene Sajine
  1 sibling, 1 reply; 13+ messages in thread
From: Thomas Rast @ 2009-10-22 15:02 UTC (permalink / raw
  To: Eugene Sajine; +Cc: git

Eugene Sajine wrote:
> $ git describe
> 
> gives:
> 
> fatal: cannot describe 'SHA-1'

man git-describe:

DESCRIPTION
       The command finds the most recent tag that is reachable from a
       commit.
[...]
       By default (without --all or --tags) git describe only shows
       annotated tags. For more information about creating annotated
       tags see the -a and -s options to git-tag(1).

If there is no such tag, it refuses to work.  Annotate your tags, or
try --always.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: git describe is failing
  2009-10-22 15:02 ` Thomas Rast
@ 2009-10-22 15:10   ` Eugene Sajine
  2009-10-22 15:44     ` [PATCH] describe: when failing, tell the user about options that work Thomas Rast
  0 siblings, 1 reply; 13+ messages in thread
From: Eugene Sajine @ 2009-10-22 15:10 UTC (permalink / raw
  To: Thomas Rast; +Cc: git

> man git-describe:
>
> DESCRIPTION
>       The command finds the most recent tag that is reachable from a
>       commit.
> [...]
>       By default (without --all or --tags) git describe only shows
>       annotated tags. For more information about creating annotated
>       tags see the -a and -s options to git-tag(1).
>
> If there is no such tag, it refuses to work.  Annotate your tags, or
> try --always.
>
> --
> Thomas Rast
> trast@{inf,student}.ethz.ch
>

Thanks! It is working ok.
Although it is probably not the best error handling.
I believe git should fail with some meaningful message in this case...

Thanks,
Eugene

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] describe: when failing, tell the user about options that work
  2009-10-22 15:10   ` Eugene Sajine
@ 2009-10-22 15:44     ` Thomas Rast
  2009-10-22 16:40       ` Alex Riesen
  2009-10-23  0:25       ` Junio C Hamano
  0 siblings, 2 replies; 13+ messages in thread
From: Thomas Rast @ 2009-10-22 15:44 UTC (permalink / raw
  To: Eugene Sajine; +Cc: git

Users seem to call git-describe without reading the manpage, and then
wonder why it doesn't work with unannotated tags by default.

Make a minimal effort towards seeing if there would have been
unannotated tags, and tell the user.  Specifically, we say that --tags
could work if we found any unannotated tags.  If not, we say that
--always would have given results.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Eugene Sajine wrote:
> [git-describe fails if you don't have annotated tags]
>  
> Thanks! It is working ok.
> Although it is probably not the best error handling.
> I believe git should fail with some meaningful message in this case...

We already had most of the information available, so hey, why not.


 builtin-describe.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/builtin-describe.c b/builtin-describe.c
index 2dcfd3d..1ffa0d8 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -96,8 +96,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void 
 	if (!all) {
 		if (!prio)
 			return 0;
-		if (!tags && prio < 2)
-			return 0;
 	}
 	add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);
 	return 0;
@@ -184,6 +182,7 @@ static void describe(const char *arg, int last_one)
 	struct possible_tag all_matches[MAX_TAGS];
 	unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
 	unsigned long seen_commits = 0;
+	unsigned int unannotated_cnt = 0;
 
 	if (get_sha1(arg, sha1))
 		die("Not a valid object name %s", arg);
@@ -217,7 +216,9 @@ static void describe(const char *arg, int last_one)
 		seen_commits++;
 		n = c->util;
 		if (n) {
-			if (match_cnt < max_candidates) {
+			if (!tags && !all && n->prio < 2) {
+				unannotated_cnt++;
+			} else if (match_cnt < max_candidates) {
 				struct possible_tag *t = &all_matches[match_cnt++];
 				t->name = n;
 				t->depth = seen_commits - 1;
@@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
 			printf("%s\n", find_unique_abbrev(sha1, abbrev));
 			return;
 		}
-		die("cannot describe '%s'", sha1_to_hex(sha1));
+		if (unannotated_cnt)
+			die("cannot describe '%s'"
+			    " with only\nannotated tags. Try --tags.",
+			    sha1_to_hex(sha1));
+		else
+			die("cannot describe '%s'"
+			    " with tags\nTry --always, or create some tags.",
+			    sha1_to_hex(sha1));
 	}
 
 	qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);
-- 
1.6.5.1.70.g1383ae

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that  work
  2009-10-22 15:44     ` [PATCH] describe: when failing, tell the user about options that work Thomas Rast
@ 2009-10-22 16:40       ` Alex Riesen
  2009-10-22 22:26         ` Junio C Hamano
  2009-10-23  0:25       ` Junio C Hamano
  1 sibling, 1 reply; 13+ messages in thread
From: Alex Riesen @ 2009-10-22 16:40 UTC (permalink / raw
  To: Thomas Rast; +Cc: Eugene Sajine, git

On Thu, Oct 22, 2009 at 17:44, Thomas Rast <trast@student.ethz.ch> wrote:
> @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
>                        printf("%s\n", find_unique_abbrev(sha1, abbrev));
>                        return;
>                }
> -               die("cannot describe '%s'", sha1_to_hex(sha1));
> +               if (unannotated_cnt)
> +                       die("cannot describe '%s'"
> +                           " with only\nannotated tags. Try --tags.",
> +                           sha1_to_hex(sha1));
> +               else
> +                       die("cannot describe '%s'"
> +                           " with tags\nTry --always, or create some tags.",
> +                           sha1_to_hex(sha1));

These are quite verbose. Could they be conditional on something like
advice.describeHints?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that work
  2009-10-22 16:40       ` Alex Riesen
@ 2009-10-22 22:26         ` Junio C Hamano
  2009-10-23  0:13           ` Nicolas Pitre
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2009-10-22 22:26 UTC (permalink / raw
  To: Alex Riesen; +Cc: Thomas Rast, Eugene Sajine, git

Alex Riesen <raa.lkml@gmail.com> writes:

> These are quite verbose. Could they be conditional on something like
> advice.describeHints?

Concurred.  Please make it so.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that  work
  2009-10-22 22:26         ` Junio C Hamano
@ 2009-10-23  0:13           ` Nicolas Pitre
  2009-10-23  0:28             ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Pitre @ 2009-10-23  0:13 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Alex Riesen, Thomas Rast, Eugene Sajine, git

On Thu, 22 Oct 2009, Junio C Hamano wrote:

> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> > These are quite verbose. Could they be conditional on something like
> > advice.describeHints?
> 
> Concurred.  Please make it so.

I don't have a strong opinion either ways, but is having a less verbose 
message in the _error_ path really a big issue?


Nicolas

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that work
  2009-10-22 15:44     ` [PATCH] describe: when failing, tell the user about options that work Thomas Rast
  2009-10-22 16:40       ` Alex Riesen
@ 2009-10-23  0:25       ` Junio C Hamano
  2009-10-23  8:34         ` Thomas Rast
  1 sibling, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2009-10-23  0:25 UTC (permalink / raw
  To: Thomas Rast; +Cc: Eugene Sajine, git

Thomas Rast <trast@student.ethz.ch> writes:

> @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
>  			printf("%s\n", find_unique_abbrev(sha1, abbrev));
>  			return;
>  		}
> -		die("cannot describe '%s'", sha1_to_hex(sha1));
> +		if (unannotated_cnt)
> +			die("cannot describe '%s'"
> +			    " with only\nannotated tags. Try --tags.",

Did you mean UNannotated tags here?

> +			    sha1_to_hex(sha1));
> +		else
> +			die("cannot describe '%s'"
> +			    " with tags\nTry --always, or create some tags.",
> +			    sha1_to_hex(sha1));
>  	}
>  
>  	qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that work
  2009-10-23  0:13           ` Nicolas Pitre
@ 2009-10-23  0:28             ` Junio C Hamano
  0 siblings, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-10-23  0:28 UTC (permalink / raw
  To: Nicolas Pitre; +Cc: Alex Riesen, Thomas Rast, Eugene Sajine, git

Nicolas Pitre <nico@fluxnic.net> writes:

> On Thu, 22 Oct 2009, Junio C Hamano wrote:
>
>> Alex Riesen <raa.lkml@gmail.com> writes:
>> 
>> > These are quite verbose. Could they be conditional on something like
>> > advice.describeHints?
>> 
>> Concurred.  Please make it so.
>
> I don't have a strong opinion either ways, but is having a less verbose 
> message in the _error_ path really a big issue?

Thanks for catching a thinko---I somehow thought the patch was about
warning when we give an annotated tag that is farther than an unannotated
one.

It should be good enough to unconditionally give hints upon an error, as
long as they are correct.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that work
  2009-10-23  0:25       ` Junio C Hamano
@ 2009-10-23  8:34         ` Thomas Rast
  2009-10-23 18:57           ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Rast @ 2009-10-23  8:34 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Eugene Sajine, git

Junio C Hamano wrote:
> Thomas Rast <trast@student.ethz.ch> writes:
> 
> > @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
> >  			printf("%s\n", find_unique_abbrev(sha1, abbrev));
> >  			return;
> >  		}
> > -		die("cannot describe '%s'", sha1_to_hex(sha1));
> > +		if (unannotated_cnt)
> > +			die("cannot describe '%s'"
> > +			    " with only\nannotated tags. Try --tags.",
> 
> Did you mean UNannotated tags here?

No, but I think I see where the misunderstanding came from.

This code path means that we did not find a tag to describe with, but
we counted some unannotated tags (and because of how the counting
logic is wrapped, this only triggers when neither --all nor --tags are
in effect).

So I wanted it to say "it is impossible to describe this with the tags
you told me to use", which in this case are the annotated ones.

I tried to keep the general structure of the message ("cannot describe
..."), and with this restriction I can't seem to find a clearer
wording.  However, it could be written e.g.

  No annotated tags can describe '%s'.  However, there were
  unannotated tags: try --tags.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH] describe: when failing, tell the user about options that work
  2009-10-23  8:34         ` Thomas Rast
@ 2009-10-23 18:57           ` Junio C Hamano
  2009-10-28 22:10             ` [PATCH v2] " Thomas Rast
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2009-10-23 18:57 UTC (permalink / raw
  To: Thomas Rast; +Cc: Eugene Sajine, git

Thomas Rast <trast@student.ethz.ch> writes:

> Junio C Hamano wrote:
>> Thomas Rast <trast@student.ethz.ch> writes:
>> 
>> > @@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
>> >  			printf("%s\n", find_unique_abbrev(sha1, abbrev));
>> >  			return;
>> >  		}
>> > -		die("cannot describe '%s'", sha1_to_hex(sha1));
>> > +		if (unannotated_cnt)
>> > +			die("cannot describe '%s'"
>> > +			    " with only\nannotated tags. Try --tags.",
>> 
>> Did you mean UNannotated tags here?
>
> No, but I think I see where the misunderstanding came from.
>
> This code path means that we did not find a tag to describe with, but
> we counted some unannotated tags (and because of how the counting
> logic is wrapped, this only triggers when neither --all nor --tags are
> in effect).

I think I read the code right ;-).

> So I wanted it to say "it is impossible to describe this with the tags
> you told me to use", which in this case are the annotated ones.

The way I read it was "it is impossible to describe it in the way you told
me to, when the tags you have are only unannotated kind."

> However, it could be written e.g.
>
>   No annotated tags can describe '%s'.  However, there were
>   unannotated tags: try --tags.

Sounds better.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2] describe: when failing, tell the user about options that work
  2009-10-23 18:57           ` Junio C Hamano
@ 2009-10-28 22:10             ` Thomas Rast
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Rast @ 2009-10-28 22:10 UTC (permalink / raw
  To: git; +Cc: Junio C Hamano, Eugene Sajine

Users seem to call git-describe without reading the manpage, and then
wonder why it doesn't work with unannotated tags by default.

Make a minimal effort towards seeing if there would have been
unannotated tags, and tell the user.  Specifically, we say that --tags
could work if we found any unannotated tags.  If not, we say that
--always would have given results.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Junio C Hamano wrote:
> Thomas Rast <trast@student.ethz.ch> writes:
> > However, it could be written e.g.
> >
> >   No annotated tags can describe '%s'.  However, there were
> >   unannotated tags: try --tags.
> 
> Sounds better.

Then let's make it so.  Sorry for taking so long.


 builtin-describe.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/builtin-describe.c b/builtin-describe.c
index 2dcfd3d..4ea6f88 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -96,8 +96,6 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void 
 	if (!all) {
 		if (!prio)
 			return 0;
-		if (!tags && prio < 2)
-			return 0;
 	}
 	add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);
 	return 0;
@@ -184,6 +182,7 @@ static void describe(const char *arg, int last_one)
 	struct possible_tag all_matches[MAX_TAGS];
 	unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
 	unsigned long seen_commits = 0;
+	unsigned int unannotated_cnt = 0;
 
 	if (get_sha1(arg, sha1))
 		die("Not a valid object name %s", arg);
@@ -217,7 +216,9 @@ static void describe(const char *arg, int last_one)
 		seen_commits++;
 		n = c->util;
 		if (n) {
-			if (match_cnt < max_candidates) {
+			if (!tags && !all && n->prio < 2) {
+				unannotated_cnt++;
+			} else if (match_cnt < max_candidates) {
 				struct possible_tag *t = &all_matches[match_cnt++];
 				t->name = n;
 				t->depth = seen_commits - 1;
@@ -259,7 +260,14 @@ static void describe(const char *arg, int last_one)
 			printf("%s\n", find_unique_abbrev(sha1, abbrev));
 			return;
 		}
-		die("cannot describe '%s'", sha1_to_hex(sha1));
+		if (unannotated_cnt)
+			die("No annotated tags can describe '%s'.\n"
+			    "However, there were unannotated tags: try --tags.",
+			    sha1_to_hex(sha1));
+		else
+			die("No tags can describe '%s'.\n"
+			    "Try --always, or create some tags.",
+			    sha1_to_hex(sha1));
 	}
 
 	qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);
-- 
1.6.5.1.161.g3b9c0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-10-28 22:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-22 14:47 git describe is failing Eugene Sajine
2009-10-22 14:59 ` Mikael Magnusson
2009-10-22 15:02 ` Thomas Rast
2009-10-22 15:10   ` Eugene Sajine
2009-10-22 15:44     ` [PATCH] describe: when failing, tell the user about options that work Thomas Rast
2009-10-22 16:40       ` Alex Riesen
2009-10-22 22:26         ` Junio C Hamano
2009-10-23  0:13           ` Nicolas Pitre
2009-10-23  0:28             ` Junio C Hamano
2009-10-23  0:25       ` Junio C Hamano
2009-10-23  8:34         ` Thomas Rast
2009-10-23 18:57           ` Junio C Hamano
2009-10-28 22:10             ` [PATCH v2] " Thomas Rast

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).