Merge branch 'jc/pass-repo-to-builtins'

The convention to calling into built-in command implementation has
been updated to pass the repository, if known, together with the
prefix value.

* jc/pass-repo-to-builtins:
  add: pass in repo variable instead of global the_repository
  builtin: remove USE_THE_REPOSITORY for those without the_repository
  builtin: remove USE_THE_REPOSITORY_VARIABLE from builtin.h
  builtin: add a repository parameter for builtin functions
This commit is contained in:
Junio C Hamano
2024-09-23 10:35:09 -07:00
128 changed files with 903 additions and 437 deletions

View File

@ -5,8 +5,9 @@
*
* Based on git-merge.sh by Junio C Hamano.
*/
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
#include "config.h"
@ -1279,7 +1280,10 @@ static int merging_a_throwaway_tag(struct commit *commit)
return is_throwaway_tag;
}
int cmd_merge(int argc, const char **argv, const char *prefix)
int cmd_merge(int argc,
const char **argv,
const char *prefix,
struct repository *repo UNUSED)
{
struct object_id result_tree, stash, head_oid;
struct commit *head_commit;
@ -1351,7 +1355,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
REF_NO_DEREF);
/* Invoke 'git reset --merge' */
ret = cmd_reset(nargc, nargv, prefix);
ret = cmd_reset(nargc, nargv, prefix, the_repository);
if (!is_null_oid(&stash_oid)) {
oid_to_hex_r(stash_oid_hex, &stash_oid);
@ -1383,7 +1387,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die(_("There is no merge in progress (MERGE_HEAD missing)."));
/* Invoke 'git commit' */
ret = cmd_commit(nargc, nargv, prefix);
ret = cmd_commit(nargc, nargv, prefix, the_repository);
goto done;
}