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

Re: [Funky] "git -p cmd" inside a bare repository

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Dec 14, 2007, 13:58 UTC
Message-ID
<fcaeb9bf0712140558p37eb3387h7c4d3177473e6fcd@mail.gmail.com>
In-Reply-To
<7vmysexdvw.fsf@gitster.siamese.dyndns.org>
On Dec 14, 2007 8:29 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 29 quoted lines
> If you have a bare repository and try this there:
>
>         $ PAGER=head git show HEAD:gcc/ChangeLog
>
> it works as expected, but if you explicitly ask for pagination, like
> this:
>
>         $ PAGER=head git -p show HEAD:gcc/ChangeLog
>
> you would get a very funky error message:
>
>         fatal: ambiguous argument 'HEAD:gcc/ChangeLog': unknown revision or path not in the working tree.
>         Use '--' to separate paths from revisions
>
> as if we are working with a repository with working tree.
>
> I originally noticed this with ls-tree.  The symptom is a bit different:
>
>         $ git -p ls-tree HEAD
>         fatal: Not a valid object name HEAD
>
>
>
> I _think_ what is happening is that setup_pager() tries to run
> git_config(), which runs setup(), and then RUN_SETUP set for "ls-tree"
> (or "show") internal command runs setup again.  HEAD is given to
> resolve_ref() and git_path("%s", ref) makes it to ".git/HEAD", even
> though in a bare repository git_dir should be set to ".", and of course
> we cannot find such a path in the git directory.

You meant setup_git_directory() or setup_git_env()? If find that setup_git_env() is called too soon so it caches wrong git_dir and friends if you setup_pager().

Another option (BTW I think your patch is fine) is to call setup_git_env one more time to refresh its cache.

-- 
Duy
Previous: Junio C HamanoNext: Johannes Schindelin
Message 7 of 10 in “Do check_repository_format() early”
  1. Do check_repository_format() earlyNguyễn Thái Ngọc Duy, Nov 29, 2007
  2. [Funky] "git -p cmd" inside a bare repositoryJunio C Hamano, Dec 14, 2007
  3. make git start-up sequence a bit more robustJunio C Hamano, Dec 14, 2007
  4. Jeff KingDec 14, 2007
  5. Jeff KingDec 14, 2007
  6. Junio C HamanoDec 14, 2007
  7. Nguyen Thai Ngoc DuyDec 14, 2007
  8. Johannes SchindelinDec 14, 2007
  9. Junio C HamanoDec 14, 2007
  10. Johannes SchindelinDec 14, 2007

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.