{"thread":{"id":"37424","subject":"[RFC] add detached HEAD to --all listing","startedAt":"2014-08-27T14:18:21Z","lastAt":"2014-09-03T16:18:56Z","messageCount":8,"participants":["Max Kirillov","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"248398","messageId":"CAF7_NFRKzU0_5Eq4kgtW3RChW3z5q8QBjWvvN+TSyOhORkf8hQ@mail.gmail.com","threadId":"37424","inReplyTo":null,"subject":"[RFC] add detached HEAD to --all listing","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2014-08-27T14:18:21Z","receivedAt":"2014-08-27T14:18:21Z","isPatch":false,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"Hello.\n\nCould HEAD be added to list of heads while using --all switch?\nDetached heads are not something very unusual and incorrect, in\nsubmodules for example, or for some scripts. Having to specify it\nadditionally when I meet such checkout feels like some flaw.\n\nWhat are opinions on that, could it be changed?\n\n-- \nMax\n"},{"id":"248400","messageId":"20140827142249.GC31879@peff.net","threadId":"37424","inReplyTo":"CAF7_NFRKzU0_5Eq4kgtW3RChW3z5q8QBjWvvN+TSyOhORkf8hQ@mail.gmail.com","subject":"Re: [RFC] add detached HEAD to --all listing","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-08-27T14:22:50Z","receivedAt":"2014-08-27T14:22:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 27, 2014 at 05:18:21PM +0300, Max Kirillov wrote:\n\n> Could HEAD be added to list of heads while using --all switch?\n\nTo which command?\n\nIf you mean \"git branch\", I think the detached HEAD is already\nmentioned:\n\n  $ git branch\n  * (detached from 1290ebd)\n    master\n\nIf you mean \"git log\", I think it is included there, too:\n\n  $ git log --decorate --oneline --all\n  685450f (HEAD) more\n  1290ebd (master) foo\n\nIs there some other command you have in mind? git-push, maybe?\n\n-Peff\n"},{"id":"248401","messageId":"CAF7_NFRz6Zc-wTDSFdkW4N2wRATZ8-g05j6sFu1t7DB0X72dkg@mail.gmail.com","threadId":"37424","inReplyTo":"20140827142249.GC31879@peff.net","subject":"Re: [RFC] add detached HEAD to --all listing","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2014-08-27T14:33:00Z","receivedAt":"2014-08-27T14:33:00Z","isPatch":false,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"On Wed, Aug 27, 2014 at 5:22 PM, Jeff King <peff@peff.net> wrote:\n> If you mean \"git log\", I think it is included there, too:\n>\n>   $ git log --decorate --oneline --all\n>   685450f (HEAD) more\n>   1290ebd (master) foo\n\nI meant \"git log\", did not know it's there. Where I actually would\nlike to see it in gitk --all, apparently it performs its own\nfiltering.\n\nThanks.\n\n-- \nMax\n"},{"id":"248668","messageId":"1409437488-25233-1-git-send-email-max@max630.net","threadId":"37424","inReplyTo":"CAF7_NFRz6Zc-wTDSFdkW4N2wRATZ8-g05j6sFu1t7DB0X72dkg@mail.gmail.com","subject":"[PATCH] rev-parse: include HEAD in --all output","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2014-08-30T22:24:48Z","receivedAt":"2014-08-30T22:24:48Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"for_each_ref() does not include it itself, and without the hash\nthe detached HEAD may be missed by some frontends (like gitk).\n\nAdd test which verifies the head is returned\n\nUpdate test t6018-rev-list-glob.sh which relied on exact list of\nreturned hashes.\n\nSigned-off-by: Max Kirillov <max@max630.net>\n---\n builtin/rev-parse.c           |  1 +\n t/t1514-rev-parse-detached.sh | 21 +++++++++++++++++++++\n t/t6018-rev-list-glob.sh      |  4 ++--\n 3 files changed, 24 insertions(+), 2 deletions(-)\n create mode 100755 t/t1514-rev-parse-detached.sh\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex d85e08c..42f468c 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -642,6 +642,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--all\")) {\n+\t\t\t\thead_ref(show_reference, NULL);\n \t\t\t\tfor_each_ref(show_reference, NULL);\n \t\t\t\tcontinue;\n \t\t\t}\ndiff --git a/t/t1514-rev-parse-detached.sh b/t/t1514-rev-parse-detached.sh\nnew file mode 100755\nindex 0000000..eeb2318\n--- /dev/null\n+++ b/t/t1514-rev-parse-detached.sh\n@@ -0,0 +1,21 @@\n+#!/bin/sh\n+\n+test_description='test git rev-parse references'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'make repo' '\n+\tgit commit --allow-empty -m commit1 &&\n+\tgit commit --allow-empty -m commit2 &&\n+\tgit checkout  --detach master &&\n+\tgit commit --allow-empty -m commit3\n+'\n+\n+head_sha1=`git rev-parse HEAD`\n+\n+test_expect_success 'HEAD should be listed in rev-parse --all' '\n+\tgit rev-parse --all >all_refs &&\n+\tgrep -q \"$head_sha1\" all_refs\n+'\n+\n+test_done\ndiff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh\nindex d00f7db..ba0b89c 100755\n--- a/t/t6018-rev-list-glob.sh\n+++ b/t/t6018-rev-list-glob.sh\n@@ -134,11 +134,11 @@ test_expect_success 'rev-parse --exclude with --branches' '\n '\n \n test_expect_success 'rev-parse --exclude with --all' '\n-\tcompare rev-parse \"--exclude=refs/remotes/* --all\" \"--branches --tags\"\n+\tcompare rev-parse \"--exclude=refs/remotes/* --all\" \"HEAD --branches --tags\"\n '\n \n test_expect_success 'rev-parse accumulates multiple --exclude' '\n-\tcompare rev-parse \"--exclude=refs/remotes/* --exclude=refs/tags/* --all\" --branches\n+\tcompare rev-parse \"--exclude=refs/remotes/* --exclude=refs/tags/* --all\" \"HEAD --branches\"\n '\n \n test_expect_success 'rev-list --glob=refs/heads/subspace/*' '\n-- \n2.0.1.1697.g73c6810\n"},{"id":"248686","messageId":"20140831153054.GD17449@peff.net","threadId":"37424","inReplyTo":"1409437488-25233-1-git-send-email-max@max630.net","subject":"Re: [PATCH] rev-parse: include HEAD in --all output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-08-31T15:30:54Z","receivedAt":"2014-08-31T15:30:54Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Aug 31, 2014 at 01:24:48AM +0300, Max Kirillov wrote:\n\n> for_each_ref() does not include it itself, and without the hash\n> the detached HEAD may be missed by some frontends (like gitk).\n> \n> Add test which verifies the head is returned\n> \n> Update test t6018-rev-list-glob.sh which relied on exact list of\n> returned hashes.\n\nI think the missing bit of the justification here is that \"--all\" _does_\ninclude HEAD in other contexts (like in git-log), and rev-parse should\nprobably match it.\n\nThis is probably the right thing to do. It's possible that some caller\nof rev-parse really depends on \"--all\" meaning \"just the refs\", but I\nkind of doubt it. Being in sync with the revision.c parser seems saner.\n\n-Peff\n"},{"id":"248694","messageId":"20140831213606.GB6385@wheezy.local","threadId":"37424","inReplyTo":"20140831153054.GD17449@peff.net","subject":"Re: [PATCH] rev-parse: include HEAD in --all output","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2014-08-31T21:36:06Z","receivedAt":"2014-08-31T21:36:06Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"On Sun, Aug 31, 2014 at 11:30:54AM -0400, Jeff King wrote:\n> On Sun, Aug 31, 2014 at 01:24:48AM +0300, Max Kirillov wrote:\n> \n>> for_each_ref() does not include it itself, and without\n>> the hash the detached HEAD may be missed by some\n>> frontends (like gitk).\n>> \n>> Add test which verifies the head is returned\n>> \n>> Update test t6018-rev-list-glob.sh which relied on exact\n>> list of returned hashes.\n> \n> I think the missing bit of the justification here is that\n> \"--all\" _does_ include HEAD in other contexts (like in\n> git-log), and rev-parse should probably match it.\n> \n> This is probably the right thing to do. It's possible that\n> some caller of rev-parse really depends on \"--all\" meaning\n> \"just the refs\", but I kind of doubt it. Being in sync\n> with the revision.c parser seems saner.\n\nActually, yes, this is a bit incompatible change, and while\nI'm pretty sure that rev-parse returning hashes should\ninclude detached HEAD, returning HEAD when it's called with\nsomething like \"--symbolic\" might be questioned. It could\ndepend on the output mode (add HEAD only if printing hashes)\nbut this kind of logic does not look good. So maybe some\nmore opinions should be asked for.\n\nbtw, manpage for git-rev-parse says \"Show all refs found in\nrefs/.\", should it also be changed?\n\n-- \nMax\n"},{"id":"248716","messageId":"xmqqsika2c2i.fsf@gitster.dls.corp.google.com","threadId":"37424","inReplyTo":"20140831213606.GB6385@wheezy.local","subject":"Re: [PATCH] rev-parse: include HEAD in --all output","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-09-02T16:59:17Z","receivedAt":"2014-09-02T16:59:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Max Kirillov <max@max630.net> writes:\n\n> btw, manpage for git-rev-parse says \"Show all refs found in\n> refs/.\", should it also be changed?\n\nI would rather see \"rev-parse --all\" not to include HEAD, especially\nif it has been documented that way.\n"},{"id":"248789","messageId":"20140903161856.GC6385@wheezy.local","threadId":"37424","inReplyTo":"xmqqsika2c2i.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] rev-parse: include HEAD in --all output","fromName":"Max Kirillov","fromEmail":"max@max630.net","sentAt":"2014-09-03T16:18:56Z","receivedAt":"2014-09-03T16:18:56Z","isPatch":true,"sender":{"key":"max@max630.net","avatar":"https://avatars.githubusercontent.com/u/381560?v=4"},"body":"On Tue, Sep 02, 2014 at 09:59:17AM -0700, Junio C Hamano wrote:\n> \n> I would rather see \"rev-parse --all\" not to include HEAD,\n> especially if it has been documented that way.\n\nOk, then probably I'll want to change it in gitk.\n\nBut, with the \"multiple working trees\" feature, I would also\nwant to get other HEADs in view, even if they are detached.\nI could add it to --all when it returns detached HEAD (like\nin git-rev-list), but if it does not, probably some\nnew dedicated option should be for that purpose. Something\nlike \"git rev-parse --heads\", for example.\n\n-- \nMax\n"}]}