@@ -897,6 +897,7 @@ static int merge(int argc, const char **argv, const char *prefix)
897
897
1 , PARSE_OPT_NONEG ),
898
898
OPT_END ()
899
899
};
900
+ char * notes_ref ;
900
901
901
902
argc = parse_options (argc , argv , prefix , options ,
902
903
git_notes_merge_usage , 0 );
@@ -924,7 +925,8 @@ static int merge(int argc, const char **argv, const char *prefix)
924
925
if (do_commit )
925
926
return merge_commit (& o );
926
927
927
- o .local_ref = default_notes_ref ();
928
+ notes_ref = default_notes_ref (the_repository );
929
+ o .local_ref = notes_ref ;
928
930
strbuf_addstr (& remote_ref , argv [0 ]);
929
931
expand_loose_notes_ref (& remote_ref );
930
932
o .remote_ref = remote_ref .buf ;
@@ -953,15 +955,15 @@ static int merge(int argc, const char **argv, const char *prefix)
953
955
}
954
956
955
957
strbuf_addf (& msg , "notes: Merged notes from %s into %s" ,
956
- remote_ref .buf , default_notes_ref () );
958
+ remote_ref .buf , notes_ref );
957
959
strbuf_add (& (o .commit_msg ), msg .buf + 7 , msg .len - 7 ); /* skip "notes: " */
958
960
959
961
result = notes_merge (& o , t , & result_oid );
960
962
961
963
if (result >= 0 ) /* Merge resulted (trivially) in result_oid */
962
964
/* Update default notes ref with new commit */
963
965
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 ,
965
967
UPDATE_REFS_DIE_ON_ERR );
966
968
else { /* Merge has unresolved conflicts */
967
969
struct worktree * * worktrees ;
@@ -973,21 +975,22 @@ static int merge(int argc, const char **argv, const char *prefix)
973
975
/* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
974
976
worktrees = get_worktrees ();
975
977
wt = find_shared_symref (worktrees , "NOTES_MERGE_REF" ,
976
- default_notes_ref () );
978
+ notes_ref );
977
979
if (wt )
978
980
die (_ ("a notes merge into %s is already in-progress at %s" ),
979
- default_notes_ref () , wt -> path );
981
+ notes_ref , wt -> path );
980
982
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 ))
982
984
die (_ ("failed to store link to current notes ref (%s)" ),
983
- default_notes_ref () );
985
+ notes_ref );
984
986
fprintf (stderr , _ ("Automatic notes merge failed. Fix conflicts in %s "
985
987
"and commit the result with 'git notes merge --commit', "
986
988
"or abort the merge with 'git notes merge --abort'.\n" ),
987
989
git_path (NOTES_MERGE_WORKTREE ));
988
990
}
989
991
990
992
free_notes (t );
993
+ free (notes_ref );
991
994
strbuf_release (& remote_ref );
992
995
strbuf_release (& msg );
993
996
return result < 0 ; /* return non-zero on conflicts */
@@ -1084,6 +1087,7 @@ static int prune(int argc, const char **argv, const char *prefix)
1084
1087
static int get_ref (int argc , const char * * argv , const char * prefix )
1085
1088
{
1086
1089
struct option options [] = { OPT_END () };
1090
+ char * notes_ref ;
1087
1091
argc = parse_options (argc , argv , prefix , options ,
1088
1092
git_notes_get_ref_usage , 0 );
1089
1093
@@ -1092,7 +1096,9 @@ static int get_ref(int argc, const char **argv, const char *prefix)
1092
1096
usage_with_options (git_notes_get_ref_usage , options );
1093
1097
}
1094
1098
1095
- puts (default_notes_ref ());
1099
+ notes_ref = default_notes_ref (the_repository );
1100
+ puts (notes_ref );
1101
+ free (notes_ref );
1096
1102
return 0 ;
1097
1103
}
1098
1104
0 commit comments