Skip to content

Commit 8e676e8

Browse files
committed
revision.c: allow handle_revision_arg() to take other flags
The existing "cant_be_filename" that tells the function that the caller knows the arg is not a path (hence it does not have to be checked for absense of the file whose name matches it) is made into a bit in the flag word. Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd74e47 commit 8e676e8

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ static void get_object_list(int ac, const char **av)
22902290
}
22912291
die("not a rev '%s'", line);
22922292
}
2293-
if (handle_revision_arg(line, &revs, flags, 1))
2293+
if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
22942294
die("bad revision '%s'", line);
22952295
}
22962296

revision.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,16 +1093,15 @@ static void prepare_show_merge(struct rev_info *revs)
10931093
revs->limited = 1;
10941094
}
10951095

1096-
int handle_revision_arg(const char *arg_, struct rev_info *revs,
1097-
int flags,
1098-
int cant_be_filename)
1096+
int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsigned revarg_opt)
10991097
{
11001098
struct object_context oc;
11011099
char *dotdot;
11021100
struct object *object;
11031101
unsigned char sha1[20];
11041102
int local_flags;
11051103
const char *arg = arg_;
1104+
int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;
11061105

11071106
dotdot = strstr(arg, "..");
11081107
if (dotdot) {
@@ -1236,7 +1235,7 @@ static void read_revisions_from_stdin(struct rev_info *revs,
12361235
}
12371236
die("options not supported in --stdin mode");
12381237
}
1239-
if (handle_revision_arg(sb.buf, revs, 0, 1))
1238+
if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
12401239
die("bad revision '%s'", sb.buf);
12411240
}
12421241
if (seen_dashdash)
@@ -1684,7 +1683,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
16841683
*/
16851684
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
16861685
{
1687-
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
1686+
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0, revarg_opt;
16881687
struct cmdline_pathspec prune_data;
16891688
const char *submodule = NULL;
16901689

@@ -1708,6 +1707,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
17081707

17091708
/* Second, deal with arguments and options */
17101709
flags = 0;
1710+
revarg_opt = seen_dashdash ? REVARG_CANNOT_BE_FILENAME : 0;
17111711
read_from_stdin = 0;
17121712
for (left = i = 1; i < argc; i++) {
17131713
const char *arg = argv[i];
@@ -1743,7 +1743,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
17431743
continue;
17441744
}
17451745

1746-
if (handle_revision_arg(arg, revs, flags, seen_dashdash)) {
1746+
1747+
if (handle_revision_arg(arg, revs, flags, revarg_opt)) {
17471748
int j;
17481749
if (seen_dashdash || *arg == '^')
17491750
die("bad revision '%s'", arg);

revision.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, s
190190
extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
191191
const struct option *options,
192192
const char * const usagestr[]);
193-
extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
193+
#define REVARG_CANNOT_BE_FILENAME 01
194+
extern int handle_revision_arg(const char *arg, struct rev_info *revs, int flags, unsigned revarg_opt);
194195

195196
extern int prepare_revision_walk(struct rev_info *revs);
196197
extern struct commit *get_revision(struct rev_info *revs);

0 commit comments

Comments
 (0)