Re: th/remote-usage

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

 



Hi,

Another thought.

Yesterday, Tim Henigan wrote:

> Do you object to the new #defines for the strings?  I added them since we now
> really need to construct the usage string for 2 separate uses:
>   (1) When 'git remote -h' is invoked, we need to return the usage
> string showing
>        all subcommands.
>   (2) When 'git remote <subcommand> -h' is invoked, we need to return the
>       usage for just that command.
>
> It doesn't make sense to me to maintain separate strings for the two use cases.

Another option would be to make the strings into static variables.

I vaguely hoped this would help the code size a little, but gcc is
already smart enough to notice the strings are the same on its own.
Actually, this increases the text size by 15 bytes.  Apparently,
static arrays have to live at 4-byte aligned addresses in the x86 ABI.

So there is not much to recommend this.  I am sending it mostly for
academic interest.  It also has the virtue of decreasing the density
of capital letters in the code.

 builtin-remote.c |   47 ++++++++++++++++++++++++-----------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index cfd8a36..185ce42 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -7,34 +7,35 @@
 #include "run-command.h"
 #include "refs.h"
 
-#define REMOTE_BARE_USAGE "git remote [options]"
-#define REMOTE_ADD_USAGE "git remote add [options] <name> <url>"
-#define REMOTE_RENAME_USAGE "git remote rename <old> <new>"
-#define REMOTE_RM_USAGE "git remote rm <name>"
-#define REMOTE_SETHEAD_USAGE "git remote set-head <name> (-a|-d|<branch>)"
-#define REMOTE_SHOW_USAGE "git remote show [options] <name>"
-#define REMOTE_PRUNE_USAGE "git remote prune [options] <name>"
-#define REMOTE_UPDATE_USAGE "git remote update [options]"
+static const char remote_bare_usage[] = "git remote [options]";
+static const char remote_add_usage[] = "git remote add [options] <name> <url>";
+static const char remote_rename_usage[] = "git remote rename <old> <new>";
+static const char remote_rm_usage[] = "git remote rm <name>";
+static const char remote_sethead_usage[] =
+"git remote set-head <name> (-a|-d|<branch>)";
+static const char remote_show_usage[] = "git remote show [options] <name>";
+static const char remote_prune_usage[] = "git remote prune [options] <name>";
+static const char remote_update_usage[] = "git remote update [options]";
 
 static const char * const builtin_remote_usage[] = {
-	REMOTE_BARE_USAGE,
-	REMOTE_ADD_USAGE,
-	REMOTE_RENAME_USAGE,
-	REMOTE_RM_USAGE,
-	REMOTE_SETHEAD_USAGE,
-	REMOTE_SHOW_USAGE,
-	REMOTE_PRUNE_USAGE,
-	REMOTE_UPDATE_USAGE,
+	remote_bare_usage,
+	remote_add_usage,
+	remote_rename_usage,
+	remote_rm_usage,
+	remote_sethead_usage,
+	remote_show_usage,
+	remote_prune_usage,
+	remote_update_usage,
 	NULL
 };
 
-static const char * const builtin_remote_add_usage[] = { REMOTE_ADD_USAGE, NULL };
-static const char * const builtin_remote_rename_usage[] = { REMOTE_RENAME_USAGE, NULL };
-static const char * const builtin_remote_rm_usage[] = { REMOTE_RM_USAGE, NULL };
-static const char * const builtin_remote_sethead_usage[] = { REMOTE_SETHEAD_USAGE, NULL };
-static const char * const builtin_remote_show_usage[] = { REMOTE_SHOW_USAGE, NULL };
-static const char * const builtin_remote_prune_usage[] = { REMOTE_PRUNE_USAGE, NULL };
-static const char * const builtin_remote_update_usage[] = { REMOTE_UPDATE_USAGE, NULL };
+static const char * const builtin_remote_add_usage[] = { remote_add_usage, NULL };
+static const char * const builtin_remote_rename_usage[] = { remote_rename_usage, NULL };
+static const char * const builtin_remote_rm_usage[] = { remote_rm_usage, NULL };
+static const char * const builtin_remote_sethead_usage[] = { remote_sethead_usage, NULL };
+static const char * const builtin_remote_show_usage[] = { remote_show_usage, NULL };
+static const char * const builtin_remote_prune_usage[] = { remote_prune_usage, NULL };
+static const char * const builtin_remote_update_usage[] = { remote_update_usage, NULL };
 
 #define GET_REF_STATES (1<<0)
 #define GET_HEAD_NAMES (1<<1)
-- 
1.6.5.2

--
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]