threads / bug / 62798

Bug report - Apple git

Subject: Bug report - Apple git

## tl;dr

6 messages between Jan 13, 2025 and Jan 14, 2025.

replies: 5people: 5as markdown or json

André de Castro· Jan 13, 2025, 14:23 UTC · lore

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue) Checked out a branch, ran "git diff --merge-base <some-annotated-tag> HEAD".

What did you expect to happen? (Expected behavior) To see a normal git diff output.

What happened instead? (Actual behavior) Didn't get a diff output. Got the following error instead: "fatal: --merge-base only works with commits"

What's different between what you expected and what actually happened? I didn't get the expected diff output and got an error message instead.

Anything else you want to add: Seems it happens when I use a tag as one of the commits for git diff --merge-base. This is on a macOS, with apple git. On Windows, with Git Bash, it works as expected.

I can get this to work with "git diff --merge-base $(git rev-list -n 1 <some-annotated-tag>) HEAD".

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.39.5 (Apple Git-154) cpu: arm64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Darwin 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 18:56:34 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6020 arm64 compiler info: clang: 16.0.0 (clang-1600.0.26.6) libc info: no libc information available $SHELL (typically, interactive shell): /bin/zsh

[Enabled Hooks] pre-push

Kristoffer Haugsbakk· Jan 13, 2025, 16:32 UTC · re: André de Castro · lore

Re: Bug report - Apple git

On Mon, Jan 13, 2025, at 15:23, André de Castro wrote:
Show 8 quoted lines
> Checked out a branch, ran "git diff --merge-base <some-annotated-tag> HEAD".
>
> What did you expect to happen? (Expected behavior)
> To see a normal git diff output.
>
> What happened instead? (Actual behavior)
> Didn't get a diff output. Got the following error instead:
> "fatal: --merge-base only works with commits"

This works for me on version 2.48.0. It seems to have been fixed in 2.43.0. You would have to update to a newer version.

It looks like it was fixed in 4adceb5a299 (diff: fix --merge-base with annotated tags, 2023-10-01).[1] The intent of the error message was to disallow non-commit-ish like trees:

    v2.48.0^{tree}
But it also rejected annotated tags instead of peeling them.
🔗 1: https://lore.kernel.org/git/20231001151845.3621551-1-hi@alyssa.is/
Torsten Bögershausen· Jan 13, 2025, 16:35 UTC · re: André de Castro · lore

Re: Bug report - Apple git

(Please no top-posting here)
On 2025-01-13 15:23, André de Castro wrote:
Show 46 quoted lines
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
> Checked out a branch, ran "git diff --merge-base <some-annotated-tag> HEAD".
>
> What did you expect to happen? (Expected behavior)
> To see a normal git diff output.
>
> What happened instead? (Actual behavior)
> Didn't get a diff output. Got the following error instead:
> "fatal: --merge-base only works with commits"
>
> What's different between what you expected and what actually happened?
> I didn't get the expected diff output and got an error message instead.
>
> Anything else you want to add:
> Seems it happens when I use a tag as one of the commits for git diff
> --merge-base. This is on a macOS, with apple git.
> On Windows, with Git Bash, it works as expected.
>
> I can get this to work with "git diff --merge-base $(git rev-list -n 1
> <some-annotated-tag>) HEAD".
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
>
>
> [System Info]
> git version:
> git version 2.39.5 (Apple Git-154)
> cpu: arm64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> feature: fsmonitor--daemon
> uname: Darwin 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 18:56:34 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6020 arm64
> compiler info: clang: 16.0.0 (clang-1600.0.26.6)
> libc info: no libc information available
> $SHELL (typically, interactive shell): /bin/zsh
>
>
> [Enabled Hooks]
> pre-push
>

Hm, I don't think that this group/mailing list takes responsibility for binaries shipped by companies.

If you want, you can compile Git yourself to be "on par" with what you find under other OS. That is the good thing with open source - please let us know, if help is needed.

D. Ben Knoble· Jan 14, 2025, 21:57 UTC · re: André de Castro · lore

Re: Bug report - Apple git

