All of lore.kernel.org
 help / color / mirror / Atom feed
From: allejo <me@allejo.io>
To: "git" <git@vger.kernel.org>
Subject: bug: `git diff` implies folder isn’t a git repo
Date: Thu, 19 May 2022 21:22:27 -0700	[thread overview]
Message-ID: <180dfb3d8d3.12352a818142651.7062268074453572353@allejo.io> (raw)
In-Reply-To: 

Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

Change ownership of a Git repo to require `safe.directory` behavior.

What did you expect to happen? (Expected behavior)

If you run `git diff --exit-code` on a non-`safe.directory`, you should get the standard error.

    Error: fatal: unsafe repository ('/path/to/repo' is owned by someone else)

What happened instead? (Actual behavior)

I get an error message saying it's not actually a git repository even though it is, it's just not safe to work in.

    warning: Not a git repository. Use --no-index to compare two paths outside a working tree
    usage: git diff --no-index [<options>] <path> <path>

    Diff output format options
        -p, --patch           generate patch
        -s, --no-patch        suppress diff output
        -u                    generate patch
        -U, --unified[=<n>]   generate diffs with <n> lines context
        -W, --function-context
                              generate diffs with <n> lines context
        --raw                 generate the diff in raw format
        --patch-with-raw      synonym for '-p --raw'
        --patch-with-stat     synonym for '-p --stat'
        --numstat             machine friendly --stat
        --shortstat           output only the last line of --stat
        -X, --dirstat[=<param1,param2>...]
                              output the distribution of relative amount of changes for each sub-directory
    ...

What's different between what you expected and what actually happened?

One error message implies the folder isn't a Git repo while the other explicitly says it's not safe to work in and how to fix it.

Anything else you want to add:

I am installing git on Ubuntu 20.04.4 from its default repositories inside of a GitHub Actions runner.

[System Info]
git version:
git version 2.25.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]
not run from a git repository - no hooks to show


             reply	other threads:[~2022-05-20  4:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  4:22 allejo [this message]
2022-05-21 18:39 ` bug: `git diff` implies folder isn’t a git repo brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=180dfb3d8d3.12352a818142651.7062268074453572353@allejo.io \
    --to=me@allejo.io \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.