From: Junio C Hamano Date: Wed, 24 Mar 2010 23:26:43 +0000 (-0700) Subject: Merge branch 'tr/notes-display' X-Git-Tag: v1.7.1-rc0~43 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a86ed83cce0fc0b9a9fe4e17ac1bf4f719028d20;p=git.git Merge branch 'tr/notes-display' * tr/notes-display: git-notes(1): add a section about the meaning of history notes: track whether notes_trees were changed at all notes: add shorthand --ref to override GIT_NOTES_REF commit --amend: copy notes to the new commit rebase: support automatic notes copying notes: implement helpers needed for note copying during rewrite notes: implement 'git notes copy --stdin' rebase -i: invoke post-rewrite hook rebase: invoke post-rewrite hook commit --amend: invoke post-rewrite hook Documentation: document post-rewrite hook Support showing notes from more than one notes tree test-lib: unset GIT_NOTES_REF to stop it from influencing tests Conflicts: git-am.sh refs.c --- a86ed83cce0fc0b9a9fe4e17ac1bf4f719028d20 diff --cc Documentation/git-notes.txt index bef2f3942,e2701cff1..4e5113b83 --- a/Documentation/git-notes.txt +++ b/Documentation/git-notes.txt @@@ -52,9 -57,19 +57,19 @@@ add: copy:: Copy the notes for the first object onto the second object. Abort if the second object already has notes, or if the first - objects has none. (use -f to overwrite existing notes to the + object has none (use -f to overwrite existing notes to the second object). This subcommand is equivalent to: `git notes add [-f] -C $(git notes list ) ` + + + In `\--stdin` mode, take lines in the format + + + ---------- + SP [ SP ] LF + ---------- + + + on standard input, and copy the notes from each to its + corresponding . (The optional `` is ignored so that + the command can read the input given to the `post-rewrite` hook.) append:: Append to the notes of an existing object (defaults to HEAD). diff --cc builtin/notes.c index feb710ac4,e5046b98e..4543d1131 --- a/builtin/notes.c +++ b/builtin/notes.c @@@ -278,25 -445,27 +436,32 @@@ int cmd_notes(int argc, const char **ar char logmsg[100]; int list = 0, add = 0, copy = 0, append = 0, edit = 0, show = 0, - remove = 0, prune = 0, force = 0; + remove = 0, prune = 0, force = 0, from_stdin = 0; 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", - "note contents as a string", parse_msg_arg), - OPT_CALLBACK('F', "file", &msg, "FILE", - "note contents in a file", parse_file_arg), - OPT_CALLBACK('c', "reedit-message", &msg, "OBJECT", - "reuse and edit specified note object", parse_reedit_arg), - OPT_CALLBACK('C', "reuse-message", &msg, "OBJECT", - "reuse specified note object", parse_reuse_arg), + OPT_GROUP("Notes contents options"), + { OPTION_CALLBACK, 'm', "message", &msg, "MSG", + "note contents as a string", PARSE_OPT_NONEG, + parse_msg_arg}, + { OPTION_CALLBACK, 'F', "file", &msg, "FILE", + "note contents in a file", PARSE_OPT_NONEG, + parse_file_arg}, + { OPTION_CALLBACK, 'c', "reedit-message", &msg, "OBJECT", + "reuse and edit specified note object", PARSE_OPT_NONEG, + parse_reedit_arg}, + { OPTION_CALLBACK, 'C', "reuse-message", &msg, "OBJECT", + "reuse specified note object", PARSE_OPT_NONEG, + parse_reuse_arg}, + OPT_GROUP("Other options"), 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 "), + OPT_STRING(0, "for-rewrite", &rewrite_cmd, "command", + "load rewriting config for (implies --stdin)"), OPT_END() }; diff --cc cache.h index f62db0bd7,a04f37f14..2928107bb --- a/cache.h +++ b/cache.h @@@ -387,16 -385,10 +387,19 @@@ static inline enum object_type object_t #define ATTRIBUTE_MACRO_PREFIX "[attr]" #define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF" #define GIT_NOTES_DEFAULT_REF "refs/notes/commits" + #define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF" + #define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF" + #define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE" +/* + * Repository-local GIT_* environment variables + * The array is NULL-terminated to simplify its usage in contexts such + * environment creation or simple walk of the list. + * The number of non-NULL entries is available as a macro. + */ +#define LOCAL_REPO_ENV_SIZE 8 +extern const char *const local_repo_env[LOCAL_REPO_ENV_SIZE + 1]; + extern int is_bare_repository_cfg; extern int is_bare_repository(void); extern int is_inside_git_dir(void); diff --cc git-am.sh index 50a292a7d,7644474bc..105607554 --- a/git-am.sh +++ b/git-am.sh @@@ -791,5 -780,13 +797,12 @@@ d go_next done + if test -s "$dotest"/rewritten; then + git notes copy --for-rewrite=rebase < "$dotest"/rewritten + if test -x "$GIT_DIR"/hooks/post-rewrite; then + "$GIT_DIR"/hooks/post-rewrite rebase < "$dotest"/rewritten + fi + fi + -git gc --auto - rm -fr "$dotest" +git gc --auto diff --cc notes.c index 07941b723,0261e7898..e425e1982 --- a/notes.c +++ b/notes.c @@@ -891,9 -1028,10 +1028,10 @@@ void remove_note(struct notes_tree *t, if (!t) t = &default_notes_tree; assert(t->initialized); + t->dirty = 1; hashcpy(l.key_sha1, object_sha1); hashclr(l.val_sha1); - return note_tree_remove(t, t->root, 0, &l); + note_tree_remove(t, t->root, 0, &l); } const unsigned char *get_note(struct notes_tree *t,