post-rewrite hook and copying notes
PATCH v6 13/13 git-notes(1): add a section about the meaning of history
In reply to Thomas RastTo the displaying code, the only interesting thing about a notes ref is that it has a tree of the required format. However, notes actually have a history since they are recorded as successive commits.
Make a note about the existence of this history in the manpage, but keep some doors open if we want to change the details.
---
New in v6, as per Junio's comment
Quoted 5 lines
- As to the determination of committer/author identity, I think what the code currently does (i.e. honor the environment and user.* config) is perfectly sane, but at the same time I think it would be surprising for unsuspecting users. We may want to advise users about this in the documentation.
(but see the series leader for more discussion about this).
Documentation/git-notes.txt | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
Documentation/git-notes.txt +14 -0
@@ -121,6 +121,20 @@ OPTIONS GIT_NOTES_REF and the "core.notesRef" configuration. The ref is taken to be in `refs/notes/` if it is not qualified. + +NOTES +----- + +Every notes change creates a new commit at the specified notes ref. +You can therefore inspect the history of the notes by invoking, e.g., +`git log -p notes/commits`. + +Currently the commit message only records which operation triggered +the update, and the commit authorship is determined according to the +usual rules (see linkgit:git-commit[1]). These details may change in +the future. + + Author ------ Written by Johannes Schindelin <[email protected]> and
Signature · 1 line
1.7.0.2.407.g21ebda
Re: [PATCH v6 13/13] git-notes(1): add a section about the meaning of history
Quoted 8 lines · Thomas Rast
To the displaying code, the only interesting thing about a notes ref is that it has a tree of the required format. However, notes actually have a history since they are recorded as successive commits.
Make a note about the existence of this history in the manpage, but keep some doors open if we want to change the details.
Signed-off-by Thomas Rast <[email protected]>
Signature · 2 lines
Johan Herland, <[email protected]> www.herland.net
PATCH v5 10/11 commit --amend: copy notes to the new commit
In reply to Thomas RastTeaches 'git commit --amend' to copy notes. The catch is that this must also be guarded by --no-post-rewrite, which we use to prevent --amend from copying notes during a rebase -i 'edit'/'reword'.
---
builtin-commit.c | 6 ++++++ t/t7501-commit.sh | 12 ++++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-)
builtin-commit.c +6 -0
@@ -1340,6 +1340,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)rerere (0 );run_hook (get_index_file (),"post-commit" ,NULL );if (amend && !no_post_rewrite) { +struct notes_rewrite_cfg *cfg; + cfg =init_copy_notes_for_rewrite ("amend" ); +if (cfg) { +copy_note_for_rewrite (cfg, head_sha1, commit_sha1); +finish_copy_notes_for_rewrite (cfg); + }run_rewrite_hook (head_sha1, commit_sha1); }if (!quiet)
t/t7501-commit.sh +12 -0
@@ -425,4 +425,16 @@ test_expect_success 'amend using the message from a commit named with tag' ' ' +test_expect_success 'amend can copy notes' ' + + git config notes.rewrite.amend true && + git config notes.rewriteRef "refs/notes/*" && + test_commit foo && + git notes add -m"a note" && + test_tick && + git commit --amend -m"new foo" && + test "$(git notes show)" = "a note" + +' + test_done
Signature · 1 line
1.7.0.218.g73a398
PATCH v5 11/11 notes: add shorthand --ref to override GIT_NOTES_REF
In reply to Thomas RastAdds a shorthand option that overrides the GIT_NOTES_REF variable, and hence determines the notes tree that will be manipulated. It also DWIMs a refs/notes/ prefix.
---
Changes since v4:
* doc tweaks
Documentation/git-notes.txt | 5 +++++ builtin-notes.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/git-notes.txt +5 -0
@@ -115,6 +115,11 @@ OPTIONS Like '-C', but with '-c' the editor is invoked, so that the user can further edit the note message. +--ref <ref>:: + Manipulate the notes tree in <ref>. This overrides both + GIT_NOTES_REF and the "core.notesRef" configuration. The ref + is taken to be in `refs/notes/` if it is not qualified. + Author ------ Written by Johannes Schindelin <[email protected]> and
builtin-notes.c +16 -0
@@ -447,6 +447,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)int given_object =0 , i =1 , retval =0 ;struct msg_arg msg = {0 ,0 ,STRBUF_INIT };const char *rewrite_cmd =NULL ; +const char *override_notes_ref =NULL ;struct option options[] = {OPT_GROUP ("Notes options" ), OPT_CALLBACK('m', "message", &msg, "MSG",
@@ -459,6 +460,8 @@ int cmd_notes(int argc, const char **argv, const char *prefix) "reuse specified note object", parse_reuse_arg),OPT_BOOLEAN ('f' ,"force" , &force,"replace existing notes" ),OPT_BOOLEAN (0 ,"stdin" , &from_stdin,"read objects from stdin" ), +OPT_STRING (0 ,"ref" , &override_notes_ref,"notes_ref" , +"use notes from <notes_ref>" ),OPT_STRING (0 ,"for-rewrite" , &rewrite_cmd,"command" ,"load rewriting config for <command> (implies --stdin)" ),OPT_END ()
@@ -468,6 +471,19 @@ int cmd_notes(int argc, const char **argv, const char *prefix) argc =parse_options (argc, argv, prefix, options, git_notes_usage,0 ); +if (override_notes_ref) { +struct strbuf sb =STRBUF_INIT ; +if (!prefixcmp (override_notes_ref,"refs/notes/" )) +/* we're happy */ ; +else if (!prefixcmp (override_notes_ref,"notes/" )) +strbuf_addstr (&sb,"refs/" ); +else +strbuf_addstr (&sb,"refs/notes/" ); +strbuf_addstr (&sb, override_notes_ref); +setenv ("GIT_NOTES_REF" , sb.buf,1 ); +strbuf_release (&sb); + } +if (argc && !strcmp (argv[0 ],"list" )) list =1 ;else if (argc && !strcmp (argv[0 ],"add" ))
Signature · 1 line
1.7.0.218.g73a398