{"thread":{"id":"16437","subject":"[PATCH] git checkout: don't warn about unborn branch if -f is already passed","startedAt":"2008-11-24T06:55:22Z","lastAt":"2008-12-01T16:47:27Z","messageCount":3,"participants":["Matt McCutchen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"96402","messageId":"1227509722.32583.0.camel@mattlaptop2.local","threadId":"16437","inReplyTo":null,"subject":"[PATCH] git checkout: don't warn about unborn branch if -f is already passed","fromName":"Matt McCutchen","fromEmail":"matt@mattmccutchen.net","sentAt":"2008-11-24T06:55:22Z","receivedAt":"2008-11-24T06:55:22Z","isPatch":true,"sender":{"key":"matt@mattmccutchen.net","avatar":"https://avatars.githubusercontent.com/u/8885753?v=4"},"body":"I think it's unnecessary to warn that the checkout has been forced due to an\nunborn current branch if -f has been explicitly passed.  For one project, I am\nusing git-new-workdir to create workdirs from a bare repository whose HEAD is\nset to an unborn branch, and this warning started to irritate me.\n\nSigned-off-by: Matt McCutchen <matt@mattmccutchen.net>\n---\n builtin-checkout.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 464fd25..7f3bd7b 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -553,7 +553,7 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \tif (!opts->quiet && !old.path && old.commit && new->commit != old.commit)\n \t\tdescribe_detached_head(\"Previous HEAD position was\", old.commit);\n \n-\tif (!old.commit) {\n+\tif (!old.commit && !opts->force) {\n \t\tif (!opts->quiet) {\n \t\t\tfprintf(stderr, \"warning: You appear to be on a branch yet to be born.\\n\");\n \t\t\tfprintf(stderr, \"warning: Forcing checkout of %s.\\n\", new->name);\n-- \n1.6.0.2.593.g91df\n"},{"id":"96573","messageId":"7vr64yfexp.fsf@gitster.siamese.dyndns.org","threadId":"16437","inReplyTo":"1227509722.32583.0.camel@mattlaptop2.local","subject":"Re: [PATCH] git checkout: don't warn about unborn branch if -f is already passed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-26T19:46:42Z","receivedAt":"2008-11-26T19:46:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matt McCutchen <matt@mattmccutchen.net> writes:\n\n> I think it's unnecessary to warn that the checkout has been forced due to an\n> unborn current branch if -f has been explicitly passed.  For one project, I am\n> using git-new-workdir to create workdirs from a bare repository whose HEAD is\n> set to an unborn branch, and this warning started to irritate me.\n\nI doubt anybody minds this particular change per-se, but I wonder what the\njustification of keeping a dangling HEAD in a bare repository is.\n\nAfter all, the primary intended purpose of a bare repository is to serve\nas a distribution point (i.e. something you can clone from), and I think a\ndangling HEAD interferes with the usual operation of clone (although I've\nnever tested this).\n\nCare to explain why?\n"},{"id":"96871","messageId":"1228150047.2643.5.camel@mattlaptop2.local","threadId":"16437","inReplyTo":"7vr64yfexp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git checkout: don't warn about unborn branch if -f is already passed","fromName":"Matt McCutchen","fromEmail":"matt@mattmccutchen.net","sentAt":"2008-12-01T16:47:27Z","receivedAt":"2008-12-01T16:47:27Z","isPatch":true,"sender":{"key":"matt@mattmccutchen.net","avatar":"https://avatars.githubusercontent.com/u/8885753?v=4"},"body":"On Wed, 2008-11-26 at 11:46 -0800, Junio C Hamano wrote:\n> Matt McCutchen <matt@mattmccutchen.net> writes:\n> \n> > I think it's unnecessary to warn that the checkout has been forced due to an\n> > unborn current branch if -f has been explicitly passed.  For one project, I am\n> > using git-new-workdir to create workdirs from a bare repository whose HEAD is\n> > set to an unborn branch, and this warning started to irritate me.\n> \n> I doubt anybody minds this particular change per-se, but I wonder what the\n> justification of keeping a dangling HEAD in a bare repository is.\n> \n> After all, the primary intended purpose of a bare repository is to serve\n> as a distribution point (i.e. something you can clone from), and I think a\n> dangling HEAD interferes with the usual operation of clone (although I've\n> never tested this).\n> \n> Care to explain why?\n\nI am taking a course with six programming projects.  I want a separate\nworking tree for each project, but I want all the working trees\nconnected to the same repository because I often copy changes from one\nproject to another and that makes it more convenient to inspect the\nhistory of one project while I am working on another.  I didn't want to\nput the repository inside an arbitrary one of the working trees, so I\nleft it bare, and I didn't want to point its HEAD to an arbitrary one of\nthe projects, so I left it unborn.\n\nThe upshot is that I am using a bare repository as a distribution point\nfor *working trees* (via git-new-workdir), not for push/pull.\n\nMatt\n"}]}