git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Can a note be pushed to origin?
@ 2024-09-25 12:07 Stephen P. Smith
  0 siblings, 0 replies; 8+ messages in thread
From: Stephen P. Smith @ 2024-09-25 12:07 UTC (permalink / raw)
  To: git; +Cc: Stephen P. Smith

In a project that I am working on, some metadata is currently embedded in some 
source files.  The question was asked yesterday if there is a way to move that 
metadata a git specific file and link it to the source file or commit.

I remembered that git has notes which can be used to add such data to a 
commit, but I don't believe that such metadata gets pushed to origin nor 
fetched from origin but another user.  

Is there a currently implemented way to do something like this?




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

* Can a note be pushed to origin?
@ 2024-09-25 12:25 Stephen P. Smith
  2024-09-25 15:29 ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen P. Smith @ 2024-09-25 12:25 UTC (permalink / raw)
  To: git; +Cc: ishchis2

In a project that I am working on, some metadata is currently embedded in some 
source files.  The question was asked yesterday if there is a way to move that 
metadata a git specific file and link it to the source file or commit.

I remembered that git has notes which can be used to add such data to a 
commit, but I don't believe that such metadata gets pushed to origin nor 
fetched from origin but another user.  

Is there a currently implemented way to do something like this?

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

* Can a note be pushed to origin?
@ 2024-09-25 12:29 Stephen Steves Linda Smith
  2024-10-02  1:37 ` Carlisle T. Hamlin
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Steves Linda Smith @ 2024-09-25 12:29 UTC (permalink / raw)
  To: git

In a project that I am working on, some metadata is currently embedded in some 
source files.  The question was asked yesterday if there is a way to move that 
metadata a git specific file and link it to the source file or commit.

I remembered that git has notes which can be used to add such data to a 
commit, but I don't believe that such metadata gets pushed to origin nor 
fetched from origin but another user.  

Is there a currently implemented way to do something like this?

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

* Re: Can a note be pushed to origin?
  2024-09-25 12:25 Can a note be pushed to origin? Stephen P. Smith
@ 2024-09-25 15:29 ` Kristoffer Haugsbakk
  2024-09-27  4:15   ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2024-09-25 15:29 UTC (permalink / raw)
  To: Stephen P. Smith; +Cc: git

Hi

On Wed, Sep 25, 2024, at 14:25, Stephen P. Smith wrote:
> In a project that I am working on, some metadata is currently embedded in some
> source files.  The question was asked yesterday if there is a way to move that
> metadata a git specific file and link it to the source file or commit.
>
> I remembered that git has notes which can be used to add such data to a
> commit, but I don't believe that such metadata gets pushed to origin nor
> fetched from origin but another user.
>
> Is there a currently implemented way to do something like this?

You have to do it manually.

In `.git/config`:

```
[remote "origin"]
	url = <url>
        […]
	fetch = refs/notes/commits:refs/notes/commits
```

That fetches the default Notes ref on `git fetch origin`.

That will refuse to update if your own notes ever diverge from the
remote.  If you want to always overwrite your local notes with the
remote ones:

```
[remote "origin"]
	url = <url>
        […]
	fetch = +refs/notes/commits:refs/notes/commits
```

But then you should also enable reflog updates for all refs:

```
git config set --global core.logAllRefUpdates always
```

In case you do a fetch that you want to undo.

-- 
Kristoffer Haugsbakk


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

* Re: Can a note be pushed to origin?
  2024-09-25 15:29 ` Kristoffer Haugsbakk
@ 2024-09-27  4:15   ` Jeff King
  2024-09-28  9:52     ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2024-09-27  4:15 UTC (permalink / raw)
  To: Kristoffer Haugsbakk; +Cc: Stephen P. Smith, git

On Wed, Sep 25, 2024 at 05:29:30PM +0200, Kristoffer Haugsbakk wrote:

> That will refuse to update if your own notes ever diverge from the
> remote.  If you want to always overwrite your local notes with the
> remote ones:

There are some specialized strategies for merging notes (e.g., taking
the union of lines). See the "merge" subcommand in git-notes(1).

I don't recall ever really using it myself, and I don't think there's
really any porcelain support, so you're on your own to invoke the merge.
But I guess the use case would be something like:

  # fetch their notes into a holding spot
  git config remote.origin.fetch refs/notes/commits:refs/notes/origin/commits

  # and then after every fetch, you merge if necessary. By default we're
  # merging into our own "refs/notes/commits". And it should be OK to
  # use the short "origin/commits" here, since notes-refs have their own
  # special lookup rules. Though using the fully qualified refname is
  # probably reasonable, too.
  git fetch
  git notes merge -s union origin/commits

-Peff

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

* Re: Can a note be pushed to origin?
  2024-09-27  4:15   ` Jeff King
@ 2024-09-28  9:52     ` Kristoffer Haugsbakk
  0 siblings, 0 replies; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2024-09-28  9:52 UTC (permalink / raw)
  To: Jeff King; +Cc: Stephen P. Smith, git

