* Re: Minor inconsistency: "git tag" requires space after -m.
From: Sergei Organov @ 2007-10-27 13:14 UTC (permalink / raw)
To: git
In-Reply-To: <Pine.LNX.4.64.0710271347510.4362@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Hi,
>
> On Sat, 27 Oct 2007, Sergei Organov wrote:
>
>> It seems options parsing is somewhat broken in git-tag:
>>
>> $ git tag -a -m"Annotated tag" annotated-tag
>> usage: git-tag [-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>] <tagname> [<head>]
>> $ git tag -a -m "Annotated tag" annotated-tag
>> $ git --version
>> git version 1.5.3.4
>>
>> This is inconsistent with, say, "git commit", that groks -m"Message"
>> (without space after -m) just fine.
>
> As it happens, we are in the middle of adding our own option parser which
> probably solves the issue. Can you please retest when we have that, and
> use it in builtin-tag?
I'm 100% sure there will be no inconsistencies once you unify options
parsing among the tools, but I won't refrain from re-testing this
anyway.
--
Sergei.
^ permalink raw reply
* Re: Minor inconsistency: "git tag" requires space after -m.
From: Johannes Schindelin @ 2007-10-27 12:48 UTC (permalink / raw)
To: Sergei Organov; +Cc: git
In-Reply-To: <ffv8ul$5a2$1@ger.gmane.org>
Hi,
On Sat, 27 Oct 2007, Sergei Organov wrote:
> It seems options parsing is somewhat broken in git-tag:
>
> $ git tag -a -m"Annotated tag" annotated-tag
> usage: git-tag [-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>] <tagname> [<head>]
> $ git tag -a -m "Annotated tag" annotated-tag
> $ git --version
> git version 1.5.3.4
>
> This is inconsistent with, say, "git commit", that groks -m"Message"
> (without space after -m) just fine.
As it happens, we are in the middle of adding our own option parser which
probably solves the issue. Can you please retest when we have that, and
use it in builtin-tag?
Thanks,
Dscho
^ permalink raw reply
* Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
From: Johannes Schindelin @ 2007-10-27 12:45 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <20071027081954.GA23406@laptop>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 668 bytes --]
Hi,
On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
> +mkdir -p work/sub/dir || exit 1
> +mv .git work
> +if test "$1" = --normal; then
> + say "Normal case"
> +else
> + say "Worktree case"
> +fi
> +test "$1" = --normal || mv work/.git repo.git || exit 1
> +
> +test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
> +export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
> +test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
> +
> +cd work/sub || exit 1
Why don't you put this block into a test_expect_success? And then just
make a
for mode in normal worktree
do
...
done
Hmm? I would like to see this test case in the official git.git.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Add NEED_WORK_TREE for more commands
From: Johannes Schindelin @ 2007-10-27 12:42 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <20071027081910.GA23381@laptop>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1215 bytes --]
Hi,
On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:
> + { "annotate", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },
> + { "blame", cmd_blame, RUN_SETUP | NEED_WORK_TREE },
Both can be sensibly run without a work tree: "git blame <commit> <file>"
> + { "format-patch", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },
This can be run without work tree in any case, methinks. AFAICT
format-patch only ever uses information from the object database.
> + { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
That has already been commented on.
> + { "reset", cmd_reset, RUN_SETUP | NEED_WORK_TREE },
"git reset --soft HEAD <commit>" makes sense in a bare repository.
> + { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
That has been coommented on, too.
I agree that there are modes for these commands (except format-patch), in
which they want a work-tree, but they have other modes, too, so IMHO it
should be solved a la 6d9ba67b(Commands requiring a work tree must not run
in GIT_DIR). You'll see that ls-files already has some special handling
here, and this could be refactorised to requires_work_tree(), which should
make the code much more elegant.
Ciao,
Dscho
^ permalink raw reply
* Re: merge vs rebase: Is visualization in gitk the only problem?
From: Johannes Schindelin @ 2007-10-27 12:33 UTC (permalink / raw)
To: Steffen Prohaska; +Cc: David Symonds, Git Mailing List
In-Reply-To: <CEA39C15-F9AE-46F5-BBE9-3F7AB0711494@zib.de>
Hi,
On Sat, 27 Oct 2007, Steffen Prohaska wrote:
> Could we somehow send rerere information together with a patch? This
> would give the upstream maintainer (and everyone else who wants to test
> the patch) the help needed to do a merge.
IMHO this is not sensible to send over email. But think I that something
like this could be done for pullers: they fetch from somewhere, and then
recreate the rerere information from the merge commits they just got (this
would have to be a new option to git-rerere, methinks).
Ciao,
Dscho
^ permalink raw reply
* Minor inconsistency: "git tag" requires space after -m.
From: Sergei Organov @ 2007-10-27 11:55 UTC (permalink / raw)
To: git
Hello,
It seems options parsing is somewhat broken in git-tag:
$ git tag -a -m"Annotated tag" annotated-tag
usage: git-tag [-n [<num>]] -l [<pattern>] | [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>] <tagname> [<head>]
$ git tag -a -m "Annotated tag" annotated-tag
$ git --version
git version 1.5.3.4
This is inconsistent with, say, "git commit", that groks -m"Message"
(without space after -m) just fine.
--
Sergei.
^ permalink raw reply
* Re: [PATCH] Add NEED_WORK_TREE for more commands
From: Mike Hommey @ 2007-10-27 10:42 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git
In-Reply-To: <20071027101839.GA26043@laptop>
On Sat, Oct 27, 2007 at 05:18:39PM +0700, Nguyen Thai Ngoc Duy wrote:
> On Sat, Oct 27, 2007 at 11:08:22AM +0200, Mike Hommey wrote:
> > On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguy???n Th??i Ng???c Duy wrote:
> > >
> > > Signed-off-by: Nguy???n Th??i Ng???c Duy <pclouds@gmail.com>
> > > ---
> > > git.c | 12 ++++++------
> > > 1 files changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/git.c b/git.c
> > > index 23a430c..9db40b3 100644
> > > --- a/git.c
> > > +++ b/git.c
> > > + { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
> > > + { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
> >
> > At least these two work very fine without a working tree (and I *do*
> > need them to work without a working tree).
>
> How can you do that while both need index and a working directory to
> operate?
For example, ls-files -c and update-index --remove don't need more than
the index, and you don't need a working tree to fiddle with the index
with these commands.
By the way, git-rm has a --cached option that allows it to only work on
the index, but it has a NEED_WORK_TREE which prevents its use without a
working tree in such a case (though I don't know if the implementation
itself relies on the working tree or not, but if it does, it shouldn't).
It's sad to have to do
git-ls-files -c directory | xargs -d "\n" git-update-index --remove
instead of
git-rm -r --cached directory
when you want to remove a directory in a bare repository.
Mike
^ permalink raw reply
* Re: [PATCH] Add NEED_WORK_TREE for more commands
From: Nguyen Thai Ngoc Duy @ 2007-10-27 10:18 UTC (permalink / raw)
To: Mike Hommey; +Cc: git
In-Reply-To: <20071027090822.GA6789@glandium.org>
On Sat, Oct 27, 2007 at 11:08:22AM +0200, Mike Hommey wrote:
> On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguy???n Th??i Ng???c Duy wrote:
> >
> > Signed-off-by: Nguy???n Th??i Ng???c Duy <pclouds@gmail.com>
> > ---
> > git.c | 12 ++++++------
> > 1 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/git.c b/git.c
> > index 23a430c..9db40b3 100644
> > --- a/git.c
> > +++ b/git.c
> > + { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
> > + { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
>
> At least these two work very fine without a working tree (and I *do*
> need them to work without a working tree).
How can you do that while both need index and a working directory to
operate?
> Mike
--
Duy
^ permalink raw reply
* Re: [POSSIBLE BUG] 'git log' option --no-color adds bogus empty line
From: Marco Costalba @ 2007-10-27 10:01 UTC (permalink / raw)
To: Johannes Gilger; +Cc: Git Mailing List
In-Reply-To: <472306BA.5060409@hackvalue.de>
On 10/27/07, Johannes Gilger <heipei@hackvalue.de> wrote:
> Marco Costalba wrote:
> > Form git tree:
> >
> > $ git log -n 1 8d863c98b2f9b0d37 | wc
> > 7 28 246
> >
> > $ git log --no-color -n 1 8d863c98b2f9b0d37 | wc
> > 8 28 247
> >
> > $ git --version
> > git version 1.5.3.2.124.g648db
>
> Hi,
>
> using git version 1.5.3.4.383.gd90a7 i can't confirm this, the two
> outputs are of the same length here.
>
Yes. With the latest git everything works as expected.
Sorry fo rthe noise!
Marco
^ permalink raw reply
* Re: [POSSIBLE BUG] 'git log' option --no-color adds bogus empty line
From: Johannes Gilger @ 2007-10-27 9:36 UTC (permalink / raw)
To: Marco Costalba, Git Mailing List
In-Reply-To: <e5bfff550710270210g6d363b40of597c3160124fb85@mail.gmail.com>
Marco Costalba wrote:
> Form git tree:
>
> $ git log -n 1 8d863c98b2f9b0d37 | wc
> 7 28 246
>
> $ git log --no-color -n 1 8d863c98b2f9b0d37 | wc
> 8 28 247
>
> $ git --version
> git version 1.5.3.2.124.g648db
Hi,
using git version 1.5.3.4.383.gd90a7 i can't confirm this, the two
outputs are of the same length here.
Regards,
Johannes
--
Johannes Gilger <heipei@hackvalue.de>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81 882C 58EE B178 42F6 DE81
^ permalink raw reply
* [POSSIBLE BUG] 'git log' option --no-color adds bogus empty line
From: Marco Costalba @ 2007-10-27 9:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git list, Yaacov Akiba Slama
Form git tree:
$ git log -n 1 8d863c98b2f9b0d37 | wc
7 28 246
$ git log --no-color -n 1 8d863c98b2f9b0d37 | wc
8 28 247
$ git --version
git version 1.5.3.2.124.g648db
What's worst is that when using --log-size option, the size is always
the same (198 in this case) breaking qgit parsing when --no-color
option is used.
BTW --no-color option is needed to correctly handle repositories where
"diff.color = true" in the configuration as pointed out (and patched)
by Yaacov Akiba Slama.
Thanks
Marco
^ permalink raw reply
* Re: [PATCH] Add NEED_WORK_TREE for more commands
From: Mike Hommey @ 2007-10-27 9:08 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <20071027081910.GA23381@laptop>
On Sat, Oct 27, 2007 at 03:19:10PM +0700, Nguyễn Thái Ngọc Duy wrote:
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> git.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/git.c b/git.c
> index 23a430c..9db40b3 100644
> --- a/git.c
> +++ b/git.c
> + { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
> + { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
At least these two work very fine without a working tree (and I *do*
need them to work without a working tree).
Mike
^ permalink raw reply
* Re: merge vs rebase: Is visualization in gitk the only problem?
From: Steffen Prohaska @ 2007-10-27 8:58 UTC (permalink / raw)
To: David Symonds; +Cc: Git Mailing List
In-Reply-To: <ee77f5c20710270116g45a644bp2b6783310e16ff20@mail.gmail.com>
On Oct 27, 2007, at 10:16 AM, David Symonds wrote:
> On 10/27/07, Steffen Prohaska <prohaska@zib.de> wrote:
>>
>> Rebase has definitely benefits but not all of its details
>> are obvious at a first glance. Tell a newbie to read the
>> git rebase man page and explain what git reabase does and
>> you know what I mean. Rebase definitely can help to create a
>> cleaner history. But it rewrites history and therefore destroys
>> information, for example information about the original code
>> base a patch was developed against, or merge conflicts that
>> were resolved. You also need to decide when to use rebase and
>> when to use merge. So you need to make a choice.
>>
>> Why not always use git merge?
>
> I'd use git-rebase for when I'm sending stuff upstream that I don't
> want to force the maintainer to merge, because I can probably do it
> better and quicker by rebasing. Once that's done, the upstream
> maintainer can just do a git-am (or similar), and it'll apply neatly
> on top of the current head. In other words, git-rebase allows the
> "merge effort" to be shifted to the brancher and away from the
> mainline maintainer/developer.
That definitely makes sense.
But you may need to do more merging because you need to merge every
single commit. It may be easier to merge only the final state of
a topic branch.
Could we somehow send rerere information together with a
patch? This would give the upstream maintainer (and everyone
else who wants to test the patch) the help needed to do a merge.
Steffen
^ permalink raw reply
* [PATCH 7/7] shell should call the new setup_path() to setup $PATH
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-6-git-send-email-srp@srparish.net>
Shell currently does its own manual thing for setting up the $PATH;
it can now call setup_path().
Signed-off-by: Scott R Parish <srp@srparish.net>
---
shell.c | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/shell.c b/shell.c
index cfe372b..9826109 100644
--- a/shell.c
+++ b/shell.c
@@ -24,17 +24,11 @@ static int do_cvs_cmd(const char *me, char *arg)
const char *cvsserver_argv[3] = {
"cvsserver", "server", NULL
};
- const char *oldpath = getenv("PATH");
- struct strbuf newpath = STRBUF_INIT;
if (!arg || strcmp(arg, "server"))
die("git-cvsserver only handles server: %s", arg);
- strbuf_addstr(&newpath, git_exec_path());
- strbuf_addch(&newpath, ':');
- strbuf_addstr(&newpath, oldpath);
-
- setenv("PATH", strbuf_detach(&newpath, NULL), 1);
+ setup_path(NULL);
return execv_git_cmd(cvsserver_argv);
}
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 2/7] remove unused/unneeded "pattern" argument of list_commands
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-1-git-send-email-srp@srparish.net>
list_commands() currently accepts and ignores a "pattern" argument,
and then hard codes a prefix as well as some magic numbers. This
hardcodes the prefix inside of the function and removes the magic
numbers.
Signed-off-by: Scott R Parish <srp@srparish.net>
---
help.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/help.c b/help.c
index d4b1818..b636774 100644
--- a/help.c
+++ b/help.c
@@ -93,10 +93,12 @@ static void pretty_print_string_list(struct cmdname **cmdname, int longest)
}
}
-static void list_commands(const char *exec_path, const char *pattern)
+static void list_commands(const char *exec_path)
{
unsigned int longest = 0;
char path[PATH_MAX];
+ const char *prefix = "git-";
+ int prefix_len = strlen(prefix);
int dirlen;
DIR *dir = opendir(exec_path);
struct dirent *de;
@@ -120,7 +122,7 @@ static void list_commands(const char *exec_path, const char *pattern)
struct stat st;
int entlen;
- if (prefixcmp(de->d_name, "git-"))
+ if (prefixcmp(de->d_name, prefix))
continue;
strcpy(path+dirlen, de->d_name);
if (stat(path, &st) || /* stat, not lstat */
@@ -128,14 +130,14 @@ static void list_commands(const char *exec_path, const char *pattern)
!(st.st_mode & S_IXUSR))
continue;
- entlen = strlen(de->d_name);
+ entlen = strlen(de->d_name) - prefix_len;
if (has_extension(de->d_name, ".exe"))
entlen -= 4;
if (longest < entlen)
longest = entlen;
- add_cmdname(de->d_name + 4, entlen-4);
+ add_cmdname(de->d_name + prefix_len, entlen);
}
closedir(dir);
@@ -143,7 +145,7 @@ static void list_commands(const char *exec_path, const char *pattern)
printf("----------------------------");
mput_char('-', strlen(exec_path));
putchar('\n');
- pretty_print_string_list(cmdname, longest - 4);
+ pretty_print_string_list(cmdname, longest);
putchar('\n');
}
@@ -210,7 +212,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
printf("usage: %s\n\n", git_usage_string);
if(exec_path)
- list_commands(exec_path, "git-*");
+ list_commands(exec_path);
exit(0);
}
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 6/7] walk $PATH to generate list of commands for "help -a"
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-5-git-send-email-srp@srparish.net>
Git had previously been using the $PATH for scripts--a previous
patch moved exec'ed commands to also use the $PATH. For consistancy
"help -a" should also use the $PATH.
We walk all the paths in $PATH collecting the names of "git-*"
commands. To help distinguish between the main git commands
and commands picked up elsewhere (probably extensions) we
print them seperately. The main commands are the ones that
are found in the first directory in $PATH that contains the
"git" binary.
Signed-off-by: Scott R Parish <srp@srparish.net>
---
help.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 125 insertions(+), 33 deletions(-)
diff --git a/help.c b/help.c
index ce3d795..ee4fce0 100644
--- a/help.c
+++ b/help.c
@@ -37,24 +37,29 @@ static inline void mput_char(char c, unsigned int num)
putchar(c);
}
-static struct cmdname {
- size_t len;
- char name[1];
-} **cmdname;
-static int cmdname_alloc, cmdname_cnt;
-
-static void add_cmdname(const char *name, int len)
+static struct cmdnames {
+ int alloc;
+ int cnt;
+ char *dir;
+ struct cmdname {
+ size_t len;
+ char name[1];
+ } **names;
+} main_cmds, other_cmds;
+
+static void add_cmdname(struct cmdnames *cmds, const char *name, int len)
{
struct cmdname *ent;
- if (cmdname_alloc <= cmdname_cnt) {
- cmdname_alloc = cmdname_alloc + 200;
- cmdname = xrealloc(cmdname, cmdname_alloc * sizeof(*cmdname));
+ if (cmds->alloc <= cmds->cnt) {
+ cmds->alloc = cmds->alloc + 200;
+ cmds->names = xrealloc(cmds->names,
+ cmds->alloc * sizeof(*cmds->names));
}
ent = xmalloc(sizeof(*ent) + len);
ent->len = len;
memcpy(ent->name, name, len);
ent->name[len] = 0;
- cmdname[cmdname_cnt++] = ent;
+ cmds->names[cmds->cnt++] = ent;
}
static int cmdname_compare(const void *a_, const void *b_)
@@ -64,7 +69,42 @@ static int cmdname_compare(const void *a_, const void *b_)
return strcmp(a->name, b->name);
}
-static void pretty_print_string_list(struct cmdname **cmdname, int longest)
+static void uniq(struct cmdnames *cmds)
+{
+ int i, j;
+
+ if (!cmds->cnt)
+ return;
+
+ for (i = j = 1; i < cmds->cnt; i++) {
+ if (strcmp(cmds->names[i]->name, cmds->names[i-1]->name)) {
+ cmds->names[j++] = cmds->names[i];
+ }
+ }
+
+ cmds->cnt = j;
+}
+
+static void subtract_cmds(struct cmdnames *a, struct cmdnames *b) {
+ int ai, aj, bi;
+
+ ai = aj = bi = 0;
+ while (ai < a->cnt && bi < b->cnt) {
+ if (0 > strcmp(a->names[ai]->name, b->names[bi]->name))
+ a->names[aj++] = a->names[ai++];
+ else if (0 > strcmp(a->names[ai]->name, b->names[bi]->name))
+ bi++;
+ else
+ ai++, bi++;
+ }
+
+ while (ai < a->cnt)
+ a->names[aj++] = a->names[ai++];
+
+ a->cnt = aj;
+}
+
+static void pretty_print_string_list(struct cmdnames *cmds, int longest)
{
int cols = 1, rows;
int space = longest + 1; /* min 1 SP between words */
@@ -73,9 +113,7 @@ static void pretty_print_string_list(struct cmdname **cmdname, int longest)
if (space < max_cols)
cols = max_cols / space;
- rows = (cmdname_cnt + cols - 1) / cols;
-
- qsort(cmdname, cmdname_cnt, sizeof(*cmdname), cmdname_compare);
+ rows = (cmds->cnt + cols - 1) / cols;
for (i = 0; i < rows; i++) {
printf(" ");
@@ -83,31 +121,39 @@ static void pretty_print_string_list(struct cmdname **cmdname, int longest)
for (j = 0; j < cols; j++) {
int n = j * rows + i;
int size = space;
- if (n >= cmdname_cnt)
+ if (n >= cmds->cnt)
break;
- if (j == cols-1 || n + rows >= cmdname_cnt)
+ if (j == cols-1 || n + rows >= cmds->cnt)
size = 1;
- printf("%-*s", size, cmdname[n]->name);
+ printf("%-*s", size, cmds->names[n]->name);
}
putchar('\n');
}
}
-static void list_commands(const char *exec_path)
+static unsigned int list_commands_in_dir(const char *dir)
{
unsigned int longest = 0;
const char *prefix = "git-";
int prefix_len = strlen(prefix);
- DIR *dir = opendir(exec_path);
+ DIR *dirp = opendir(dir);
+ struct cmdnames *cmds;
struct dirent *de;
+ struct stat st;
- if (!dir || chdir(exec_path)) {
- fprintf(stderr, "git: '%s': %s\n", exec_path, strerror(errno));
- exit(1);
+ if (!dirp || chdir(dir))
+ return 0;
+
+ if (!main_cmds.cnt &&
+ !stat("git", &st) &&
+ S_ISREG(st.st_mode) && (st.st_mode & S_IXUSR)) {
+ cmds = &main_cmds;
+ cmds->dir = xstrdup(dir);
}
+ else
+ cmds = &other_cmds;
- while ((de = readdir(dir)) != NULL) {
- struct stat st;
+ while ((de = readdir(dirp)) != NULL) {
int entlen;
if (prefixcmp(de->d_name, prefix))
@@ -122,18 +168,66 @@ static void list_commands(const char *exec_path)
if (has_extension(de->d_name, ".exe"))
entlen -= 4;
+ if (has_extension(de->d_name, ".perl") ||
+ has_extension(de->d_name, ".sh"))
+ continue;
+
if (longest < entlen)
longest = entlen;
- add_cmdname(de->d_name + prefix_len, entlen);
+ add_cmdname(cmds, de->d_name + prefix_len, entlen);
+ }
+ closedir(dirp);
+
+ return longest;
+}
+
+static void list_commands()
+{
+ unsigned int longest = 0;
+ unsigned int len;
+ const char *env_path = getenv("PATH");
+ char *paths, *path, *colon;
+
+ if (!env_path) {
+ fprintf(stderr, "PATH not set\n");
+ exit(1);
}
- closedir(dir);
- printf("git commands available in '%s'\n", exec_path);
+ path = paths = xstrdup(env_path);
+ while ((char *)1 != path) {
+ if ((colon = strchr(path, ':')))
+ *colon = 0;
+
+ len = list_commands_in_dir(path);
+ longest = MAX(longest, len);
+
+ path = colon + 1;
+ }
+ free(paths);
+
+ qsort(main_cmds.names, main_cmds.cnt,
+ sizeof(*main_cmds.names), cmdname_compare);
+ uniq(&main_cmds);
+
+ qsort(other_cmds.names, other_cmds.cnt,
+ sizeof(*other_cmds.names), cmdname_compare);
+ uniq(&other_cmds);
+ subtract_cmds(&other_cmds, &main_cmds);
+
+ printf("available git commands in '%s'\n", main_cmds.dir);
printf("----------------------------");
- mput_char('-', strlen(exec_path));
+ mput_char('-', strlen(main_cmds.dir));
+ putchar('\n');
+ pretty_print_string_list(&main_cmds, longest);
putchar('\n');
- pretty_print_string_list(cmdname, longest);
+
+ if (!other_cmds.cnt)
+ return;
+
+ printf("git commands available from elsewhere on your $PATH\n");
+ printf("---------------------------------------------------\n");
+ pretty_print_string_list(&other_cmds, longest);
putchar('\n');
}
@@ -189,7 +283,6 @@ int cmd_version(int argc, const char **argv, const char *prefix)
int cmd_help(int argc, const char **argv, const char *prefix)
{
const char *help_cmd = argc > 1 ? argv[1] : NULL;
- const char *exec_path = git_exec_path();
if (!help_cmd) {
printf("usage: %s\n\n", git_usage_string);
@@ -199,8 +292,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
printf("usage: %s\n\n", git_usage_string);
- if(exec_path)
- list_commands(exec_path);
+ list_commands();
exit(0);
}
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 5/7] use only the $PATH for exec'ing git commands
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-4-git-send-email-srp@srparish.net>
We need to correctly set up $PATH for non-c based git commands.
Since we already do this, we can just use that $PATH and execvp,
instead of looping over the paths with execve.
This patch adds a setup_path() function to exec_cmd.c, which sets
the $PATH order correctly for our search order. execv_git_cmd() is
stripped down to setting up argv and calling execvp(). git.c's
main() only only needs to call setup_path().
Signed-off-by: Scott R Parish <srp@srparish.net>
---
exec_cmd.c | 121 ++++++++++++++++++++++++++----------------------------------
exec_cmd.h | 1 +
git.c | 43 +++------------------
3 files changed, 60 insertions(+), 105 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index 8b681d0..c228dbf 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -29,85 +29,68 @@ const char *git_exec_path(void)
return builtin_exec_path;
}
+static void add_path(struct strbuf *out, const char *path)
+{
+ if (path && strlen(path)) {
+ if (is_absolute_path(path))
+ strbuf_addstr(out, path);
+ else
+ strbuf_addstr(out, make_absolute_path(path));
+
+ strbuf_addch(out, ':');
+ }
+}
+
+void setup_path(const char *cmd_path)
+{
+ const char *old_path = getenv("PATH");
+ struct strbuf new_path;
+
+ strbuf_init(&new_path, 0);
+
+ add_path(&new_path, argv_exec_path);
+ add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
+ add_path(&new_path, builtin_exec_path);
+ add_path(&new_path, cmd_path);
+
+ if (old_path)
+ strbuf_addstr(&new_path, old_path);
+ else
+ strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
+
+ setenv("PATH", new_path.buf, 1);
+
+ strbuf_release(&new_path);
+}
int execv_git_cmd(const char **argv)
{
- char git_command[PATH_MAX + 1];
- int i;
- const char *paths[] = { argv_exec_path,
- getenv(EXEC_PATH_ENVIRONMENT),
- builtin_exec_path };
-
- for (i = 0; i < ARRAY_SIZE(paths); ++i) {
- size_t len;
- int rc;
- const char *exec_dir = paths[i];
- const char *tmp;
-
- if (!exec_dir || !*exec_dir) continue;
-
- if (*exec_dir != '/') {
- if (!getcwd(git_command, sizeof(git_command))) {
- fprintf(stderr, "git: cannot determine "
- "current directory: %s\n",
- strerror(errno));
- break;
- }
- len = strlen(git_command);
-
- /* Trivial cleanup */
- while (!prefixcmp(exec_dir, "./")) {
- exec_dir += 2;
- while (*exec_dir == '/')
- exec_dir++;
- }
-
- rc = snprintf(git_command + len,
- sizeof(git_command) - len, "/%s",
- exec_dir);
- if (rc < 0 || rc >= sizeof(git_command) - len) {
- fprintf(stderr, "git: command name given "
- "is too long.\n");
- break;
- }
- } else {
- if (strlen(exec_dir) + 1 > sizeof(git_command)) {
- fprintf(stderr, "git: command name given "
- "is too long.\n");
- break;
- }
- strcpy(git_command, exec_dir);
- }
-
- len = strlen(git_command);
- rc = snprintf(git_command + len, sizeof(git_command) - len,
- "/git-%s", argv[0]);
- if (rc < 0 || rc >= sizeof(git_command) - len) {
- fprintf(stderr,
- "git: command name given is too long.\n");
- break;
- }
+ struct strbuf cmd;
+ const char *tmp;
- /* argv[0] must be the git command, but the argv array
- * belongs to the caller, and my be reused in
- * subsequent loop iterations. Save argv[0] and
- * restore it on error.
- */
+ strbuf_init(&cmd, 0);
+ strbuf_addf(&cmd, "git-%s", argv[0]);
- tmp = argv[0];
- argv[0] = git_command;
+ /* argv[0] must be the git command, but the argv array
+ * belongs to the caller, and my be reused in
+ * subsequent loop iterations. Save argv[0] and
+ * restore it on error.
+ */
+ tmp = argv[0];
+ argv[0] = cmd.buf;
- trace_argv_printf(argv, -1, "trace: exec:");
+ trace_argv_printf(argv, -1, "trace: exec:");
- /* execve() can only ever return if it fails */
- execve(git_command, (char **)argv, environ);
+ /* execvp() can only ever return if it fails */
+ execvp(cmd.buf, (char **)argv);
- trace_printf("trace: exec failed: %s\n", strerror(errno));
+ trace_printf("trace: exec failed: %s\n", strerror(errno));
- argv[0] = tmp;
- }
- return -1;
+ argv[0] = tmp;
+ strbuf_release(&cmd);
+
+ return -1;
}
diff --git a/exec_cmd.h b/exec_cmd.h
index da99287..a892355 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -3,6 +3,7 @@
extern void git_set_argv_exec_path(const char *exec_path);
extern const char* git_exec_path(void);
+extern void setup_path(const char *);
extern int execv_git_cmd(const char **argv); /* NULL terminated */
extern int execl_git_cmd(const char *cmd, ...);
diff --git a/git.c b/git.c
index c7cabf5..4e10581 100644
--- a/git.c
+++ b/git.c
@@ -6,28 +6,6 @@
const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
-static void prepend_to_path(const char *dir, int len)
-{
- const char *old_path = getenv("PATH");
- char *path;
- int path_len = len;
-
- if (!old_path)
- old_path = "/usr/local/bin:/usr/bin:/bin";
-
- path_len = len + strlen(old_path) + 1;
-
- path = xmalloc(path_len + 1);
-
- memcpy(path, dir, len);
- path[len] = ':';
- memcpy(path + len + 1, old_path, path_len - len);
-
- setenv("PATH", path, 1);
-
- free(path);
-}
-
static int handle_options(const char*** argv, int* argc, int* envchanged)
{
int handled = 0;
@@ -408,7 +386,7 @@ int main(int argc, const char **argv)
{
const char *cmd = argv[0] ? argv[0] : "git-help";
char *slash = strrchr(cmd, '/');
- const char *exec_path = NULL;
+ const char *cmd_path = NULL;
int done_alias = 0;
/*
@@ -418,10 +396,7 @@ int main(int argc, const char **argv)
*/
if (slash) {
*slash++ = 0;
- if (*cmd == '/')
- exec_path = cmd;
- else
- exec_path = xstrdup(make_absolute_path(cmd));
+ cmd_path = cmd;
cmd = slash;
}
@@ -458,16 +433,12 @@ int main(int argc, const char **argv)
cmd = argv[0];
/*
- * We execute external git command via execv_git_cmd(),
- * which looks at "--exec-path" option, GIT_EXEC_PATH
- * environment, and $(gitexecdir) in Makefile while built,
- * in this order. For scripted commands, we prepend
- * the value of the exec_path variable to the PATH.
+ * We use PATH to find git commands, but we prepend some higher
+ * precidence paths: the "--exec-path" option, the GIT_EXEC_PATH
+ * environment, and the $(gitexecdir) from the Makefile at build
+ * time.
*/
- if (exec_path)
- prepend_to_path(exec_path, strlen(exec_path));
- exec_path = git_exec_path();
- prepend_to_path(exec_path, strlen(exec_path));
+ setup_path(cmd_path);
while (1) {
/* See if it's an internal command */
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 3/7] "current_exec_path" is a misleading name, use "argv_exec_path"
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-2-git-send-email-srp@srparish.net>
Signed-off-by: Scott R Parish <srp@srparish.net>
---
exec_cmd.c | 12 ++++++------
exec_cmd.h | 2 +-
git.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index 9b74ed2..8b681d0 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -5,11 +5,11 @@
extern char **environ;
static const char *builtin_exec_path = GIT_EXEC_PATH;
-static const char *current_exec_path;
+static const char *argv_exec_path = 0;
-void git_set_exec_path(const char *exec_path)
+void git_set_argv_exec_path(const char *exec_path)
{
- current_exec_path = exec_path;
+ argv_exec_path = exec_path;
}
@@ -18,8 +18,8 @@ const char *git_exec_path(void)
{
const char *env;
- if (current_exec_path)
- return current_exec_path;
+ if (argv_exec_path)
+ return argv_exec_path;
env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
@@ -34,7 +34,7 @@ int execv_git_cmd(const char **argv)
{
char git_command[PATH_MAX + 1];
int i;
- const char *paths[] = { current_exec_path,
+ const char *paths[] = { argv_exec_path,
getenv(EXEC_PATH_ENVIRONMENT),
builtin_exec_path };
diff --git a/exec_cmd.h b/exec_cmd.h
index 849a839..da99287 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -1,7 +1,7 @@
#ifndef GIT_EXEC_CMD_H
#define GIT_EXEC_CMD_H
-extern void git_set_exec_path(const char *exec_path);
+extern void git_set_argv_exec_path(const char *exec_path);
extern const char* git_exec_path(void);
extern int execv_git_cmd(const char **argv); /* NULL terminated */
extern int execl_git_cmd(const char *cmd, ...);
diff --git a/git.c b/git.c
index efed91c..c7cabf5 100644
--- a/git.c
+++ b/git.c
@@ -51,7 +51,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
if (!prefixcmp(cmd, "--exec-path")) {
cmd += 11;
if (*cmd == '=')
- git_set_exec_path(cmd + 1);
+ git_set_argv_exec_path(cmd + 1);
else {
puts(git_exec_path());
exit(0);
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 1/7] "git" returns 1; "git help" and "git help -a" return 0
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
Signed-off-by: Scott R Parish <srp@srparish.net>
---
builtin.h | 1 +
git.c | 7 ++++---
help.c | 6 +++---
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/builtin.h b/builtin.h
index 65cc0fb..9a6213a 100644
--- a/builtin.h
+++ b/builtin.h
@@ -6,6 +6,7 @@
extern const char git_version_string[];
extern const char git_usage_string[];
+extern void list_common_cmds_help(void);
extern void help_unknown_cmd(const char *cmd);
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
extern void prune_packed_objects(int);
diff --git a/git.c b/git.c
index 23a430c..efed91c 100644
--- a/git.c
+++ b/git.c
@@ -450,9 +450,10 @@ int main(int argc, const char **argv)
if (!prefixcmp(argv[0], "--"))
argv[0] += 2;
} else {
- /* Default command: "help" */
- argv[0] = "help";
- argc = 1;
+ /* The user didn't specify a command; give them help */
+ printf("usage: %s\n\n", git_usage_string);
+ list_common_cmds_help();
+ exit(1);
}
cmd = argv[0];
diff --git a/help.c b/help.c
index 1cd33ec..d4b1818 100644
--- a/help.c
+++ b/help.c
@@ -147,7 +147,7 @@ static void list_commands(const char *exec_path, const char *pattern)
putchar('\n');
}
-static void list_common_cmds_help(void)
+void list_common_cmds_help(void)
{
int i, longest = 0;
@@ -204,14 +204,14 @@ int cmd_help(int argc, const char **argv, const char *prefix)
if (!help_cmd) {
printf("usage: %s\n\n", git_usage_string);
list_common_cmds_help();
- exit(1);
+ exit(0);
}
else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
printf("usage: %s\n\n", git_usage_string);
if(exec_path)
list_commands(exec_path, "git-*");
- exit(1);
+ exit(0);
}
else
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH 4/7] list_commands(): simplify code by using chdir()
From: Scott R Parish @ 2007-10-27 8:36 UTC (permalink / raw)
To: git; +Cc: Scott R Parish
In-Reply-To: <1193474215-6728-3-git-send-email-srp@srparish.net>
The current code builds absolute path strings for each file to
stat(), this can easily be avoided by chdir()ing into the directory.
Signed-off-by: Scott R Parish <srp@srparish.net>
---
help.c | 18 +++---------------
1 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/help.c b/help.c
index b636774..ce3d795 100644
--- a/help.c
+++ b/help.c
@@ -96,36 +96,24 @@ static void pretty_print_string_list(struct cmdname **cmdname, int longest)
static void list_commands(const char *exec_path)
{
unsigned int longest = 0;
- char path[PATH_MAX];
const char *prefix = "git-";
int prefix_len = strlen(prefix);
- int dirlen;
DIR *dir = opendir(exec_path);
struct dirent *de;
- if (!dir) {
+ if (!dir || chdir(exec_path)) {
fprintf(stderr, "git: '%s': %s\n", exec_path, strerror(errno));
exit(1);
}
- dirlen = strlen(exec_path);
- if (PATH_MAX - 20 < dirlen) {
- fprintf(stderr, "git: insanely long exec-path '%s'\n",
- exec_path);
- exit(1);
- }
-
- memcpy(path, exec_path, dirlen);
- path[dirlen++] = '/';
-
while ((de = readdir(dir)) != NULL) {
struct stat st;
int entlen;
if (prefixcmp(de->d_name, prefix))
continue;
- strcpy(path+dirlen, de->d_name);
- if (stat(path, &st) || /* stat, not lstat */
+
+ if (stat(de->d_name, &st) || /* stat, not lstat */
!S_ISREG(st.st_mode) ||
!(st.st_mode & S_IXUSR))
continue;
--
gitgui.0.8.4.11178.g9a1bf-dirty
^ permalink raw reply related
* [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE
From: Nguyễn Thái Ngọc Duy @ 2007-10-27 8:19 UTC (permalink / raw)
To: git
This one is ugly (and not intended to submit to git.git), but
it shows how to reproduce the issues. You can run it with
arg "--normal" to see it works just fine without GIT_WORK_TREE.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
t/t1502-subworktree.sh | 109 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 109 insertions(+), 0 deletions(-)
create mode 100755 t/t1502-subworktree.sh
diff --git a/t/t1502-subworktree.sh b/t/t1502-subworktree.sh
new file mode 100755
index 0000000..6b8f02f
--- /dev/null
+++ b/t/t1502-subworktree.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+test_description='test commands on separate work tree'
+. ./test-lib.sh
+
+mkdir -p work/sub/dir || exit 1
+mv .git work
+if test "$1" = --normal; then
+ say "Normal case"
+else
+ say "Worktree case"
+fi
+test "$1" = --normal || mv work/.git repo.git || exit 1
+
+test "$1" = --normal || export GIT_DIR=$(pwd)/repo.git
+export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+test "$1" = --normal || export GIT_WORK_TREE=$(pwd)/work
+
+cd work/sub || exit 1
+
+cat >expected <<EOF
+100644 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 0 dir/untracked
+EOF
+
+test_expect_success 'git-ls-files' 'test expected = "$(git ls-files --others)"'
+
+test_expect_success 'git-add' '
+ ( : > dir/untracked &&
+ git add dir/untracked &&
+ test dir/untracked = "$(git ls-files)")
+'
+test_expect_success 'git-update-index' '
+ ( echo test > dir/untracked &&
+ git update-index dir/untracked &&
+ git ls-files --stage > check &&
+ cmp expected check)
+'
+
+test_expect_success 'git-commit' 'git commit -m one'
+
+cat >expected <<EOF
+100644 blob 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 dir/untracked
+EOF
+
+test_expect_success 'git-ls-tree' '
+ (git ls-tree -r HEAD > check &&
+ cmp expected check)
+'
+test_expect_success 'git-rm' '
+ (git rm --cached dir/untracked &&
+ test -z "$(git ls-files)")
+'
+test_expect_success 'git-reset' '
+ (git reset HEAD -- dir/untracked &&
+ test dir/untracked = "$(git ls-files)")
+'
+test_expect_success 'git-annotate' 'git annotate dir/untracked'
+
+test_expect_success 'git-blame' 'git blame dir/untracked'
+
+cat > patch <<EOF
+From b774efc5a2199bfc1c9c18db70363c69a5a10c86 Mon Sep 17 00:00:00 2001
+From: A U Thor <author@example.com>
+Date: Tue, 23 Oct 2007 21:17:24 +0700
+Subject: bah
+
+---
+ sub/dir/untracked | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/sub/dir/untracked b/sub/dir/untracked
+index 9daeafb..c73d3ff 100644
+--- a/sub/dir/untracked
++++ b/sub/dir/untracked
+@@ -1 +1,2 @@
+ test
++test again
+--
+1.5.3.rc4.3.gab089
+
+EOF
+
+cat > expected <<EOF
+100644 c73d3ffa5fa32888de8219e49fd45d37dc209677 0 dir/untracked
+EOF
+
+test_expect_success 'git-apply to index' '
+ (git apply --index patch &&
+ git ls-files --stage > check &&
+ cmp expected check)'
+
+test_expect_failure 'git-apply to worktree' 'test -f sub/dir/untracked'
+
+test_expect_success 'git-reset --hard' '( git reset --hard HEAD && test -z "$(git ls-files -m)")'
+
+test_expect_failure 'git-am must not be run from subdir' 'git-am -k patch'
+
+test_expect_success 'git-reset --hard' 'git reset --hard HEAD'
+
+test_expect_success 'git-am' '(cd .. && git-am -k sub/patch)'
+
+test_expect_success 'git-format-patch' '
+ (git format-patch -k HEAD^ &&
+ sed "1d;/^-- /,\$d" patch > expected &&
+ sed "1d;/^-- /,\$d" 0001-bah.patch > check &&
+ cmp expected check)
+'
+
+test_done
--
1.5.3.rc4.3.gab089
^ permalink raw reply related
* [PATCH] Add NEED_WORK_TREE for more commands
From: Nguyễn Thái Ngọc Duy @ 2007-10-27 8:19 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
git.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/git.c b/git.c
index 23a430c..9db40b3 100644
--- a/git.c
+++ b/git.c
@@ -307,10 +307,10 @@ static void handle_internal_command(int argc, const char **argv)
const char *cmd = argv[0];
static struct cmd_struct commands[] = {
{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
- { "annotate", cmd_annotate, RUN_SETUP },
+ { "annotate", cmd_annotate, RUN_SETUP | NEED_WORK_TREE },
{ "apply", cmd_apply },
{ "archive", cmd_archive },
- { "blame", cmd_blame, RUN_SETUP },
+ { "blame", cmd_blame, RUN_SETUP | NEED_WORK_TREE },
{ "branch", cmd_branch, RUN_SETUP },
{ "bundle", cmd_bundle },
{ "cat-file", cmd_cat_file, RUN_SETUP },
@@ -333,7 +333,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "fetch--tool", cmd_fetch__tool, RUN_SETUP },
{ "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP },
{ "for-each-ref", cmd_for_each_ref, RUN_SETUP },
- { "format-patch", cmd_format_patch, RUN_SETUP },
+ { "format-patch", cmd_format_patch, RUN_SETUP | NEED_WORK_TREE },
{ "fsck", cmd_fsck, RUN_SETUP },
{ "fsck-objects", cmd_fsck, RUN_SETUP },
{ "gc", cmd_gc, RUN_SETUP },
@@ -346,7 +346,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "init", cmd_init_db },
{ "init-db", cmd_init_db },
{ "log", cmd_log, RUN_SETUP | USE_PAGER },
- { "ls-files", cmd_ls_files, RUN_SETUP },
+ { "ls-files", cmd_ls_files, RUN_SETUP | NEED_WORK_TREE },
{ "ls-tree", cmd_ls_tree, RUN_SETUP },
{ "mailinfo", cmd_mailinfo },
{ "mailsplit", cmd_mailsplit },
@@ -363,7 +363,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "reflog", cmd_reflog, RUN_SETUP },
{ "repo-config", cmd_config },
{ "rerere", cmd_rerere, RUN_SETUP },
- { "reset", cmd_reset, RUN_SETUP },
+ { "reset", cmd_reset, RUN_SETUP | NEED_WORK_TREE },
{ "rev-list", cmd_rev_list, RUN_SETUP },
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
@@ -377,7 +377,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "tag", cmd_tag, RUN_SETUP },
{ "tar-tree", cmd_tar_tree },
{ "unpack-objects", cmd_unpack_objects, RUN_SETUP },
- { "update-index", cmd_update_index, RUN_SETUP },
+ { "update-index", cmd_update_index, RUN_SETUP | NEED_WORK_TREE },
{ "update-ref", cmd_update_ref, RUN_SETUP },
{ "upload-archive", cmd_upload_archive },
{ "verify-tag", cmd_verify_tag, RUN_SETUP },
--
1.5.3.rc4.3.gab089
^ permalink raw reply related
* Re: merge vs rebase: Is visualization in gitk the only problem?
From: David Symonds @ 2007-10-27 8:16 UTC (permalink / raw)
To: Steffen Prohaska; +Cc: Git Mailing List
In-Reply-To: <8E86BDBA-A49A-49BB-8E00-8BF6DD7237E9@zib.de>
On 10/27/07, Steffen Prohaska <prohaska@zib.de> wrote:
>
> Rebase has definitely benefits but not all of its details
> are obvious at a first glance. Tell a newbie to read the
> git rebase man page and explain what git reabase does and
> you know what I mean. Rebase definitely can help to create a
> cleaner history. But it rewrites history and therefore destroys
> information, for example information about the original code
> base a patch was developed against, or merge conflicts that
> were resolved. You also need to decide when to use rebase and
> when to use merge. So you need to make a choice.
>
> Why not always use git merge?
I'd use git-rebase for when I'm sending stuff upstream that I don't
want to force the maintainer to merge, because I can probably do it
better and quicker by rebasing. Once that's done, the upstream
maintainer can just do a git-am (or similar), and it'll apply neatly
on top of the current head. In other words, git-rebase allows the
"merge effort" to be shifted to the brancher and away from the
mainline maintainer/developer.
Dave.
^ permalink raw reply
* [PATCH] git-sh-setup.sh: use "git rev-parse --show-cdup" to check for SUBDIRECTORY_OK
From: Nguyễn Thái Ngọc Duy @ 2007-10-27 7:47 UTC (permalink / raw)
To: git
"git rev-parse --git-dir" trick does not play well with worktree
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
git-sh-setup.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 3c325fd..86d7d4c 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -110,7 +110,7 @@ esac
if [ -z "$SUBDIRECTORY_OK" ]
then
: ${GIT_DIR=.git}
- GIT_DIR=$(GIT_DIR="$GIT_DIR" git rev-parse --git-dir) || {
+ test -z "$(git rev-parse --show-cdup)" || {
exit=$?
echo >&2 "You need to run this command from the toplevel of the working tree."
exit $exit
--
1.5.3.rc4.3.gab089
^ permalink raw reply related
* Re: [PATCH 1/7] "git" calls help_unknown_cmd(""); "git help" and "git help -a" return 0
From: Scott Parish @ 2007-10-27 7:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v640twka3.fsf@gitster.siamese.dyndns.org>
On Fri, Oct 26, 2007 at 04:03:48PM -0700, Junio C Hamano wrote:
> > Regarding "git: '' is not a git-command" the way i was seeing that
> > is that git is usually only called with commands, and '' isn't a
> > valid command, hence the reason to exit 1, the help is just a nice
> > user experience.
>
> But think who would type "git<Enter>". They are either people
> who (1) do not even know that "git" alone is not useful and that
> it always wants a subcommand, or (2) know "git<Enter>" is the
> same as "git help" and wants to get the "common command list"
> quickly. Technically, "'' is not a git-command" is correct, but
> the message does not help either audience, does it?
Fair enough, i'll drop that in the updated patch set i'm about ready
to send. Incidentally i was also missing the "usage" string.
sRp
--
Scott Parish
http://srparish.net/
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox