From: Nicolas Pitre <nico@cam.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] add short options to show-files
Date: Thu, 28 Apr 2005 17:48:34 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.62.0504281742580.14033@localhost.localdomain> (raw)
The show-files long options are cumbersome to type. This patch adds
equivalent short options.
Also add missing "unmerged" to usage string.
Finally reduce the number of lines for argument parsing in half.
Signed-off-by: Nicolas Pitre <nico@cam.org>
--- k/show-files.c
+++ l/show-files.c
@@ -206,6 +206,10 @@ static void show_files(void)
}
}
+static const char *show_files_usage =
+ "show-files [-z] (--[cached|deleted|others|stage|unmerged])* "
+ "[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]";
+
int main(int argc, char **argv)
{
int i;
@@ -215,55 +219,30 @@ int main(int argc, char **argv)
if (!strcmp(arg, "-z")) {
line_terminator = 0;
- continue;
- }
-
- if (!strcmp(arg, "--cached")) {
+ } else if (!strcmp(arg, "-c") || !strcmp(arg, "--cached")) {
show_cached = 1;
- continue;
- }
- if (!strcmp(arg, "--deleted")) {
+ } else if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
show_deleted = 1;
- continue;
- }
- if (!strcmp(arg, "--others")) {
+ } else if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
show_others = 1;
- continue;
- }
- if (!strcmp(arg, "--ignored")) {
+ } else if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
show_ignored = 1;
- continue;
- }
- if (!strcmp(arg, "--stage")) {
+ } else if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) {
show_stage = 1;
- continue;
- }
- if (!strcmp(arg, "--unmerged")) {
+ } else if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) {
// There's no point in showing unmerged unless you also show the stage information
show_stage = 1;
show_unmerged = 1;
- continue;
- }
-
- if (!strcmp(arg, "-x") && i+1 < argc) {
+ } else if (!strcmp(arg, "-x") && i+1 < argc) {
add_exclude(argv[++i]);
- continue;
- }
- if (!strncmp(arg, "--exclude=", 10)) {
+ } else if (!strncmp(arg, "--exclude=", 10)) {
add_exclude(arg+10);
- continue;
- }
- if (!strcmp(arg, "-X") && i+1 < argc) {
+ } else if (!strcmp(arg, "-X") && i+1 < argc) {
add_excludes_from_file(argv[++i]);
- continue;
- }
- if (!strncmp(arg, "--exclude-from=", 15)) {
+ } else if (!strncmp(arg, "--exclude-from=", 15)) {
add_excludes_from_file(arg+15);
- continue;
- }
-
- usage("show-files [-z] (--[cached|deleted|others|stage])* "
- "[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]");
+ } else
+ usage(show_files_usage);
}
if (show_ignored && !nr_excludes) {
reply other threads:[~2005-04-28 21:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.62.0504281742580.14033@localhost.localdomain \
--to=nico@cam.org \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).