{"thread":{"id":"15224","subject":"git-shortlog hangs on bare repo without --bare option","startedAt":"2008-08-27T19:52:33Z","lastAt":"2008-08-28T07:16:07Z","messageCount":12,"participants":["Garry Dolley","Junio C Hamano","René Scharfe","Jeff King","Nguyen Thai Ngoc Duy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"88768","messageId":"20080827195233.GA2477@garry-thinkpad.arpnetworks.com","threadId":"15224","inReplyTo":null,"subject":"git-shortlog hangs on bare repo without --bare option","fromName":"Garry Dolley","fromEmail":"gdolley@arpnetworks.com","sentAt":"2008-08-27T19:52:33Z","receivedAt":"2008-08-27T19:52:33Z","isPatch":false,"sender":{"key":"gdolley@ucla.edu","avatar":"https://gravatar.com/avatar/b9ca98e2d5fd3a993ad695e8315f078b7ae364d2d1b637a6adecf8953a034dd2?d=mp&s=160"},"body":"I didn't see this happen with git 1.5.x, but if you do git-shortlog on a bare \nrepo, without specifying --bare, the command will seemingly hang indefinitely.\n\nHere's my output:\n\n[garry@garry-thinkpad] ~/dev (master) $ cd ebay4r/                       <----- Repo with working tree (non-bare)\n[garry@garry-thinkpad] ~/dev/ebay4r (master) $ git shortlog -e -s\n   130  Garry Dolley <gdolley@arpnetworks.com>\n[garry@garry-thinkpad] ~/dev/ebay4r (master) $ cd ..\n[garry@garry-thinkpad] ~/dev (master) $ git clone --mirror ebay4r/ ebay4r-bare\nInitialized empty Git repository in /home/garry/dev/ebay4r-bare/\n[garry@garry-thinkpad] ~/dev (master) $ cd ebay4r-bare/\n[garry@garry-thinkpad] ~/dev/ebay4r-bare (master) $ git shortlog -e -s\n<hang>                                                                   <----- *** It hangs here ***\n\n[garry@garry-thinkpad] ~/dev/ebay4r-bare (master) $ git --bare shortlog -e -s\n   130  Garry Dolley <gdolley@arpnetworks.com>\n[garry@garry-thinkpad] ~/dev/ebay4r-bare (master) $ \n\n\nIf newlines break this output in your reader, you can also view it \nhere: http://pastie.org/261134\n\nI'm using git 1.6.0.1\n\nIs this a bug?\n\n-- \nGarry Dolley\nARP Networks, Inc.\n818-206-0181\nLos Angeles County REACT, Unit 336\nWQGK336\n"},{"id":"88776","messageId":"7vtzd6nqqo.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"20080827195233.GA2477@garry-thinkpad.arpnetworks.com","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T20:32:31Z","receivedAt":"2008-08-27T20:32:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Garry Dolley <gdolley@arpnetworks.com> writes:\n\n> [garry@garry-thinkpad] ~/dev/ebay4r-bare (master) $ git shortlog -e -s\n> <hang>                                                                   <----- *** It hangs here ***\n\nTryp typing ^D here.  I think it is operating in the filter mode.\n"},{"id":"88786","messageId":"20080827212148.GA7952@garry-thinkpad.arpnetworks.com","threadId":"15224","inReplyTo":"7vtzd6nqqo.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Garry Dolley","fromEmail":"gdolley@arpnetworks.com","sentAt":"2008-08-27T21:21:49Z","receivedAt":"2008-08-27T21:21:49Z","isPatch":false,"sender":{"key":"gdolley@ucla.edu","avatar":"https://gravatar.com/avatar/b9ca98e2d5fd3a993ad695e8315f078b7ae364d2d1b637a6adecf8953a034dd2?d=mp&s=160"},"body":"On Wed, Aug 27, 2008 at 01:32:31PM -0700, Junio C Hamano wrote:\n> Garry Dolley <gdolley@arpnetworks.com> writes:\n> \n> > [garry@garry-thinkpad] ~/dev/ebay4r-bare (master) $ git shortlog -e -s\n> > <hang>                                                                   <----- *** It hangs here ***\n> \n> Tryp typing ^D here.  I think it is operating in the filter mode.\n\nYeah, ^D just gets me back to the prompt, no output.  It does indeed\nseem to be waiting for something.\n\n-- \nGarry Dolley\nhttp://scie.nti.st\n"},{"id":"88790","messageId":"48B5C9E4.4030807@lsrfire.ath.cx","threadId":"15224","inReplyTo":"20080827195233.GA2477@garry-thinkpad.arpnetworks.com","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2008-08-27T21:40:52Z","receivedAt":"2008-08-27T21:40:52Z","isPatch":false,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Garry Dolley schrieb:\n> I didn't see this happen with git 1.5.x, but if you do git-shortlog on a bare \n> repo, without specifying --bare, the command will seemingly hang indefinitely.\n\nFWIW, I tried git 1.5.0 and it hangs, too.  Which exact version did work\nfor you?  Could you, based on it, bisect the commit that introduced this\nbehaviour?\n\nAs a workaround, you can use \"git log | git shortlog\".\n\nRené\n"},{"id":"88799","messageId":"20080827221544.GA12459@garry-thinkpad.arpnetworks.com","threadId":"15224","inReplyTo":"48B5C9E4.4030807@lsrfire.ath.cx","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Garry Dolley","fromEmail":"gdolley@arpnetworks.com","sentAt":"2008-08-27T22:15:45Z","receivedAt":"2008-08-27T22:15:45Z","isPatch":false,"sender":{"key":"gdolley@ucla.edu","avatar":"https://gravatar.com/avatar/b9ca98e2d5fd3a993ad695e8315f078b7ae364d2d1b637a6adecf8953a034dd2?d=mp&s=160"},"body":"On Wed, Aug 27, 2008 at 11:40:52PM +0200, Ren?? Scharfe wrote:\n> Garry Dolley schrieb:\n> > I didn't see this happen with git 1.5.x, but if you do git-shortlog on a bare \n> > repo, without specifying --bare, the command will seemingly hang indefinitely.\n> \n> FWIW, I tried git 1.5.0 and it hangs, too.  Which exact version did work\n> for you?  Could you, based on it, bisect the commit that introduced this\n> behaviour?\n\nI just tried it with 1.5.6.2, and it hung.  Unfortunately, I had\nseveral versions of git inside my ~/src as I upgraded over the\nmonths, and just last week I decided to blow away the old ones, so I\ndon't know what version it was that I saw this work. :(\n\nEither way, it's too big a deal, I just wanted to point out what I\nsaw.\n\nIf it helps, this is the last few lines of strace before it hangs:\n\nstat(\".git\", 0x7fff6e44dd90)            = -1 ENOENT (No such file or directory)\nopen(\".git/config\", O_RDONLY)           = -1 ENOENT (No such file or directory)\npipe([3, 4])                            = 0\nclone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f7a6642d790) = 12674\ndup2(3, 0)                              = 0\nclose(3)                                = 0\nclose(4)                                = 0\nselect(1, [0], NULL, [0], NULL\n\nSo looks like it is waiting to be fed some input?  It's hungry :)\n\n> As a workaround, you can use \"git log | git shortlog\".\n\nAlso, 'git --bare shortlog' works too.\n\n-- \nGarry Dolley\nhttp://scie.nti.st\nARP Networks, Inc.\n818-206-0181\nLos Angeles County REACT, Unit 336\nWQGK336\n"},{"id":"88800","messageId":"7vvdxmm78o.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"48B5C9E4.4030807@lsrfire.ath.cx","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T22:19:03Z","receivedAt":"2008-08-27T22:19:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Garry Dolley schrieb:\n>> I didn't see this happen with git 1.5.x, but if you do git-shortlog on a bare \n>> repo, without specifying --bare, the command will seemingly hang indefinitely.\n>\n> FWIW, I tried git 1.5.0 and it hangs, too.  Which exact version did work\n> for you?  Could you, based on it, bisect the commit that introduced this\n> behaviour?\n>\n> As a workaround, you can use \"git log | git shortlog\".\n\nIt is not a workaround.  Shortlog can work as a filter to \"git log\", but\nif you give revs to work on, e.g. \"git shortlog -s -n v1.5.6.5..\" or \"git\nshortlog HEAD\", it can generate the log and feed to itself.\n\nSomehow it (perhaps incorrectly, I did not look at the command line input)\njudging that your command line is telling it not to do the log generation\nitself but instead you will feed the log from its standard input, which\nhappens to be your terminal.  So another workaround would be to type the\nseries of log messages ;-)\n"},{"id":"88806","messageId":"7vod3em67d.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"7vvdxmm78o.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T22:41:26Z","receivedAt":"2008-08-27T22:41:26Z","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> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n>\n>> Garry Dolley schrieb:\n>>> I didn't see this happen with git 1.5.x, but if you do git-shortlog on a bare \n>>> repo, without specifying --bare, the command will seemingly hang indefinitely.\n>>\n>> FWIW, I tried git 1.5.0 and it hangs, too.  Which exact version did work\n>> for you?  Could you, based on it, bisect the commit that introduced this\n>> behaviour?\n>>\n>> As a workaround, you can use \"git log | git shortlog\".\n>\n> It is not a workaround.  Shortlog can work as a filter to \"git log\", but\n> if you give revs to work on, e.g. \"git shortlog -s -n v1.5.6.5..\" or \"git\n> shortlog HEAD\", it can generate the log and feed to itself.\n>\n> Somehow it (perhaps incorrectly, I did not look at the command line input)\n> judging that your command line is telling it not to do the log generation\n> itself but instead you will feed the log from its standard input, which\n> happens to be your terminal.  So another workaround would be to type the\n> series of log messages ;-)\n\nAnd I think this is related to the complexity that snuck in when worktree\nfeature was added to the setup sequence.\n\nUntested, but I think this would help.\n\n setup.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git c/setup.c w/setup.c\nindex 6cf9094..296f712 100644\n--- c/setup.c\n+++ w/setup.c\n@@ -461,7 +461,7 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \t\t\tinside_git_dir = 1;\n \t\t\tif (!work_tree_env)\n \t\t\t\tinside_work_tree = 0;\n-\t\t\tsetenv(GIT_DIR_ENVIRONMENT, \".\", 1);\n+\t\t\tset_git_dir(\".\");\n \t\t\tcheck_repository_format_gently(nongit_ok);\n \t\t\treturn NULL;\n \t\t}\n"},{"id":"88819","messageId":"7vfxoqm4vs.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"7vod3em67d.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T23:09:59Z","receivedAt":"2008-08-27T23:09:59Z","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> And I think this is related to the complexity that snuck in when worktree\n> feature was added to the setup sequence.\n>\n> Untested, but I think this would help.\n\nWhile it might help, I see there are more serious issue here.\n\nIf you start \"git-shortlog\" (or anything that has USE_PAGER but not\nRUN_SETUP in git.c) inside your project/.git directory (or a bare one, for\nthat matter), the call sequence would become like this:\n\ngit.c::main()\n -> handle_internal_command()\n   -> run_command()\n     -> commit_pager_choice()\n       -> setup_pager() (this is in pager.c)\n         -> git_config(git_default_config, NULL)\n           -> git_path(\"config\")\n             -> get_git_dir()\n               -> setup_git_env()\n                 This sets git_dir to \".git\"!!!!\n\nAnd that was part of the reason why \"git-shortlog\" started from a bare\nrepository did not even notice that the default \"HEAD\" that is given\ninternally by the program is not a valid ref (because it tries to read\nfrom .git/HEAD without the patch I sent earlier).\n\nThis may be repeating what Jeff said earlier in another thread, but I\nthink we should rethink the start-up sequence carefully.  Ideally (I am\nthinking aloud)...\n\n * Have a single function \"git_setup()\" that notices --bare and --git-dir\n   from the command line and GIT_DIR environment, and does the discovery\n   of git_dir (if not told with the command line or environment\n   explicitly); if we do not find it, do *NOT* barf.  Just record the\n   facts it finds somewhere (e.g. the location of git_dir, absense of\n   git_dir, if the repository is explicitly bare, etc.).\n\n * As the next step, still in this single function, if we have git_dir,\n   find out where the work_tree is, paying attention to --work-tree from\n   the command line and GIT_WORK_TREE environment if exists.  If we do not\n   have work tree, do *NOT* barf.  Again, just record the facts it finds.\n   If we do not have --work-tree from the command line and if we are not\n   told that it is --bare from the command line, then we may need to open\n   the config to see where core.worktree points at.\n\n * Before returning from that single setup function, i think it is Ok to\n   make it mimick the current git_setup_directory_gently(), cd up to the\n   normal work-tree top if needed, and make it return prefix.\n\n * After all of the above is done, then we can start futzing with other\n   things such as pager.  At that point we know we can read from the\n   correct configuratoin.\n\n * Each individual command may decide to refuse to work in the absense of\n   git_dir and/or work_tree, by calling require_work_tree(), etc.\n\nHmm?\n"},{"id":"88811","messageId":"7v8wuim4kv.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"7vod3em67d.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T23:16:32Z","receivedAt":"2008-08-27T23:16:32Z","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> And I think this is related to the complexity that snuck in when worktree\n> feature was added to the setup sequence.\n>\n> Untested, but I think this would help.\n\nWhile this might help, I see there are more serious issues here.\n\nIf you start \"git-shortlog\" (or anything that has USE_PAGER but not\nRUN_SETUP in git.c) inside your project/.git directory (or a bare one, for\nthat matter), the call sequence would become like this:\n\ngit.c::main()\n -> handle_internal_command()\n   -> run_command()\n     -> commit_pager_choice()\n       -> setup_pager() (this is in pager.c)\n         -> git_config(git_default_config, NULL)\n           -> git_path(\"config\")\n             -> get_git_dir()\n               -> setup_git_env()\n                 This sets git_dir to \".git\"!!!!\n\nAnd that was part of the reason why \"git-shortlog\" started from a bare\nrepository did not even notice that the default \"HEAD\" that is given\ninternally by the program is not a valid ref (because it tries to read\nfrom .git/HEAD without the patch I sent earlier).  Oh, of course that\ngit_config() won't read from the right config file either.\n\nThis may be repeating what Jeff said earlier in another thread, but I\nthink we should rethink the start-up sequence carefully.  Ideally (I am\nthinking aloud)...\n\n * Have a single function \"git_setup()\" that notices --bare and --git-dir\n   from the command line and GIT_DIR environment, and does the discovery\n   of git_dir (if not told with the command line or environment\n   explicitly); if we do not find it, do *NOT* barf.  Just record the\n   facts it finds somewhere (e.g. the location of git_dir, absense of\n   git_dir, if the repository is explicitly bare, etc.).\n\n * As the next step, still in this single function, if we have git_dir,\n   find out where the work_tree is, paying attention to --work-tree from\n   the command line and GIT_WORK_TREE environment if exists.  If we do not\n   have work tree, do *NOT* barf.  Again, just record the facts it finds.\n   If we do not have --work-tree from the command line and if we are not\n   told that it is --bare from the command line, then we may need to open\n   the config to see where core.worktree points at.\n\n * Before returning from that single setup function, i think it is Ok to\n   make it mimick the current git_setup_directory_gently(), cd up to the\n   normal work-tree top if needed, and make it return prefix.\n\n * After all of the above is done, then we can start futzing with other\n   things such as pager.  At that point we know we can read from the\n   correct configuratoin.\n\n * Each individual command may decide to refuse to work in the absense of\n   git_dir and/or work_tree, by calling require_work_tree(), etc.\n\nHmm?\n"},{"id":"88817","messageId":"20080827233056.GA25745@coredump.intra.peff.net","threadId":"15224","inReplyTo":"7v8wuim4kv.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-08-27T23:30:56Z","receivedAt":"2008-08-27T23:30:56Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 27, 2008 at 04:16:32PM -0700, Junio C Hamano wrote:\n\n> While this might help, I see there are more serious issues here.\n> \n> If you start \"git-shortlog\" (or anything that has USE_PAGER but not\n> RUN_SETUP in git.c) inside your project/.git directory (or a bare one, for\n> that matter), the call sequence would become like this:\n> \n> git.c::main()\n>  -> handle_internal_command()\n>    -> run_command()\n>      -> commit_pager_choice()\n>        -> setup_pager() (this is in pager.c)\n>          -> git_config(git_default_config, NULL)\n>            -> git_path(\"config\")\n>              -> get_git_dir()\n>                -> setup_git_env()\n>                  This sets git_dir to \".git\"!!!!\n> [...]\n> This may be repeating what Jeff said earlier in another thread, but I\n> think we should rethink the start-up sequence carefully.  Ideally (I am\n> thinking aloud)...\n\nYep. This is the exact same problem I have been complaining about for a\nwhile.\n\n> [some implementation ideas]\n\nYes, this is roughly what I have been thinking of, as well. IOW,\nunconditionally find everything right at the beginning, but let us\ndecide whether to barf later, when we know what command we are running.\n\nA few complexities I found were:\n\n  - some things really want no setup, like init and clone. I don't\n    recall the exact issues, but trying obvious things caused breakage\n    there.\n\n  - the setup needs to not just be part of git.c, but factored out so\n    non-builtin C programs can use it. I don't recall if there are\n    issues related to git-sh-setup that need to be dealt with.\n\nI think my approach was something like \"let's just unconditionally call\nsetup_git_directory() in git.c, and wrap it with a static variable to\nmake sure we don't run it twice.\" but I ran into a host of issues. Sorry\nI can't remember specifics.\n\n-Peff\n"},{"id":"88870","messageId":"7vd4jthh45.fsf@gitster.siamese.dyndns.org","threadId":"15224","inReplyTo":"20080827233056.GA25745@coredump.intra.peff.net","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-28T04:56:58Z","receivedAt":"2008-08-28T04:56:58Z","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> A few complexities I found were:\n>\n>   - some things really want no setup, like init and clone. I don't\n>     recall the exact issues, but trying obvious things caused breakage\n>     there.\n\nAn obvious thing is to start these commands in a subdirectory of an\nexisting git worktree.\n\n>   - the setup needs to not just be part of git.c, but factored out so\n>     non-builtin C programs can use it.\n\nObviously.\n"},{"id":"88983","messageId":"fcaeb9bf0808280016k7378cc0ev985f90b270f615e5@mail.gmail.com","threadId":"15224","inReplyTo":"7v8wuim4kv.fsf@gitster.siamese.dyndns.org","subject":"Re: git-shortlog hangs on bare repo without --bare option","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-08-28T07:16:07Z","receivedAt":"2008-08-28T07:16:07Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 8/28/08, Junio C Hamano <gitster@pobox.com> wrote:\n>  This may be repeating what Jeff said earlier in another thread, but I\n>  think we should rethink the start-up sequence carefully.  Ideally (I am\n>  thinking aloud)...\n>\n>   * Have a single function \"git_setup()\" that notices --bare and --git-dir\n>    from the command line and GIT_DIR environment, and does the discovery\n>    of git_dir (if not told with the command line or environment\n>    explicitly); if we do not find it, do *NOT* barf.  Just record the\n>    facts it finds somewhere (e.g. the location of git_dir, absense of\n>    git_dir, if the repository is explicitly bare, etc.).\n>\n>   * As the next step, still in this single function, if we have git_dir,\n>    find out where the work_tree is, paying attention to --work-tree from\n>    the command line and GIT_WORK_TREE environment if exists.  If we do not\n>    have work tree, do *NOT* barf.  Again, just record the facts it finds.\n>    If we do not have --work-tree from the command line and if we are not\n>    told that it is --bare from the command line, then we may need to open\n>    the config to see where core.worktree points at.\n\nPart of worktree issues comes from the fact that worktree setup is\nspread over many functions, starting at setup_git_dir*() and ending at\nsetup_work_tree().\nSo setting it up in a single function and turning setup_work_tree()\ninto \"check and die()\" logic sounds great.\n-- \nDuy\n"}]}