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

Re: [PATCH 0/3] Refactor useful notes functions into notes-utils.[ch]

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2013, 20:02 UTC
Message-ID
<7vzjuv14ir.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1370995981-1553-1-git-send-email-johan@herland.net>
Johan Herland <johan@herland.net> writes:
Show 10 quoted lines
>> There is only one right solution.  If a useful function is buried in
>> builtin/*.o as a historical accident (i.e. it started its life as a
>> helper for that particular command, and nobody else used it from
>> outside so far) and that makes it impossible to use the function
>> from outside builtin/*.o, refactor the function and its callers and
>> move it to libgit.a.
>
> Here goes...
>
> ...Johan

With these three patches, if you apply the following skeleton patch (lifted from $gmane/226851 and adjusted minimally to the change these patches introduce), we can see that the link breakage Felipe observed in the message:

    Felipe Contreras <felipe.contreras@gmail.com> writes in $gmane/226851:
    > What happens?
    > 
    > libgit.a(sequencer.o): In function `copy_notes':
    > /home/felipec/dev/git/sequencer.c:110: undefined reference to
    > `init_copy_notes_for_rewrite'
    > /home/felipec/dev/git/sequencer.c:114: undefined reference to
    > `finish_copy_notes_for_rewrite'
is gone.
    > It is not the first time, nor the last that top-level code needs
    > builtin code, and the solution is easy; organize the code.

And as I already said, the above is correct. The problem and the general approach to solve it correctly were identified in the message.

But what followed was a nonsense, which ended up wastign everybody's time:

> ... Alas, this
> simple solution reject on the basis that we shouldn't organize the
> code, because the code is not meant to be organized.

The proposed patch was rejected on the basis that it was organized the code in a wrong way. And your patch shows how it should be done.

Thanks for doing it right.
-- skeleton patch --
 sequencer.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/sequencer.c b/sequencer.c
index ab6f8a7..4281466 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -14,6 +14,7 @@
 #include "merge-recursive.h"
 #include "refs.h"
 #include "argv-array.h"
+#include "notes-utils.h"
 
 #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION"
 
@@ -979,6 +980,17 @@ static void save_opts(struct replay_opts *opts)
 	}
 }
 
+static void copy_notes(const char *name, const char *msg)
+{
+       struct notes_rewrite_cfg *cfg;
+
+       cfg = init_copy_notes_for_rewrite(name);
+       if (!cfg)
+               return;
+
+       finish_copy_notes_for_rewrite(cfg, msg);
+}
+
 static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
 {
 	struct commit_list *cur;
@@ -997,6 +1009,8 @@ static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
 			return res;
 	}
 
+	copy_notes("cherry-pick", "notes copied by cherry-pick");
+
 	/*
 	 * Sequence of picks finished successfully; cleanup by
 	 * removing the .git/sequencer directory
Previous: Johan HerlandNext: Felipe Contreras
Message 49 of 59 in “build: get rid of the notion of a git library”
  1. build: get rid of the notion of a git libraryFelipe Contreras, Jun 8, 2013
  2. Ramkumar RamachandraJun 8, 2013
  3. Felipe ContrerasJun 8, 2013
  4. Ramkumar RamachandraJun 9, 2013
  5. John KeepingJun 9, 2013
  6. Felipe ContrerasJun 9, 2013
  7. John KeepingJun 9, 2013
  8. Felipe ContrerasJun 9, 2013
  9. John KeepingJun 9, 2013
  10. Ramkumar RamachandraJun 9, 2013
  11. Ramkumar RamachandraJun 9, 2013
  12. Felipe ContrerasJun 9, 2013
  13. John KeepingJun 9, 2013
  14. Felipe ContrerasJun 9, 2013
  15. Ramkumar RamachandraJun 9, 2013
  16. Vincent van RavesteijnJun 9, 2013
  17. Felipe ContrerasJun 9, 2013
  18. Jeff KingJun 10, 2013
  19. Felipe ContrerasJun 10, 2013
  20. Jeff KingJun 10, 2013
  21. Felipe ContrerasJun 10, 2013
  22. Junio C HamanoJun 10, 2013
  23. Junio C HamanoJun 10, 2013
  24. Felipe ContrerasJun 10, 2013
  25. Junio C HamanoJun 11, 2013
  26. Junio C HamanoJun 11, 2013
  27. Felipe ContrerasJun 11, 2013
  28. Junio C HamanoJun 11, 2013
  29. Felipe ContrerasJun 11, 2013
  30. Junio C HamanoJun 11, 2013
  31. Felipe ContrerasJun 11, 2013
  32. Linus TorvaldsJun 11, 2013
  33. Felipe ContrerasJun 11, 2013
  34. Junio C HamanoJun 11, 2013
  35. Felipe ContrerasJun 11, 2013
  36. 0/3 Refactor useful notes functions into notes-utils.[ch]Johan Herland, Jun 12, 2013
  37. 1/3 finish_copy_notes_for_rewrite(): Let caller provide commit messageJohan Herland, Jun 12, 2013
  38. Junio C HamanoJun 12, 2013
  39. 2/3 Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.cJohan Herland, Jun 12, 2013
  40. Felipe ContrerasJun 12, 2013
  41. Johan HerlandJun 12, 2013
  42. Felipe ContrerasJun 12, 2013
  43. Johan HerlandJun 12, 2013
  44. Felipe ContrerasJun 12, 2013
  45. Andreas KreyJun 13, 2013
  46. Felipe ContrerasJun 13, 2013
  47. Junio C HamanoJun 12, 2013
  48. 3/3 Move create_notes_commit() from notes-merge.c into notes-utils.cJohan Herland, Jun 12, 2013
  49. Junio C HamanoJun 12, 2013
  50. Felipe ContrerasJun 12, 2013
  51. Junio C HamanoJun 13, 2013
  52. Felipe ContrerasJun 13, 2013
  53. Felipe ContrerasJun 13, 2013
  54. Junio C HamanoJun 11, 2013
  55. Felipe ContrerasJun 11, 2013
  56. Junio C HamanoJun 11, 2013
  57. Felipe ContrerasJun 11, 2013
  58. Felipe ContrerasJun 11, 2013
  59. Felipe ContrerasJun 9, 2013

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.