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

Re: Q. about usage of notes

From
Stefan Naewe <stefan.naewe@atlas-elektronik.com>
Date
Aug 31, 2010, 10:13 UTC
Message-ID
<4C7CD5B8.20602@atlas-elektronik.com>
In-Reply-To
<201008311107.32278.johan@herland.net>
On 8/31/2010 11:07 AM, Johan Herland wrote:
Show 19 quoted lines
> On Tuesday 31 August 2010, Stefan Naewe wrote:
>> Hi,
>>
>> I was playing around with 'git notes' these days (after reading S.Chacons
>> post to this list and hist blog post at progit.org).
>>
>> Some things came to my mind when doing some 'git notes add' and
>> 'git notes remove':
>>
>> How do I really get rid of git notes ? 'git notes remove' doesn't really
>> remove the notes but creates a new commit (like 'git rm file ; git
>> commit..' does).
> 
> Well, how do you "really" get rid of a file on a "regular" Git branch? The 
> answer is that Git doesn't let you do this without rewriting history (e.g. 
> using 'git filter-branch' to create a new history where that file never 
> existed). The same argument goes for notes: If you want to remove all traces 
> of notes for a given object, you must rewrite the notes history so that 
> those notes never existed.
OK. Understood.
 
Show 12 quoted lines
> At least that's how the 'git notes' porcelain behaves. At the plumbing 
> level, it's possible to create notes commits that don't point to the 
> preceding notes history (every notes commit is a root commit), and thus end 
> up with "history-less" notes. An example of this is the notes-cache code.
> 
>> And why does 'git remove' do that repetetively (is that even a word...?),
>> i.e. 'git add -m"Note" ; git remove; git remove; git remove; git remove'
>> creates 5 commit objects under 'refs/notes/commits' Is that the intended
>> behaviour ?
> 
> (I assume your meant to put "notes" in all those commands: git notes add, 
> git notes remove, etc.)
Yes, sorry.
Show 5 quoted lines
> Yes, this is the intended behaviour. Otherwise you would need a separate 
> notes index where you could stage notes changes (with git notes add/remove), 
> and then later commit those notes changes with (the imaginary) git notes 
> commit. This was deemed too cumbersome/complicated, and we settled for the 
> current approach instead.
But if I do:
$ touch file ; git add file ; git commit -m"add file"
and then 
$ for n in 1 2 3; do git rm file; git commit -m"rm file"; done
 
I get:
rm 'file'
[master 5b24511] rm file
 0 files changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 file
fatal: pathspec 'file' did not match any files
# On branch master
nothing to commit (working directory clean)
fatal: pathspec 'file' did not match any files
# On branch master
nothing to commit (working directory clean)
I don't get 4 commits. That's the part I don't understand :-(
> If you want to make several adds/removes per notes commit, you could:
> 
> 1. Use git-fast-import and its 'N' command (search the manual page for 
> "notemodify").
OK. Thanks. Didn't know that. 
Show 5 quoted lines
> 2. Check out the notes ref into your working tree ("git checkout 
> refs/notes/commits"). You can now edit notes directly, like you would edit 
> your "regular" files. (Ideally, you should have some knowledge about the 
> format of notes trees before you add/rename files). When you're done, you 
> stage and commit as you would do in your regular checkout.
OK. I already tried that.
 
And to delete the 'notes branch' I can only use 'git update-ref' ?!
Thanks for your answer
Stefan
-- 
----------------------------------------------------------------
/dev/random says: Nostalgia isn't what it used to be.
Previous: Johan HerlandNext: Stefan Naewe
Message 3 of 16 in “Q. about usage of notes”
  1. Stefan NaeweAug 31, 2010
  2. Johan HerlandAug 31, 2010
  3. Stefan NaeweAug 31, 2010
  4. Stefan NaeweAug 31, 2010
  5. [RFC] notes: avoid recommitting identical treesMichael J Gruber, Aug 31, 2010
  6. Jeff KingAug 31, 2010
  7. Michael J GruberAug 31, 2010
  8. Junio C HamanoAug 31, 2010
  9. Michael J GruberAug 31, 2010
  10. Jeff KingAug 31, 2010
  11. Michael J GruberAug 31, 2010
  12. Junio C HamanoAug 31, 2010
  13. Johan HerlandAug 31, 2010
  14. Johan HerlandAug 31, 2010
  15. 1/2 notes: Don't create (empty) commit when removing non-existing notesJohan Herland, Aug 31, 2010
  16. 2/2 notes.h: Extend remove_note to return the SHA1 of the removed note, if anyJohan Herland, Aug 31, 2010

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.