On Mon, Jan 13, 2025 at 9:23 AM André de Castro <aramosdecastro@gmail.com> wrote:

Show 24 quoted lines
>
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
> Checked out a branch, ran "git diff --merge-base <some-annotated-tag> HEAD".
>
> What did you expect to happen? (Expected behavior)
> To see a normal git diff output.
>
> What happened instead? (Actual behavior)
> Didn't get a diff output. Got the following error instead:
> "fatal: --merge-base only works with commits"
>
> What's different between what you expected and what actually happened?
> I didn't get the expected diff output and got an error message instead.
>
> Anything else you want to add:
> Seems it happens when I use a tag as one of the commits for git diff
> --merge-base. This is on a macOS, with apple git.
> On Windows, with Git Bash, it works as expected.
>
> I can get this to work with "git diff --merge-base $(git rev-list -n 1
> <some-annotated-tag>) HEAD".

A shorter workaround is probably "git diff --merge-base <your-tag>^{commit} HEAD" (this is the "peeling" that Kristoffer references)

Show 24 quoted lines
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
>
>
> [System Info]
> git version:
> git version 2.39.5 (Apple Git-154)
> cpu: arm64
> no commit associated with this build
> sizeof-long: 8
> sizeof-size_t: 8
> shell-path: /bin/sh
> feature: fsmonitor--daemon
> uname: Darwin 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 18:56:34 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6020 arm64
> compiler info: clang: 16.0.0 (clang-1600.0.26.6)
> libc info: no libc information available
> $SHELL (typically, interactive shell): /bin/zsh
>
>
> [Enabled Hooks]
> pre-push
>
>
-- 
D. Ben Knoble
Junio C Hamano· Jan 14, 2025, 22:43 UTC · re: D. Ben Knoble · lore

Re: Bug report - Apple git

"D. Ben Knoble" <ben.knoble@gmail.com> writes:
Show 7 quoted lines
>> What happened instead? (Actual behavior)
>> Didn't get a diff output. Got the following error instead:
>> "fatal: --merge-base only works with commits"
>> ...
> A shorter workaround is probably "git diff --merge-base
> <your-tag>^{commit} HEAD" (this is the "peeling" that Kristoffer
> references)
Thanks.  
    $ git log -S'only works with commits' ':!po/'

finds 4adceb5a (diff: fix --merge-base with annotated tags, 2023-10-01), which is v2.43.0-rc0~36^2 and v2.43 is from Nov 2023, so this seems to be a rather ancient bug that has been already fixed in our codebase.

The reason why I started writing this message is a bit offtopic (and that is why Jiang is CC'ed). We do still have that string in our "codebase" but in po/

    $ git grep -c 'only works with commits' po/
    po/es.po:1
    po/pl.po:1
    po/pt_PT.po:1
    po/ru.po:1

I suspect there may be other strings and translations that are no longer in use.

Are they something we can easily remove mechanically, and if so should we?

Thanks.
André de Castro· Jan 13, 2025, 16:50 UTC · lore

Re: Bug report - Apple git

Show 12 quoted lines
> This works for me on version 2.48.0.  It seems to have been fixed in
> 2.43.0.  You would have to update to a newer version.
> 
> It looks like it was fixed in 4adceb5a299 (diff: fix --merge-base with
> annotated tags, 2023-10-01).[1]  The intent of the error message was to
> disallow non-commit-ish like trees:
> 
>    v2.48.0^{tree}
> 
> But it also rejected annotated tags instead of peeling them.
> 
> 🔗 1: https://lore.kernel.org/git/20231001151845.3621551-1-hi@alyssa.is/
Indeed it works here with the homebrew version (2.48.0).
Thank you for the quick reply.
Show 7 quoted lines
> Hm, I don't think that this group/mailing list takes responsibility
> for binaries shipped by companies.
> 
> If you want, you can compile Git yourself to be "on par" with
> what you find under other OS.
> That is the good thing with open source - please let us know,
> if help is needed.
I was unsure whether this was the right place to post. Thanks for the tip.
André de Castro

← back to recent threads