git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!

From
Philip Oakley <philipoakley@iee.org>
Date
Nov 2, 2013, 12:54 UTC
Message-ID
<11593D3DCFCD4D24BB881B9E5FAB79C0@PhilipOakley>
In-Reply-To
<20131102105816.GC24023@serenity.lan>
From: "John Keeping" <john@keeping.me.uk>
Sent: Saturday, November 02, 2013 10:58 AM
Show 26 quoted lines
> On Fri, Nov 01, 2013 at 06:19:51PM -0500, Ville Walveranta wrote:
>> "git-rev-parse --is-inside-git-dir" outputs "fatal: Not a git
>> repository (or any of the parent directories): .git", instead of
>> "false" when outside of a git directory.  "--is-inside-work-tree"
>> behaves the same way. Both commands work correctly (i.e. output
>> "true") when inside a git directory, or inside a work tree,
>> respectively.
>
> I think that's intentional - and it looks like the behaviour has not
> changed since these options were added.  With the current behaviour 
> you
> get three possible outcomes from "git 
> rev-parse --is-inside-work-tree":
>
>    if worktree=$(git rev-parse --is-inside-work-tree 2>/dev/null)
>    then
>        if test "$worktree" = true
>        then
>            echo 'inside work tree'
>        else
>            echo 'in repository, but not in work tree'
>        fi
>    else
>        echo 'not in repository'
>    fi
> --

Shouldn't this case which produces "fatal:..." need to be documented in the man page? https://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html doesn't mention it.

Philip 
Previous: John KeepingNext: John Keeping
Message 4 of 9 in “Git 1.8.4.2: 'git-rev-parse --is-inside-git-dir' wrong output!”
  1. Ville WalverantaNov 1, 2013
  2. Øystein WalleNov 2, 2013
  3. John KeepingNov 2, 2013
  4. Philip OakleyNov 2, 2013
  5. John KeepingNov 2, 2013
  6. Philip OakleyNov 2, 2013
  7. Ville WalverantaNov 2, 2013
  8. John KeepingNov 2, 2013
  9. Ville WalverantaNov 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.