Revert "Merge branch 'js/notes'"
This reverts commit 7b75b331f6744fbf953fe8913703378ef86a2189, reversing changes made to 5d680a67d7909c89af96eba4a2d77abed606292b.
Junio C Hamano committed
Feb 10, 2009 at 21:31 UTC
954cfb5cfd17d57b9b31b19b73efe73199407e07
16 files changed
-506
.gitignore
-1
@@ -82,7 +82,6 @@ git-mktag
82
git-mktree
83
git-name-rev
84
git-mv
85
-git-notes
85
git-pack-redundant
86
git-pack-objects
87
git-pack-refs
Documentation/RelNotes-1.6.2.txt
-2
@@ -37,8 +37,6 @@ Updates since v1.6.1
37
38
* automatic typo correction works on aliases as well
39
40
-* Initial support for "git notes" implemented.
41
-
40
* @{-1} is a way to refer to the last branch you were on. This is
41
accepted not only where an object name is expected, but anywhere
42
a branch name is expected. E.g. "git branch --track mybranch @{-1}"
Documentation/config.txt
-13
@@ -422,19 +422,6 @@ relatively high IO latencies. With this set to 'true', git will do the
422
index comparison to the filesystem data in parallel, allowing
423
overlapping IO's.
424
425
-core.notesRef::
426
- When showing commit messages, also show notes which are stored in
427
- the given ref. This ref is expected to contain files named
428
- after the full SHA-1 of the commit they annotate.
429
-+
430
-If such a file exists in the given ref, the referenced blob is read, and
431
-appended to the commit message, separated by a "Notes:" line. If the
432
-given ref itself does not exist, it is not an error, but means that no
433
-notes should be printed.
434
-+
435
-This setting defaults to "refs/notes/commits", and can be overridden by
436
-the `GIT_NOTES_REF` environment variable.
437
-
425
alias.*::
426
Command aliases for the linkgit:git[1] command wrapper - e.g.
427
after defining "alias.last = cat-file commit HEAD", the invocation
Documentation/git-notes.txt
deleted
-46
@@ -1,46 +0,0 @@
1
-git-notes(1)
2
-============
3
-
4
-NAME
5
-----
6
-git-notes - Add/inspect commit notes
7
-
8
-SYNOPSIS
9
---------
10
-[verse]
11
-'git-notes' (edit | show) [commit]
12
-
13
-DESCRIPTION
14
------------
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:".
19
-
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".
24
-
25
-
26
-SUBCOMMANDS
27
------------
28
-
29
-edit::
30
- Edit the notes for a given commit (defaults to HEAD).
31
-
32
-show::
33
- Show the notes for a given commit (defaults to HEAD).
34
-
35
-
36
-Author
37
-------
38
-Written by Johannes Schindelin <johannes.schindelin@gmx.de>
39
-
40
-Documentation
41
--------------
42
-Documentation by Johannes Schindelin
43
-
44
-GIT
45
----
46
-Part of the gitlink:git[7] suite
Makefile
-3
@@ -265,7 +265,6 @@ SCRIPT_SH += git-merge-octopus.sh
265
SCRIPT_SH += git-merge-one-file.sh
266
SCRIPT_SH += git-merge-resolve.sh
267
SCRIPT_SH += git-mergetool.sh
268
-SCRIPT_SH += git-notes.sh
268
SCRIPT_SH += git-parse-remote.sh
269
SCRIPT_SH += git-pull.sh
270
SCRIPT_SH += git-quiltimport.sh
@@ -378,7 +377,6 @@ LIB_H += ll-merge.h
377
LIB_H += log-tree.h
378
LIB_H += mailmap.h
379
LIB_H += merge-recursive.h
381
-LIB_H += notes.h
380
LIB_H += object.h
381
LIB_H += pack.h
382
LIB_H += pack-refs.h
@@ -461,7 +459,6 @@ LIB_OBJS += match-trees.o
459
LIB_OBJS += merge-file.o
460
LIB_OBJS += merge-recursive.o
461
LIB_OBJS += name-hash.o
464
-LIB_OBJS += notes.o
462
LIB_OBJS += object.o
463
LIB_OBJS += pack-check.o
464
LIB_OBJS += pack-refs.o
cache.h
-3
@@ -371,8 +371,6 @@ static inline enum object_type object_type(unsigned int mode)
371
#define GITATTRIBUTES_FILE ".gitattributes"
372
#define INFOATTRIBUTES_FILE "info/attributes"
373
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
374
-#define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
375
-#define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
374
375
extern int is_bare_repository_cfg;
376
extern int is_bare_repository(void);
@@ -544,7 +542,6 @@ enum rebase_setup_type {
542
543
extern enum branch_track git_branch_track;
544
extern enum rebase_setup_type autorebase;
547
-extern char *notes_ref_name;
545
546
#define GIT_REPO_VERSION 0
547
extern int repository_format_version;
command-list.txt
-1
@@ -73,7 +73,6 @@ git-mktag plumbingmanipulators
73
git-mktree plumbingmanipulators
74
git-mv mainporcelain common
75
git-name-rev plumbinginterrogators
76
-git-notes mainporcelain
76
git-pack-objects plumbingmanipulators
77
git-pack-redundant plumbinginterrogators
78
git-pack-refs ancillarymanipulators
commit.c
-1
@@ -5,7 +5,6 @@
5
#include "utf8.h"
6
#include "diff.h"
7
#include "revision.h"
8
-#include "notes.h"
8
9
int save_commit_buffer = 1;
10
config.c
-5
@@ -469,11 +469,6 @@ static int git_default_core_config(const char *var, const char *value)
469
return 0;
470
}
471
472
- if (!strcmp(var, "core.notesref")) {
473
- notes_ref_name = xstrdup(value);
474
- return 0;
475
- }
476
-
472
if (!strcmp(var, "core.pager"))
473
return git_config_string(&pager_program, var, value);
474
environment.c
-1
@@ -45,7 +45,6 @@ enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
45
46
/* Parallel index stat data preload? */
47
int core_preload_index = 0;
48
-char *notes_ref_name;
48
49
/* This is set by setup_git_dir_gently() and/or git_default_config() */
50
char *git_work_tree_cfg;
git-notes.sh
deleted
-65
@@ -1,65 +0,0 @@
1
-#!/bin/sh
2
-
3
-USAGE="(edit | show) [commit]"
4
-. git-sh-setup
5
-
6
-test -n "$3" && usage
7
-
8
-test -z "$1" && usage
9
-ACTION="$1"; shift
10
-
11
-test -z "$GIT_NOTES_REF" && GIT_NOTES_REF="$(git config core.notesref)"
12
-test -z "$GIT_NOTES_REF" && GIT_NOTES_REF="refs/notes/commits"
13
-
14
-COMMIT=$(git rev-parse --verify --default HEAD "$@") ||
15
-die "Invalid commit: $@"
16
-
17
-MESSAGE="$GIT_DIR"/new-notes-$COMMIT
18
-trap '
19
- test -f "$MESSAGE" && rm "$MESSAGE"
20
-' 0
21
-
22
-case "$ACTION" in
23
-edit)
24
- GIT_NOTES_REF= git log -1 $COMMIT | sed "s/^/#/" > "$MESSAGE"
25
-
26
- GIT_INDEX_FILE="$MESSAGE".idx
27
- export GIT_INDEX_FILE
28
-
29
- CURRENT_HEAD=$(git show-ref "$GIT_NOTES_REF" | cut -f 1 -d ' ')
30
- if [ -z "$CURRENT_HEAD" ]; then
31
- PARENT=
32
- else
33
- PARENT="-p $CURRENT_HEAD"
34
- git read-tree "$GIT_NOTES_REF" || die "Could not read index"
35
- git cat-file blob :$COMMIT >> "$MESSAGE" 2> /dev/null
36
- fi
37
-
38
- ${VISUAL:-${EDITOR:-vi}} "$MESSAGE"
39
-
40
- grep -v ^# < "$MESSAGE" | git stripspace > "$MESSAGE".processed
41
- mv "$MESSAGE".processed "$MESSAGE"
42
- if [ -s "$MESSAGE" ]; then
43
- BLOB=$(git hash-object -w "$MESSAGE") ||
44
- die "Could not write into object database"
45
- git update-index --add --cacheinfo 0644 $BLOB $COMMIT ||
46
- die "Could not write index"
47
- else
48
- test -z "$CURRENT_HEAD" &&
49
- die "Will not initialise with empty tree"
50
- git update-index --force-remove $COMMIT ||
51
- die "Could not update index"
52
- fi
53
-
54
- TREE=$(git write-tree) || die "Could not write tree"
55
- NEW_HEAD=$(echo Annotate $COMMIT | git commit-tree $TREE $PARENT) ||
56
- die "Could not annotate"
57
- git update-ref -m "Annotate $COMMIT" \
58
- "$GIT_NOTES_REF" $NEW_HEAD $CURRENT_HEAD
59
-;;
60
-show)
61
- git show "$GIT_NOTES_REF":$COMMIT
62
-;;
63
-*)
64
- usage
65
-esac
notes.c
deleted
-160
@@ -1,160 +0,0 @@
1
-#include "cache.h"
2
-#include "commit.h"
3
-#include "notes.h"
4
-#include "refs.h"
5
-#include "utf8.h"
6
-#include "strbuf.h"
7
-#include "tree-walk.h"
8
-
9
-struct entry {
10
- unsigned char commit_sha1[20];
11
- unsigned char notes_sha1[20];
12
-};
13
-
14
-struct hash_map {
15
- struct entry *entries;
16
- off_t count, size;
17
-};
18
-
19
-static int initialized;
20
-static struct hash_map hash_map;
21
-
22
-static int hash_index(struct hash_map *map, const unsigned char *sha1)
23
-{
24
- int i = ((*(unsigned int *)sha1) % map->size);
25
-
26
- for (;;) {
27
- unsigned char *current = map->entries[i].commit_sha1;
28
-
29
- if (!hashcmp(sha1, current))
30
- return i;
31
-
32
- if (is_null_sha1(current))
33
- return -1 - i;
34
-
35
- if (++i == map->size)
36
- i = 0;
37
- }
38
-}
39
-
40
-static void add_entry(const unsigned char *commit_sha1,
41
- const unsigned char *notes_sha1)
42
-{
43
- int index;
44
-
45
- if (hash_map.count + 1 > hash_map.size >> 1) {
46
- int i, old_size = hash_map.size;
47
- struct entry *old = hash_map.entries;
48
-
49
- hash_map.size = old_size ? old_size << 1 : 64;
50
- hash_map.entries = (struct entry *)
51
- xcalloc(sizeof(struct entry), hash_map.size);
52
-
53
- for (i = 0; i < old_size; i++)
54
- if (!is_null_sha1(old[i].commit_sha1)) {
55
- index = -1 - hash_index(&hash_map,
56
- old[i].commit_sha1);
57
- memcpy(hash_map.entries + index, old + i,
58
- sizeof(struct entry));
59
- }
60
- free(old);
61
- }
62
-
63
- index = hash_index(&hash_map, commit_sha1);
64
- if (index < 0) {
65
- index = -1 - index;
66
- hash_map.count++;
67
- }
68
-
69
- hashcpy(hash_map.entries[index].commit_sha1, commit_sha1);
70
- hashcpy(hash_map.entries[index].notes_sha1, notes_sha1);
71
-}
72
-
73
-static void initialize_hash_map(const char *notes_ref_name)
74
-{
75
- unsigned char sha1[20], commit_sha1[20];
76
- unsigned mode;
77
- struct tree_desc desc;
78
- struct name_entry entry;
79
- void *buf;
80
-
81
- if (!notes_ref_name || read_ref(notes_ref_name, commit_sha1) ||
82
- get_tree_entry(commit_sha1, "", sha1, &mode))
83
- return;
84
-
85
- buf = fill_tree_descriptor(&desc, sha1);
86
- if (!buf)
87
- die("Could not read %s for notes-index", sha1_to_hex(sha1));
88
-
89
- while (tree_entry(&desc, &entry))
90
- if (!get_sha1(entry.path, commit_sha1))
91
- add_entry(commit_sha1, entry.sha1);
92
- free(buf);
93
-}
94
-
95
-static unsigned char *lookup_notes(const unsigned char *commit_sha1)
96
-{
97
- int index;
98
-
99
- if (!hash_map.size)
100
- return NULL;
101
-
102
- index = hash_index(&hash_map, commit_sha1);
103
- if (index < 0)
104
- return NULL;
105
- return hash_map.entries[index].notes_sha1;
106
-}
107
-
108
-void get_commit_notes(const struct commit *commit, struct strbuf *sb,
109
- const char *output_encoding)
110
-{
111
- static const char *utf8 = "utf-8";
112
- unsigned char *sha1;
113
- char *msg, *msg_p;
114
- unsigned long linelen, msglen;
115
- enum object_type type;
116
-
117
- if (!initialized) {
118
- const char *env = getenv(GIT_NOTES_REF_ENVIRONMENT);
119
- if (env)
120
- notes_ref_name = getenv(GIT_NOTES_REF_ENVIRONMENT);
121
- else if (!notes_ref_name)
122
- notes_ref_name = GIT_NOTES_DEFAULT_REF;
123
- initialize_hash_map(notes_ref_name);
124
- initialized = 1;
125
- }
126
-
127
- sha1 = lookup_notes(commit->object.sha1);
128
- if (!sha1)
129
- return;
130
-
131
- if (!(msg = read_sha1_file(sha1, &type, &msglen)) || !msglen ||
132
- type != OBJ_BLOB)
133
- return;
134
-
135
- if (output_encoding && *output_encoding &&
136
- strcmp(utf8, output_encoding)) {
137
- char *reencoded = reencode_string(msg, output_encoding, utf8);
138
- if (reencoded) {
139
- free(msg);
140
- msg = reencoded;
141
- msglen = strlen(msg);
142
- }
143
- }
144
-
145
- /* we will end the annotation by a newline anyway */
146
- if (msglen && msg[msglen - 1] == '\n')
147
- msglen--;
148
-
149
- strbuf_addstr(sb, "\nNotes:\n");
150
-
151
- for (msg_p = msg; msg_p < msg + msglen; msg_p += linelen + 1) {
152
- linelen = strchrnul(msg_p, '\n') - msg_p;
153
-
154
- strbuf_addstr(sb, " ");
155
- strbuf_add(sb, msg_p, linelen);
156
- strbuf_addch(sb, '\n');
157
- }
158
-
159
- free(msg);
160
-}
notes.h
deleted
-7
@@ -1,7 +0,0 @@
1
-#ifndef NOTES_H
2
-#define NOTES_H
3
-
4
-void get_commit_notes(const struct commit *commit, struct strbuf *sb,
5
- const char *output_encoding);
6
-
7
-#endif
pretty.c
-5
@@ -6,7 +6,6 @@
6
#include "string-list.h"
7
#include "mailmap.h"
8
#include "log-tree.h"
9
-#include "notes.h"
9
#include "color.h"
10
11
static char *user_format;
@@ -921,9 +920,5 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
920
*/
921
if (fmt == CMIT_FMT_EMAIL && sb->len <= beginning_of_body)
922
strbuf_addch(sb, '\n');
924
-
925
- if (fmt != CMIT_FMT_ONELINE)
926
- get_commit_notes(commit, sb, encoding);
927
-
923
free(reencoded);
924
}
t/t3301-notes.sh
deleted
-95
@@ -1,95 +0,0 @@
1
-#!/bin/sh
2
-#
3
-# Copyright (c) 2007 Johannes E. Schindelin
4
-#
5
-
6
-test_description='Test commit notes'
7
-
8
-. ./test-lib.sh
9
-
10
-cat > fake_editor.sh << \EOF
11
-echo "$MSG" > "$1"
12
-echo "$MSG" >& 2
13
-EOF
14
-chmod a+x fake_editor.sh
15
-VISUAL=./fake_editor.sh
16
-export VISUAL
17
-
18
-test_expect_success 'cannot annotate non-existing HEAD' '
19
- ! MSG=3 git notes edit
20
-'
21
-
22
-test_expect_success setup '
23
- : > a1 &&
24
- git add a1 &&
25
- test_tick &&
26
- git commit -m 1st &&
27
- : > a2 &&
28
- git add a2 &&
29
- test_tick &&
30
- git commit -m 2nd
31
-'
32
-
33
-test_expect_success 'need valid notes ref' '
34
- ! MSG=1 GIT_NOTES_REF='/' git notes edit &&
35
- ! MSG=2 GIT_NOTES_REF='/' git notes show
36
-'
37
-
38
-test_expect_success 'create notes' '
39
- git config core.notesRef refs/notes/commits &&
40
- MSG=b1 git notes edit &&
41
- test ! -f .git/new-notes &&
42
- test 1 = $(git ls-tree refs/notes/commits | wc -l) &&
43
- test b1 = $(git notes show) &&
44
- git show HEAD^ &&
45
- ! git notes show HEAD^
46
-'
47
-
48
-cat > expect << EOF
49
-commit 268048bfb8a1fb38e703baceb8ab235421bf80c5
50
-Author: A U Thor <author@example.com>
51
-Date: Thu Apr 7 15:14:13 2005 -0700
52
-
53
- 2nd
54
-
55
-Notes:
56
- b1
57
-EOF
58
-
59
-test_expect_success 'show notes' '
60
- ! (git cat-file commit HEAD | grep b1) &&
61
- git log -1 > output &&
62
- test_cmp expect output
63
-'
64
-test_expect_success 'create multi-line notes (setup)' '
65
- : > a3 &&
66
- git add a3 &&
67
- test_tick &&
68
- git commit -m 3rd &&
69
- MSG="b3
70
-c3c3c3c3
71
-d3d3d3" git notes edit
72
-'
73
-
74
-cat > expect-multiline << EOF
75
-commit 1584215f1d29c65e99c6c6848626553fdd07fd75
76
-Author: A U Thor <author@example.com>
77
-Date: Thu Apr 7 15:15:13 2005 -0700
78
-
79
- 3rd
80
-
81
-Notes:
82
- b3
83
- c3c3c3c3
84
- d3d3d3
85
-EOF
86
-
87
-printf "\n" >> expect-multiline
88
-cat expect >> expect-multiline
89
-
90
-test_expect_success 'show multi-line notes' '
91
- git log -2 > output &&
92
- test_cmp expect-multiline output
93
-'
94
-
95
-test_done
t/t3302-notes-index-expensive.sh
deleted
-98
@@ -1,98 +0,0 @@
1
-#!/bin/sh
2
-#
3
-# Copyright (c) 2007 Johannes E. Schindelin
4
-#
5
-
6
-test_description='Test commit notes index (expensive!)'
7
-
8
-. ./test-lib.sh
9
-
10
-test -z "$GIT_NOTES_TIMING_TESTS" && {
11
- say Skipping timing tests
12
- test_done
13
- exit
14
-}
15
-
16
-create_repo () {
17
- number_of_commits=$1
18
- nr=0
19
- parent=
20
- test -d .git || {
21
- git init &&
22
- tree=$(git write-tree) &&
23
- while [ $nr -lt $number_of_commits ]; do
24
- test_tick &&
25
- commit=$(echo $nr | git commit-tree $tree $parent) ||
26
- return
27
- parent="-p $commit"
28
- nr=$(($nr+1))
29
- done &&
30
- git update-ref refs/heads/master $commit &&
31
- {
32
- export GIT_INDEX_FILE=.git/temp;
33
- git rev-list HEAD | cat -n | sed "s/^[ ][ ]*/ /g" |
34
- while read nr sha1; do
35
- blob=$(echo note $nr | git hash-object -w --stdin) &&
36
- echo $sha1 | sed "s/^/0644 $blob 0 /"
37
- done | git update-index --index-info &&
38
- tree=$(git write-tree) &&
39
- test_tick &&
40
- commit=$(echo notes | git commit-tree $tree) &&
41
- git update-ref refs/notes/commits $commit
42
- } &&
43
- git config core.notesRef refs/notes/commits
44
- }
45
-}
46
-
47
-test_notes () {
48
- count=$1 &&
49
- git config core.notesRef refs/notes/commits &&
50
- git log | grep "^ " > output &&
51
- i=1 &&
52
- while [ $i -le $count ]; do
53
- echo " $(($count-$i))" &&
54
- echo " note $i" &&
55
- i=$(($i+1));
56
- done > expect &&
57
- git diff expect output
58
-}
59
-
60
-cat > time_notes << \EOF
61
- mode=$1
62
- i=1
63
- while [ $i -lt $2 ]; do
64
- case $1 in
65
- no-notes)
66
- export GIT_NOTES_REF=non-existing
67
- ;;
68
- notes)
69
- unset GIT_NOTES_REF
70
- ;;
71
- esac
72
- git log >/dev/null
73
- i=$(($i+1))
74
- done
75
-EOF
76
-
77
-time_notes () {
78
- for mode in no-notes notes
79
- do
80
- echo $mode
81
- /usr/bin/time sh ../time_notes $mode $1
82
- done
83
-}
84
-
85
-for count in 10 100 1000 10000; do
86
-
87
- mkdir $count
88
- (cd $count;
89
-
90
- test_expect_success "setup $count" "create_repo $count"
91
-
92
- test_expect_success 'notes work' "test_notes $count"
93
-
94
- test_expect_success 'notes timing' "time_notes 100"
95
- )
96
-done
97
-
98
-test_done