@@ -897,6 +897,7 @@ static int merge(int argc, const char **argv, const char *prefix)
897897 1 , PARSE_OPT_NONEG ),
898898 OPT_END ()
899899 };
900+ char * notes_ref ;
900901
901902 argc = parse_options (argc , argv , prefix , options ,
902903 git_notes_merge_usage , 0 );
@@ -924,7 +925,8 @@ static int merge(int argc, const char **argv, const char *prefix)
924925 if (do_commit )
925926 return merge_commit (& o );
926927
927- o .local_ref = default_notes_ref ();
928+ notes_ref = default_notes_ref (the_repository );
929+ o .local_ref = notes_ref ;
928930 strbuf_addstr (& remote_ref , argv [0 ]);
929931 expand_loose_notes_ref (& remote_ref );
930932 o .remote_ref = remote_ref .buf ;
@@ -953,15 +955,15 @@ static int merge(int argc, const char **argv, const char *prefix)
953955 }
954956
955957 strbuf_addf (& msg , "notes: Merged notes from %s into %s" ,
956- remote_ref .buf , default_notes_ref () );
958+ remote_ref .buf , notes_ref );
957959 strbuf_add (& (o .commit_msg ), msg .buf + 7 , msg .len - 7 ); /* skip "notes: " */
958960
959961 result = notes_merge (& o , t , & result_oid );
960962
961963 if (result >= 0 ) /* Merge resulted (trivially) in result_oid */
962964 /* Update default notes ref with new commit */
963965 refs_update_ref (get_main_ref_store (the_repository ), msg .buf ,
964- default_notes_ref () , & result_oid , NULL , 0 ,
966+ notes_ref , & result_oid , NULL , 0 ,
965967 UPDATE_REFS_DIE_ON_ERR );
966968 else { /* Merge has unresolved conflicts */
967969 struct worktree * * worktrees ;
@@ -973,21 +975,22 @@ static int merge(int argc, const char **argv, const char *prefix)
973975 /* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
974976 worktrees = get_worktrees ();
975977 wt = find_shared_symref (worktrees , "NOTES_MERGE_REF" ,
976- default_notes_ref () );
978+ notes_ref );
977979 if (wt )
978980 die (_ ("a notes merge into %s is already in-progress at %s" ),
979- default_notes_ref () , wt -> path );
981+ notes_ref , wt -> path );
980982 free_worktrees (worktrees );
981- if (refs_update_symref (get_main_ref_store (the_repository ), "NOTES_MERGE_REF" , default_notes_ref () , NULL ))
983+ if (refs_update_symref (get_main_ref_store (the_repository ), "NOTES_MERGE_REF" , notes_ref , NULL ))
982984 die (_ ("failed to store link to current notes ref (%s)" ),
983- default_notes_ref () );
985+ notes_ref );
984986 fprintf (stderr , _ ("Automatic notes merge failed. Fix conflicts in %s "
985987 "and commit the result with 'git notes merge --commit', "
986988 "or abort the merge with 'git notes merge --abort'.\n" ),
987989 git_path (NOTES_MERGE_WORKTREE ));
988990 }
989991
990992 free_notes (t );
993+ free (notes_ref );
991994 strbuf_release (& remote_ref );
992995 strbuf_release (& msg );
993996 return result < 0 ; /* return non-zero on conflicts */
@@ -1084,6 +1087,7 @@ static int prune(int argc, const char **argv, const char *prefix)
10841087static int get_ref (int argc , const char * * argv , const char * prefix )
10851088{
10861089 struct option options [] = { OPT_END () };
1090+ char * notes_ref ;
10871091 argc = parse_options (argc , argv , prefix , options ,
10881092 git_notes_get_ref_usage , 0 );
10891093
@@ -1092,7 +1096,9 @@ static int get_ref(int argc, const char **argv, const char *prefix)
10921096 usage_with_options (git_notes_get_ref_usage , options );
10931097 }
10941098
1095- puts (default_notes_ref ());
1099+ notes_ref = default_notes_ref (the_repository );
1100+ puts (notes_ref );
1101+ free (notes_ref );
10961102 return 0 ;
10971103}
10981104
0 commit comments