{"thread":{"id":"35263","subject":"Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","startedAt":"2013-11-01T23:19:51Z","lastAt":"2013-11-02T22:58:48Z","messageCount":9,"participants":["Ville Walveranta","Øystein Walle","John Keeping","Philip Oakley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"230025","messageId":"CACbqpSvU4qxc0WtquP6Eq8bZGjLxTrVhtT2Nqw90wb23ESkfcw@mail.gmail.com","threadId":"35263","inReplyTo":null,"subject":"Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Ville Walveranta","fromEmail":"walveranta@gmail.com","sentAt":"2013-11-01T23:19:51Z","receivedAt":"2013-11-01T23:19:51Z","isPatch":false,"sender":{"key":"walveranta@gmail.com","avatar":"https://gravatar.com/avatar/3a3dd575ea35e53860815ae8c4bba97b2f304c852db6eb3419cac98ff2bac798?d=mp&s=160"},"body":"\"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\nrepository (or any of the parent directories): .git\", instead of\n\"false\" when outside of a git directory.  \"--is-inside-work-tree\"\nbehaves the same way. Both commands work correctly (i.e. output\n\"true\") when inside a git directory, or inside a work tree,\nrespectively.\n\nTo test, I installed git 1.8.4.2 initially from\nhttps://launchpad.net/~git-core/+archive/ppa for Ubuntu 12.04.3, and\nthen also compiled it from source, but both seem to behave the same\nway. The problem is not yet present in version 1.7.9.5.\n\nThanks,\n\nVille Walveranta\n"},{"id":"230031","messageId":"loom.20131102T110932-618@post.gmane.org","threadId":"35263","inReplyTo":"CACbqpSvU4qxc0WtquP6Eq8bZGjLxTrVhtT2Nqw90wb23ESkfcw@mail.gmail.com","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Øystein Walle","fromEmail":"oystwa@gmail.com","sentAt":"2013-11-02T10:24:36Z","receivedAt":"2013-11-02T10:24:36Z","isPatch":false,"sender":{"key":"oystwa@gmail.com","avatar":"https://avatars.githubusercontent.com/u/794585?v=4"},"body":"Ville Walveranta <walveranta <at> gmail.com> writes:\n\n> \n> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n> repository (or any of the parent directories): .git\", instead of\n> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n> behaves the same way. Both commands work correctly (i.e. output\n> \"true\") when inside a git directory, or inside a work tree,\n> respectively.\n> \n> To test, I installed git 1.8.4.2 initially from\n> https://launchpad.net/~git-core/+archive/ppa for Ubuntu 12.04.3, and\n> then also compiled it from source, but both seem to behave the same\n> way. The problem is not yet present in version 1.7.9.5.\n> \n> Thanks,\n> \n> Ville Walveranta\n>\n\nHi,\n\nI thought I'd try to bisect this but I ended up discovering that I get\nthe exact same behaviour with both 1.7.9.5 and 1.8.4.2. 1.7.9.5 will\nalso output 'fatal: ...' like 1.8.4.2 does.\n\nBoth version will however behave as expected if you provide --git-dir\nand --work-tree:\n\n    $ pwd\n    /home/osse\n    $ git --version\n    git version 1.8.4.2\n    $ git --git-dir=/home/osse/git/.git \\\n          --work-tree=/home/osse/git    \\\n        rev-parse  --is-inside-work-tree\n    false\n\nDitto for --is-inside-git-dir.\n\nIncidentally I discovered that the new -C option does *not* behave this\nway:\n\n$ git --version\ngit version 1.8.5.rc0.23.gaa27064\n$ git -C /home/osse/git rev-parse --is-inside-work-tree\ntrue\n\nBut given that the purpose of the -C option is to make Git behave as if\nyou were in that directory this is perhaps expected behaviour.\n\nRegards,\nØsse\n"},{"id":"230032","messageId":"20131102105816.GC24023@serenity.lan","threadId":"35263","inReplyTo":"CACbqpSvU4qxc0WtquP6Eq8bZGjLxTrVhtT2Nqw90wb23ESkfcw@mail.gmail.com","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-11-02T10:58:16Z","receivedAt":"2013-11-02T10:58:16Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n> repository (or any of the parent directories): .git\", instead of\n> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n> behaves the same way. Both commands work correctly (i.e. output\n> \"true\") when inside a git directory, or inside a work tree,\n> respectively.\n\nI think that's intentional - and it looks like the behaviour has not\nchanged since these options were added.  With the current behaviour you\nget three possible outcomes from \"git rev-parse --is-inside-work-tree\":\n\n    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n    then\n        if test \"$worktree\" = true\n        then\n            echo 'inside work tree'\n        else\n            echo 'in repository, but not in work tree'\n        fi\n    else\n        echo 'not in repository'\n    fi\n"},{"id":"230036","messageId":"11593D3DCFCD4D24BB881B9E5FAB79C0@PhilipOakley","threadId":"35263","inReplyTo":"20131102105816.GC24023@serenity.lan","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2013-11-02T12:54:52Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"John Keeping\" <john@keeping.me.uk>\nSent: Saturday, November 02, 2013 10:58 AM\n> On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n>> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n>> repository (or any of the parent directories): .git\", instead of\n>> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n>> behaves the same way. Both commands work correctly (i.e. output\n>> \"true\") when inside a git directory, or inside a work tree,\n>> respectively.\n>\n> I think that's intentional - and it looks like the behaviour has not\n> changed since these options were added.  With the current behaviour \n> you\n> get three possible outcomes from \"git \n> rev-parse --is-inside-work-tree\":\n>\n>    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n>    then\n>        if test \"$worktree\" = true\n>        then\n>            echo 'inside work tree'\n>        else\n>            echo 'in repository, but not in work tree'\n>        fi\n>    else\n>        echo 'not in repository'\n>    fi\n> --\n\n\nShouldn't this case which produces \"fatal:...\" need to be documented in \nthe man page?\nhttps://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html \ndoesn't mention it.\n\nPhilip \n"},{"id":"230037","messageId":"20131102140656.GE24023@serenity.lan","threadId":"35263","inReplyTo":"11593D3DCFCD4D24BB881B9E5FAB79C0@PhilipOakley","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-11-02T14:06:57Z","receivedAt":"2013-11-02T14:06:57Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Sat, Nov 02, 2013 at 01:47:02PM -0000, Philip Oakley wrote:\n> From: \"John Keeping\" <john@keeping.me.uk>\n> Sent: Saturday, November 02, 2013 10:58 AM\n> > On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n> >> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n> >> repository (or any of the parent directories): .git\", instead of\n> >> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n> >> behaves the same way. Both commands work correctly (i.e. output\n> >> \"true\") when inside a git directory, or inside a work tree,\n> >> respectively.\n> >\n> > I think that's intentional - and it looks like the behaviour has not\n> > changed since these options were added.  With the current behaviour \n> > you\n> > get three possible outcomes from \"git \n> > rev-parse --is-inside-work-tree\":\n> >\n> >    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n> >    then\n> >        if test \"$worktree\" = true\n> >        then\n> >            echo 'inside work tree'\n> >        else\n> >            echo 'in repository, but not in work tree'\n> >        fi\n> >    else\n> >        echo 'not in repository'\n> >    fi\n> > --\n> \n> \n> Shouldn't this case which produces \"fatal:...\" need to be documented in \n> the man page?\n> https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html \n> doesn't mention it.\n\nI'm not sure where it should go in there.  The documentation for\n--git-dir says:\n\n   If $GIT_DIR is not defined and the current directory is not detected\n   to lie in a Git repository or work tree print a message to stderr and\n   exit with nonzero status.\n\nbut there reality is that if you do not specify --parseopt or --sq-quote\nthen the command expects to be run in a Git repository [1], so perhaps\nit would be better to say something under \"Operation Modes\" or in the\ndescription.\n\n\n[1] After taking account of $GIT_DIR, $GIT_WORK_TREE, and arguments to\n    the base \"git\" driver that affect these variables.\n"},{"id":"230039","messageId":"CE13C82CA4C24CA8B56380DA00A700A5@PhilipOakley","threadId":"35263","inReplyTo":"20131102140656.GE24023@serenity.lan","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2013-11-02T16:11:31Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"John Keeping\" <john@keeping.me.uk>\nSent: Saturday, November 02, 2013 2:06 PM\n> On Sat, Nov 02, 2013 at 01:47:02PM -0000, Philip Oakley wrote:\n>> From: \"John Keeping\" <john@keeping.me.uk>\n>> Sent: Saturday, November 02, 2013 10:58 AM\n>> > On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n>> >> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n>> >> repository (or any of the parent directories): .git\", instead of\n>> >> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n>> >> behaves the same way. Both commands work correctly (i.e. output\n>> >> \"true\") when inside a git directory, or inside a work tree,\n>> >> respectively.\n>> >\n>> > I think that's intentional - and it looks like the behaviour has\n>> > not\n>> > changed since these options were added.  With the current behaviour\n>> > you\n>> > get three possible outcomes from \"git\n>> > rev-parse --is-inside-work-tree\":\n>> >\n>> >    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n>> >    then\n>> >        if test \"$worktree\" = true\n>> >        then\n>> >            echo 'inside work tree'\n>> >        else\n>> >            echo 'in repository, but not in work tree'\n>> >        fi\n>> >    else\n>> >        echo 'not in repository'\n>> >    fi\n>> > --\n>>\n>>\n>> Shouldn't this case which produces \"fatal:...\" need to be documented\n>> in\n>> the man page?\n>> https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html\n>> doesn't mention it.\n>\n> I'm not sure where it should go in there.  The documentation for\n> --git-dir says:\n>\n>   If $GIT_DIR is not defined and the current directory is not detected\n>   to lie in a Git repository or work tree print a message to stderr\n> and\n>   exit with nonzero status.\n>\n> but there reality is that if you do not specify --parseopt\n> or --sq-quote\n> then the command expects to be run in a Git repository [1], so perhaps\n> it would be better to say something under \"Operation Modes\" or in the\n> description.\n>\n>\n> [1] After taking account of $GIT_DIR, $GIT_WORK_TREE, and arguments to\n>    the base \"git\" driver that affect these variables.\n>\n\nYes, but given Ville's surprise and the need for special prior knowledge\nof the points you raised, I still think that some short note is needed.\n\nIt can/could be read that you need to invoke --git-dir as an option\nbefore the mentioned die() exit is taken, rather than it applying to\nall(?) the path relevant options.\n\nEither the --git-dir condition needs to say it also applies\nto --is-inside-git-dir and --is-inside-work-tree\n(and --is-bare-repository?), or add a \"see --git-dir preconditions.\" to\neach of those options. It's easy to be wise after the event hence my \npreference for a suitable note.\n\nregards\n\nPhilip\n"},{"id":"230040","messageId":"CACbqpSspsUvw3QXnSmOXA2boenh3y4DjHO-813OTna7cpSXkZQ@mail.gmail.com","threadId":"35263","inReplyTo":"CE13C82CA4C24CA8B56380DA00A700A5@PhilipOakley","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Ville Walveranta","fromEmail":"walveranta@gmail.com","sentAt":"2013-11-02T19:42:04Z","receivedAt":"2013-11-02T19:42:04Z","isPatch":false,"sender":{"key":"walveranta@gmail.com","avatar":"https://gravatar.com/avatar/3a3dd575ea35e53860815ae8c4bba97b2f304c852db6eb3419cac98ff2bac798?d=mp&s=160"},"body":"Without the functionality such as that 1.7.9.5 still offered, it is\nnow not possible to use \"git-rev-parse --is-inside-work-tree\" to\ndetect whether the current location is controlled by a git repository\nwithout emitting the \"fatal: Not a git\nrepository (or any of the parent directories): .git\" error message,\nwhen it is not. There is no functional \"--quiet\" switch, and the usual\nerror/std redirection to /dev/null doesn't seem to work to squelch the\noutput.\n\nIf \"--is-inside-git-dir\" and \"--is-inside-work-tree\" are indeed not\nsupposed to emit \"false\" when outside of a git repository, perhaps\nthere is another way I can use (in a bash script) to cleanly detect\nwhether a specific path is part of a git repo or not?\n\nThanks for any insights on this! :-)\n\nVille\n\nOn Sat, Nov 2, 2013 at 12:03 PM, Philip Oakley <philipoakley@iee.org> wrote:\n> From: \"John Keeping\" <john@keeping.me.uk>\n> Sent: Saturday, November 02, 2013 2:06 PM\n>\n>> On Sat, Nov 02, 2013 at 01:47:02PM -0000, Philip Oakley wrote:\n>>>\n>>> From: \"John Keeping\" <john@keeping.me.uk>\n>>> Sent: Saturday, November 02, 2013 10:58 AM\n>>> > On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n>>> >> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n>>> >> repository (or any of the parent directories): .git\", instead of\n>>> >> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n>>> >> behaves the same way. Both commands work correctly (i.e. output\n>>> >> \"true\") when inside a git directory, or inside a work tree,\n>>> >> respectively.\n>>> >\n>>> > I think that's intentional - and it looks like the behaviour has\n>>> > not\n>>> > changed since these options were added.  With the current behaviour\n>>> > you\n>>> > get three possible outcomes from \"git\n>>> > rev-parse --is-inside-work-tree\":\n>>> >\n>>> >    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n>>> >    then\n>>> >        if test \"$worktree\" = true\n>>> >        then\n>>> >            echo 'inside work tree'\n>>> >        else\n>>> >            echo 'in repository, but not in work tree'\n>>> >        fi\n>>> >    else\n>>> >        echo 'not in repository'\n>>> >    fi\n>>> > --\n>>>\n>>>\n>>> Shouldn't this case which produces \"fatal:...\" need to be documented\n>>> in\n>>> the man page?\n>>> https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html\n>>> doesn't mention it.\n>>\n>>\n>> I'm not sure where it should go in there.  The documentation for\n>> --git-dir says:\n>>\n>>   If $GIT_DIR is not defined and the current directory is not detected\n>>   to lie in a Git repository or work tree print a message to stderr\n>> and\n>>   exit with nonzero status.\n>>\n>> but there reality is that if you do not specify --parseopt\n>> or --sq-quote\n>> then the command expects to be run in a Git repository [1], so perhaps\n>> it would be better to say something under \"Operation Modes\" or in the\n>> description.\n>>\n>>\n>> [1] After taking account of $GIT_DIR, $GIT_WORK_TREE, and arguments to\n>>    the base \"git\" driver that affect these variables.\n>>\n>\n> Yes, but given Ville's surprise and the need for special prior knowledge\n> of the points you raised, I still think that some short note is needed.\n>\n> It can/could be read that you need to invoke --git-dir as an option\n> before the mentioned die() exit is taken, rather than it applying to\n> all(?) the path relevant options.\n>\n> Either the --git-dir condition needs to say it also applies\n> to --is-inside-git-dir and --is-inside-work-tree\n> (and --is-bare-repository?), or add a \"see --git-dir preconditions.\" to\n> each of those options. It's easy to be wise after the event hence my\n> preference for a suitable note.\n>\n> regards\n>\n> Philip\n>\n>\n"},{"id":"230041","messageId":"20131102202041.GF24023@serenity.lan","threadId":"35263","inReplyTo":"CACbqpSspsUvw3QXnSmOXA2boenh3y4DjHO-813OTna7cpSXkZQ@mail.gmail.com","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-11-02T20:20:41Z","receivedAt":"2013-11-02T20:20:41Z","isPatch":false,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"On Sat, Nov 02, 2013 at 02:42:04PM -0500, Ville Walveranta wrote:\n> Without the functionality such as that 1.7.9.5 still offered, it is\n> now not possible to use \"git-rev-parse --is-inside-work-tree\" to\n> detect whether the current location is controlled by a git repository\n> without emitting the \"fatal: Not a git\n> repository (or any of the parent directories): .git\" error message,\n> when it is not. There is no functional \"--quiet\" switch, and the usual\n> error/std redirection to /dev/null doesn't seem to work to squelch the\n> output.\n\nHow doesn't redirection work?  The message is printed to stderr; the\nsnippet I posted below does indeed squelch the output.\n\n> If \"--is-inside-git-dir\" and \"--is-inside-work-tree\" are indeed not\n> supposed to emit \"false\" when outside of a git repository, perhaps\n> there is another way I can use (in a bash script) to cleanly detect\n> whether a specific path is part of a git repo or not?\n\nSomething like this, maybe?\n\n    (cd \"$dir\" && git rev-parse --git-dir >/dev/null 2>&1)\n\n> On Sat, Nov 2, 2013 at 12:03 PM, Philip Oakley <philipoakley@iee.org> wrote:\n> > From: \"John Keeping\" <john@keeping.me.uk>\n> > Sent: Saturday, November 02, 2013 2:06 PM\n> >\n> >> On Sat, Nov 02, 2013 at 01:47:02PM -0000, Philip Oakley wrote:\n> >>>\n> >>> From: \"John Keeping\" <john@keeping.me.uk>\n> >>> Sent: Saturday, November 02, 2013 10:58 AM\n> >>> > On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n> >>> >> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n> >>> >> repository (or any of the parent directories): .git\", instead of\n> >>> >> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n> >>> >> behaves the same way. Both commands work correctly (i.e. output\n> >>> >> \"true\") when inside a git directory, or inside a work tree,\n> >>> >> respectively.\n> >>> >\n> >>> > I think that's intentional - and it looks like the behaviour has\n> >>> > not\n> >>> > changed since these options were added.  With the current behaviour\n> >>> > you\n> >>> > get three possible outcomes from \"git\n> >>> > rev-parse --is-inside-work-tree\":\n> >>> >\n> >>> >    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n> >>> >    then\n> >>> >        if test \"$worktree\" = true\n> >>> >        then\n> >>> >            echo 'inside work tree'\n> >>> >        else\n> >>> >            echo 'in repository, but not in work tree'\n> >>> >        fi\n> >>> >    else\n> >>> >        echo 'not in repository'\n> >>> >    fi\n> >>> > --\n"},{"id":"230045","messageId":"CACbqpSs3DcHuypbBwLJ6Dbd5nKz6c=oozTxyJepEmi1Zis7WRQ@mail.gmail.com","threadId":"35263","inReplyTo":"20131102202041.GF24023@serenity.lan","subject":"Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!","fromName":"Ville Walveranta","fromEmail":"walveranta@gmail.com","sentAt":"2013-11-02T22:58:48Z","receivedAt":"2013-11-02T22:58:48Z","isPatch":false,"sender":{"key":"walveranta@gmail.com","avatar":"https://gravatar.com/avatar/3a3dd575ea35e53860815ae8c4bba97b2f304c852db6eb3419cac98ff2bac798?d=mp&s=160"},"body":"Yes, stderr redirection in a subshell seems to work ok.  Since I'm\ncreating a small git utility script I ended up doing:\n\n--\n#!/bin/bash\n\n(git rev-parse --git-dir >/dev/null 2>&1)\n\nif [ $? -ne 0 ] ; then\n  echo \"Not in a git repo\"\nelse\n  echo \"Git repo; proceeding..\"\n  # more logic..\nfi\n-- \n\nThat works! Thanks for your help!\n\nVille\n\nOn Sat, Nov 2, 2013 at 3:20 PM, John Keeping <john@keeping.me.uk> wrote:\n> On Sat, Nov 02, 2013 at 02:42:04PM -0500, Ville Walveranta wrote:\n>> Without the functionality such as that 1.7.9.5 still offered, it is\n>> now not possible to use \"git-rev-parse --is-inside-work-tree\" to\n>> detect whether the current location is controlled by a git repository\n>> without emitting the \"fatal: Not a git\n>> repository (or any of the parent directories): .git\" error message,\n>> when it is not. There is no functional \"--quiet\" switch, and the usual\n>> error/std redirection to /dev/null doesn't seem to work to squelch the\n>> output.\n>\n> How doesn't redirection work?  The message is printed to stderr; the\n> snippet I posted below does indeed squelch the output.\n>\n>> If \"--is-inside-git-dir\" and \"--is-inside-work-tree\" are indeed not\n>> supposed to emit \"false\" when outside of a git repository, perhaps\n>> there is another way I can use (in a bash script) to cleanly detect\n>> whether a specific path is part of a git repo or not?\n>\n> Something like this, maybe?\n>\n>     (cd \"$dir\" && git rev-parse --git-dir >/dev/null 2>&1)\n>\n>> On Sat, Nov 2, 2013 at 12:03 PM, Philip Oakley <philipoakley@iee.org> wrote:\n>> > From: \"John Keeping\" <john@keeping.me.uk>\n>> > Sent: Saturday, November 02, 2013 2:06 PM\n>> >\n>> >> On Sat, Nov 02, 2013 at 01:47:02PM -0000, Philip Oakley wrote:\n>> >>>\n>> >>> From: \"John Keeping\" <john@keeping.me.uk>\n>> >>> Sent: Saturday, November 02, 2013 10:58 AM\n>> >>> > On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:\n>> >>> >> \"git-rev-parse --is-inside-git-dir\" outputs \"fatal: Not a git\n>> >>> >> repository (or any of the parent directories): .git\", instead of\n>> >>> >> \"false\" when outside of a git directory.  \"--is-inside-work-tree\"\n>> >>> >> behaves the same way. Both commands work correctly (i.e. output\n>> >>> >> \"true\") when inside a git directory, or inside a work tree,\n>> >>> >> respectively.\n>> >>> >\n>> >>> > I think that's intentional - and it looks like the behaviour has\n>> >>> > not\n>> >>> > changed since these options were added.  With the current behaviour\n>> >>> > you\n>> >>> > get three possible outcomes from \"git\n>> >>> > rev-parse --is-inside-work-tree\":\n>> >>> >\n>> >>> >    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)\n>> >>> >    then\n>> >>> >        if test \"$worktree\" = true\n>> >>> >        then\n>> >>> >            echo 'inside work tree'\n>> >>> >        else\n>> >>> >            echo 'in repository, but not in work tree'\n>> >>> >        fi\n>> >>> >    else\n>> >>> >        echo 'not in repository'\n>> >>> >    fi\n>> >>> > --\n"}]}