Re: Bring parse_options to the shell

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Friday, November 2, 2007 - 8:51 am

On Fri, 2 Nov 2007, Pierre Habouzit wrote:


Hmm. Any reason why you didn't just extend on "git rev-parse"?

That command was written exactly to parse a command line. This is really 
cheesy, and doesn't really work right (it splits up numbers too), but you 
get the idea..

		Linus

---
 builtin-rev-parse.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 8d78b69..10b62f7 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -116,6 +116,17 @@ static int show_flag(const char *arg)
 	if (!(filter & DO_FLAGS))
 		return 0;
 	if (filter & (is_rev_argument(arg) ? DO_REVS : DO_NOREV)) {
+		if (arg[0] == '-' && arg[1] != '-') {
+			char split[3];
+			split[0] = '-';
+			split[2] = 0;
+			while (arg[1]) {
+				split[1] = arg[1];
+				arg++;
+				show(split);
+			}
+			return 1;
+		}
 		show(arg);
 		return 1;
 	}
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Bring parse_options to the shell, Pierre Habouzit, (Fri Nov 2, 8:09 am)
[PATCH] Migrate git-clean.sh to use git-parseoptions(1), Pierre Habouzit, (Fri Nov 2, 8:09 am)
Re: Bring parse_options to the shell, Pierre Habouzit, (Fri Nov 2, 8:14 am)
Re: Bring parse_options to the shell, Linus Torvalds, (Fri Nov 2, 8:51 am)
[PATCH] Migrate git-clone to use git-parseopt(1), Pierre Habouzit, (Fri Nov 2, 8:58 am)
Re: Bring parse_options to the shell, Pierre Habouzit, (Fri Nov 2, 9:09 am)
Re: Bring parse_options to the shell, Johannes Schindelin, (Fri Nov 2, 11:21 am)
Re: Bring parse_options to the shell, Pierre Habouzit, (Fri Nov 2, 11:48 am)