{"thread":{"id":"15336","subject":"[RFC] Detached-HEAD reminder on commit?","startedAt":"2008-09-02T19:31:45Z","lastAt":"2008-10-04T02:13:49Z","messageCount":67,"participants":["Pieter de Bie","Robin Rosenberg","Nicolas Pitre","Matthieu Moy","Junio C Hamano","Stephan Beyer","Johan Herland","Jeff King","Jakub Narebski","Andreas Ericsson","Wincent Colaiuta","Daniel Barkalow","Avery Pennarun","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"89527","messageId":"1220383905-48316-1-git-send-email-pdebie@ai.rug.nl","threadId":"15336","inReplyTo":null,"subject":"[RFC] Detached-HEAD reminder on commit?","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-02T19:31:45Z","receivedAt":"2008-09-02T19:31:45Z","isPatch":false,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"Sometimes I work on a detached HEAD and then forget about it. If I then create\nsome commits and checkout another branch, I have to dig through my reflog to\nfind the older commits. I know that \"git commit\" adds has a \"Not currently on\nany branch\", but it's not very noticeable and also doesn't work when you\nspecify a commit message on the command line.\n\nI suggest to add some extra output to the STDOUT after a commit if we're on a\ndetached HEAD. The quick patch below adds output like:\n\nVienna:git pieter$ ./git commit --allow-empty -m\"test\"\nCreated commit 6ce62c8b: test\nYou are on a detached head, so this commit has not been recorded in a branch.\nIf you don't want to lose this commit, checkout a branch and then run:\n\tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n\nAre there any comments to this / strong opinions against such a change?\n\n- Pieter\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex ec65ac5..bfe25f9 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -845,6 +845,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n        struct rev_info rev;\n        struct commit *commit;\n+       unsigned char sha[20];\n+       const char* head = resolve_ref(\"HEAD\", sha, 0, NULL);\n \n        commit = lookup_commit(sha1);\n        if (!commit)\n@@ -877,6 +879,15 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n                printf(\"%s\\n\", buf.buf);\n                strbuf_release(&buf);\n        }\n+\n+       /* Are we on a detached HEAD? */\n+       if (!strcmp(\"HEAD\", head))\n+               printf(\"You are on a detached head, so this commit \"\n+                       \"has not been recorded in a branch.\\n\"\n+                       \"If you don't want to lose this commit, checkout a \"\n+                       \"branch and then run:\\n\"\n+                       \"       git merge %s\\n\", sha1_to_hex(sha1));\n+\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n"},{"id":"89528","messageId":"200809022143.33294.robin.rosenberg.lists@dewire.com","threadId":"15336","inReplyTo":"1220383905-48316-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2008-09-02T19:43:33Z","receivedAt":"2008-09-02T19:43:33Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"tisdagen den 2 september 2008 21.31.45 skrev Pieter de Bie:\n> Sometimes I work on a detached HEAD and then forget about it. If I then create\n> some commits and checkout another branch, I have to dig through my reflog to\n> find the older commits. I know that \"git commit\" adds has a \"Not currently on\n> any branch\", but it's not very noticeable and also doesn't work when you\n> specify a commit message on the command line.\n> \n> I suggest to add some extra output to the STDOUT after a commit if we're on a\n> detached HEAD. The quick patch below adds output like:\n> \n> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> Created commit 6ce62c8b: test\n> You are on a detached head, so this commit has not been recorded in a branch.\n> If you don't want to lose this commit, checkout a branch and then run:\n> \tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n> \n> Are there any comments to this / strong opinions against such a change?\n\nProbably doesn't hurt, but I think you should enable the git prompt. That will\ngive you notice before committing.\n\n-- robin\n"},{"id":"89536","messageId":"alpine.LFD.1.10.0809021620290.23787@xanadu.home","threadId":"15336","inReplyTo":"1220383905-48316-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-02T20:24:20Z","receivedAt":"2008-09-02T20:24:20Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 2 Sep 2008, Pieter de Bie wrote:\n\n> Sometimes I work on a detached HEAD and then forget about it. If I then create\n> some commits and checkout another branch, I have to dig through my reflog to\n> find the older commits. I know that \"git commit\" adds has a \"Not currently on\n> any branch\", but it's not very noticeable and also doesn't work when you\n> specify a commit message on the command line.\n> \n> I suggest to add some extra output to the STDOUT after a commit if we're on a\n> detached HEAD. The quick patch below adds output like:\n> \n> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> Created commit 6ce62c8b: test\n> You are on a detached head, so this commit has not been recorded in a branch.\n> If you don't want to lose this commit, checkout a branch and then run:\n> \tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n\nNah.\n\nI have nothing against the idea of an extra message, but there are other \nways to preserve commits made on top of a detached head.  So I'd keep \nonly the first line.\n\n\nNicolas\n"},{"id":"89537","messageId":"vpq3aki1eh6.fsf@bauges.imag.fr","threadId":"15336","inReplyTo":"1220383905-48316-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2008-09-02T20:26:29Z","receivedAt":"2008-09-02T20:26:29Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Pieter de Bie <pdebie@ai.rug.nl> writes:\n\n> +       if (!strcmp(\"HEAD\", head))\n> +               printf(\"You are on a detached head, so this commit \"\n> +                       \"has not been recorded in a branch.\\n\"\n> +                       \"If you don't want to lose this commit, checkout a \"\n> +                       \"branch and then run:\\n\"\n> +                       \"       git merge %s\\n\", sha1_to_hex(sha1));\n\nI'd say\n\n+                       \"If you don't want to lose this commit, run \"\n+                       \"git branch <some-name>\\n\"\n+\t\t\t\"to create a named branch for the commit you just made\");\n\n(or whatever better wording you find, but I think suggesting to name\nthe branch makes more sense that merging it)\n\n-- \nMatthieu\n"},{"id":"89539","messageId":"alpine.LFD.1.10.0809021634300.23787@xanadu.home","threadId":"15336","inReplyTo":"vpq3aki1eh6.fsf@bauges.imag.fr","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-02T20:35:47Z","receivedAt":"2008-09-02T20:35:47Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 2 Sep 2008, Matthieu Moy wrote:\n\n> Pieter de Bie <pdebie@ai.rug.nl> writes:\n> \n> > +       if (!strcmp(\"HEAD\", head))\n> > +               printf(\"You are on a detached head, so this commit \"\n> > +                       \"has not been recorded in a branch.\\n\"\n> > +                       \"If you don't want to lose this commit, checkout a \"\n> > +                       \"branch and then run:\\n\"\n> > +                       \"       git merge %s\\n\", sha1_to_hex(sha1));\n> \n> I'd say\n> \n> +                       \"If you don't want to lose this commit, run \"\n> +                       \"git branch <some-name>\\n\"\n> +\t\t\t\"to create a named branch for the commit you just made\");\n> \n> (or whatever better wording you find, but I think suggesting to name\n> the branch makes more sense that merging it)\n\nAgreed. Something that repeat more or less the message that was given \nwhen detaching HEAD in the first place would be best.\n\n\nNicolas\n"},{"id":"89541","messageId":"7vk5dujn9h.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"1220383905-48316-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-02T20:39:22Z","receivedAt":"2008-09-02T20:39:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pieter de Bie <pdebie@ai.rug.nl> writes:\n\n> Sometimes I work on a detached HEAD and then forget about it. If I then create\n> some commits and checkout another branch, I have to dig through my reflog to\n> find the older commits. I know that \"git commit\" adds has a \"Not currently on\n> any branch\", but it's not very noticeable and also doesn't work when you\n> specify a commit message on the command line.\n>\n> I suggest to add some extra output to the STDOUT after a commit if we're on a\n> detached HEAD. The quick patch below adds output like:\n>\n> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> Created commit 6ce62c8b: test\n> You are on a detached head, so this commit has not been recorded in a branch.\n> If you don't want to lose this commit, checkout a branch and then run:\n> \tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n>\n> Are there any comments to this / strong opinions against such a change?\n\nUnconditionally doing this is too loud for my taste.  You probably can do\nthis in your post-commit hook.\n"},{"id":"89546","messageId":"20080902210524.GB7757@leksak.fem-net","threadId":"15336","inReplyTo":"7vk5dujn9h.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-09-02T21:05:24Z","receivedAt":"2008-09-02T21:05:24Z","isPatch":false,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJunio C Hamano wrote:\n> Pieter de Bie <pdebie@ai.rug.nl> writes:\n> \n[..]\n> > Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> > Created commit 6ce62c8b: test\n> > You are on a detached head, so this commit has not been recorded in a branch.\n> > If you don't want to lose this commit, checkout a branch and then run:\n> > \tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n> >\n> > Are there any comments to this / strong opinions against such a change?\n> \n> Unconditionally doing this is too loud for my taste.  You probably can do\n> this in your post-commit hook.\n\nWell, Pieter probably can do this in his post-commit hook. But I think\nthis is useful for usability... especially for beginners who might not\neven know what a hook is. ;)\n\nFor me this felt too loud, too, especially since \"git status\" and\n\"git commit\" (without message option) already tells the user that\nshe is on a detached HEAD. And \"git commit -a\" is usually done after\na \"git status\", too, isn't it? (I do not use \"git commit -a\", I *use*\nthe index.)\n\nBut nonetheless... Some days ago I accidentally detached my head (hihi)\nand at the end of the day, after switching and rebasing branches, I noticed\nthat some commits in my branch were \"lost\"... Such a patch may have helped.\n(Yes, \"git fsck --lost-found\" and \"git cherry-pick ...\" helped.)\n\nSo I'm somewhere in between. I think this patch can be useful to\nminimize some annoyance for git users, but on the other hand the\nloud output can annoy people if they, for example, use git-commit in\nscripts (like git-rebase and git-rebase--interactive does).\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"89551","messageId":"200809022339.20123.johan@herland.net","threadId":"15336","inReplyTo":"20080902210524.GB7757@leksak.fem-net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-02T21:39:20Z","receivedAt":"2008-09-02T21:39:20Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 02 September 2008, Stephan Beyer wrote:\n> Junio C Hamano wrote:\n> > Pieter de Bie <pdebie@ai.rug.nl> writes:\n> > > Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> > > Created commit 6ce62c8b: test\n> > > You are on a detached head, so this commit has not been recorded in a\n> > > branch. If you don't want to lose this commit, checkout a branch and\n> > > then run: git merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n> > >\n> > > Are there any comments to this / strong opinions against such a\n> > > change?\n> >\n> > Unconditionally doing this is too loud for my taste.  You probably can\n> > do this in your post-commit hook.\n>\n> Well, Pieter probably can do this in his post-commit hook. But I think\n> this is useful for usability... especially for beginners who might not\n> even know what a hook is. ;)\n\nI'm not sure I like this personally, but if we _really_ don't want newbies \nto shoot themselves in the foot, we could make \"git commit\" fail on a \ndetached HEAD unless the user has indicated that s/he knows what's going \non; i.e. something like this:\n\nVienna:git pieter$ ./git commit --allow-empty -m\"test\"\nYou are on a detached head, so this commit would not be recorded in a\nbranch. If you don't want to lose this commit, please switch to a (new) \nbranch before committing. If you know what you're doing, and want to\nproceed on a detached HEAD, please enable commit.detached in your \nconfiguration (git config --global commit.detached true)\n\n...but I sympathize with those that think this is overkill.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"89552","messageId":"20080902214428.GA20355@sigill.intra.peff.net","threadId":"15336","inReplyTo":"200809022339.20123.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-02T21:44:28Z","receivedAt":"2008-09-02T21:44:28Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 02, 2008 at 11:39:20PM +0200, Johan Herland wrote:\n\n> I'm not sure I like this personally, but if we _really_ don't want newbies \n> to shoot themselves in the foot, we could make \"git commit\" fail on a \n> detached HEAD unless the user has indicated that s/he knows what's going \n> on; i.e. something like this:\n\nThis was discussed to death when detached HEAD was introduced, and the\ndecision was to go with the current behavior. Try looking in the list\narchives around December 2006 / January 2007 if you are truly\nmasochistic.\n\n-Peff\n"},{"id":"89553","messageId":"20080902215102.GB20355@sigill.intra.peff.net","threadId":"15336","inReplyTo":"20080902214428.GA20355@sigill.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-02T21:51:02Z","receivedAt":"2008-09-02T21:51:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 02, 2008 at 05:44:28PM -0400, Jeff King wrote:\n\n> This was discussed to death when detached HEAD was introduced, and the\n> decision was to go with the current behavior. Try looking in the list\n> archives around December 2006 / January 2007 if you are truly\n> masochistic.\n\n<gouges eyes with a rusty spoon>\n\nTry http://thread.gmane.org/gmane.comp.version-control.git/35777\n\n-Peff\n"},{"id":"89554","messageId":"0578A0F2-F90A-4555-9B34-726F26A1CDBB@ai.rug.nl","threadId":"15336","inReplyTo":"20080902210524.GB7757@leksak.fem-net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-02T21:51:18Z","receivedAt":"2008-09-02T21:51:18Z","isPatch":false,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"\nOn 2 sep 2008, at 23:05, Stephan Beyer wrote:\n\n> Junio C Hamano wrote:\n>> Pieter de Bie <pdebie@ai.rug.nl> writes:\n>>\n> [..]\n>>> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n>>> Created commit 6ce62c8b: test\n>>> You are on a detached head, so this commit has not been recorded  \n>>> in a branch.\n>>> If you don't want to lose this commit, checkout a branch and then  \n>>> run:\n>>> \tgit merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n>>>\n>>> Are there any comments to this / strong opinions against such a  \n>>> change?\n>>\n>> Unconditionally doing this is too loud for my taste.  You probably  \n>> can do\n>> this in your post-commit hook.\n>\n> Well, Pieter probably can do this in his post-commit hook. But I think\n> this is useful for usability... especially for beginners who might not\n> even know what a hook is. ;)\n\nExactly..I can fix this for myself, and when things go wrong I can also\nfix it, but there are people less with Git that don't understand what's\ngoing on.\n\n> For me this felt too loud, too, especially since \"git status\" and\n> \"git commit\" (without message option) already tells the user that\n> she is on a detached HEAD. And \"git commit -a\" is usually done after\n> a \"git status\", too, isn't it? (I do not use \"git commit -a\", I *use*\n> the index.)\n\n\nThe one in \"git status\" is somewhat noticeable with color highlighting,\nbut the \"git commit\" one doesn't exactly stand out:\n\n\t# Please enter the commit message for your changes. Lines starting\n\t# with '#' will be ignored, and an empty message aborts the commit.\n\t# Not currently on any branch.\n\t# Untracked files:\n\t#   (use \"git add <file>...\" to include in what will be committed)\n\nIt's the third line, surrounded by other lines and at the bottom of  \nthe window.\n\nHow about a single line then, something like\n\n\tVienna:git pieter$ ./git commit --allow-empty -m\"test\"\n\tCreated commit 6ce62c8b: test\n\tRemember you are on a detached head, create a new branch to not lose  \nthese changes\n"},{"id":"89556","messageId":"7vr682i50g.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"200809022339.20123.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-02T21:58:55Z","receivedAt":"2008-09-02T21:58:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> On Tuesday 02 September 2008, Stephan Beyer wrote:\n>> Junio C Hamano wrote:\n>> > Pieter de Bie <pdebie@ai.rug.nl> writes:\n>> > > Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n>> > > Created commit 6ce62c8b: test\n>> > > You are on a detached head, so this commit has not been recorded in a\n>> > > branch. If you don't want to lose this commit, checkout a branch and\n>> > > then run: git merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n>> > >\n>> > > Are there any comments to this / strong opinions against such a\n>> > > change?\n>> >\n>> > Unconditionally doing this is too loud for my taste.  You probably can\n>> > do this in your post-commit hook.\n>>\n>> Well, Pieter probably can do this in his post-commit hook. But I think\n>> this is useful for usability... especially for beginners who might not\n>> even know what a hook is. ;)\n>\n> I'm not sure I like this personally, but if we _really_ don't want newbies \n> to shoot themselves in the foot, we could make \"git commit\" fail on a \n> detached HEAD unless the user has indicated that s/he knows what's going \n> on; i.e. something like this:\n\nIf we _really_ don't want newbies to shoot themselves in the foot, we\nprobably can issue a loud warning when they detach there HEAD.\n\nOh, wait,... we already do that.\n"},{"id":"89560","messageId":"g9kdn4$rgs$1@ger.gmane.org","threadId":"15336","inReplyTo":"0578A0F2-F90A-4555-9B34-726F26A1CDBB@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-09-02T22:11:52Z","receivedAt":"2008-09-02T22:11:52Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Pieter de Bie wrote:\n\n>         # Please enter the commit message for your changes. Lines starting\n>         # with '#' will be ignored, and an empty message aborts the commit.\n>         # Not currently on any branch.\n>         # Untracked files:\n>         #   (use \"git add <file>...\" to include in what will be committed)\n> \n> It's the third line, surrounded by other lines and at the bottom of  \n> the window.\n\nPerhaps instead of poposed patch we should simply put empty lines\nto emphasize that we are on no branch:\n\n        # Please enter the commit message for your changes. Lines starting\n        # with '#' will be ignored, and an empty message aborts the commit.\n        #\n        # Not currently on any branch.\n        #\n        # Untracked files:\n        #   (use \"git add <file>...\" to include in what will be committed)\n\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"89564","messageId":"7vabeqi2n3.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"g9kdn4$rgs$1@ger.gmane.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-02T22:50:08Z","receivedAt":"2008-09-02T22:50:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Perhaps instead of poposed patch we should simply put empty lines\n> to emphasize that we are on no branch:\n>\n>         # Please enter the commit message for your changes. Lines starting\n>         # with '#' will be ignored, and an empty message aborts the commit.\n>         #\n>         # Not currently on any branch.\n>         #\n>         # Untracked files:\n>         #   (use \"git add <file>...\" to include in what will be committed)\n\nThat sounds sensible, easy and safe enough.\n\n\n wt-status.c |   20 ++++++++++----------\n 1 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git i/wt-status.c w/wt-status.c\nindex 889e50f..97076e8 100644\n--- i/wt-status.c\n+++ w/wt-status.c\n@@ -342,17 +342,17 @@ void wt_status_print(struct wt_status *s)\n \n \ts->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;\n \tif (s->branch) {\n-\t\tconst char *on_what = \"On branch \";\n-\t\tconst char *branch_name = s->branch;\n-\t\tif (!prefixcmp(branch_name, \"refs/heads/\"))\n-\t\t\tbranch_name += 11;\n-\t\telse if (!strcmp(branch_name, \"HEAD\")) {\n-\t\t\tbranch_name = \"\";\n-\t\t\tbranch_color = color(WT_STATUS_NOBRANCH);\n-\t\t\ton_what = \"Not currently on any branch.\";\n+\t\tif (!prefixcmp(s->branch, \"refs/heads/\")) {\n+\t\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n+\t\t\tcolor_fprintf_ln(s->fp, branch_color,\n+\t\t\t\t\t \"On branch %s\", s->branch + 11);\n+\t\t} else if (!strcmp(s->branch, \"HEAD\")) {\n+\t\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n+\t\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n+\t\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_NOBRANCH),\n+\t\t\t\t\t \"Not currently on any branch.\");\n+\t\t\tcolor_fprintf_ln(s->fp, color(WT_STATUS_HEADER), \"#\");\n \t\t}\n-\t\tcolor_fprintf(s->fp, color(WT_STATUS_HEADER), \"# \");\n-\t\tcolor_fprintf_ln(s->fp, branch_color, \"%s%s\", on_what, branch_name);\n \t\tif (!s->is_initial)\n \t\t\twt_status_print_tracking(s);\n \t}\n"},{"id":"89565","messageId":"alpine.LFD.1.10.0809021849390.23787@xanadu.home","threadId":"15336","inReplyTo":"200809022339.20123.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-02T22:53:00Z","receivedAt":"2008-09-02T22:53:00Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 2 Sep 2008, Johan Herland wrote:\n\n> On Tuesday 02 September 2008, Stephan Beyer wrote:\n> > Junio C Hamano wrote:\n> > > Pieter de Bie <pdebie@ai.rug.nl> writes:\n> > > > Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> > > > Created commit 6ce62c8b: test\n> > > > You are on a detached head, so this commit has not been recorded in a\n> > > > branch. If you don't want to lose this commit, checkout a branch and\n> > > > then run: git merge 6ce62c8bfcfb341106f3587d1c141c3955c2544c\n> > > >\n> > > > Are there any comments to this / strong opinions against such a\n> > > > change?\n> > >\n> > > Unconditionally doing this is too loud for my taste.  You probably can\n> > > do this in your post-commit hook.\n> >\n> > Well, Pieter probably can do this in his post-commit hook. But I think\n> > this is useful for usability... especially for beginners who might not\n> > even know what a hook is. ;)\n> \n> I'm not sure I like this personally, but if we _really_ don't want newbies \n> to shoot themselves in the foot, we could make \"git commit\" fail on a \n> detached HEAD unless the user has indicated that s/he knows what's going \n> on; i.e. something like this:\n> \n> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> You are on a detached head, so this commit would not be recorded in a\n> branch. If you don't want to lose this commit, please switch to a (new) \n> branch before committing. If you know what you're doing, and want to\n> proceed on a detached HEAD, please enable commit.detached in your \n> configuration (git config --global commit.detached true)\n> \n> ...but I sympathize with those that think this is overkill.\n\nThis is going over board indeed.\n\nAdding commits to a detached head is _cool_, and it is also _useful_ in \nmany occasions.  Let's not obfuscate that capability.\n\nAdding an extra line of warning when the commit is done is fine, but \nmore than that is too much IMHO.\n\n\nNicolas\n"},{"id":"89566","messageId":"alpine.LFD.1.10.0809021856310.23787@xanadu.home","threadId":"15336","inReplyTo":"7vabeqi2n3.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-02T22:58:53Z","receivedAt":"2008-09-02T22:58:53Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 2 Sep 2008, Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > Perhaps instead of poposed patch we should simply put empty lines\n> > to emphasize that we are on no branch:\n> >\n> >         # Please enter the commit message for your changes. Lines starting\n> >         # with '#' will be ignored, and an empty message aborts the commit.\n> >         #\n> >         # Not currently on any branch.\n> >         #\n> >         # Untracked files:\n> >         #   (use \"git add <file>...\" to include in what will be committed)\n> \n> That sounds sensible, easy and safe enough.\n\nYep.  And I would go as far as suggesting that the branch information be \nthe first line of the lot:\n\n# Not currently on any branch.\n#\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# Untracked files:\n#   (use \"git add <file>...\" to include in what will be committed)\n# [...]\n\n\nNicolas\n"},{"id":"89589","messageId":"200809030945.08619.johan@herland.net","threadId":"15336","inReplyTo":"20080902214428.GA20355@sigill.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-03T07:45:08Z","receivedAt":"2008-09-03T07:45:08Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 02 September 2008, Jeff King wrote:\n> On Tue, Sep 02, 2008 at 11:39:20PM +0200, Johan Herland wrote:\n> > I'm not sure I like this personally, but if we _really_ don't want\n> > newbies to shoot themselves in the foot, we could make \"git commit\"\n> > fail on a detached HEAD unless the user has indicated that s/he knows\n> > what's going on; i.e. something like this:\n>\n> This was discussed to death when detached HEAD was introduced, and the\n> decision was to go with the current behavior. Try looking in the list\n> archives around December 2006 / January 2007 if you are truly\n> masochistic.\n\nOk. Scratch that.\n\nBut what happened to the various suggestions in that original thread on \nadding a safety valve when _leaving_ the detached state (i.e. preventing \nthe user from leaving their detached commits unreachable)?\n\nIt seems to have been suggested (in various forms) by several people and \ngenerally well-received in the original thread, but nothing seems to have \ncome of it (at least nothing that has survived till today).\n\n\nApparently masochistic,\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"89591","messageId":"7vljy9d540.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"200809030945.08619.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-03T08:07:59Z","receivedAt":"2008-09-03T08:07:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> It seems to have been suggested (in various forms) by several people and \n> generally well-received in the original thread, but nothing seems to have \n> come of it (at least nothing that has survived till today).\n\nYou are masochistic enough to have noticed that people were talking about\nthe safety in the context of \"HEAD lacks its own reflog\"?  Yes, we had\nreflogs on each refs/*, but HEAD itself did not have one.\n\nThe situation has changed --- HEAD has its own reflog these days, which\nnot only helps this particular issue but is useful in contexts that never\ninvolves a detached HEAD.\n"},{"id":"89606","messageId":"200809031147.15612.johan@herland.net","threadId":"15336","inReplyTo":"7vljy9d540.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-03T09:47:15Z","receivedAt":"2008-09-03T09:47:15Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Wednesday 03 September 2008, Junio C Hamano wrote:\n> Johan Herland <johan@herland.net> writes:\n> > It seems to have been suggested (in various forms) by several\n> > people and generally well-received in the original thread, but\n> > nothing seems to have come of it (at least nothing that has\n> > survived till today).\n>\n> You are masochistic enough to have noticed that people were talking\n> about the safety in the context of \"HEAD lacks its own reflog\"?  Yes,\n> we had reflogs on each refs/*, but HEAD itself did not have one.\n\nYes, I noticed that...\n\n> The situation has changed --- HEAD has its own reflog these days,\n> which not only helps this particular issue but is useful in contexts\n> that never involves a detached HEAD.\n\n...and that is certainly good, but I wonder if the people we want to \nprotect from losing detached commits might not be aware of the \nexistence and usage of reflogs (since we already assume they might not \nyet have fully grasped the branch concept). Even so, this would provide \na golden opportunity to teach them about it. So, what about this: \n\nWhen switching away from a detached HEAD that will cause it to become \nunreachable, we should warn the user of what is happening, and how to \nrecover from this situation. I.e. something like:\n\n  The commit you switched away from is not reachable from an existing\n  ref, and will be deleted when its reflog entry expires (in $X days).\n  See \"git help reflog\" for more information.\n  If you want to keep this commit, you must bind it to a ref, for\n  example by doing\n    git branch <new-branch-name> $SHA1_SUM_HERE\n\n\nOf course, this warning can be hidden by giving -q to git checkout.\n\nHmm?\n\n\nHopefully no longer masochistic,\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"89619","messageId":"4C04A26E-5829-4A39-AD89-F5A68E606AA3@ai.rug.nl","threadId":"15336","inReplyTo":"0578A0F2-F90A-4555-9B34-726F26A1CDBB@ai.rug.nl","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-03T11:27:33Z","receivedAt":"2008-09-03T11:27:33Z","isPatch":false,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"\nOn 2 sep 2008, at 23:51, Pieter de Bie wrote:\n>\n> How about a single line then, something like\n>\n> \tVienna:git pieter$ ./git commit --allow-empty -m\"test\"\n> \tCreated commit 6ce62c8b: test\n> \tRemember you are on a detached head, create a new branch to not  \n> lose these changes\n\nOr, as a final suggestion, something unintrusive like:\n\n(on detached head)\n\tVienna:git pieter$ ./git commit --allow-empty -m\"test\"\n\tCreated commit 6ce62c8b on detached head: test\n(on branch)\n\tVienna:git pieter$ ./git commit --allow-empty -m\"test\"\n\tCreated commit 6ce62c8b on branch 'master': test\n\n- Pieter\n"},{"id":"89624","messageId":"20080903131507.GC12936@coredump.intra.peff.net","threadId":"15336","inReplyTo":"200809030945.08619.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-03T13:15:07Z","receivedAt":"2008-09-03T13:15:07Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 03, 2008 at 09:45:08AM +0200, Johan Herland wrote:\n\n> But what happened to the various suggestions in that original thread on \n> adding a safety valve when _leaving_ the detached state (i.e. preventing \n> the user from leaving their detached commits unreachable)?\n\nHrm. I thought we decided on a message like:\n\n  Previous HEAD position was 1234abcd\n\nwhen leaving the detached HEAD state, but it seems to have disappeared.\nMaybe with the move to builtin-checkout (sorry, I don't have time to\nbisect right at this second). Was that intentional?\n\n-Peff\n"},{"id":"89625","messageId":"20080903133446.GA6967@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20080903131507.GC12936@coredump.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-03T13:34:46Z","receivedAt":"2008-09-03T13:34:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 03, 2008 at 09:15:07AM -0400, Jeff King wrote:\n\n> Hrm. I thought we decided on a message like:\n> \n>   Previous HEAD position was 1234abcd\n> \n> when leaving the detached HEAD state, but it seems to have disappeared.\n> Maybe with the move to builtin-checkout (sorry, I don't have time to\n> bisect right at this second). Was that intentional?\n\nOK, I lied. I did have time to bisect it.\n\nIt never worked in builtin-checkout, and I am a bit suspicious of the\ncode (and comment) below. Why would we not want to show such a message\nif moving to a branch (as long as it is not a _new_ branch)? The patch\nbelow makes more sense to me.\n\n---\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex b380ad6..b2c7d3c 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -386,12 +386,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \t}\n \n \t/*\n-\t * If the new thing isn't a branch and isn't HEAD and we're\n+\t * If the new thing isn't isn't HEAD and we're\n \t * not starting a new branch, and we want messages, and we\n \t * weren't on a branch, and we're moving to a new commit,\n \t * describe the old commit.\n \t */\n-\tif (!new->path && strcmp(new->name, \"HEAD\") && !opts->new_branch &&\n+\tif (strcmp(new->name, \"HEAD\") && !opts->new_branch &&\n \t    !opts->quiet && !old.path && new->commit != old.commit)\n \t\tdescribe_detached_head(\"Previous HEAD position was\", old.commit);\n \n"},{"id":"89626","messageId":"48BE9526.9030104@op5.se","threadId":"15336","inReplyTo":"20080903133446.GA6967@coredump.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-03T13:46:14Z","receivedAt":"2008-09-03T13:46:14Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Wed, Sep 03, 2008 at 09:15:07AM -0400, Jeff King wrote:\n> \n>> Hrm. I thought we decided on a message like:\n>>\n>>   Previous HEAD position was 1234abcd\n>>\n>> when leaving the detached HEAD state, but it seems to have disappeared.\n>> Maybe with the move to builtin-checkout (sorry, I don't have time to\n>> bisect right at this second). Was that intentional?\n> \n> OK, I lied. I did have time to bisect it.\n> \n> It never worked in builtin-checkout, and I am a bit suspicious of the\n> code (and comment) below. Why would we not want to show such a message\n> if moving to a branch (as long as it is not a _new_ branch)? The patch\n> below makes more sense to me.\n> \n> ---\n> diff --git a/builtin-checkout.c b/builtin-checkout.c\n> index b380ad6..b2c7d3c 100644\n> --- a/builtin-checkout.c\n> +++ b/builtin-checkout.c\n> @@ -386,12 +386,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n>  \t}\n>  \n>  \t/*\n> -\t * If the new thing isn't a branch and isn't HEAD and we're\n> +\t * If the new thing isn't isn't HEAD and we're\n\n\"isn't isn't\"\n\n>  \t * not starting a new branch, and we want messages, and we\n>  \t * weren't on a branch, and we're moving to a new commit,\n>  \t * describe the old commit.\n>  \t */\n\nApart from the typo above, this patch makes a whole lot of sense.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"89630","messageId":"8A00EA31-ED43-45CF-A162-66DC45AE41F0@wincent.com","threadId":"15336","inReplyTo":"20080903131507.GC12936@coredump.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-09-03T14:11:32Z","receivedAt":"2008-09-03T14:11:32Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 3/9/2008, a las 15:15, Jeff King escribió:\n\n> On Wed, Sep 03, 2008 at 09:45:08AM +0200, Johan Herland wrote:\n>\n>> But what happened to the various suggestions in that original  \n>> thread on\n>> adding a safety valve when _leaving_ the detached state (i.e.  \n>> preventing\n>> the user from leaving their detached commits unreachable)?\n>\n> Hrm. I thought we decided on a message like:\n>\n>  Previous HEAD position was 1234abcd\n>\n> when leaving the detached HEAD state, but it seems to have  \n> disappeared.\n\nMightn't \"Previous HEAD position was 1234abcd (detached)\" be even more  \nhelpful?\n\nCheers,\nWincent\n"},{"id":"89633","messageId":"alpine.LFD.1.10.0809031113580.23787@xanadu.home","threadId":"15336","inReplyTo":"200809030945.08619.johan@herland.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2008-09-03T15:16:58Z","receivedAt":"2008-09-03T15:16:58Z","isPatch":false,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Wed, 3 Sep 2008, Johan Herland wrote:\n\n> On Tuesday 02 September 2008, Jeff King wrote:\n> > On Tue, Sep 02, 2008 at 11:39:20PM +0200, Johan Herland wrote:\n> > > I'm not sure I like this personally, but if we _really_ don't want\n> > > newbies to shoot themselves in the foot, we could make \"git commit\"\n> > > fail on a detached HEAD unless the user has indicated that s/he knows\n> > > what's going on; i.e. something like this:\n> >\n> > This was discussed to death when detached HEAD was introduced, and the\n> > decision was to go with the current behavior. Try looking in the list\n> > archives around December 2006 / January 2007 if you are truly\n> > masochistic.\n> \n> Ok. Scratch that.\n> \n> But what happened to the various suggestions in that original thread on \n> adding a safety valve when _leaving_ the detached state (i.e. preventing \n> the user from leaving their detached commits unreachable)?\n\nIt has been made unnecessary when the HEAD reflog started recording \ndetached head states.\n\n\nNicolas\n"},{"id":"89644","messageId":"alpine.LNX.1.00.0809031234560.19665@iabervon.org","threadId":"15336","inReplyTo":"20080903133446.GA6967@coredump.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-09-03T16:49:43Z","receivedAt":"2008-09-03T16:49:43Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 3 Sep 2008, Jeff King wrote:\n\n> On Wed, Sep 03, 2008 at 09:15:07AM -0400, Jeff King wrote:\n> \n> > Hrm. I thought we decided on a message like:\n> > \n> >   Previous HEAD position was 1234abcd\n> > \n> > when leaving the detached HEAD state, but it seems to have disappeared.\n> > Maybe with the move to builtin-checkout (sorry, I don't have time to\n> > bisect right at this second). Was that intentional?\n> \n> OK, I lied. I did have time to bisect it.\n> \n> It never worked in builtin-checkout, and I am a bit suspicious of the\n> code (and comment) below. Why would we not want to show such a message\n> if moving to a branch (as long as it is not a _new_ branch)? The patch\n> below makes more sense to me.\n\nGood point. I think I confused myself with the new branch case. On the \nother hand, I think the \"not starting a new branch\" case should go as \nwell. If you've got a detached HEAD, and you do:\n\n$ git checkout -b foo origin/master\n\nwe probably ought to describe the old state. The reason that starting a \nnew branch usually shouldn't give the message is that new->commit == \nold.commit (assuming that the defaults have gotten filled in by this \npoint, which they should have).\n\n(I think I included the new branch case to match the existing branch case; \nI'm not sure where I got the idea that switching to a branch shouldn't \ngive the message. Hey, at least the comment makes it clear that I was \nactually trying to write the wrong code...)\n\nActually, the test for HEAD should be able to go, also, since checking out \nHEAD wouldn't change the current commit, although this doesn't matter to \nanything other than the complexity of the condition.\n\n> \n> ---\n> diff --git a/builtin-checkout.c b/builtin-checkout.c\n> index b380ad6..b2c7d3c 100644\n> --- a/builtin-checkout.c\n> +++ b/builtin-checkout.c\n> @@ -386,12 +386,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n>  \t}\n>  \n>  \t/*\n> -\t * If the new thing isn't a branch and isn't HEAD and we're\n> +\t * If the new thing isn't isn't HEAD and we're\n>  \t * not starting a new branch, and we want messages, and we\n>  \t * weren't on a branch, and we're moving to a new commit,\n>  \t * describe the old commit.\n>  \t */\n> -\tif (!new->path && strcmp(new->name, \"HEAD\") && !opts->new_branch &&\n> +\tif (strcmp(new->name, \"HEAD\") && !opts->new_branch &&\n>  \t    !opts->quiet && !old.path && new->commit != old.commit)\n>  \t\tdescribe_detached_head(\"Previous HEAD position was\", old.commit);\n>  \n> \n"},{"id":"89661","messageId":"20080903180726.GA16454@coredump.intra.peff.net","threadId":"15336","inReplyTo":"alpine.LNX.1.00.0809031234560.19665@iabervon.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-03T18:07:26Z","receivedAt":"2008-09-03T18:07:26Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 03, 2008 at 12:49:43PM -0400, Daniel Barkalow wrote:\n\n> Good point. I think I confused myself with the new branch case. On the \n> other hand, I think the \"not starting a new branch\" case should go as \n> well. If you've got a detached HEAD, and you do:\n> \n> $ git checkout -b foo origin/master\n> \n> we probably ought to describe the old state. The reason that starting a \n> new branch usually shouldn't give the message is that new->commit == \n> old.commit (assuming that the defaults have gotten filled in by this \n> point, which they should have).\n\nRight, I was thinking it was necessary for the starting a new branch\ncase, but a better test is checking whether the commits are the same.\n\nSo based on what you said and thinking a bit, I came up with:\n\n    if (!opts->quiet && !old.path && new->commit != old.commit)\n\nand then I had the brilliant idea of checking what git-checkout.sh did.\nAnd sure enough:\n\n    elif test -z \"$oldbranch\" && test \"$new\" != \"$old\"\n    then\n            describe_detached_head 'Previous HEAD position was' \"$old\"\n    fi\n\nPatch is below.\n\n-- >8 --\ncheckout: fix message when leaving detached HEAD\n\nThe shell version of git checkout would print:\n\n  Previous HEAD position was 1234abcd... commit subject line\n\nwhen leaving a detached HEAD for another commit. Ths C\nversion attempted to implement this, but got the condition\nwrong such that the behavior never triggered.\n\nThis patch simplifies the conditions for showing the message\nto the ones used by the shell version: any time we are\nleaving a detached HEAD and the new and old commits are not\nthe same (this suppresses it for the \"git checkout -b new\"\ncase recommended when you enter the detached state).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin-checkout.c |   10 ++++------\n 1 files changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex b380ad6..efdb1e0 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -386,13 +386,11 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \t}\n \n \t/*\n-\t * If the new thing isn't a branch and isn't HEAD and we're\n-\t * not starting a new branch, and we want messages, and we\n-\t * weren't on a branch, and we're moving to a new commit,\n-\t * describe the old commit.\n+\t * If we were on a detached HEAD, but we are now moving to\n+\t * a new commit, we want to mention the old commit once more\n+\t * to remind the user that it might be lost.\n \t */\n-\tif (!new->path && strcmp(new->name, \"HEAD\") && !opts->new_branch &&\n-\t    !opts->quiet && !old.path && new->commit != old.commit)\n+\tif (!opts->quiet && !old.path && new->commit != old.commit)\n \t\tdescribe_detached_head(\"Previous HEAD position was\", old.commit);\n \n \tif (!old.commit) {\n-- \n1.6.0.1.208.gcc04.dirty\n"},{"id":"89662","messageId":"20080903180846.GB16454@coredump.intra.peff.net","threadId":"15336","inReplyTo":"8A00EA31-ED43-45CF-A162-66DC45AE41F0@wincent.com","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-03T18:08:46Z","receivedAt":"2008-09-03T18:08:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 03, 2008 at 04:11:32PM +0200, Wincent Colaiuta wrote:\n\n>>  Previous HEAD position was 1234abcd\n>>\n>> when leaving the detached HEAD state, but it seems to have disappeared.\n>\n> Mightn't \"Previous HEAD position was 1234abcd (detached)\" be even more  \n> helpful?\n\nThe full message is actually:\n\n    Previous HEAD position was 1234abcd... subject line of 1234abcd\n\nI am not opposed to changing it, but I will let others decide on what it\nshould say; my patch just reinstates the message itself (for which there\nwas code, but broken code).\n\n-Peff\n"},{"id":"89675","messageId":"7vljy9auoq.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"20080903180726.GA16454@coredump.intra.peff.net","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-03T19:36:05Z","receivedAt":"2008-09-03T19:36:05Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Wed, Sep 03, 2008 at 12:49:43PM -0400, Daniel Barkalow wrote:\n>\n>> Good point. I think I confused myself with the new branch case. On the \n>> other hand, I think the \"not starting a new branch\" case should go as \n>> well. If you've got a detached HEAD, and you do:\n>> \n>> $ git checkout -b foo origin/master\n>> \n>> we probably ought to describe the old state. The reason that starting a \n>> new branch usually shouldn't give the message is that new->commit == \n>> old.commit (assuming that the defaults have gotten filled in by this \n>> point, which they should have).\n>\n> Right, I was thinking it was necessary for the starting a new branch\n> case, but a better test is checking whether the commits are the same.\n>\n> So based on what you said and thinking a bit, I came up with:\n>\n>     if (!opts->quiet && !old.path && new->commit != old.commit)\n>\n> and then I had the brilliant idea of checking what git-checkout.sh did.\n> And sure enough:\n>\n>     elif test -z \"$oldbranch\" && test \"$new\" != \"$old\"\n>     then\n>             describe_detached_head 'Previous HEAD position was' \"$old\"\n>     fi\n>\n> Patch is below.\n\nIt was a good idea to keep the scripted ones in contrib/examples so that\nthey are readily accessible to find out what we used to do ;-).\n\nThanks.  Will apply to 'maint'.\n"},{"id":"89677","messageId":"20080903194156.GA31756@coredump.intra.peff.net","threadId":"15336","inReplyTo":"7vljy9auoq.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-03T19:41:56Z","receivedAt":"2008-09-03T19:41:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Sep 03, 2008 at 12:36:05PM -0700, Junio C Hamano wrote:\n\n> It was a good idea to keep the scripted ones in contrib/examples so that\n> they are readily accessible to find out what we used to do ;-).\n\nWho's to say I didn't do:\n\n  deleted=$(git log -1 --pretty=format:%H --diff-filter=D -- git-checkout.sh)\n  git show ${deleted}^:git-checkout.sh\n\n? :P\n\n-Peff\n\nPS Actually, I was about to look it up in the history when I remembered\nthat we put it into contrib. :)\n"},{"id":"89724","messageId":"32541b130809032150i418014bdo8a838f529e109f50@mail.gmail.com","threadId":"15336","inReplyTo":"alpine.LFD.1.10.0809021849390.23787@xanadu.home","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-09-04T04:50:18Z","receivedAt":"2008-09-04T04:50:18Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Tue, Sep 2, 2008 at 6:53 PM, Nicolas Pitre <nico@cam.org> wrote:\n> On Tue, 2 Sep 2008, Johan Herland wrote:\n>> Vienna:git pieter$ ./git commit --allow-empty -m\"test\"\n>> You are on a detached head, so this commit would not be recorded in a\n>> branch. If you don't want to lose this commit, please switch to a (new)\n>> branch before committing. If you know what you're doing, and want to\n>> proceed on a detached HEAD, please enable commit.detached in your\n>> configuration (git config --global commit.detached true)\n>>\n>> ...but I sympathize with those that think this is overkill.\n>\n> This is going over board indeed.\n>\n> Adding commits to a detached head is _cool_, and it is also _useful_ in\n> many occasions.  Let's not obfuscate that capability.\n>\n> Adding an extra line of warning when the commit is done is fine, but\n> more than that is too much IMHO.\n\nI think maybe we're looking at this the wrong way.  The bad thing\nisn't committing to a detached HEAD; the bad thing is detaching the\nHEAD *by accident* in the first place.\n\nWhy do people (including me) spend so much time with a detached HEAD?\nI think it happens mainly for the following reasons:\n\n1) Checking out a remote branch \"git checkout origin/master\" detaches\nmy HEAD, which is kind of bad, since it's such a common thing to want\nto do.  And \"git checkout -b master origin/master\" is *not* actually\nwhat I want to do, *most* of the time. What I actually want is for git\nto remember that I'm on origin/master, but not let me change\norigin/master, because it's a remote branch.  If I want to make\nchanges, I need to first make a topic branch, with \"git checkout -b\ntopic\".  git should prevent me from committing until I do.\n\n2) git-rebase and git-am detach the HEAD while they work.  I think\nthis is fine, but: you shouldn't be able to *reattach* the HEAD\nwithout first aborting the rebase or am operations.  When I've lost my\nwork, it's usually because I turned out to be in the middle of a\nrebase or am and forgot about it, then I checked out another branch\nand did some work, then ran git-rebase --abort, and oops! It moved me\nsomewhere else.  git should prevent me from switching branches when a\nrebase or am is in progress.\n\n3) git-submodule detaches and moves the HEAD of submodules\nautomatically.  This is a whole separate discussion :)\n\nThe remaining situations where someone is working on a detached HEAD\n(eg. checking out a particular commit, or actually implementing\ngit-rebase like operations) seem to be pretty obviously *intentional*,\nand in that case, git should stay out of their way and let them do\nwhat they're doing.\n\nI believe the reason this is such a hotly debated topic is that people\nconfuse situations #1 and #2, and try to apply the same solution to\nboth.  But in situation #1, you want to be able to switch branches; in\nsituation #2, you want to be able to commit.  They are different\nsituations, even though technically the fact that \"I'm on a detached\nHEAD!\" is the same.\n\nHave fun,\n\nAvery\n"},{"id":"89727","messageId":"7vbpz479zs.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"32541b130809032150i418014bdo8a838f529e109f50@mail.gmail.com","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-04T05:31:19Z","receivedAt":"2008-09-04T05:31:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Avery Pennarun\" <apenwarr@gmail.com> writes:\n\n> Why do people (including me) spend so much time with a detached HEAD?\n> I think it happens mainly for the following reasons:\n>\n> 1) Checking out a remote branch \"git checkout origin/master\" detaches\n> my HEAD, which is kind of bad, since it's such a common thing to want\n> to do.\n\nI do not think it is bad at all.  The feature to detach HEAD was designed\nfor that kind of usage.  Start sightseeing, possibly futz with the code,\nand even create some snapshot commits, and then:\n\n * if it starts to take a usable shape, say \"git checkout -b my-topic\",\n   from there, to give your exploration a lasting home; or\n   \n * if it doesn't pan out, just discard it with \"git checkout -f master\"\n   (or whatever you wanted to switch back to).\n\nOne thing that might help for downstream people would be to be able to say\n\"I am making 'my-topic' branch out of a detached HEAD, but it really is\nmeant to be a fork of origin/master that I detached my HEAD from, so\nplease set up tracking for that one\".\n\nYou could force people to say \"git checkout -b my-topic origin/master\"\nfrom the beginning, but that is very unreasonable and unworkable.  When\nyou are exploring, you more often than not do not know where your quest\nwould lead to until spending some time.  It is quite important to be able\nto delay the decision to create a local branch to keep what you did, and\n(more importantly) to be able to delay deciding what to name that topic.\n\nPerhaps \"git checkout -b my-topic\" from a detached HEAD should inspect the\nHEAD reflog to see which remote (or local) branch you came from, and give\nthat to the --track logic.\n\n> 2) git-rebase and git-am detach the HEAD while they work.  I think\n> this is fine, but: you shouldn't be able to *reattach* the HEAD\n> without first aborting the rebase or am operations....\n\nPS1='[\\u@\\h \\W$(__git_ps1 \" (%s)\")]\\$ ' would help here.\n\nI do not have an objection to the general idea of forbidding people from\nswitching branches out of detached HEAD while sequencer is in effect as a\nsafety measure, but I didn't think through possible negative implications.\n\n> The remaining situations where someone is working on a detached HEAD\n> (eg. checking out a particular commit, or actually implementing\n> git-rebase like operations) seem to be pretty obviously *intentional*,\n> and in that case, git should stay out of their way and let them do\n> what they're doing.\n\nAbsolutely.  Being able to explore, without having to first decide what\nyou are going to work on or what to name that branch, is a wonderful\nfeature.  It really lowers the barrier to explore.\n"},{"id":"89855","messageId":"1220634785-55543-1-git-send-email-pdebie@ai.rug.nl","threadId":"15336","inReplyTo":"4C04A26E-5829-4A39-AD89-F5A68E606AA3@ai.rug.nl","subject":"[PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-05T17:13:05Z","receivedAt":"2008-09-05T17:13:05Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"This outputs the current branch on which a commit was created, just for\nreference. For example:\n\n\tCreated commit 6d42875 on master: Fix submodule invalid command error\n\nThis also reminds the committer when he is on a detached HEAD:\n\n\tCreated commit 02a7172 on detached HEAD: Also do this for 'git commit --amend'\n\nSigned-off-by: Pieter de Bie <pdebie@ai.rug.nl>\n---\n builtin-commit.c |   26 ++++++++++++++++++++++++--\n 1 files changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 8165bb3..a82483d 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -878,10 +878,31 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \treturn commitable ? 0 : 1;\n }\n \n+static char* get_commit_format_string()\n+{\n+\tunsigned char sha[20];\n+\tconst char* head = resolve_ref(\"HEAD\", sha, 0, NULL);\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tstrbuf_addstr(&buf, \"format:%h\");\n+\n+\t/* Are we on a detached HEAD? */\n+\tif (!strcmp(\"HEAD\", head))\n+\t\tstrbuf_addstr(&buf, \" on detached HEAD\");\n+\telse if (!prefixcmp(head, \"refs/heads/\")) {\n+\t\tstrbuf_addstr(&buf, \" on \");\n+\t\tstrbuf_addstr(&buf, head + 11);\n+\t}\n+\tstrbuf_addstr(&buf, \": %s\");\n+\n+\treturn buf.buf;\n+}\n+\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\n \tstruct commit *commit;\n+\tchar* format = get_commit_format_string();\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit)\n@@ -899,7 +920,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n \trev.verbose_header = 1;\n \trev.show_root_diff = 1;\n-\tget_commit_format(\"format:%h: %s\", &rev);\n+\tget_commit_format(format, &rev);\n \trev.always_show_header = 0;\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n@@ -910,10 +931,11 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tformat_commit_message(commit, \"%h: %s\", &buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n \t\tprintf(\"%s\\n\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n+\tfree(format);\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n-- \n1.6.0.1.346.g880d9.dirty\n"},{"id":"89880","messageId":"7vabemupjb.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"7vbpz479zs.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] Detached-HEAD reminder on commit?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-05T23:43:52Z","receivedAt":"2008-09-05T23:43:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"Avery Pennarun\" <apenwarr@gmail.com> writes:\n> ...\n>> 1) Checking out a remote branch \"git checkout origin/master\" detaches\n>> my HEAD, which is kind of bad, since it's such a common thing to want\n>> to do.\n>\n> I do not think it is bad at all.  The feature to detach HEAD was designed\n> for that kind of usage.  Start sightseeing, possibly futz with the code,\n> and even create some snapshot commits, and then:\n>\n>  * if it starts to take a usable shape, say \"git checkout -b my-topic\",\n>    from there, to give your exploration a lasting home; or\n>    \n>  * if it doesn't pan out, just discard it with \"git checkout -f master\"\n>    (or whatever you wanted to switch back to).\n>\n> One thing that might help for downstream people would be to be able to say\n> \"I am making 'my-topic' branch out of a detached HEAD, but it really is\n> meant to be a fork of origin/master that I detached my HEAD from, so\n> please set up tracking for that one\".\n>\n> You could force people to say \"git checkout -b my-topic origin/master\"\n> from the beginning, but that is very unreasonable and unworkable.  When\n> you are exploring, you more often than not do not know where your quest\n> would lead to until spending some time.  It is quite important to be able\n> to delay the decision to create a local branch to keep what you did, and\n> (more importantly) to be able to delay deciding what to name that topic.\n>\n> Perhaps \"git checkout -b my-topic\" from a detached HEAD should inspect the\n> HEAD reflog to see which remote (or local) branch you came from, and give\n> that to the --track logic.\n\nSo here is a patch for discussion, not heavily tested, but:\n\n\t$ git checkout origin/master\n        $ git commit; hack hack hack ...\n        $ git checkout --track -b mybranch\n\nsequence should result in mybranch tracking the 'master' branch from the\n'origin'.\n\nThe patch is just a proof of concept; doing this for HEAD reflog that is\nseveral megabytes long might take nontrivial amount of time (at least from\nperformance standard of git); if we wanted to go this route, we should add\nan API to read the reflog entries from more recent to older.\n\n branch.c |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 59 insertions(+), 0 deletions(-)\n\ndiff --git c/branch.c w/branch.c\nindex b1e59f2..2ec6418 100644\n--- c/branch.c\n+++ w/branch.c\n@@ -48,6 +48,62 @@ static int should_setup_rebase(const struct tracking *tracking)\n }\n \n /*\n+ * A branch is created out of \"HEAD\" and we would want tracking;\n+ * go back the reflog to figure out where we really came from.\n+ */\n+static int refine_head_one(const char *name, size_t namelen,\n+\t\t\t   struct strbuf *found_ref)\n+{\n+\tchar *real_ref;\n+\tunsigned char sha1[20];\n+\tif (dwim_ref(name, namelen, sha1, &real_ref) != 1)\n+\t\treturn 0;\n+\tstrbuf_reset(found_ref);\n+\tstrbuf_addstr(found_ref, real_ref);\n+\treturn 0;\n+}\n+\n+static int one_head_ent(unsigned char *osha1, unsigned char *nsha1,\n+\t\t\tconst char *ident, unsigned long timestamp, int zone,\n+\t\t\tconst char *message, void *cbdata)\n+{\n+\t/*\n+\t * Look for signs of HEAD coming from elsewhere.\n+\t *\n+\t * \"checkout: moving from %*s to %s\" done by \"git checkout\"\n+\t * \"%s: updating HEAD\" done by \"git reset\"\n+\t */\n+\tstruct strbuf *found_ref = cbdata;\n+\tchar *cp;\n+\tsize_t len;\n+\n+\tif (!prefixcmp(message, \"checkout: moving from \")) {\n+\t\tcp = strstr(message, \" to \");\n+\t\tif (!cp)\n+\t\t\treturn 0;\n+\t\tcp += 4;\n+\t\tlen = strlen(cp);\n+\t\tif (cp[len-1] == '\\n')\n+\t\t\tlen--;\n+\t\treturn refine_head_one(cp, len, found_ref);\n+\t}\n+\n+\tcp = strstr(message, \": updating HEAD\");\n+\tif (cp && !cp[15])\n+\t\treturn refine_head_one(message, cp - message, found_ref);\n+\treturn 0;\n+}\n+\n+static const char *refine_head_ref(void)\n+{\n+\tstruct strbuf found = STRBUF_INIT;\n+\n+\tstrbuf_addstr(&found, \"HEAD\");\n+\tfor_each_reflog_ent(\"HEAD\", one_head_ent, &found);\n+\treturn strbuf_detach(&found, NULL);\n+}\n+\n+/*\n  * This is called when new_ref is branched off of orig_ref, and tries\n  * to infer the settings for branch.<new_ref>.{remote,merge} from the\n  * config.\n@@ -58,6 +114,9 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \tchar key[1024];\n \tstruct tracking tracking;\n \n+\tif (!strcmp(orig_ref, \"HEAD\"))\n+\t\torig_ref = refine_head_ref();\n+\n \tif (strlen(new_ref) > 1024 - 7 - 7 - 1)\n \t\treturn error(\"Tracking not set up: name too long: %s\",\n \t\t\t\tnew_ref);\n"},{"id":"89943","messageId":"7vzlmkpltb.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"1220634785-55543-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-07T05:27:44Z","receivedAt":"2008-09-07T05:27:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pieter de Bie <pdebie@ai.rug.nl> writes:\n\n> This outputs the current branch on which a commit was created, just for\n> reference. For example:\n>\n> \tCreated commit 6d42875 on master: Fix submodule invalid command error\n>\n> This also reminds the committer when he is on a detached HEAD:\n>\n> \tCreated commit 02a7172 on detached HEAD: Also do this for 'git commit --amend'\n>\n\nGiven the recent \"reminder\" discussion, I suspect people without $PS1 set\nto show the current branch would like this, majority of others would be\nneutral, while some may actively hate it for cluttering the output even\nmore.  But I also suspect the initial annoyance the third camp may feel\nwill pass rather quickly after they get used to seeing these.\n\n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index 8165bb3..a82483d 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -878,10 +878,31 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n>  \treturn commitable ? 0 : 1;\n>  }\n>  \n> +static char* get_commit_format_string()\n\nStyle.\n\n\tstatic char *get_commit_format_string(void)\n\n> +{\n> +\tunsigned char sha[20];\n> +\tconst char* head = resolve_ref(\"HEAD\", sha, 0, NULL);\n\nStyle.\n\n\tconst char *head = ...\n\n> ...\n> +\telse if (!prefixcmp(head, \"refs/heads/\")) {\n> +\t\tstrbuf_addstr(&buf, \" on \");\n> +\t\tstrbuf_addstr(&buf, head + 11);\n\nIsn't this function crafting a format string for format_commit_message()?\nWhat happens if your branch name has % in it?\n\n> +\t}\n> +\tstrbuf_addstr(&buf, \": %s\");\n> +\n> +\treturn buf.buf;\n\nAPI violation, I think; see strbuf_detach().\n\n> +}\n> +\n>  static void print_summary(const char *prefix, const unsigned char *sha1)\n>  {\n>  \tstruct rev_info rev;\n>  \tstruct commit *commit;\n> +\tchar* format = get_commit_format_string();\n\nStyle.\n\n\tchar *format = ...\n\n> @@ -910,10 +931,11 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n>  \n>  \tif (!log_tree_commit(&rev, commit)) {\n>  \t\tstruct strbuf buf = STRBUF_INIT;\n> -\t\tformat_commit_message(commit, \"%h: %s\", &buf, DATE_NORMAL);\n> +\t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n> \t\tprintf(\"%s\\n\", buf.buf);\n> \t\tstrbuf_release(&buf);\n\nI somehow suspect it might be much simpler, more contained and robust if you:\n\n (1) chuck get_commit_format_string(), and leave all the existing code as-is;\n\n (2) format \"%h: %s\" into buf here;\n\n (3) call resolve_ref(HEAD) here to see if you are on detached HEAD (or\n     otherwise what branch you are on) after (2),\n\n (4) find the first ':' in buf.buf and do your \"on HEAD\"/\"on master\"\n     magic, using the result from (3).\n"},{"id":"89946","messageId":"7vd4jgpkce.fsf@gitster.siamese.dyndns.org","threadId":"15336","inReplyTo":"7vzlmkpltb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-07T05:59:29Z","receivedAt":"2008-09-07T05:59:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> I somehow suspect it might be much simpler, more contained and robust if you:\n\nAh, that would not work, sorry, because this if() statement is only about\nan uninteresting case of --allow-empty.  You need to do this the hard way\nand teach get_commit_format_string() quote % characters in branch names.\n"},{"id":"90018","messageId":"1220828741-91050-1-git-send-email-pdebie@ai.rug.nl","threadId":"15336","inReplyTo":"7vd4jgpkce.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 1/2] pretty.c: add %% format specifier","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-07T23:05:40Z","receivedAt":"2008-09-07T23:05:40Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"This adds a %% format which just prints a literal %\n\nSigned-off-by: Pieter de Bie <pdebie@ai.rug.nl>\n---\n\nOn 7 sep 2008, at 07:59, Junio C Hamano wrote:\n>Junio C Hamano <gitster@pobox.com> writes:\n>>I somehow suspect it might be much simpler, more contained and robust if you:\n>\n>Ah, that would not work, sorry, because this if() statement is only about\n>an uninteresting case of --allow-empty.  You need to do this the hard way\n>and teach get_commit_format_string() quote % characters in branch names.\n\nYes, here is patch for this. Sorry for the style issues. I also fixed the\nstrbuf issue.\n\n Documentation/pretty-formats.txt |    1 +\n pretty.c                         |    3 +++\n 2 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex f18d33e..b91db86 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -127,6 +127,7 @@ The placeholders are:\n - '%m': left, right or boundary mark\n - '%n': newline\n - '%x00': print a byte from a hex code\n+- '%%': print a literal '%'\n \n * 'tformat:'\n +\ndiff --git a/pretty.c b/pretty.c\nindex 8beafa0..f66d687 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -538,6 +538,9 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,\n \t\t\treturn 3;\n \t\t} else\n \t\t\treturn 0;\n+\tcase '%':\n+\t\tstrbuf_addch(sb, '%');\n+\t\treturn 1;\n \t}\n \n \t/* these depend on the commit */\n-- \n1.6.0.1.346.g880d9.dirty\n"},{"id":"90019","messageId":"1220828741-91050-2-git-send-email-pdebie@ai.rug.nl","threadId":"15336","inReplyTo":"1220828741-91050-1-git-send-email-pdebie@ai.rug.nl","subject":"[PATCH 2/2] builtin-commit: show on which branch a commit was added","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-07T23:05:41Z","receivedAt":"2008-09-07T23:05:41Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"This outputs the current branch on which a commit was created, just for\nreference. For example:\n\n\tCreated commit 6d42875 on master: Fix submodule invalid command error\n\nThis also reminds the committer when he is on a detached HEAD:\n\n\tCreated commit 02a7172 on detached HEAD: Also do this for 'git commit --amend'\n\nSigned-off-by: Pieter de Bie <pdebie@ai.rug.nl>\n---\n builtin-commit.c |   32 ++++++++++++++++++++++++++++++--\n 1 files changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 8165bb3..47b76e6 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -878,10 +878,37 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \treturn commitable ? 0 : 1;\n }\n \n+static char *get_commit_format_string(void)\n+{\n+\tunsigned char sha[20];\n+\tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n+\tstruct strbuf buf = STRBUF_INIT;\n+\n+\tstrbuf_addstr(&buf, \"format:%h\");\n+\n+\t/* Are we on a detached HEAD? */\n+\tif (!strcmp(\"HEAD\", head))\n+\t\tstrbuf_addstr(&buf, \" on detached HEAD\");\n+\telse if (!prefixcmp(head, \"refs/heads/\")) {\n+\t\tconst char *cp;\n+\t\tstrbuf_addstr(&buf, \" on \");\n+\t\tfor (cp = head + 11; *cp; cp++) {\n+\t\t\tif (*cp == '%')\n+\t\t\t\tstrbuf_addstr(&buf, \"%%\");\n+\t\t\telse\n+\t\t\t\tstrbuf_addch(&buf, *cp);\n+\t\t}\n+\t}\n+\tstrbuf_addstr(&buf, \": %s\");\n+\n+\treturn strbuf_detach(&buf, NULL);\n+}\n+\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\n \tstruct commit *commit;\n+\tchar *format = get_commit_format_string();\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit)\n@@ -899,7 +926,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n \trev.verbose_header = 1;\n \trev.show_root_diff = 1;\n-\tget_commit_format(\"format:%h: %s\", &rev);\n+\tget_commit_format(format, &rev);\n \trev.always_show_header = 0;\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n@@ -910,10 +937,11 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tformat_commit_message(commit, \"%h: %s\", &buf, DATE_NORMAL);\n+\t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n \t\tprintf(\"%s\\n\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n+\tfree(format);\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n-- \n1.6.0.1.346.g880d9.dirty\n"},{"id":"91219","messageId":"20080921104238.GA9217@sigill.intra.peff.net","threadId":"15336","inReplyTo":"7vzlmkpltb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-21T10:42:38Z","receivedAt":"2008-09-21T10:42:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Sep 06, 2008 at 10:27:44PM -0700, Junio C Hamano wrote:\n\n> Given the recent \"reminder\" discussion, I suspect people without $PS1 set\n> to show the current branch would like this, majority of others would be\n> neutral, while some may actively hate it for cluttering the output even\n> more.  But I also suspect the initial annoyance the third camp may feel\n> will pass rather quickly after they get used to seeing these.\n\nOK, I have lived with it for a little while, and I am still annoyed. ;)\n\nMy complaints are:\n\n  1. It wastes more horizontal screen real estate, making it more likely\n     that the line will wrap.\n\n  2. In almost all of my projects (including git), I use the subject\n     line convention of \"subsystem: one line summary\". So you end up\n     with the visually confusing:\n\n       Created commit abcd1234 on master: subsystem: one line summary\n\n     which is even worse on a topic branch which is meaningful to the\n     project:\n\n       Created commit abcd1234 on widget: subwidget: one line summary\n\n     which has literally left me scratching my head wondering why I put\n     \"widget\" into the commit message.\n\nMaybe it is better to simply break the line, which solves both problems.\nSomething like:\n\n  Created commit abcd1234 on master:\n   subsystem: do some stuff\n   1 files changes, 1 insertions(+), 0 deletions(-)\n\nTrivial patch is below.\n\n---\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 917f638..53dcde6 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -899,7 +899,7 @@ static char *get_commit_format_string(void)\n \t\t\t\tstrbuf_addch(&buf, *cp);\n \t\t}\n \t}\n-\tstrbuf_addstr(&buf, \": %s\");\n+\tstrbuf_addstr(&buf, \":%n %s\");\n \n \treturn strbuf_detach(&buf, NULL);\n }\n"},{"id":"91877","messageId":"A36A4B61-D223-4821-9969-FA76EAECD1EC@ai.rug.nl","threadId":"15336","inReplyTo":"20080921104238.GA9217@sigill.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-09-29T20:09:17Z","receivedAt":"2008-09-29T20:09:17Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"(Sorry for a late response)\n\nOn 21 sep 2008, at 12:42, Jeff King wrote:\n\n> OK, I have lived with it for a little while, and I am still  \n> annoyed. ;)\n>\n> My complaints are:\n>\n>  1. It wastes more horizontal screen real estate, making it more  \n> likely\n>     that the line will wrap.\n>\n>  2. In almost all of my projects (including git), I use the subject\n>     line convention of \"subsystem: one line summary\". So you end up\n>     with the visually confusing:\n>\n>       Created commit abcd1234 on master: subsystem: one line summary\n>\n>     which is even worse on a topic branch which is meaningful to the\n>     project:\n>\n>       Created commit abcd1234 on widget: subwidget: one line summary\n>\n>     which has literally left me scratching my head wondering why I put\n>     \"widget\" into the commit message.\n\nHow about something like\n\n\tCreated commit abcd1234 on widget -- \"subwidget: one line summary\"\n\n?\n> Maybe it is better to simply break the line, which solves both  \n> problems.\n> Something like:\n\nI don't like a multi-line approach.. I tried it myself, and the second  \nline\nmakes the first line easier to overlook\n\n- Pieter\n"},{"id":"91884","messageId":"20080929224430.GA11545@sigill.intra.peff.net","threadId":"15336","inReplyTo":"A36A4B61-D223-4821-9969-FA76EAECD1EC@ai.rug.nl","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-29T22:44:30Z","receivedAt":"2008-09-29T22:44:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Sep 29, 2008 at 10:09:17PM +0200, Pieter de Bie wrote:\n\n> How about something like\n>\n> \tCreated commit abcd1234 on widget -- \"subwidget: one line summary\"\n\nI think that is probably just trading one visual problem for another.\nThat is, there are other people will have the same problem with \"--\"\nthat I had with \": \".\n\nAnd of course it doesn't deal with the line length issues.\n\nAnyway, I seem to be the only one complaining, so perhaps it should just\nbe left as-is.\n\n-Peff\n"},{"id":"91893","messageId":"48E1C39F.4070906@op5.se","threadId":"15336","inReplyTo":"20080929224430.GA11545@sigill.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-30T06:13:51Z","receivedAt":"2008-09-30T06:13:51Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Mon, Sep 29, 2008 at 10:09:17PM +0200, Pieter de Bie wrote:\n> \n>> How about something like\n>>\n>> \tCreated commit abcd1234 on widget -- \"subwidget: one line summary\"\n> \n> I think that is probably just trading one visual problem for another.\n> That is, there are other people will have the same problem with \"--\"\n> that I had with \": \".\n> \n\nCreated 6207abc (subwidget: one quite long line of sum...) on <branch>\n\n\"commit\" is just noise. Parentheses are often used to extemporize when\nusing normal written language so it should work well here too.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"91894","messageId":"20080930061654.GA14584@sigill.intra.peff.net","threadId":"15336","inReplyTo":"48E1C39F.4070906@op5.se","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-30T06:16:54Z","receivedAt":"2008-09-30T06:16:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 30, 2008 at 08:13:51AM +0200, Andreas Ericsson wrote:\n\n> Created 6207abc (subwidget: one quite long line of sum...) on <branch>\n>\n> \"commit\" is just noise. Parentheses are often used to extemporize when\n> using normal written language so it should work well here too.\n\nI do like that better, and there is some precedent in the way we mention\ncommits in emails (I know Junio even has an alias that formats it as\n$hash ($subject)).\n\nBy your \"...\" are you suggesting to truncate the subject?\n\n-Peff\n"},{"id":"91895","messageId":"836C204F-F5AF-4887-99C9-04E70FEEB998@wincent.com","threadId":"15336","inReplyTo":"48E1C39F.4070906@op5.se","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-09-30T06:37:00Z","receivedAt":"2008-09-30T06:37:00Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 30/9/2008, a las 8:13, Andreas Ericsson escribió:\n\n> Jeff King wrote:\n>> On Mon, Sep 29, 2008 at 10:09:17PM +0200, Pieter de Bie wrote:\n>>> How about something like\n>>>\n>>> \tCreated commit abcd1234 on widget -- \"subwidget: one line summary\"\n>> I think that is probably just trading one visual problem for another.\n>> That is, there are other people will have the same problem with \"--\"\n>> that I had with \": \".\n>\n> Created 6207abc (subwidget: one quite long line of sum...) on <branch>\n>\n> \"commit\" is just noise.\n\nExcellent point on the noise. Independently of whether the branch info  \ngets added the word \"commit\" should probably be dropped.\n\nAs far as long-line-wrapping goes, I don't really think this is a  \nproblem for Git to solve (by truncation or any other means); it's more  \nof a user behaviour thing where one would hope that users would get  \ninto the habit of using concise subject lines and branch names.\n\nCheers,\nWincent\n"},{"id":"91898","messageId":"20080930070938.GA14757@sigill.intra.peff.net","threadId":"15336","inReplyTo":"836C204F-F5AF-4887-99C9-04E70FEEB998@wincent.com","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-09-30T07:09:38Z","receivedAt":"2008-09-30T07:09:38Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 30, 2008 at 08:37:00AM +0200, Wincent Colaiuta wrote:\n\n>> \"commit\" is just noise.\n>\n> Excellent point on the noise. Independently of whether the branch info  \n> gets added the word \"commit\" should probably be dropped.\n\nThe branch info has already been added, if you count it being in next\n(in the form of \"on $branch: \").\n\n> As far as long-line-wrapping goes, I don't really think this is a problem \n> for Git to solve (by truncation or any other means); it's more of a user \n> behaviour thing where one would hope that users would get into the habit \n> of using concise subject lines and branch names.\n\nHow concise must we be? I wrap my commit messages at 60 characters,\nwhich I consider quite conservative. But\n\n  Created commit abcd1234 on jk/my-topic-branch:\n\ntakes up over half of an 80-column terminal. Is that a long branch name?\nBrowsing \"git log --grep=Merge.branch --pretty=format:%s origin/next\"\nsuggests it's not terribly out of line (at least by Junio's standards).\n\nDropping \"commit \" will help some. But given how much width is still\nused, and the fact that this message is really just to say \"yes, I\nconfirm that we just created the commit you asked for\", I think\ntruncating (with dots) to keep it within 80 characters is reasonable.\n\n-Peff\n"},{"id":"91912","messageId":"48E1F54E.20401@op5.se","threadId":"15336","inReplyTo":"20080930061654.GA14584@sigill.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-30T09:45:50Z","receivedAt":"2008-09-30T09:45:50Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Tue, Sep 30, 2008 at 08:13:51AM +0200, Andreas Ericsson wrote:\n> \n>> Created 6207abc (subwidget: one quite long line of sum...) on <branch>\n>>\n>> \"commit\" is just noise. Parentheses are often used to extemporize when\n>> using normal written language so it should work well here too.\n> \n> I do like that better, and there is some precedent in the way we mention\n> commits in emails (I know Junio even has an alias that formats it as\n> $hash ($subject)).\n> \n> By your \"...\" are you suggesting to truncate the subject?\n> \n\nYes, although that can be added later. I'm sending a format fix to the\nlist in a minute or two.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"91913","messageId":"48E1F6F2.5080302@op5.se","threadId":"15336","inReplyTo":"20080930061654.GA14584@sigill.intra.peff.net","subject":"[PATCH] git commit: Reformat output somewhat","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-30T09:52:50Z","receivedAt":"2008-09-30T09:52:50Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Previously, we used to print something along the lines of\n\n\tCreated commit abc9056 on master: Snib the sprock\n\nbut that output was sometimes confusing, as many projects use\nthe \"subsystem: message\" style of commit subjects (just like\nthis commit message does). When such improvements are done on\ntopic-branches, it's not uncommon to name the topic-branch the\nsame as the subsystem, leading to output like this:\n\n\tCreated commit abc9056 on i386: i386: Snib the sprock\n\nwhich doesn't look very nice and can be highly confusing.\nThis patch alters the format so that the noise-word \"commit\"\nis dropped except when it makes the output read better and\nthe commit subject is put inside parentheses. We also\nemphasize the detached case so that users do not overlook it\nin case the commit subject is long enough to extend to the\nnext line. The end result looks thusly:\n\n\tnormal case\n\tCreated abc9056 (i386: Snib the sprock) on i386\n\n\tdetached head\n\tCreated DETACHED commit abc9056 (i386: Snib the sprock)\n\nWhile we're at it, we rename \"initial commit\" to \"root-commit\"\nto align it with the argument to 'git log', producing this:\n\n\tinitial commit\n\tCreated root-commit abc9056 (i386: Snib the sprock) on i386\n\nDocumentation/gittutorial-2.txt is updated accordingly so that\nnew users recognize what they're looking at.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n---\n\nAccording to the few entries in the discussion about showing the\nbranch we're on, this patch should probably go on top of next\nfairly soon.\n\nIf the code-change isn't accepted, let me know and I'll fix the\ndocumentation update to match whatever goes in builtin-commit.c.\n\nFeel free to alter shouty-caps for detached when applying. I have\nno strong opinion either way, as I never commit on detached head\nanyway.\n\nThanks.\n\n Documentation/gittutorial-2.txt |   13 ++++++++-----\n builtin-commit.c                |   12 +++++-------\n 2 files changed, 13 insertions(+), 12 deletions(-)\n\ndiff --git a/Documentation/gittutorial-2.txt b/Documentation/gittutorial-2.txt\nindex 6609046..8484e7a 100644\n--- a/Documentation/gittutorial-2.txt\n+++ b/Documentation/gittutorial-2.txt\n@@ -32,22 +32,25 @@ Initialized empty Git repository in .git/\n $ echo 'hello world' > file.txt\n $ git add .\n $ git commit -a -m \"initial commit\"\n-Created initial commit 54196cc2703dc165cbd373a65a4dcf22d50ae7f7\n+Created root-commit 54196cc (initial commit) on master\n  create mode 100644 file.txt\n $ echo 'hello world!' >file.txt\n $ git commit -a -m \"add emphasis\"\n-Created commit c4d59f390b9cfd4318117afde11d601c1085f241\n+Created c4d59f3 (add emphasis) on master\n ------------------------------------------------\n \n-What are the 40 digits of hex that git responded to the commit with?\n+What are the 7 digits of hex that git responded to the commit with?\n \n We saw in part one of the tutorial that commits have names like this.\n It turns out that every object in the git history is stored under\n-such a 40-digit hex name.  That name is the SHA1 hash of the object's\n+a 40-digit hex name.  That name is the SHA1 hash of the object's\n contents; among other things, this ensures that git will never store\n the same data twice (since identical data is given an identical SHA1\n name), and that the contents of a git object will never change (since\n-that would change the object's name as well).\n+that would change the object's name as well). The 7 char hex strings\n+here are simply the abbreviation of such 40 character long strings.\n+Abbreviations can be used everywhere where the 40 character strings\n+can be used, so long as they are unambiguous.\n \n It is expected that the content of the commit object you created while\n following the example above generates a different SHA1 hash than\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 161128b..f0765cc 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -884,12 +884,11 @@ static char *get_commit_format_string(void)\n \tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tstrbuf_addstr(&buf, \"format:%h\");\n+\t/* use shouty-caps if we're on detached HEAD */\n+\tstrbuf_addf(&buf, \"format:%s\", strcmp(\"HEAD\", head) ? \"\" : \"DETACHED commit\");\n+\tstrbuf_addstr(&buf, \"%h (%s)\");\n \n-\t/* Are we on a detached HEAD? */\n-\tif (!strcmp(\"HEAD\", head))\n-\t\tstrbuf_addstr(&buf, \" on detached HEAD\");\n-\telse if (!prefixcmp(head, \"refs/heads/\")) {\n+\tif (!prefixcmp(head, \"refs/heads/\")) {\n \t\tconst char *cp;\n \t\tstrbuf_addstr(&buf, \" on \");\n \t\tfor (cp = head + 11; *cp; cp++) {\n@@ -899,7 +898,6 @@ static char *get_commit_format_string(void)\n \t\t\t\tstrbuf_addch(&buf, *cp);\n \t\t}\n \t}\n-\tstrbuf_addstr(&buf, \": %s\");\n \n \treturn strbuf_detach(&buf, NULL);\n }\n@@ -933,7 +931,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.diffopt.break_opt = 0;\n \tdiff_setup_done(&rev.diffopt);\n \n-\tprintf(\"Created %scommit \", initial_commit ? \"initial \" : \"\");\n+\tprintf(\"Created %s\", initial_commit ? \"root-commit \" : \"\");\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n-- \n1.6.0.2.529.g37dbc.dirty\n"},{"id":"91915","messageId":"48E1F87D.2010906@op5.se","threadId":"15336","inReplyTo":"20080930070938.GA14757@sigill.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-09-30T09:59:25Z","receivedAt":"2008-09-30T09:59:25Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Tue, Sep 30, 2008 at 08:37:00AM +0200, Wincent Colaiuta wrote:\n> \n>> As far as long-line-wrapping goes, I don't really think this is a problem \n>> for Git to solve (by truncation or any other means); it's more of a user \n>> behaviour thing where one would hope that users would get into the habit \n>> of using concise subject lines and branch names.\n> \n> How concise must we be? I wrap my commit messages at 60 characters,\n> which I consider quite conservative. But\n> \n>   Created commit abcd1234 on jk/my-topic-branch:\n> \n> takes up over half of an 80-column terminal. Is that a long branch name?\n> Browsing \"git log --grep=Merge.branch --pretty=format:%s origin/next\"\n> suggests it's not terribly out of line (at least by Junio's standards).\n> \n> Dropping \"commit \" will help some. But given how much width is still\n> used, and the fact that this message is really just to say \"yes, I\n> confirm that we just created the commit you asked for\", I think\n> truncating (with dots) to keep it within 80 characters is reasonable.\n> \n\nI agree. Obvious solution is to do\n\nsubj_len = term_width - (strlen(cruft) + strlen(branch_name))\n\nwhere strlen(cruft) is just 8 less if we drop 'commit ' from the\ncases. See the patch I just sent though. I sort of like that one.\n\nAnother way would be to write\n<branch>: Created <hash>: \"subject line...\"\n\nAs <hash> will very, very rarely match anything the user would put\nin his/her commit message themselves. Quoting the subject is probably\na nice touch, and it can make sense to put it last as it's the least\ninteresting of the things we print. Ah well. I'll just await commentary\non the patch I've already sent before I go ahead and do something like\nthat.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"92013","messageId":"20081001031400.GA24513@coredump.intra.peff.net","threadId":"15336","inReplyTo":"48E1F87D.2010906@op5.se","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T03:14:01Z","receivedAt":"2008-10-01T03:14:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 30, 2008 at 11:59:25AM +0200, Andreas Ericsson wrote:\n\n> I agree. Obvious solution is to do\n>\n> subj_len = term_width - (strlen(cruft) + strlen(branch_name))\n\nI think the difficulty is that the printing is sometimes done by our\nprintf and sometimes by log_tree_commit, and there isn't a convenient\nway to hook into log_tree_commit to postprocess the formatted output.\n\n> where strlen(cruft) is just 8 less if we drop 'commit ' from the\n> cases. See the patch I just sent though. I sort of like that one.\n\nI like it much better than what is on next (and I thought your commit\nmessage summed up the issue nicely), but...\n\n> Another way would be to write\n> <branch>: Created <hash>: \"subject line...\"\n\nI think I like this even better. My only concern is that many programs\nsay \"program: some error\", so you could potentially have a confusing\nbranch name. But I personally have never used a branch name that would\ncause such confusion.\n\n> As <hash> will very, very rarely match anything the user would put\n> in his/her commit message themselves. Quoting the subject is probably\n> a nice touch, and it can make sense to put it last as it's the least\n> interesting of the things we print. Ah well. I'll just await commentary\n> on the patch I've already sent before I go ahead and do something like\n> that.\n\nHere is a patch for that format on top of next (the patch between this\nand what is in master is even more simple, since we are mostly removing\nPieter's helper function).\n\n---\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex 917f638..9954a81 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -876,41 +876,17 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \trollback_index_files();\n \n \treturn commitable ? 0 : 1;\n }\n \n-static char *get_commit_format_string(void)\n-{\n-\tunsigned char sha[20];\n-\tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n-\tstruct strbuf buf = STRBUF_INIT;\n-\n-\tstrbuf_addstr(&buf, \"format:%h\");\n-\n-\t/* Are we on a detached HEAD? */\n-\tif (!strcmp(\"HEAD\", head))\n-\t\tstrbuf_addstr(&buf, \" on detached HEAD\");\n-\telse if (!prefixcmp(head, \"refs/heads/\")) {\n-\t\tconst char *cp;\n-\t\tstrbuf_addstr(&buf, \" on \");\n-\t\tfor (cp = head + 11; *cp; cp++) {\n-\t\t\tif (*cp == '%')\n-\t\t\t\tstrbuf_addstr(&buf, \"%x25\");\n-\t\t\telse\n-\t\t\t\tstrbuf_addch(&buf, *cp);\n-\t\t}\n-\t}\n-\tstrbuf_addstr(&buf, \": %s\");\n-\n-\treturn strbuf_detach(&buf, NULL);\n-}\n-\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\n \tstruct commit *commit;\n-\tchar *format = get_commit_format_string();\n+\tstatic const char *format = \"format:%h: \\\"%s\\\"\";\n+\tunsigned char junk_sha1[20];\n+\tconst char *head = resolve_ref(\"HEAD\", junk_sha1, 0, NULL);\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit)\n \t\tdie(\"couldn't look up newly created commit\");\n \tif (!commit || parse_commit(commit))\n@@ -931,19 +907,20 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n \trev.diffopt.break_opt = 0;\n \tdiff_setup_done(&rev.diffopt);\n \n-\tprintf(\"Created %scommit \", initial_commit ? \"initial \" : \"\");\n+\tprintf(\"%s%s: created \",\n+\t\t!prefixcmp(head, \"refs/heads/\") ? head + 11 : head,\n+\t\tinitial_commit ? \" (initial)\" : \"\");\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n \t\tprintf(\"%s\\n\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n-\tfree(format);\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n {\n \tif (!strcmp(k, \"commit.template\"))\n"},{"id":"92038","messageId":"48E3312E.4090601@op5.se","threadId":"15336","inReplyTo":"20081001031400.GA24513@coredump.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-10-01T08:13:34Z","receivedAt":"2008-10-01T08:13:34Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Tue, Sep 30, 2008 at 11:59:25AM +0200, Andreas Ericsson wrote:\n> \n>> I agree. Obvious solution is to do\n>>\n>> subj_len = term_width - (strlen(cruft) + strlen(branch_name))\n> \n> I think the difficulty is that the printing is sometimes done by our\n> printf and sometimes by log_tree_commit, and there isn't a convenient\n> way to hook into log_tree_commit to postprocess the formatted output.\n> \n>> where strlen(cruft) is just 8 less if we drop 'commit ' from the\n>> cases. See the patch I just sent though. I sort of like that one.\n> \n> I like it much better than what is on next (and I thought your commit\n> message summed up the issue nicely), but...\n> \n\nThanks. Feel free to recycle it :)\n\n>> Another way would be to write\n>> <branch>: Created <hash>: \"subject line...\"\n> \n> I think I like this even better.\n\nMe too, but I thought it up after I sent out the first patch. The nicest\npart is that the info that's always present will always end up in the\nsame place, while my patch moves the branch-name around depending on\nthe length of the subject line.\n\nLet's agree here and now that the subject should be last and that \"commit \"\nshould be dropped, at least for the normal cases.\n\n> My only concern is that many programs\n> say \"program: some error\", so you could potentially have a confusing\n> branch name. But I personally have never used a branch name that would\n> cause such confusion.\n> \n\nA valid concern, certainly. We needn't use colons for the branch-name\nthough, but could instead use some other delimiter, like this:\n[<branch>] Created <hash>: \"subject line...\"\nalthough I do believe we're close to nitpicking this issue to death\nnow. It's not *that* important after all.\n\n>> As <hash> will very, very rarely match anything the user would put\n>> in his/her commit message themselves. Quoting the subject is probably\n>> a nice touch, and it can make sense to put it last as it's the least\n>> interesting of the things we print. Ah well. I'll just await commentary\n>> on the patch I've already sent before I go ahead and do something like\n>> that.\n> \n> Here is a patch for that format on top of next (the patch between this\n> and what is in master is even more simple, since we are mostly removing\n> Pieter's helper function).\n> \n\nI don't quite like the fact that you're removing the \"detached\" thingie.\nI have coworkers that have been bitten by committing on detached head,\nso I'd like to have some mention of it. I'll rework it to take that\ninto account. Otherwise, this looks good. Less code is always a good\nthing, imo.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"92058","messageId":"20081001151011.GA21310@spearce.org","threadId":"15336","inReplyTo":"48E3312E.4090601@op5.se","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T15:10:11Z","receivedAt":"2008-10-01T15:10:11Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Andreas Ericsson <ae@op5.se> wrote:\n> Jeff King wrote:\n>> On Tue, Sep 30, 2008 at 11:59:25AM +0200, Andreas Ericsson wrote:\n>\n>>> Another way would be to write\n>>> <branch>: Created <hash>: \"subject line...\"\n>>\n>> I think I like this even better.\n>\n> Me too, but I thought it up after I sent out the first patch. The nicest\n> part is that the info that's always present will always end up in the\n> same place, while my patch moves the branch-name around depending on\n> the length of the subject line.\n>\n> Let's agree here and now that the subject should be last and that \"commit \"\n> should be dropped, at least for the normal cases.\n\nActually I rather like the patch you submitted yesterday:\n\n        normal case\n        Created abc9056 (i386: Snib the sprock) on i386\n\n        detached head\n        Created DETACHED commit abc9056 (i386: Snib the sprock)\n\n        initial commit\n        Created root-commit abc9056 (i386: Snib the sprock) on i386\n\nThe detached HEAD and root-commit cases are clearly denoted at the\nvery start of the line, where your eyes are likely to start scanning\nfrom first before you say \"Doh, its just line noise because Git wants\na pat on the back for doing what I asked\".  Thus you are likely\nto notice something out of the ordinary (commit on detached HEAD)\npretty quick.\n\nThe \"<branch>: Created <hash>: subject\" format described above\nhas the problem that a lot of errors look like \"error: foo: bar\"\nand the human eye is probably trained to glance over it.  IMHO its\nformatted too much like an error message line.\n\n>> My only concern is that many programs\n>> say \"program: some error\", so you could potentially have a confusing\n>> branch name. But I personally have never used a branch name that would\n>> cause such confusion.\n>\n> A valid concern, certainly. We needn't use colons for the branch-name\n> though, but could instead use some other delimiter, like this:\n> [<branch>] Created <hash>: \"subject line...\"\n> although I do believe we're close to nitpicking this issue to death\n> now. It's not *that* important after all.\n\nYup, its a bikeshed.\n\nRight now I'm happy with your patch in next.  I don't like taking\nthe paint brush away from folks, but I also don't want to be applying\na ton of commit message reformatting patches over the next week.  ;-)\n\n-- \nShawn.\n"},{"id":"92061","messageId":"20081001151800.GA4962@coredump.intra.peff.net","threadId":"15336","inReplyTo":"48E3312E.4090601@op5.se","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T15:18:01Z","receivedAt":"2008-10-01T15:18:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 01, 2008 at 10:13:34AM +0200, Andreas Ericsson wrote:\n\n> Me too, but I thought it up after I sent out the first patch. The nicest\n> part is that the info that's always present will always end up in the\n> same place, while my patch moves the branch-name around depending on\n> the length of the subject line.\n>\n> Let's agree here and now that the subject should be last and that \"commit \"\n> should be dropped, at least for the normal cases.\n\nYes, I agree that those are the most important aspects, and the rest of\nit is just minor formatting details.\n\n> A valid concern, certainly. We needn't use colons for the branch-name\n> though, but could instead use some other delimiter, like this:\n> [<branch>] Created <hash>: \"subject line...\"\n> although I do believe we're close to nitpicking this issue to death\n> now. It's not *that* important after all.\n\nHeh. Yes, I feel a little silly discussing this so much. But it probably\nis _the_ most frequently seen informational message in git. So not only\ndoes it affect new users' perception of git, but I have to see it every\nday. ;)\n\n> I don't quite like the fact that you're removing the \"detached\" thingie.\n> I have coworkers that have been bitten by committing on detached head,\n> so I'd like to have some mention of it. I'll rework it to take that\n> into account. Otherwise, this looks good. Less code is always a good\n> thing, imo.\n\nI thought the all-caps \"HEAD\" instead of the branch name would make it\nstand out. But given that it isn't the common case, I don't think it is\nthe end of the world to spend a little more screen real estate\nmentioning it.\n\nI am ready to bikeshed the next patch you produce. ;)\n\n-Peff\n"},{"id":"92062","messageId":"48E395BF.5080005@op5.se","threadId":"15336","inReplyTo":"20081001151011.GA21310@spearce.org","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-10-01T15:22:39Z","receivedAt":"2008-10-01T15:22:39Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Shawn O. Pearce wrote:\n> Andreas Ericsson <ae@op5.se> wrote:\n>> Jeff King wrote:\n>>> On Tue, Sep 30, 2008 at 11:59:25AM +0200, Andreas Ericsson wrote:\n>>>> Another way would be to write\n>>>> <branch>: Created <hash>: \"subject line...\"\n>>> I think I like this even better.\n>> Me too, but I thought it up after I sent out the first patch. The nicest\n>> part is that the info that's always present will always end up in the\n>> same place, while my patch moves the branch-name around depending on\n>> the length of the subject line.\n>>\n>> Let's agree here and now that the subject should be last and that \"commit \"\n>> should be dropped, at least for the normal cases.\n> \n> Actually I rather like the patch you submitted yesterday:\n> \n>         normal case\n>         Created abc9056 (i386: Snib the sprock) on i386\n> \n>         detached head\n>         Created DETACHED commit abc9056 (i386: Snib the sprock)\n> \n>         initial commit\n>         Created root-commit abc9056 (i386: Snib the sprock) on i386\n> \n> The detached HEAD and root-commit cases are clearly denoted at the\n> very start of the line, where your eyes are likely to start scanning\n> from first before you say \"Doh, its just line noise because Git wants\n> a pat on the back for doing what I asked\".  Thus you are likely\n> to notice something out of the ordinary (commit on detached HEAD)\n> pretty quick.\n> \n> The \"<branch>: Created <hash>: subject\" format described above\n> has the problem that a lot of errors look like \"error: foo: bar\"\n> and the human eye is probably trained to glance over it.  IMHO its\n> formatted too much like an error message line.\n> \n>>> My only concern is that many programs\n>>> say \"program: some error\", so you could potentially have a confusing\n>>> branch name. But I personally have never used a branch name that would\n>>> cause such confusion.\n>> A valid concern, certainly. We needn't use colons for the branch-name\n>> though, but could instead use some other delimiter, like this:\n>> [<branch>] Created <hash>: \"subject line...\"\n>> although I do believe we're close to nitpicking this issue to death\n>> now. It's not *that* important after all.\n> \n> Yup, its a bikeshed.\n> \n> Right now I'm happy with your patch in next.  I don't like taking\n> the paint brush away from folks, but I also don't want to be applying\n> a ton of commit message reformatting patches over the next week.  ;-)\n> \n\nThanks for putting your foot down. Having thought more about it, I\nwas quite disgusted to realize I spent brain-time on something so\nunimportant.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"92063","messageId":"20081001152546.GB4962@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20081001151011.GA21310@spearce.org","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T15:25:46Z","receivedAt":"2008-10-01T15:25:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 01, 2008 at 08:10:11AM -0700, Shawn O. Pearce wrote:\n\n> Actually I rather like the patch you submitted yesterday:\n> \n>         normal case\n>         Created abc9056 (i386: Snib the sprock) on i386\n> \n>         detached head\n>         Created DETACHED commit abc9056 (i386: Snib the sprock)\n> \n>         initial commit\n>         Created root-commit abc9056 (i386: Snib the sprock) on i386\n> \n> The detached HEAD and root-commit cases are clearly denoted at the\n> very start of the line, where your eyes are likely to start scanning\n> from first before you say \"Doh, its just line noise because Git wants\n> a pat on the back for doing what I asked\".  Thus you are likely\n> to notice something out of the ordinary (commit on detached HEAD)\n> pretty quick.\n\nI agree with your assumption that people scan the line from left to\nright, and that the most important stuff should come first. So that\nformat covers _those_ cases, but not the case of \"oops, I committed on\na different branch than I intended.\" So I think it really makes sense\nto keep the branch name on the left side, and the commit subject last.\n\n> Right now I'm happy with your patch in next.  I don't like taking\n> the paint brush away from folks, but I also don't want to be applying\n> a ton of commit message reformatting patches over the next week.  ;-)\n\nWelcome to maintainership. ;P\n\n-Peff\n"},{"id":"92065","messageId":"20081001153637.GC21310@spearce.org","threadId":"15336","inReplyTo":"20081001152546.GB4962@coredump.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T15:36:37Z","receivedAt":"2008-10-01T15:36:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Wed, Oct 01, 2008 at 08:10:11AM -0700, Shawn O. Pearce wrote:\n> \n> > Actually I rather like the patch you submitted yesterday:\n> > \n> >         normal case\n> >         Created abc9056 (i386: Snib the sprock) on i386\n> > \n> >         detached head\n> >         Created DETACHED commit abc9056 (i386: Snib the sprock)\n> > \n> >         initial commit\n> >         Created root-commit abc9056 (i386: Snib the sprock) on i386\n> > \n> > The detached HEAD and root-commit cases are clearly denoted at the\n> > very start of the line, where your eyes are likely to start scanning\n> \n> I agree with your assumption that people scan the line from left to\n> right, and that the most important stuff should come first. So that\n> format covers _those_ cases, but not the case of \"oops, I committed on\n> a different branch than I intended.\" So I think it really makes sense\n> to keep the branch name on the left side, and the commit subject last.\n\nI briefly considered a format like this while replying above, but\nat prior day-job I used rather long branch names (sometimes with\ncommon prefixes) so it would truncate alot:\n\n  normal case\n  On i386           abc9056 (i386: Snib the sprock)\n\n  detached head\n  On DETACHED HEAD  abc9056 (i386: Snib the sprock)\n\n  initial commit\n  On i386\n  Root commit       abc9056 (i386: Snib the sprock)\n\nWith the branch name field set at about 15 characters and truncated.\nThe initial commit case is very infrequent so burning two lines\nfor it to help make it stand out *and* make the branch name clear\nisn't really a problem.\n \n> > Right now I'm happy with your patch in next.  I don't like taking\n> > the paint brush away from folks, but I also don't want to be applying\n> > a ton of commit message reformatting patches over the next week.  ;-)\n> \n> Welcome to maintainership. ;P\n\n*sigh*  And I just took up the #@*#@!&!*!@ paintbrush myself.\nDammit.  I'm putting it down now.  Really.  :-)\n\n-- \nShawn.\n"},{"id":"92067","messageId":"20081001154205.GD4962@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20081001153637.GC21310@spearce.org","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T15:42:05Z","receivedAt":"2008-10-01T15:42:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 01, 2008 at 08:36:37AM -0700, Shawn O. Pearce wrote:\n\n> I briefly considered a format like this while replying above, but\n> at prior day-job I used rather long branch names (sometimes with\n> common prefixes) so it would truncate alot:\n> \n>   normal case\n>   On i386           abc9056 (i386: Snib the sprock)\n\nI don't like this purely for the reason that it wastes horizontal space,\nwhich is one of the problems that started this discussion.\n\nAlso, there is no verb, which I think is worse. :)\n\n> *sigh*  And I just took up the #@*#@!&!*!@ paintbrush myself.\n> Dammit.  I'm putting it down now.  Really.  :-)\n\nHeh. I don't want to stir up trouble or drag you into a discussion you\ndon't want to be in. But it seems like you are saying \"OK, this is\nsilly, let's just go with what is in next.\" But I think Andreas raised a\ngood point about \"stuff the user should check should go on the left\"\nwhich is not consistent with what is in next. So I just want to confirm\nthat you either disagree with that, or simply think it is not important\nenough to keep the discussion going.\n\n-Peff\n"},{"id":"92068","messageId":"20081001154425.GE21310@spearce.org","threadId":"15336","inReplyTo":"20081001154205.GD4962@coredump.intra.peff.net","subject":"Re: [PATCH] Builtin-commit: show on which branch a commit was added","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-01T15:44:25Z","receivedAt":"2008-10-01T15:44:25Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Wed, Oct 01, 2008 at 08:36:37AM -0700, Shawn O. Pearce wrote:\n> \n> > *sigh*  And I just took up the #@*#@!&!*!@ paintbrush myself.\n> > Dammit.  I'm putting it down now.  Really.  :-)\n> \n> Heh. I don't want to stir up trouble or drag you into a discussion you\n> don't want to be in. But it seems like you are saying \"OK, this is\n> silly, let's just go with what is in next.\" But I think Andreas raised a\n> good point about \"stuff the user should check should go on the left\"\n> which is not consistent with what is in next. So I just want to confirm\n> that you either disagree with that, or simply think it is not important\n> enough to keep the discussion going.\n\nI agree with \"important stuff on the left\".  So as much as I'd like\nto just move on, I guess I'm willing to look at a 3rd patch that\nmoves the branch name onto the left side.\n\n-- \nShawn.\n"},{"id":"92096","messageId":"48E3E66E.7020501@op5.se","threadId":"15336","inReplyTo":"20081001154425.GE21310@spearce.org","subject":"[PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-10-01T21:06:54Z","receivedAt":"2008-10-01T21:06:54Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Since we want the most important information furthest\nleft while at the same time preserving valuable screen\nestate, we move the branch-name to the leftmost side\nof the commit result output. To make it read properly\nwe get rid of \"Created\", which I just can't fit into\na sentence without putting the branch-name last.\n\nHaving taken inspiration from the \"git reset\" command,\noutput for the three conceivable cases now look thus:\n\n  normal commit\n  <branch> is now at b930c4a (i386: Snib the sprock)\n\n  detached commit\n  DETACHED HEAD is now at b930c4a (i386: Snib the sprock)\n\n  initial commit\n  History has begun anew. Root-commit created.\n  <branch> is now at bc930c4a (i386: Snib the sprock)\n\nAs a nice side-effect, we can get rid of the get_commit_format\nhelper function and thereby remove more code than we add.\n\nThis is a substantial rewrite of a patch originally sent by\nJeff King <peff@peff.net>.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n---\n\n\"Created\" is a problem when one wants to put branch-name before the\nsubject line, because the subject has to follow the hash (it doesn't\ndescribe the pre-state of the branch/detached head), but the newly\nadded commit. \"Created, on branch, hash (subject)\" just looks\nstilted and stupid, so I had to change it. Hopefully this can be\naccepted. If not, count me out.\n\nI'm not sure if the last \"else\" case setting branch = head; can\never happen, but I figured it can't hurt to make sure. Feel free\nto modify commentary around it or the entire section when applying.\n\nThis is based on current next (798a2a426a).\n\n builtin-commit.c |   47 ++++++++++++++++++-----------------------------\n 1 files changed, 18 insertions(+), 29 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex e4e1448..3b43344 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -878,35 +878,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \treturn commitable ? 0 : 1;\n }\n \n-static char *get_commit_format_string(void)\n-{\n-\tunsigned char sha[20];\n-\tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n-\tstruct strbuf buf = STRBUF_INIT;\n-\n-\t/* use shouty-caps if we're on detached HEAD */\n-\tstrbuf_addf(&buf, \"format:%s\", strcmp(\"HEAD\", head) ? \"\" : \"DETACHED commit\");\n-\tstrbuf_addstr(&buf, \"%h (%s)\");\n-\n-\tif (!prefixcmp(head, \"refs/heads/\")) {\n-\t\tconst char *cp;\n-\t\tstrbuf_addstr(&buf, \" on \");\n-\t\tfor (cp = head + 11; *cp; cp++) {\n-\t\t\tif (*cp == '%')\n-\t\t\t\tstrbuf_addstr(&buf, \"%x25\");\n-\t\t\telse\n-\t\t\t\tstrbuf_addch(&buf, *cp);\n-\t\t}\n-\t}\n-\n-\treturn strbuf_detach(&buf, NULL);\n-}\n-\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\n \tstruct commit *commit;\n-\tchar *format = get_commit_format_string();\n+\tunsigned char head_sha1[20];\n+\tconst char *branch, *head, *format = \"format:%h (%s)\";\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit)\n@@ -931,15 +908,27 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.diffopt.break_opt = 0;\n \tdiff_setup_done(&rev.diffopt);\n \n-\tprintf(\"Created %s\", initial_commit ? \"root-commit \" : \"\");\n+\t/* a pretty rare occurrance, so let's celebrate it specially */\n+\tif (initial_commit)\n+\t\tprintf(\"History has begun anew. Root-commit created.\\n\");\n+\n+\thead = resolve_ref(\"HEAD\", head_sha1, 0, NULL);\n+\tif (!strcmp(head, \"HEAD\"))\n+\t\tbranch = \"DETACHED HEAD\";\n+\telse if (!prefixcmp(head, \"refs/heads/\"))\n+\t\tbranch = &head[strlen(\"refs/heads/\")];\n+\telse {\n+\t\t/* refs/git-svn, fe */\n+\t\tbranch = head;\n+\t}\n+\n+\tprintf(\"%s is now at \", branch);\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tformat_commit_message(commit, format + 7, &buf, DATE_NORMAL);\n-\t\tprintf(\"%s\\n\", buf.buf);\n-\t\tstrbuf_release(&buf);\n+\t\tprintf(\"%s\\n\", strbuf_detach(&buf, NULL));\n \t}\n-\tfree(format);\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n-- \n1.6.0.2.529.g37dbc.dirty\n"},{"id":"92100","messageId":"20081001220604.GB18058@coredump.intra.peff.net","threadId":"15336","inReplyTo":"48E3E66E.7020501@op5.se","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Jeff King","fromEmail":"jrk@wrek.org","sentAt":"2008-10-01T22:06:04Z","receivedAt":"2008-10-01T22:06:04Z","isPatch":true,"sender":{"key":"jrk@wrek.org","avatar":null},"body":"On Wed, Oct 01, 2008 at 11:06:54PM +0200, Andreas Ericsson wrote:\n\n> of the commit result output. To make it read properly\n> we get rid of \"Created\", which I just can't fit into\n> a sentence without putting the branch-name last.\n\nAll of the other proposals indicate the hash and subject as the object\nof creation. IOW, \"created: <hash>: subject\" or similar.\n\n> Having taken inspiration from the \"git reset\" command,\n> output for the three conceivable cases now look thus:\n>\n>  normal commit\n>  <branch> is now at b930c4a (i386: Snib the sprock)\n\nI think I still like your other proposal:\n\n  [branch] created b930c4a: \"i386: Snib the sprock\"\n\nbetter. But in the interests of just agreeing on something, I am willing\nto accept this. FWIW, the git-reset command doesn't use any delimiter\nfor the message:\n\n   <branch> is now at <hash> <subject>\n\nSo perhaps they should be the same. I don't think it overly matters.\n\n>  detached commit\n>  DETACHED HEAD is now at b930c4a (i386: Snib the sprock)\n\nYou mentioned the shouty caps before. I think \"detached HEAD\" is\nprobably caps enough, but not enough to argue for it (I just want to\nmention as an informal vote if Shawn wants to mark it up while\napplying).\n\n>  initial commit\n>  History has begun anew. Root-commit created.\n>  <branch> is now at bc930c4a (i386: Snib the sprock)\n\nHeh.\n\n> \"Created\" is a problem when one wants to put branch-name before the\n> subject line, because the subject has to follow the hash (it doesn't\n> describe the pre-state of the branch/detached head), but the newly\n> added commit. \"Created, on branch, hash (subject)\" just looks\n> stilted and stupid, so I had to change it. Hopefully this can be\n> accepted. If not, count me out.\n\nThat was the reason for the helper function that was deleted. It\nactually created a format string like \"Created %h on <branch>: %s\" and\nproperly escaped the percents in <branch>. So you would have to keep it\nif you wanted to interleave the data (but I think what you have is\nbetter -- the branch name or the detached status is the thing that\nshould be first).\n\n> I'm not sure if the last \"else\" case setting branch = head; can\n> ever happen, but I figured it can't hurt to make sure. Feel free\n> to modify commentary around it or the entire section when applying.\n\nIt should definitely be there, if only for the sanity of future\nexpansion (and because I can technically put whatever ref I want into\nHEAD :) ).\n\n> -\t\tprintf(\"%s\\n\", buf.buf);\n> -\t\tstrbuf_release(&buf);\n> +\t\tprintf(\"%s\\n\", strbuf_detach(&buf, NULL));\n\nThis change is bogus. \"release\" frees a strbuf. \"detach\" says \"Give me\nthe buffer, and I will take care of freeing it later myself\". So you\nintroduced a leak.\n\n-Peff\n"},{"id":"92101","messageId":"20081001223125.GA25267@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20081001220604.GB18058@coredump.intra.peff.net","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-01T22:31:25Z","receivedAt":"2008-10-01T22:31:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 01, 2008 at 06:06:04PM -0400, Jeff King wrote:\n\n> I think I still like your other proposal:\n> \n>   [branch] created b930c4a: \"i386: Snib the sprock\"\n\nAnd here is the patch, since it was sitting uncommitted in my working\ntree. Feel free to ignore.\n\nBTW, we should apply _something_ since what is currently in next has a\nbug: it lacks a space between \"DETACHED commit\" and the hash:\n\n  Created DETACHED commit4fde0d0 (subject line)\n\n-- >8 --\nreformat informational commit message\n\nWhen committing, we print a message like:\n\n  Created [DETACHED commit] <hash> (<subject>) on <branch>\n\nThe most useful bit of information there (besides the\ndetached status, if it is present) is which branch you made\nthe commit on. However,  it is sometimes hard to see because\nthe subject dominates the line.\n\nInstead, let's put the most useful information (detached\nstatus and commit branch) on the far left, with the subject\n(which is least likely to be interesting) on the far right.\n\nWe'll use brackets to offset the branch name so the line is\nnot mistaken for an error line of the form \"program: some\nsort of error\". E.g.,:\n\n  [jk/bikeshed] created bd8098f: \"reformat informational commit message\"\n---\n builtin-commit.c |   37 ++++++++++---------------------------\n 1 files changed, 10 insertions(+), 27 deletions(-)\n\ndiff --git a/builtin-commit.c b/builtin-commit.c\nindex e4e1448..7a66e5a 100644\n--- a/builtin-commit.c\n+++ b/builtin-commit.c\n@@ -878,35 +878,13 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n \treturn commitable ? 0 : 1;\n }\n \n-static char *get_commit_format_string(void)\n-{\n-\tunsigned char sha[20];\n-\tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n-\tstruct strbuf buf = STRBUF_INIT;\n-\n-\t/* use shouty-caps if we're on detached HEAD */\n-\tstrbuf_addf(&buf, \"format:%s\", strcmp(\"HEAD\", head) ? \"\" : \"DETACHED commit\");\n-\tstrbuf_addstr(&buf, \"%h (%s)\");\n-\n-\tif (!prefixcmp(head, \"refs/heads/\")) {\n-\t\tconst char *cp;\n-\t\tstrbuf_addstr(&buf, \" on \");\n-\t\tfor (cp = head + 11; *cp; cp++) {\n-\t\t\tif (*cp == '%')\n-\t\t\t\tstrbuf_addstr(&buf, \"%x25\");\n-\t\t\telse\n-\t\t\t\tstrbuf_addch(&buf, *cp);\n-\t\t}\n-\t}\n-\n-\treturn strbuf_detach(&buf, NULL);\n-}\n-\n static void print_summary(const char *prefix, const unsigned char *sha1)\n {\n \tstruct rev_info rev;\n \tstruct commit *commit;\n-\tchar *format = get_commit_format_string();\n+\tstatic const char *format = \"format:%h: \\\"%s\\\"\";\n+\tunsigned char junk_sha1[20];\n+\tconst char *head = resolve_ref(\"HEAD\", junk_sha1, 0, NULL);\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit)\n@@ -931,7 +909,13 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.diffopt.break_opt = 0;\n \tdiff_setup_done(&rev.diffopt);\n \n-\tprintf(\"Created %s\", initial_commit ? \"root-commit \" : \"\");\n+\tprintf(\"[%s%s]: created \",\n+\t\t!prefixcmp(head, \"refs/heads/\") ?\n+\t\t\thead + 11 :\n+\t\t\t!strcmp(head, \"HEAD\") ?\n+\t\t\t\t\"detached HEAD\" :\n+\t\t\t\thead,\n+\t\tinitial_commit ? \" (root-commit)\" : \"\");\n \n \tif (!log_tree_commit(&rev, commit)) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n@@ -939,7 +923,6 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \t\tprintf(\"%s\\n\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n-\tfree(format);\n }\n \n static int git_commit_config(const char *k, const char *v, void *cb)\n-- \n1.6.0.2.570.g2c958\n"},{"id":"92114","messageId":"48E45ECC.8070104@op5.se","threadId":"15336","inReplyTo":"20081001223125.GA25267@coredump.intra.peff.net","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-10-02T05:40:28Z","receivedAt":"2008-10-02T05:40:28Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jeff King wrote:\n> On Wed, Oct 01, 2008 at 06:06:04PM -0400, Jeff King wrote:\n> \n>> I think I still like your other proposal:\n>>\n>>   [branch] created b930c4a: \"i386: Snib the sprock\"\n> \n> And here is the patch, since it was sitting uncommitted in my working\n> tree. Feel free to ignore.\n> \n> BTW, we should apply _something_ since what is currently in next has a\n> bug: it lacks a space between \"DETACHED commit\" and the hash:\n> \n>   Created DETACHED commit4fde0d0 (subject line)\n> \n> -- >8 --\n> reformat informational commit message\n> \n> When committing, we print a message like:\n> \n>   Created [DETACHED commit] <hash> (<subject>) on <branch>\n> \n> The most useful bit of information there (besides the\n> detached status, if it is present) is which branch you made\n> the commit on. However,  it is sometimes hard to see because\n> the subject dominates the line.\n> \n> Instead, let's put the most useful information (detached\n> status and commit branch) on the far left, with the subject\n> (which is least likely to be interesting) on the far right.\n> \n> We'll use brackets to offset the branch name so the line is\n> not mistaken for an error line of the form \"program: some\n> sort of error\". E.g.,:\n> \n>   [jk/bikeshed] created bd8098f: \"reformat informational commit message\"\n> ---\n\nNo sign-off.\n\n>  builtin-commit.c |   37 ++++++++++---------------------------\n>  1 files changed, 10 insertions(+), 27 deletions(-)\n> \n> diff --git a/builtin-commit.c b/builtin-commit.c\n> index e4e1448..7a66e5a 100644\n> --- a/builtin-commit.c\n> +++ b/builtin-commit.c\n> @@ -878,35 +878,13 @@ int cmd_status(int argc, const char **argv, const char *prefix)\n>  \treturn commitable ? 0 : 1;\n>  }\n>  \n> -static char *get_commit_format_string(void)\n> -{\n> -\tunsigned char sha[20];\n> -\tconst char *head = resolve_ref(\"HEAD\", sha, 0, NULL);\n> -\tstruct strbuf buf = STRBUF_INIT;\n> -\n> -\t/* use shouty-caps if we're on detached HEAD */\n> -\tstrbuf_addf(&buf, \"format:%s\", strcmp(\"HEAD\", head) ? \"\" : \"DETACHED commit\");\n> -\tstrbuf_addstr(&buf, \"%h (%s)\");\n> -\n> -\tif (!prefixcmp(head, \"refs/heads/\")) {\n> -\t\tconst char *cp;\n> -\t\tstrbuf_addstr(&buf, \" on \");\n> -\t\tfor (cp = head + 11; *cp; cp++) {\n> -\t\t\tif (*cp == '%')\n> -\t\t\t\tstrbuf_addstr(&buf, \"%x25\");\n> -\t\t\telse\n> -\t\t\t\tstrbuf_addch(&buf, *cp);\n> -\t\t}\n> -\t}\n> -\n> -\treturn strbuf_detach(&buf, NULL);\n> -}\n> -\n>  static void print_summary(const char *prefix, const unsigned char *sha1)\n>  {\n>  \tstruct rev_info rev;\n>  \tstruct commit *commit;\n> -\tchar *format = get_commit_format_string();\n> +\tstatic const char *format = \"format:%h: \\\"%s\\\"\";\n> +\tunsigned char junk_sha1[20];\n> +\tconst char *head = resolve_ref(\"HEAD\", junk_sha1, 0, NULL);\n>  \n>  \tcommit = lookup_commit(sha1);\n>  \tif (!commit)\n> @@ -931,7 +909,13 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n>  \trev.diffopt.break_opt = 0;\n>  \tdiff_setup_done(&rev.diffopt);\n>  \n> -\tprintf(\"Created %s\", initial_commit ? \"root-commit \" : \"\");\n> +\tprintf(\"[%s%s]: created \",\n> +\t\t!prefixcmp(head, \"refs/heads/\") ?\n> +\t\t\thead + 11 :\n> +\t\t\t!strcmp(head, \"HEAD\") ?\n> +\t\t\t\t\"detached HEAD\" :\n> +\t\t\t\thead,\n> +\t\tinitial_commit ? \" (root-commit)\" : \"\");\n>  \n\nPersonally, I'm not overly fond of things like\n   something ? yay : nay_but_try ? worked_now : still_no_go\nsince I find them hard to read without thinking a lot.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"92117","messageId":"FDB56497-8600-40DA-994D-7A519B0BABE3@wincent.com","threadId":"15336","inReplyTo":"20081001220604.GB18058@coredump.intra.peff.net","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-10-02T08:36:31Z","receivedAt":"2008-10-02T08:36:31Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 2/10/2008, a las 0:06, Jeff King escribió:\n\n> better. But in the interests of just agreeing on something, I am  \n> willing\n> to accept this. FWIW, the git-reset command doesn't use any delimiter\n> for the message:\n>\n>   <branch> is now at <hash> <subject>\n>\n> So perhaps they should be the same. I don't think it overly matters.\n\nIf you're wanting to trim horizontal fat then the \"is\" isn't really  \nrequired.\n\n<branch> now at <hash> <subject>\n\nReads just as well.\n\nCheers,\nWincent\n"},{"id":"92201","messageId":"20081002211309.GB29480@coredump.intra.peff.net","threadId":"15336","inReplyTo":"48E45ECC.8070104@op5.se","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-02T21:13:09Z","receivedAt":"2008-10-02T21:13:09Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 02, 2008 at 07:40:28AM +0200, Andreas Ericsson wrote:\n\n> No sign-off.\n\nSorry, mistakenly omitted.\n\nSigned-off-by: Jeff King <peff@peff.net>\n\n>> +\tprintf(\"[%s%s]: created \",\n>> +\t\t!prefixcmp(head, \"refs/heads/\") ?\n>> +\t\t\thead + 11 :\n>> +\t\t\t!strcmp(head, \"HEAD\") ?\n>> +\t\t\t\t\"detached HEAD\" :\n>> +\t\t\t\thead,\n>> +\t\tinitial_commit ? \" (root-commit)\" : \"\");\n>>  \n>\n> Personally, I'm not overly fond of things like\n>   something ? yay : nay_but_try ? worked_now : still_no_go\n> since I find them hard to read without thinking a lot.\n\nHmm, I find them more readable. :) And often easier to visually see that\nno matter what happens, the result has _some_ value (whereas with\nif/else, you have to make sure that all branchs set the value).  But I\nam happy to change it to:\n\n  const char *branch;\n  ...\n\n  if (!prefixcmp(head, \"refs/heads/\"))\n          branch = head + 11;\n  else if (!strcmp(head, \"HEAD\"))\n          branch = \"detached HEAD\";\n  else\n          branch = head;\n\nHowever, I found your mail somewhat unexpected. Rather than comments on\nthe code, I expected rather \"yes, I do like this better\" or \"no, I think\nwe should go with the other one.\" But maybe you are just sick of\nweighing in. ;)\n\n-Peff\n"},{"id":"92208","messageId":"20081003001556.GS21310@spearce.org","threadId":"15336","inReplyTo":"20081002211309.GB29480@coredump.intra.peff.net","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-03T00:15:56Z","receivedAt":"2008-10-03T00:15:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Thu, Oct 02, 2008 at 07:40:28AM +0200, Andreas Ericsson wrote:\n> > [... many many many many many things about paints ...]\n\nI think painting is over for now.  Time to let the paint dry.\nI applied Jeff's patch:\n\n  [jk/bikeshed] created bd8098f: \"reformat informational commit message\"\n\n-- \nShawn.\n"},{"id":"92218","messageId":"20081003042405.GB1839@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20081003001556.GS21310@spearce.org","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-03T04:24:05Z","receivedAt":"2008-10-03T04:24:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 02, 2008 at 05:15:56PM -0700, Shawn O. Pearce wrote:\n\n> I think painting is over for now.  Time to let the paint dry.\n> I applied Jeff's patch:\n> \n>   [jk/bikeshed] created bd8098f: \"reformat informational commit message\"\n\nWoo! Victory by attrition!\n\n-Peff\n"},{"id":"92250","messageId":"20081003140951.GU21310@spearce.org","threadId":"15336","inReplyTo":"20081003042405.GB1839@coredump.intra.peff.net","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-03T14:09:52Z","receivedAt":"2008-10-03T14:09:52Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jeff King <peff@peff.net> wrote:\n> On Thu, Oct 02, 2008 at 05:15:56PM -0700, Shawn O. Pearce wrote:\n> \n> > I think painting is over for now.  Time to let the paint dry.\n> > I applied Jeff's patch:\n> > \n> >   [jk/bikeshed] created bd8098f: \"reformat informational commit message\"\n> \n> Woo! Victory by attrition!\n\nI think the hard part now is to get the user docs updated to reflect\nthe new format.  We need to get that done before this can merge\nover to master.\n\n-- \nShawn.\n"},{"id":"92286","messageId":"20081004021349.GA4030@coredump.intra.peff.net","threadId":"15336","inReplyTo":"20081003140951.GU21310@spearce.org","subject":"Re: [PATCH] git commit: Repaint the output format bikeshed (again)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-04T02:13:49Z","receivedAt":"2008-10-04T02:13:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 03, 2008 at 07:09:52AM -0700, Shawn O. Pearce wrote:\n\n> I think the hard part now is to get the user docs updated to reflect\n> the new format.  We need to get that done before this can merge\n> over to master.\n\nGrepping only turned up the two instances that Andreas had changed for\nhis patch, so I think that is probably it. Here's the patch.\n\n-- >8 --\ntutorial: update output of git commit\n\nCommit c85db254 changed the format of the message produced\nby \"git commit\" when creating a commit. This patch updates\nthe example session in the tutorial to the new format.\n\nIt also adds in the missing diffstat summary lines, which\nshould have been added long ago.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n Documentation/gittutorial-2.txt |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/gittutorial-2.txt b/Documentation/gittutorial-2.txt\nindex 8484e7a..bab0f34 100644\n--- a/Documentation/gittutorial-2.txt\n+++ b/Documentation/gittutorial-2.txt\n@@ -32,11 +32,13 @@ Initialized empty Git repository in .git/\n $ echo 'hello world' > file.txt\n $ git add .\n $ git commit -a -m \"initial commit\"\n-Created root-commit 54196cc (initial commit) on master\n+[master (root-commit)] created 54196cc: \"initial commit\"\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n  create mode 100644 file.txt\n $ echo 'hello world!' >file.txt\n $ git commit -a -m \"add emphasis\"\n-Created c4d59f3 (add emphasis) on master\n+[master] created c4d59f3: \"add emphasis\"\n+ 1 files changed, 1 insertions(+), 1 deletions(-)\n ------------------------------------------------\n \n What are the 7 digits of hex that git responded to the commit with?\n-- \n1.6.0.2.636.gaa7b\n"}]}