On Fri, Sep 27, 2024, at 06:15, Jeff King wrote:
> On Wed, Sep 25, 2024 at 05:29:30PM +0200, Kristoffer Haugsbakk wrote:
>
>> That will refuse to update if your own notes ever diverge from the
>> remote.  If you want to always overwrite your local notes with the
>> remote ones:
>
> There are some specialized strategies for merging notes (e.g., taking
> the union of lines). See the "merge" subcommand in git-notes(1).
>
> I don't recall ever really using it myself, and I don't think there's
> really any porcelain support, so you're on your own to invoke the merge.
> But I guess the use case would be something like:
>
>   # fetch their notes into a holding spot
>   git config remote.origin.fetch refs/notes/commits:refs/notes/origin/commits
>
>   # and then after every fetch, you merge if necessary. By default we're
>   # merging into our own "refs/notes/commits". And it should be OK to
>   # use the short "origin/commits" here, since notes-refs have their own
>   # special lookup rules. Though using the fully qualified refname is
>   # probably reasonable, too.
>   git fetch
>   git notes merge -s union origin/commits

git-notes(1) feels like the most “plumbing” command out of the “main
porcelain commands”. :) (of those that I use)

For my needs though it is high level enough since I mostly add notes to
my own commits. Certainly porcelain in that sense. I use it all the time
to add testing/general comments to my commits.

-- 
Kristoffer Haugsbakk

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

* Re: Can a note be pushed to origin?
  2024-09-25 12:29 Stephen Steves Linda Smith
@ 2024-10-02  1:37 ` Carlisle T. Hamlin
  2024-10-02  1:39   ` Carlisle T. Hamlin
  0 siblings, 1 reply; 8+ messages in thread
From: Carlisle T. Hamlin @ 2024-10-02  1:37 UTC (permalink / raw)
  To: Stephen Steves Linda Smith, git

You betcha.

Add to the 'origin' entry in the config file specific to your local
repository:

fetch = +refs/notes/*:refs/notes/*
push = *refs/notes/*:refs/notes/*

Just be aware that other developers will remain blissfully unaware of
your notes unless they either expressly fetch notes for themselves, or
replicate your config setup as regards notes.

Good luck!

On 9/25/24 05:29, Stephen Steves Linda Smith wrote:
> In a project that I am working on, some metadata is currently embedded in some
> source files.  The question was asked yesterday if there is a way to move that
> metadata a git specific file and link it to the source file or commit.
>
> I remembered that git has notes which can be used to add such data to a
> commit, but I don't believe that such metadata gets pushed to origin nor
> fetched from origin but another user.
>
> Is there a currently implemented way to do something like this?
>


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

* Re: Can a note be pushed to origin?
  2024-10-02  1:37 ` Carlisle T. Hamlin
@ 2024-10-02  1:39   ` Carlisle T. Hamlin
  0 siblings, 0 replies; 8+ messages in thread
From: Carlisle T. Hamlin @ 2024-10-02  1:39 UTC (permalink / raw)
  To: Stephen Steves Linda Smith, git

Oop - fat-fingered it; the commands are:

 > fetch = +refs/notes/*:refs/notes/*
 > push = +refs/notes/*:refs/notes/*

Accidentally typed an asterisk before the push directive. Don't do that. :)

On 10/1/24 18:37, Carlisle T. Hamlin wrote:
> You betcha.
>
> Add to the 'origin' entry in the config file specific to your local
> repository:
>
> fetch = +refs/notes/*:refs/notes/*
> push = *refs/notes/*:refs/notes/*
>
> Just be aware that other developers will remain blissfully unaware of
> your notes unless they either expressly fetch notes for themselves, or
> replicate your config setup as regards notes.
>
> Good luck!
>
> On 9/25/24 05:29, Stephen Steves Linda Smith wrote:
>> In a project that I am working on, some metadata is currently embedded
>> in some
>> source files.  The question was asked yesterday if there is a way to
>> move that
>> metadata a git specific file and link it to the source file or commit.
>>
>> I remembered that git has notes which can be used to add such data to a
>> commit, but I don't believe that such metadata gets pushed to origin nor
>> fetched from origin but another user.
>>
>> Is there a currently implemented way to do something like this?
>>
>
>


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

end of thread, other threads:[~2024-10-02  1:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 12:25 Can a note be pushed to origin? Stephen P. Smith
2024-09-25 15:29 ` Kristoffer Haugsbakk
2024-09-27  4:15   ` Jeff King
2024-09-28  9:52     ` Kristoffer Haugsbakk
  -- strict thread matches above, loose matches on Subject: below --
2024-09-25 12:29 Stephen Steves Linda Smith
2024-10-02  1:37 ` Carlisle T. Hamlin
2024-10-02  1:39   ` Carlisle T. Hamlin
2024-09-25 12:07 Stephen P. Smith

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 NNTP newsgroup(s).