Re: Multiple line ranges and files in line level history browser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder wrote:

>   If -- is found, any
>   -L arguments before the -- apply to all files specified.  Unclaimed
>   arguments before the -- are revision specifiers.

More comments.

The -L arguments describe lines in some particular revision of the
files, so how would arbitrary ‘rev-list’-style revision specifiers
work here?  They don’t: in ‘blame’, one "positive" revision is allowed
and the rest must be negative.  Good.

The modified proposal was, roughly:

  git blame [options, no -L among them] revs ((-L range)... filespec)...
  git blame [options, -L permitted] revs -- [filespec...]
  git blame [options, -L permitted] revs [filespec...]

“...” means “one or more”.  How to know whether the -L or revision
arguments are encountered first?  One approach is to abuse
STOP_AT_NON_OPTION to catch the -L, revisions, and filespecs as they
appear.  Probably better would be to make -L an unknown option and
rely on parse_revision_opt leaving a residue of any revisions it
finds, so that after the first pass, the first syntax can be
distinguished from the others by the first argument starting with "-L".

Feel free to do something else entirely (including another syntax) if
you prefer, of course.

Here’s a patch that makes STOP_AT_NON_OPTION easier to abuse, without
affecting current users.  Maybe it would make it easier to play
around.

Good night,
Jonathan

 parse-options.c |    3 ++-
 parse-options.h |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 8546d85..4e3532b 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -372,7 +372,7 @@ int parse_options_step(struct parse_opt_ctx_t *ctx,
 			if (parse_nodash_opt(ctx, arg, options) == 0)
 				continue;
 			if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
-				break;
+				return PARSE_OPT_NON_OPTION;
 			ctx->out[ctx->cpidx++] = ctx->argv[0];
 			continue;
 		}
@@ -454,6 +454,7 @@ int parse_options(int argc, const char **argv, const char *prefix,
 	switch (parse_options_step(&ctx, options, usagestr)) {
 	case PARSE_OPT_HELP:
 		exit(129);
+	case PARSE_OPT_NON_OPTION:
 	case PARSE_OPT_DONE:
 		break;
 	default: /* PARSE_OPT_UNKNOWN */
diff --git a/parse-options.h b/parse-options.h
index 7581e93..4773cf9 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -160,6 +160,7 @@ extern NORETURN void usage_msg_opt(const char *msg,
 enum {
 	PARSE_OPT_HELP = -1,
 	PARSE_OPT_DONE,
+	PARSE_OPT_NON_OPTION,
 	PARSE_OPT_UNKNOWN,
 };
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]