summaryrefslogtreecommitdiff
path: root/notes-cache.c
diff options
context:
space:
mode:
authorJohan Herland <johan@herland.net>2010-11-15 00:52:26 +0100
committerJunio C Hamano <gitster@pobox.com>2010-11-17 13:21:02 -0800
commit180619a58572b17de0ebeb96989e0aa832765186 (patch)
tree536ac12ce331a940e9c7091fcc19856670756ac7 /notes-cache.c
parente2656c82fd836a3d410230c98f6a725368f15642 (diff)
downloadgit-180619a58572b17de0ebeb96989e0aa832765186.tar.gz
notes.h/c: Propagate combine_notes_fn return value to add_note() and beyond
The combine_notes_fn functions uses a non-zero return value to indicate failure. However, this return value was converted to a call to die() in note_tree_insert(). Instead, propagate this return value out to add_note(), and return it from there to enable the caller to handle errors appropriately. Existing add_note() callers are updated to die() upon failure, thus preserving the current behaviour. The only exceptions are copy_note() and notes_cache_put() where we are able to propagate the add_note() return value instead. This patch has been improved by the following contributions: - Jonathan Nieder: Future-proof by always checking add_note() return value - Jonathan Nieder: Improve clarity of final if-condition in note_tree_insert() Thanks-to: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-cache.c')
-rw-r--r--notes-cache.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/notes-cache.c b/notes-cache.c
index dee6d62e72..4c8984ede1 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -89,6 +89,5 @@ int notes_cache_put(struct notes_cache *c, unsigned char key_sha1[20],
if (write_sha1_file(data, size, "blob", value_sha1) < 0)
return -1;
- add_note(&c->tree, key_sha1, value_sha1, NULL);
- return 0;
+ return add_note(&c->tree, key_sha1, value_sha1, NULL);
}