summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2008-06-23 22:31:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-06-30 21:51:13 (GMT)
commita32a4eaa36527ab1c9a999357f9edd5e04591a4a (patch)
tree1ecb767a721025829b3e63e13167b2ef80814b0f
parent26141b5b60eea36f1d771312f6cae9e56dbbf760 (diff)
downloadgit-a32a4eaa36527ab1c9a999357f9edd5e04591a4a.zip
git-a32a4eaa36527ab1c9a999357f9edd5e04591a4a.tar.gz
git-a32a4eaa36527ab1c9a999357f9edd5e04591a4a.tar.bz2
parse-opt: add PARSE_OPT_KEEP_ARGV0 parser option.
This way, argv[0] isn't clobbered when parse-options filters argv[]. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--parse-options.c1
-rw-r--r--parse-options.h1
2 files changed, 2 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index 0d3818a..469831d 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -248,6 +248,7 @@ void parse_options_start(struct parse_opt_ctx_t *ctx,
ctx->argc = argc - 1;
ctx->argv = argv + 1;
ctx->out = argv;
+ ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
ctx->flags = flags;
}
diff --git a/parse-options.h b/parse-options.h
index aeed627..c5f0b4b 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -20,6 +20,7 @@ enum parse_opt_type {
enum parse_opt_flags {
PARSE_OPT_KEEP_DASHDASH = 1,
PARSE_OPT_STOP_AT_NON_OPTION = 2,
+ PARSE_OPT_KEEP_ARGV0 = 4,
};
enum parse_opt_option_flags {