Skip to content

Commit 2182316

Browse files
committed
Merge branch 'jw/object-name-bitset-to-enum' into seen
* jw/object-name-bitset-to-enum: object-name: turn INTERPRET_BRANCH_* constants into enum values
2 parents 9116d80 + c5fc44f commit 2182316

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
228228
int ret = 0;
229229
int remote_branch = 0;
230230
struct strbuf bname = STRBUF_INIT;
231-
unsigned allowed_interpret;
231+
enum interpret_branch_kind allowed_interpret;
232232
struct string_list refs_to_delete = STRING_LIST_INIT_DUP;
233233
struct string_list_item *item;
234234
int branch_name_pos;

object-name.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,8 @@ static int interpret_empty_at(const char *name, int namelen, int len, struct str
16641664

16651665
static int reinterpret(struct repository *r,
16661666
const char *name, int namelen, int len,
1667-
struct strbuf *buf, unsigned allowed)
1667+
struct strbuf *buf,
1668+
enum interpret_branch_kind allowed)
16681669
{
16691670
/* we have extra data, which might need further processing */
16701671
struct strbuf tmp = STRBUF_INIT;
@@ -1696,7 +1697,8 @@ static void set_shortened_ref(struct repository *r, struct strbuf *buf, const ch
16961697
free(s);
16971698
}
16981699

1699-
static int branch_interpret_allowed(const char *refname, unsigned allowed)
1700+
static int branch_interpret_allowed(const char *refname,
1701+
enum interpret_branch_kind allowed)
17001702
{
17011703
if (!allowed)
17021704
return 1;

object-name.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,20 @@ int set_disambiguate_hint_config(const char *var, const char *value);
101101
* If the input was ok but there are not N branch switches in the
102102
* reflog, it returns 0.
103103
*/
104-
#define INTERPRET_BRANCH_LOCAL (1<<0)
105-
#define INTERPRET_BRANCH_REMOTE (1<<1)
106-
#define INTERPRET_BRANCH_HEAD (1<<2)
104+
enum interpret_branch_kind {
105+
INTERPRET_BRANCH_LOCAL = (1 << 0),
106+
INTERPRET_BRANCH_REMOTE = (1 << 1),
107+
INTERPRET_BRANCH_HEAD = (1 << 2),
108+
};
109+
107110
struct interpret_branch_name_options {
108111
/*
109112
* If "allowed" is non-zero, it is a treated as a bitfield of allowable
110113
* expansions: local branches ("refs/heads/"), remote branches
111114
* ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
112115
* allowed, even ones to refs outside of those namespaces.
113116
*/
114-
unsigned allowed;
117+
enum interpret_branch_kind allowed;
115118

116119
/*
117120
* If ^{upstream} or ^{push} (or equivalent) is requested, and the

refs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,8 @@ static char *substitute_branch_name(struct repository *r,
743743
return NULL;
744744
}
745745

746-
void copy_branchname(struct strbuf *sb, const char *name, unsigned allowed)
746+
void copy_branchname(struct strbuf *sb, const char *name,
747+
enum interpret_branch_kind allowed)
747748
{
748749
int len = strlen(name);
749750
struct interpret_branch_name_options options = {

refs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef REFS_H
22
#define REFS_H
33

4+
#include "object-name.h"
45
#include "commit.h"
56
#include "repository.h"
67
#include "repo-settings.h"
@@ -225,7 +226,7 @@ char *repo_default_branch_name(struct repository *r, int quiet);
225226
* repo_interpret_branch_name() for details.
226227
*/
227228
void copy_branchname(struct strbuf *sb, const char *name,
228-
unsigned allowed);
229+
enum interpret_branch_kind allowed);
229230

230231
/*
231232
* Like copy_branchname() above, but confirm that the result is

0 commit comments

Comments
 (0)