git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [WIP/RFC 04/13] notes.h/c: Propagate combine_notes_fn return value to add_note() and beyond

From
Johan Herland <johan@herland.net>
Date
Jul 23, 2010, 22:39 UTC
Message-ID
<201007240039.25005.johan@herland.net>
In-Reply-To
<20100723152344.GA1709@burratino>
On Friday 23 July 2010, Jonathan Nieder wrote:
Show 10 quoted lines
> Johan Herland wrote:
> > +		/* No return value checking; c_n_overwrite always returns 0 */
> >  		add_note(t, object, new_note, combine_notes_overwrite);
> 
> I suspect something like
> 
> 	if (add_note(t, object, ...))
> 		die("confused: combine_notes_overwrite failed");
> 
> would be less likely to fall out of date. ;-)
Good call, I'll squash the following into the next iteration:
Thanks!
...Johan
diff --git a/builtin/notes.c b/builtin/notes.c
index 516401c..5aaae03 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -576,9 +576,8 @@ static int add(int argc, const char **argv, const char *prefix)
 
 	if (is_null_sha1(new_note))
 		remove_note(t, object);
-	else
-		/* No return value checking; c_n_overwrite always returns 0 */
-		add_note(t, object, new_note, combine_notes_overwrite);
+	else if (add_note(t, object, new_note, combine_notes_overwrite))
+		die("confused: combine_notes_overwrite failed");
 
 	snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
 		 is_null_sha1(new_note) ? "removed" : "added", "add");
@@ -657,8 +656,8 @@ static int copy(int argc, const char **argv, const char *prefix)
 		goto out;
 	}
 
-	/* No return value checking; c_n_overwrite always returns 0 */
-	add_note(t, object, from_note, combine_notes_overwrite);
+	if (add_note(t, object, from_note, combine_notes_overwrite))
+		die("confused: combine_notes_overwrite failed");
 	commit_notes(t, "Notes added by 'git notes copy'");
 out:
 	free_notes(t);
@@ -717,9 +716,8 @@ static int append_edit(int argc, const char **argv, const char *prefix)
 
 	if (is_null_sha1(new_note))
 		remove_note(t, object);
-	else
-		/* No return value checking; c_n_overwrite always returns 0 */
-		add_note(t, object, new_note, combine_notes_overwrite);
+	else if (add_note(t, object, new_note, combine_notes_overwrite))
+		die("confused: combine_notes_overwrite failed");
 
 	snprintf(logmsg, sizeof(logmsg), "Notes %s by 'git notes %s'",
 		 is_null_sha1(new_note) ? "removed" : "added", argv[0]);
diff --git a/notes-merge.c b/notes-merge.c
index 122d6b9..47cd32a 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -442,12 +442,14 @@ static int merge_one_change(struct notes_merge_options *o,
 		return 0;
 	case NOTES_MERGE_RESOLVE_THEIRS:
 		OUTPUT(o, 2, "Using remote notes for %s", sha1_to_hex(p->obj));
-		add_note(t, p->obj, p->remote, combine_notes_overwrite);
+		if (add_note(t, p->obj, p->remote, combine_notes_overwrite))
+			die("confused: combine_notes_overwrite failed");
 		return 0;
 	case NOTES_MERGE_RESOLVE_UNION:
 		OUTPUT(o, 2, "Concatenating local and remote notes for %s",
 		       sha1_to_hex(p->obj));
-		add_note(t, p->obj, p->remote, combine_notes_concatenate);
+		if (add_note(t, p->obj, p->remote, combine_notes_concatenate))
+			die("confused: combine_notes_concatenate failed");
 		return 0;
 	}
 	die("Unknown resolve method (%i).", o->resolve);
@@ -489,7 +491,9 @@ static int merge_changes(struct notes_merge_options *o,
 			   !hashcmp(p->local, p->base)) {
 			/* no local change; adopt remote change */
 			OUTPUT(o, 5, "\t\t\tno local change, adopting remote");
-			add_note(t, p->obj, p->remote, combine_notes_overwrite);
+			if (add_note(t, p->obj, p->remote,
+				     combine_notes_overwrite))
+				die("confused: combine_notes_overwrite failed");
 		} else {
 			/* need file-level merge between local and remote */
 			OUTPUT(o, 5, "\t\t\tneed content-level merge");
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Jonathan NiederNext: Johan Herland
Message 7 of 24 in “[WIP/RFC 00/13] git notes merge”
  1. Johan HerlandJul 23, 2010
  2. 01/13 (trivial) notes.h: Minor documentation fixes to copy_notes()Johan Herland, Jul 23, 2010
  3. 02/13 notes.h: Make default_notes_ref() available in notes APIJohan Herland, Jul 23, 2010
  4. 03/13 notes.h/c: Clarify the handling of notes objects that are == null_sha1Johan Herland, Jul 23, 2010
  5. 04/13 notes.h/c: Propagate combine_notes_fn return value to add_note() and beyondJohan Herland, Jul 23, 2010
  6. Jonathan NiederJul 23, 2010
  7. Johan HerlandJul 23, 2010
  8. 05/13 (trivial) t3303: Indent with tabs instead of spaces for consistencyJohan Herland, Jul 23, 2010
  9. 06/13 notes.c: Use two newlines (instead of one) when concatenating notesJohan Herland, Jul 23, 2010
  10. 07/13 (trivial) git notes prune: Accept --verbose in addition to -vJohan Herland, Jul 23, 2010
  11. 08/13 builtin/notes.c: Split notes ref DWIMmery into a separate functionJohan Herland, Jul 23, 2010
  12. 09/13 git notes merge: Initial implementation handling trivial merges onlyJohan Herland, Jul 23, 2010
  13. Stephen BoydJul 24, 2010
  14. Johan HerlandJul 25, 2010
  15. 10/13 builtin/notes.c: Refactor creation of notes commits.Johan Herland, Jul 23, 2010
  16. 11/13 git notes merge: Handle real, non-conflicting notes mergesJohan Herland, Jul 23, 2010
  17. 12/13 git notes merge: Add automatic conflict resolvers (ours, theirs, union)Johan Herland, Jul 23, 2010
  18. Stephen BoydJul 24, 2010
  19. Johan HerlandJul 25, 2010
  20. 13/13 Documentation: Preliminary docs on 'git notes merge'Johan Herland, Jul 23, 2010
  21. Stephen BoydJul 24, 2010
  22. Johan HerlandJul 25, 2010
  23. Sam VilainJul 25, 2010
  24. Johan HerlandJul 25, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.