summaryrefslogtreecommitdiff
path: root/src/branch.c
diff options
context:
space:
mode:
authorDmitry Lobanov <gaussblurinc@gmail.com>2021-05-18 16:07:04 +0300
committerDmitry Lobanov <gaussblurinc@gmail.com>2021-05-18 16:07:04 +0300
commit94571908f82daba41c7368c79a4f4204405948cf (patch)
tree459e44ee181cd3aee927d7e1686ece24af5decb9 /src/branch.c
parent9836ca9177a56b6e170997b2e727c71ff8228848 (diff)
downloadlibgit2-94571908f82daba41c7368c79a4f4204405948cf.tar.gz
branch: git branch upstream with format format name parameter has been added.
Diffstat (limited to 'src/branch.c')
-rw-r--r--src/branch.c31
1 files changed, 3 insertions, 28 deletions
diff --git a/src/branch.c b/src/branch.c
index 831ccfcc7..e6818a86d 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -468,35 +468,10 @@ cleanup:
return error;
}
-typedef enum {
- GIT_BRANCH_UPSTREAM_FORMAT_REMOTE = 1,
- GIT_BRANCH_UPSTREAM_FORMAT_MERGE = 2
-} git_branch_upstream_format_type_t;
-
-static const char* git_branch_upstream_format_string_for_id(git_branch_upstream_format_type_t id)
-{
- switch (id) {
- case GIT_BRANCH_UPSTREAM_FORMAT_REMOTE: return "branch.%s.remote";
- case GIT_BRANCH_UPSTREAM_FORMAT_MERGE: return "branch.%s.merge";
- default: return ""; // OK?
- };
-}
-
-static const char* git_branch_upstream_format_name_for_id(git_branch_upstream_format_type_t id)
-{
- switch (id) {
- case GIT_BRANCH_UPSTREAM_FORMAT_REMOTE: return "remote";
- case GIT_BRANCH_UPSTREAM_FORMAT_MERGE: return "merge";
- default: return "UNDEFINED"; // OK?
- };
-}
-
-static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, const char *refname, git_branch_upstream_format_type_t id)
+static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, const char *refname, const char *format, const char *format_name)
{
int error;
git_config *cfg;
- const char *format = git_branch_upstream_format_string_for_id(id);
- const char *format_name = git_branch_upstream_format_name_for_id(id);
if (!git_reference__is_branch(refname))
return not_a_local_branch(refname);
@@ -519,12 +494,12 @@ static int git_branch_upstream_with_format(git_buf *buf, git_repository *repo, c
int git_branch_upstream_remote(git_buf *buf, git_repository *repo, const char *refname)
{
- return git_branch_upstream_with_format(buf, repo, refname, GIT_BRANCH_UPSTREAM_FORMAT_REMOTE);
+ return git_branch_upstream_with_format(buf, repo, refname, "branch.%s.remote", "remote");
}
int git_branch_upstream_merge(git_buf *buf, git_repository *repo, const char *refname)
{
- return git_branch_upstream_with_format(buf, repo, refname, GIT_BRANCH_UPSTREAM_FORMAT_MERGE);
+ return git_branch_upstream_with_format(buf, repo, refname, "branch.%s.merge", "merge");
}
int git_branch_remote_name(git_buf *buf, git_repository *repo, const char *refname)