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 <gitster@pobox.com>
This commit is contained in:
parent
cd74e4733d
commit
8e676e8ba5
@ -2290,7 +2290,7 @@ static void get_object_list(int ac, const char **av)
|
|||||||
}
|
}
|
||||||
die("not a rev '%s'", line);
|
die("not a rev '%s'", line);
|
||||||
}
|
}
|
||||||
if (handle_revision_arg(line, &revs, flags, 1))
|
if (handle_revision_arg(line, &revs, flags, REVARG_CANNOT_BE_FILENAME))
|
||||||
die("bad revision '%s'", line);
|
die("bad revision '%s'", line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
revision.c
13
revision.c
@ -1093,9 +1093,7 @@ static void prepare_show_merge(struct rev_info *revs)
|
|||||||
revs->limited = 1;
|
revs->limited = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int handle_revision_arg(const char *arg_, struct rev_info *revs,
|
int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsigned revarg_opt)
|
||||||
int flags,
|
|
||||||
int cant_be_filename)
|
|
||||||
{
|
{
|
||||||
struct object_context oc;
|
struct object_context oc;
|
||||||
char *dotdot;
|
char *dotdot;
|
||||||
@ -1103,6 +1101,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs,
|
|||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
int local_flags;
|
int local_flags;
|
||||||
const char *arg = arg_;
|
const char *arg = arg_;
|
||||||
|
int cant_be_filename = revarg_opt & REVARG_CANNOT_BE_FILENAME;
|
||||||
|
|
||||||
dotdot = strstr(arg, "..");
|
dotdot = strstr(arg, "..");
|
||||||
if (dotdot) {
|
if (dotdot) {
|
||||||
@ -1236,7 +1235,7 @@ static void read_revisions_from_stdin(struct rev_info *revs,
|
|||||||
}
|
}
|
||||||
die("options not supported in --stdin mode");
|
die("options not supported in --stdin mode");
|
||||||
}
|
}
|
||||||
if (handle_revision_arg(sb.buf, revs, 0, 1))
|
if (handle_revision_arg(sb.buf, revs, 0, REVARG_CANNOT_BE_FILENAME))
|
||||||
die("bad revision '%s'", sb.buf);
|
die("bad revision '%s'", sb.buf);
|
||||||
}
|
}
|
||||||
if (seen_dashdash)
|
if (seen_dashdash)
|
||||||
@ -1684,7 +1683,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
|
|||||||
*/
|
*/
|
||||||
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
|
int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt)
|
||||||
{
|
{
|
||||||
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0;
|
int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0, revarg_opt;
|
||||||
struct cmdline_pathspec prune_data;
|
struct cmdline_pathspec prune_data;
|
||||||
const char *submodule = NULL;
|
const char *submodule = NULL;
|
||||||
|
|
||||||
@ -1708,6 +1707,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||||||
|
|
||||||
/* Second, deal with arguments and options */
|
/* Second, deal with arguments and options */
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
revarg_opt = seen_dashdash ? REVARG_CANNOT_BE_FILENAME : 0;
|
||||||
read_from_stdin = 0;
|
read_from_stdin = 0;
|
||||||
for (left = i = 1; i < argc; i++) {
|
for (left = i = 1; i < argc; i++) {
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
@ -1743,7 +1743,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle_revision_arg(arg, revs, flags, seen_dashdash)) {
|
|
||||||
|
if (handle_revision_arg(arg, revs, flags, revarg_opt)) {
|
||||||
int j;
|
int j;
|
||||||
if (seen_dashdash || *arg == '^')
|
if (seen_dashdash || *arg == '^')
|
||||||
die("bad revision '%s'", arg);
|
die("bad revision '%s'", arg);
|
||||||
|
@ -190,7 +190,8 @@ extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, s
|
|||||||
extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
|
extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
|
||||||
const struct option *options,
|
const struct option *options,
|
||||||
const char * const usagestr[]);
|
const char * const usagestr[]);
|
||||||
extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
|
#define REVARG_CANNOT_BE_FILENAME 01
|
||||||
|
extern int handle_revision_arg(const char *arg, struct rev_info *revs, int flags, unsigned revarg_opt);
|
||||||
|
|
||||||
extern int prepare_revision_walk(struct rev_info *revs);
|
extern int prepare_revision_walk(struct rev_info *revs);
|
||||||
extern struct commit *get_revision(struct rev_info *revs);
|
extern struct commit *get_revision(struct rev_info *revs);
|
||||||
|
Loading…
Reference in New Issue
Block a user