From: "Ciprian Dorin Craciun" <ciprian.craciun@gmail.com>
To: git@vger.kernel.org
Subject: Repository specific git commands
Date: Mon, 7 Jan 2008 14:15:59 +0200 [thread overview]
Message-ID: <8e04b5820801070415j5166c2eco53760cffe1ab1efb@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1473 bytes --]
Hello all!
I have a question / proposal: I see on the mailing list a lot of
situations when some commands (or group of commands) are very often
used and the users demand (or would like to have) a special "git xxx"
command for them. But adding such a command -- in almost all cases --
is not worth the effort or increases the number of available commands
(thus confusing even more the users).
Thus the users are left with only two possibilities:
-- either define an alias -- but usually it is very restrictive in
terms of what the alias can do;
-- create a custom git command "git-xxx" and place it in the
executable path -- but this requires root access.
(-- or write a custom script but this can not be invoked as "git xxx")
=> Thus neither option is very useful.
So my proposal is to let the users create a special folder inside
the .git directory, for example ".git/bin" where they can place custom
built git files like "git-xxx", and when they issue "git xxx" this
folder is searched first, and if the command is found it will be
executed as any other "git-xxx".
For this I attach a very simple patch that implements it. (It
modifies the execv_git_cmd function by adding a new path in the paths
array.)
Comments? Opinions? Other solutions that I am not aware of?
(Please note that I am a git user for only a couple of months, and
this is the first time I look over git source code...)
Thanks,
Ciprian Craciun.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff; name=patch.diff, Size: 779 bytes --]
diff --git a/exec_cmd.c b/exec_cmd.c
index 9b74ed2..9082711 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -30,11 +30,32 @@ const char *git_exec_path(void)
}
+static const char *git_repo_exec_path(void)
+{
+ static char path_buffer[PATH_MAX + 1];
+ static char *path = NULL;
+
+ if (!path) {
+ path = path_buffer;
+ path[0] = '\0';
+ if (get_git_dir()) {
+ strncat(path, get_git_dir(), PATH_MAX);
+ strncat(path, "/", PATH_MAX);
+ strncat(path, "bin", PATH_MAX);
+ }
+ }
+
+ return path;
+}
+
+
int execv_git_cmd(const char **argv)
{
char git_command[PATH_MAX + 1];
int i;
- const char *paths[] = { current_exec_path,
+ const char *paths[] = {
+ git_repo_exec_path(),
+ current_exec_path,
getenv(EXEC_PATH_ENVIRONMENT),
builtin_exec_path };
next reply other threads:[~2008-01-07 12:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-07 12:15 Ciprian Dorin Craciun [this message]
2008-01-07 12:55 ` Repository specific git commands Johannes Schindelin
2008-01-07 13:14 ` Ciprian Dorin Craciun
2008-05-23 14:20 ` Ciprian Dorin Craciun
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=8e04b5820801070415j5166c2eco53760cffe1ab1efb@mail.gmail.com \
--to=ciprian.craciun@gmail.com \
--cc=git@vger.kernel.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).