git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: Git-Alias is callable from outside a git repo
@ 2022-08-10 17:03 Niklas
  2022-08-10 19:14 ` rsbecker
  2022-08-12 21:09 ` Bug: " Johannes Schindelin
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas @ 2022-08-10 17:03 UTC (permalink / raw)
  To: git

Steps to reproduce:

1. Having the following global .gitconfig

[alias]
     f = "!echo "test""

2. Calling `git f` in a folder which does not belong to a git repo

Expected Behavior: 

Seeing some message like like
`fatal: not a git repository (or any parent up to mount point /)`

Actual Behavior:

Prints "test"

Git 2.37.1 under Arch Linux

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Git-Alias is callable from outside a git repo
  2022-08-10 17:03 Bug: Git-Alias is callable from outside a git repo Niklas
@ 2022-08-10 19:14 ` rsbecker
  2022-08-12 21:09 ` Bug: " Johannes Schindelin
  1 sibling, 0 replies; 3+ messages in thread
From: rsbecker @ 2022-08-10 19:14 UTC (permalink / raw)
  To: 'Niklas', git

On August 10, 2022 1:03 PM, Niklas wrote:
>Steps to reproduce:
>
>1. Having the following global .gitconfig
>
>[alias]
>     f = "!echo "test""
>
>2. Calling `git f` in a folder which does not belong to a git repo
>
>Expected Behavior:
>
>Seeing some message like like
>`fatal: not a git repository (or any parent up to mount point /)`
>
>Actual Behavior:
>
>Prints "test"
>
>Git 2.37.1 under Arch Linux

I do not think this is a bug. There are git commands that do not require
repositories, like git version. Git has know knowledge of what your alias is
going to do without executing it. If your alias wanted to run git version or
git hash-object, it would not need a repository to do so.
--Randall


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug: Git-Alias is callable from outside a git repo
  2022-08-10 17:03 Bug: Git-Alias is callable from outside a git repo Niklas
  2022-08-10 19:14 ` rsbecker
@ 2022-08-12 21:09 ` Johannes Schindelin
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2022-08-12 21:09 UTC (permalink / raw)
  To: Niklas; +Cc: git

Hi Niklas,

On Wed, 10 Aug 2022, Niklas wrote:

> Steps to reproduce:
>
> 1. Having the following global .gitconfig
>
> [alias]
>     f = "!echo "test""

That quoting is a big bogus.

>
> 2. Calling `git f` in a folder which does not belong to a git repo
>
> Expected Behavior:
> Seeing some message like like
> `fatal: not a git repository (or any parent up to mount point /)`
>
> Actual Behavior:
>
> Prints "test"

This is by design, and definitely not a bug. It even allows you to build
relatively complex aliases that work on multiple worktrees, or even no
worktree at all.

Why would a Git alias have to be bound to any specific Git repository?

Ciao,
Johannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-12 21:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10 17:03 Bug: Git-Alias is callable from outside a git repo Niklas
2022-08-10 19:14 ` rsbecker
2022-08-12 21:09 ` Bug: " Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).