Skip to content

Commit 2949151

Browse files
committed
Merge branch 'jh/notes'
* jh/notes: (33 commits) Documentation: fix a few typos in git-notes.txt notes: fix malformed tree entry builtin-notes: Minor (mostly parse_options-related) fixes builtin-notes: Add "copy" subcommand for copying notes between objects builtin-notes: Misc. refactoring of argc and exit value handling builtin-notes: Add -c/-C options for reusing notes builtin-notes: Refactor handling of -F option to allow combining -m and -F builtin-notes: Deprecate the -m/-F options for "git notes edit" builtin-notes: Add "append" subcommand for appending to note objects builtin-notes: Add "add" subcommand for adding notes to objects builtin-notes: Add --message/--file aliases for -m/-F options builtin-notes: Add "list" subcommand for listing note objects Documentation: Generalize git-notes docs to 'objects' instead of 'commits' builtin-notes: Add "prune" subcommand for removing notes for missing objects Notes API: prune_notes(): Prune notes that belong to non-existing objects t3305: Verify that removing notes triggers automatic fanout consolidation builtin-notes: Add "remove" subcommand for removing existing notes Teach builtin-notes to remove empty notes Teach notes code to properly preserve non-notes in the notes tree t3305: Verify that adding many notes with git-notes triggers increased fanout ... Conflicts: Makefile
2 parents 3a27f41 + 48716a2 commit 2949151

File tree

14 files changed

+2167
-196
lines changed

14 files changed

+2167
-196
lines changed

Documentation/git-notes.txt

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,112 @@ git-notes(1)
33

44
NAME
55
----
6-
git-notes - Add/inspect commit notes
6+
git-notes - Add/inspect object notes
77

