{"thread":{"id":"7231","subject":"git-1.5 and bare repos","startedAt":"2007-03-13T16:09:50Z","lastAt":"2007-03-13T17:03:41Z","messageCount":2,"participants":["Florian La Roche","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"37006","messageId":"20070313160950.GA14163@dudweiler.stuttgart.redhat.com","threadId":"7231","inReplyTo":null,"subject":"git-1.5 and bare repos","fromName":"Florian La Roche","fromEmail":"laroche@redhat.com","sentAt":"2007-03-13T16:09:50Z","receivedAt":"2007-03-13T16:09:50Z","isPatch":false,"sender":{"key":"laroche@redhat.com","avatar":null},"body":"Here a patch to correctly allow also bare\nrepositories.\n\nregards,\n\nFlorian La Roche\n\n\n\n--- git-sh-setup.sh\t2007-03-05 03:15:33.000000000 +0100\n+++ git-sh-setup\t2007-03-13 17:08:22.000000000 +0100\n@@ -49,8 +49,8 @@\n \n require_work_tree () {\n \ttest $(is_bare_repository) = false &&\n-\ttest $(git-rev-parse --is-inside-git-dir) = false ||\n-\tdie \"fatal: $0 cannot be used without a working tree.\"\n+\t{ test $(git-rev-parse --is-inside-git-dir) = false ||\n+\t  die \"fatal: $0 cannot be used without a working tree.\"; }\n }\n \n if [ -z \"$LONG_USAGE\" ]\n"},{"id":"37015","messageId":"7vbqixjcsy.fsf@assigned-by-dhcp.cox.net","threadId":"7231","inReplyTo":"20070313160950.GA14163@dudweiler.stuttgart.redhat.com","subject":"Re: git-1.5 and bare repos","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-13T17:03:41Z","receivedAt":"2007-03-13T17:03:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Florian La Roche <laroche@redhat.com> writes:\n\n> Here a patch to correctly allow also bare\n> repositories.\n>\n> ...\n>\n> --- git-sh-setup.sh\t2007-03-05 03:15:33.000000000 +0100\n> +++ git-sh-setup\t2007-03-13 17:08:22.000000000 +0100\n> @@ -49,8 +49,8 @@\n>  \n>  require_work_tree () {\n>  \ttest $(is_bare_repository) = false &&\n> -\ttest $(git-rev-parse --is-inside-git-dir) = false ||\n> -\tdie \"fatal: $0 cannot be used without a working tree.\"\n> +\t{ test $(git-rev-parse --is-inside-git-dir) = false ||\n> +\t  die \"fatal: $0 cannot be used without a working tree.\"; }\n>  }\n>  \n>  if [ -z \"$LONG_USAGE\" ]\n\nChanging the meaning of the function and call the change \"to\ncorrectly allow\" needs a bit more explanation.  The function is\nsupposed to be called by certain operations to make sure that\nthey are not run from anywhere other than inside a working tree\nassociated with the repository, and that is why it says \"we are\nhappy when the repository is not bare and we are not inside .git\ndirectory --- otherwise we are unhappy\".\n\nI suspect that you found a command that calls this function,\nwhen it should also be usable in a bare repository.  If that is\nthe case, the caller needs to be fixed, perhaps not to call this\nfunction at all, or perhaps call it only before performing an\noperation that _needs_ working tree (I do not think of an\nexample offhand, but it is conceivable that a command can work\nfine in a bare repository under an option but requires a working\ntree with a different option).  Changing the meaning of this\nfunction so that it is always happy with bare repository means\nyou are breaking the assumption of other callers.\n\nFor example, git-fetch in a bare repository is fine.  It is an\noperation to update the object database and (optionally) advance\nthe refs used to track the other side.  On the other hand,\ngit-pull, git-reset nor git-checkout are not.  As they are meant\nto update the working tree from the repository, running them in\na bare repository, which lacks the working tree by definition,\ndoes not make sense.  That is why they use this function.\n"}]}