Re: [RFC] improve 'bad default revision' message for empty repo

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Tuesday, March 4, 2008 - 7:43 pm

Jeff King <peff@peff.net> writes:



How about doing it this way instead, then?

Saying "fatal: You haven't made a commit?" is like saying "How stupid do
you have to be to realize that you are not allowed to run git-log before
making a commit, dummy?", but that is not the message we need to be
sending.  Asking for log is fine.  If you are on an unborn branch and say
"git log", you deserve to get nothing.  Not even an error message.

Not that I haven't thought through the ramifications of this yet; some
callers may need to be adjusted, but they should be prepared for a case
where no rev was given from the command line anyway.

---

 revision.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/revision.c b/revision.c
index 63bf2c5..cdd5ad2 100644
--- a/revision.c
+++ b/revision.c
@@ -1323,10 +1323,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 		unsigned char sha1[20];
 		struct object *object;
 		unsigned mode;
-		if (get_sha1_with_mode(def, sha1, &mode))
-			die("bad default revision '%s'", def);
-		object = get_reference(revs, def, sha1, 0);
-		add_pending_object_with_mode(revs, object, def, mode);
+		if (!get_sha1_with_mode(def, sha1, &mode)) {
+			object = get_reference(revs, def, sha1, 0);
+			add_pending_object_with_mode(revs, object, def, mode);
+		}
 	}
 
 	/* Did the user ask for any diff output? Run the diff! */
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Some issues working with empty/bare repositories..., Reece Dunn, (Sat Mar 1, 12:40 pm)
Re: [RFC] improve 'bad default revision' message for empty ..., Junio C Hamano, (Tue Mar 4, 7:43 pm)