88
SYNOPSIS
99
--------
1010
[verse]
11-
'git notes' (edit [-F <file> | -m <msg>] | show) [commit]
11+
'git notes' [list [<object>]]
12+
'git notes' add [-f] [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
13+
'git notes' copy [-f] <from-object> <to-object>
14+
'git notes' append [-F <file> | -m <msg> | (-c | -C) <object>] [<object>]
15+
'git notes' edit [<object>]
16+
'git notes' show [<object>]
17+
'git notes' remove [<object>]
18+
'git notes' prune
19+
1220

1321
DESCRIPTION
1422
-----------
15-
This command allows you to add notes to commit messages, without
16-
changing the commit. To discern these notes from the message stored
17-
in the commit object, the notes are indented like the message, after
18-
an unindented line saying "Notes:".
23+
This command allows you to add/remove notes to/from objects, without
24+
changing the objects themselves.
25+
26+
A typical use of notes is to extend a commit message without having
27+
to change the commit itself. Such commit notes can be shown by `git log`
28+
along with the original commit message. To discern these notes from the
29+
message stored in the commit object, the notes are indented like the
30+
message, after an unindented line saying "Notes:".
1931

20-
To disable commit notes, you have to set the config variable
21-
core.notesRef to the empty string. Alternatively, you can set it
22-
to a different ref, something like "refs/notes/bugzilla". This setting
23-
can be overridden by the environment variable "GIT_NOTES_REF".
32+
To disable notes, you have to set the config variable core.notesRef to
33+
the empty string. Alternatively, you can set it to a different ref,
34+
something like "refs/notes/bugzilla". This setting can be overridden
35+
by the environment variable "GIT_NOTES_REF".
2436

2537

2638
SUBCOMMANDS
2739
-----------
2840

41+
list::
42+
List the notes object for a given object. If no object is
43+
given, show a list of all note objects and the objects they
44+
annotate (in the format "<note object> <annotated object>").
45+
This is the default subcommand if no subcommand is given.
46+
47+
add::
48+
Add notes for a given object (defaults to HEAD). Abort if the
49+
object already has notes (use `-f` to overwrite an
50+
existing note).
51+
52+
copy::
53+
Copy the notes for the first object onto the second object.
54+
Abort if the second object already has notes, or if the first
55+
object has none (use -f to overwrite existing notes to the
56+
second object). This subcommand is equivalent to:
57+
`git notes add [-f] -C $(git notes list <from-object>) <to-object>`
58+
59+
append::
60+
Append to the notes of an existing object (defaults to HEAD).
61+
Creates a new notes object if needed.
62+
2963
edit::
30-
Edit the notes for a given commit (defaults to HEAD).
64+
Edit the notes for a given object (defaults to HEAD).
3165

3266
show::
33-
Show the notes for a given commit (defaults to HEAD).
67+
Show the notes for a given object (defaults to HEAD).
68+
69+
remove::
70+
Remove the notes for a given object (defaults to HEAD).
71+
This is equivalent to specifying an empty note message to
72+
the `edit` subcommand.
3473

74+
prune::
75+
Remove all notes for non-existing/unreachable objects.
3576

3677
OPTIONS
3778
-------
79+
-f::
80+
--force::
81+
When adding notes to an object that already has notes,
82+
overwrite the existing notes (instead of aborting).
83+
3884
-m <msg>::
85+
--message=<msg>::
3986
Use the given note message (instead of prompting).
40-
If multiple `-m` (or `-F`) options are given, their
41-
values are concatenated as separate paragraphs.
87+
If multiple `-m` options are given, their values
88+
are concatenated as separate paragraphs.
4289

4390
-F <file>::
91+
--file=<file>::
4492
Take the note message from the given file. Use '-' to
4593
read the note message from the standard input.
46-
If multiple `-F` (or `-m`) options are given, their
47-
values are concatenated as separate paragraphs.
4894

95+
-C <object>::
96+
--reuse-message=<object>::
97+
Reuse the note message from the given note object.
98+
99+
-c <object>::
100+
--reedit-message=<object>::
101+
Like '-C', but with '-c' the editor is invoked, so that
102+
the user can further edit the note message.
49103

50104
Author
51105
------
52-
Written by Johannes Schindelin <[email protected]>
106+
Written by Johannes Schindelin <[email protected]> and
107+
Johan Herland <[email protected]>
53108

54109
Documentation
55110
-------------
56-
Documentation by Johannes Schindelin
111+
Documentation by Johannes Schindelin and Johan Herland
57112

58113
GIT
59114
---

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ SCRIPT_SH += git-merge-octopus.sh
335335
SCRIPT_SH += git-merge-one-file.sh
336336
SCRIPT_SH += git-merge-resolve.sh
337337
SCRIPT_SH += git-mergetool.sh
338-
SCRIPT_SH += git-notes.sh
339338
SCRIPT_SH += git-pull.sh
340339
SCRIPT_SH += git-quiltimport.sh
341340
SCRIPT_SH += git-rebase--interactive.sh
@@ -677,6 +676,7 @@ BUILTIN_OBJS += builtin/mktag.o
677676
BUILTIN_OBJS += builtin/mktree.o
678677
BUILTIN_OBJS += builtin/mv.o
679678
BUILTIN_OBJS += builtin/name-rev.o
679+
BUILTIN_OBJS += builtin/notes.o
680680
BUILTIN_OBJS += builtin/pack-objects.o
681681
BUILTIN_OBJS += builtin/pack-redundant.o
682682
BUILTIN_OBJS += builtin/pack-refs.o

builtin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "strbuf.h"
66
#include "cache.h"
77
#include "commit.h"
8+
#include "notes.h"
89

910
extern const char git_version_string[];
1011
extern const char git_usage_string[];
@@ -18,6 +19,7 @@ extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
1819
extern int commit_tree(const char *msg, unsigned char *tree,
1920
struct commit_list *parents, unsigned char *ret,
2021
const char *author);
22+
extern int commit_notes(struct notes_tree *t, const char *msg);
2123
extern int check_pager_config(const char *cmd);
2224

2325
extern int cmd_add(int argc, const char **argv, const char *prefix);
@@ -78,6 +80,7 @@ extern int cmd_mktag(int argc, const char **argv, const char *prefix);
7880
extern int cmd_mktree(int argc, const char **argv, const char *prefix);
7981
extern int cmd_mv(int argc, const char **argv, const char *prefix);
8082
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
83+
extern int cmd_notes(int argc, const char **argv, const char *prefix);
8184
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
8285
extern int cmd_pack_redundant(int argc, const char **argv, const char *prefix);
8386
extern int cmd_patch_id(int argc, const char **argv, const char *prefix);

0 commit comments

Comments
 (0)