All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>
Subject: [PATCH] Allow git help work without PATH set
Date: Thu, 28 Aug 2008 19:19:07 +0200	[thread overview]
Message-ID: <20080828171907.GD6024@blimp.local> (raw)

Just because we can

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
 help.c |   43 ++++++++++++++++++++-----------------------
 1 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/help.c b/help.c
index a17a746..ab2c2ba 100644
--- a/help.c
+++ b/help.c
@@ -178,37 +178,34 @@ void load_command_list(const char *prefix,
 		struct cmdnames *other_cmds)
 {
 	const char *env_path = getenv("PATH");
-	char *paths, *path, *colon;
 	const char *exec_path = git_exec_path();
 
-	if (exec_path)
+	if (exec_path) {
 		list_commands_in_dir(main_cmds, exec_path, prefix);
-
-	if (!env_path) {
-		fprintf(stderr, "PATH not set\n");
-		exit(1);
+		qsort(main_cmds->names, main_cmds->cnt,
+		      sizeof(*main_cmds->names), cmdname_compare);
+		uniq(main_cmds);
 	}
 
-	path = paths = xstrdup(env_path);
-	while (1) {
-		if ((colon = strchr(path, PATH_SEP)))
-			*colon = 0;
-
-		list_commands_in_dir(other_cmds, path, prefix);
+	if (env_path) {
+		char *paths, *path, *colon;
+		path = paths = xstrdup(env_path);
+		while (1) {
+			if ((colon = strchr(path, PATH_SEP)))
+				*colon = 0;
 
-		if (!colon)
-			break;
-		path = colon + 1;
-	}
-	free(paths);
+			list_commands_in_dir(other_cmds, path, prefix);
 
-	qsort(main_cmds->names, main_cmds->cnt,
-	      sizeof(*main_cmds->names), cmdname_compare);
-	uniq(main_cmds);
+			if (!colon)
+				break;
+			path = colon + 1;
+		}
+		free(paths);
 
-	qsort(other_cmds->names, other_cmds->cnt,
-	      sizeof(*other_cmds->names), cmdname_compare);
-	uniq(other_cmds);
+		qsort(other_cmds->names, other_cmds->cnt,
+		      sizeof(*other_cmds->names), cmdname_compare);
+		uniq(other_cmds);
+	}
 	exclude_cmds(other_cmds, main_cmds);
 }
 
-- 
1.6.0.1.150.g5966

                 reply	other threads:[~2008-08-28 17:26 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=20080828171907.GD6024@blimp.local \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.