* 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
* merge vs rebase: Is visualization in gitk the only problem?
From: Steffen Prohaska @ 2007-10-27 7:17 UTC (permalink / raw)
To: Git Mailing List
There are some discussions going on about merge vs. rebase. The
suggestions by Dscho is to prefer rebase over merge in a
CVS-style workflow.
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?
Is the only problem of git merge that it might create loops
in the history with potentially long running parallel lines
that are insufficiently visualized in gitk?
If so, why not improve the visualization?
Or is there any other deficiency of always using merge and
never using rebase that I don't see?
Obviously you can use git merge only if you want to have _all_
changes from the other branch. But this is often what you
want. In a CVS-style workflow you want to merge all changes
from the shared branch before pushing. Why going through the
hassel of git rebase?
I'm aware that you can do other things with git rebase that
cannot be achieved by using git merge. For example moving a
topic branch to a different stable branch without merging all
of the topic branch's history ("--onto" option). It is easy
to explain that rebase has it's own value.
Steffen
^ permalink raw reply
* Re: Git and Windows
From: Steffen Prohaska @ 2007-10-27 6:54 UTC (permalink / raw)
To: Bo Yang; +Cc: Git Mailing List
In-Reply-To: <47215396.1080202@gmail.com>
On Oct 26, 2007, at 4:40 AM, Bo Yang wrote:
> Johannes Schindelin :
>> Hi,
>>
>> On Thu, 25 Oct 2007, Bo Yang wrote:
>>
>>
>>> I am a new comer to this list but I have used git for two week
>>> development control. I think it is a very cool tool, the only
>>> flaw is that I have not found Windows version of it. Does git
>>> just aim at Linux kernel development? Is there any plan or in the
>>> future to migrate it to windows?
>>>
>>
>> Funny. The first three hits I get from Google are
>>
>> Wikipedia,
>> GitWiki and
>> msysgit
>>
>> The first two pointing to the third. And happily enough, there is
>> a Download page at the third site. Oh, and it has a description
>> what its affiliation with git is.
>>
> So, if I want to get involved with the Windows version git
> development, I should download the Gitme, right?
Yes, if you want to contribute to git on Windows.
And if you only want to use git, you can download
http://msysgit.googlecode.com/files/Git-1.5.3-preview20071019.exe
Steffen
^ permalink raw reply
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
From: Junio C Hamano @ 2007-10-27 6:12 UTC (permalink / raw)
To: Tom Prince; +Cc: git
In-Reply-To: <20071027053305.GB3115@hermes.priv>
Tom Prince <tom.prince@ualberta.net> writes:
> On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:
>> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
>> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
>> > >
>> > > +The special exit code 125 should be used when the current source code
>> > > +cannot be tested. If the "run" script exits with this code, the
>> > > current
>> > > +revision will be "skip"ped, see `git bisect skip` above.
>> > > [...]
>> >
>> Also there is:
>>
>> $ grep 77 /usr/include/sysexits.h
>> #define EX_NOPERM 77 /* permission denied */
>
> How about
>
> #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
Let's stop bikeshedding. 125 is as good as anything else.
^ permalink raw reply
* Re: recent change in git.git/master broke my repos
From: Junio C Hamano @ 2007-10-27 6:09 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Jeff King, git, Randal L. Schwartz
In-Reply-To: <Pine.LNX.4.64.0710251351330.7345@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> On Thu, 25 Oct 2007, Jeff King wrote:
>
>> On Thu, Oct 25, 2007 at 07:32:36AM -0700, Randal L. Schwartz wrote:
>>
>> > I have echo "ref: refs/remotes/origin/master" >.git/refs/heads/upstream
>> > so that my daily update script can go:
>> >
>> > git-fetch
>> > if [ repo is on master, and is not dirty ];
>> > git-merge upstream
>> > fi
>> >
>> > Yesterday that worked.
>> >
>> > Today I get a rash of:
>> >
>> > fatal: Couldn't find remote ref refs/remotes/origin/master
>> >
>> > from my git-fetch.
>>
>> Randal and I discussed this a bit on IRC, and it turns out not to be
>> related to the 'upstream' symref. Instead, he had a broken
>> branch.master.merge config that pointed to "refs/remotes/origin/master"
>> (which you can see from his script above doesn't actually get used).
>>
>> So presumably the old git-fetch didn't care that the contents of
>> branch.*.master didn't exist (it's just that nothing got marked for
>> merging), but the one just merged from the db/fetch-pack topic does.
>>
>> Is this behavior change intentional?
>
> It's not exactly intentional; it's just that nobody seems to have tested
> this particular misconfiguration. It should probably report an error
> (since the configuration is, in fact, broken and potentially misleading),
> but it probably shouldn't be fatal and certainly shouldn't be so
> uninformative.
How would we proceed from here, then?
If you had "branch.master.merge = refs/heads/foobar", kept
running happily, and suddenly the remote stopped carrying that
foobar branch, you would get a configuration that uses
nonexistent remote branch name, so this is not purely a
configuration error on the fetcher's side.
Older git used to enumerate remote tracking branches explicitly,
and one of the remote.origin.fetch entries would have said
"refs/heads/foobar:refs/remotes/origin/foobar", and that would
have made git-fetch fail with the error, complaining that such a
branch does not exist.
You are suggesting that git-fetch should not fail if
remote.origin.fetch is refs/heads/*:refs/remotes/origin/*
wildcard, and I think I can agree with that; "git pull" however
should notice and and exit with an error.
Perhaps something like this?
-- >8 --
[PATCH] git-fetch: do not fail when remote branch disappears
When the branch named with branch.$name.merge is not covered by
the fetch configuration for the remote repository named with
branch.$name.remote, we automatically add that branch to the set
of branches to be fetched. However, if the remote repository
does not have that branch (e.g. it used to exist, but got
removed), this is not a reason to fail the git-fetch itself.
The situation however will be noticed if git-fetch was called by
git-pull, as the resulting FETCH_HEAD would not have any entry
that is marked for merging.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-fetch.c | 24 ++++++++++++++++--------
remote.c | 22 +++++++++++++---------
remote.h | 5 ++++-
3 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index b9d2b0c..003ed76 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -48,15 +48,21 @@ static void add_merge_config(struct ref **head,
if (rm)
continue;
- /* Not fetched to a tracking branch? We need to fetch
+ /*
+ * Not fetched to a tracking branch? We need to fetch
* it anyway to allow this branch's "branch.$name.merge"
- * to be honored by git-pull.
+ * to be honored by git-pull, but we do not have to
+ * fail if branch.$name.merge is misconfigured to point
+ * at a nonexisting branch. If we were indeed called by
+ * git-pull, it will notice the misconfiguration because
+ * there is no entry in the resulting FETCH_HEAD marked
+ * for merging.
*/
refspec.src = branch->merge[i]->src;
refspec.dst = NULL;
refspec.pattern = 0;
refspec.force = 0;
- get_fetch_map(remote_refs, &refspec, tail);
+ get_fetch_map(remote_refs, &refspec, tail, 1);
for (rm = *old_tail; rm; rm = rm->next)
rm->merge = 1;
}
@@ -75,7 +81,7 @@ static struct ref *get_ref_map(struct transport *transport,
if (ref_count || tags) {
for (i = 0; i < ref_count; i++) {
- get_fetch_map(remote_refs, &refs[i], &tail);
+ get_fetch_map(remote_refs, &refs[i], &tail, 0);
if (refs[i].dst && refs[i].dst[0])
*autotags = 1;
}
@@ -88,7 +94,7 @@ static struct ref *get_ref_map(struct transport *transport,
refspec.dst = "refs/tags/";
refspec.pattern = 1;
refspec.force = 0;
- get_fetch_map(remote_refs, &refspec, &tail);
+ get_fetch_map(remote_refs, &refspec, &tail, 0);
}
} else {
/* Use the defaults */
@@ -97,7 +103,7 @@ static struct ref *get_ref_map(struct transport *transport,
int has_merge = branch_has_merge_config(branch);
if (remote && (remote->fetch_refspec_nr || has_merge)) {
for (i = 0; i < remote->fetch_refspec_nr; i++) {
- get_fetch_map(remote_refs, &remote->fetch[i], &tail);
+ get_fetch_map(remote_refs, &remote->fetch[i], &tail, 0);
if (remote->fetch[i].dst &&
remote->fetch[i].dst[0])
*autotags = 1;
@@ -110,11 +116,13 @@ static struct ref *get_ref_map(struct transport *transport,
* as given in branch.<name>.remote, we add the
* ref given in branch.<name>.merge, too.
*/
- if (has_merge && !strcmp(branch->remote_name,
- remote->name))
+ if (has_merge &&
+ !strcmp(branch->remote_name, remote->name))
add_merge_config(&ref_map, remote_refs, branch, &tail);
} else {
ref_map = get_remote_ref(remote_refs, "HEAD");
+ if (!ref_map)
+ die("Couldn't find remote ref HEAD");
ref_map->merge = 1;
}
}
diff --git a/remote.c b/remote.c
index 170015a..bec2ba1 100644
--- a/remote.c
+++ b/remote.c
@@ -857,7 +857,7 @@ struct ref *get_remote_ref(struct ref *remote_refs, const char *name)
struct ref *ref = find_ref_by_name_abbrev(remote_refs, name);
if (!ref)
- die("Couldn't find remote ref %s\n", name);
+ return NULL;
return copy_ref(ref);
}
@@ -889,20 +889,24 @@ static struct ref *get_local_ref(const char *name)
int get_fetch_map(struct ref *remote_refs,
const struct refspec *refspec,
- struct ref ***tail)
+ struct ref ***tail,
+ int missing_ok)
{
struct ref *ref_map, *rm;
if (refspec->pattern) {
ref_map = get_expanded_map(remote_refs, refspec);
} else {
- ref_map = get_remote_ref(remote_refs,
- refspec->src[0] ?
- refspec->src : "HEAD");
-
- ref_map->peer_ref = get_local_ref(refspec->dst);
- if (ref_map->peer_ref && refspec->force)
- ref_map->peer_ref->force = 1;
+ const char *name = refspec->src[0] ? refspec->src : "HEAD";
+
+ ref_map = get_remote_ref(remote_refs, name);
+ if (!missing_ok && !ref_map)
+ die("Couldn't find remote ref %s", name);
+ if (ref_map) {
+ ref_map->peer_ref = get_local_ref(refspec->dst);
+ if (ref_map->peer_ref && refspec->force)
+ ref_map->peer_ref->force = 1;
+ }
}
for (rm = ref_map; rm; rm = rm->next) {
diff --git a/remote.h b/remote.h
index c62636d..878b4ec 100644
--- a/remote.h
+++ b/remote.h
@@ -67,9 +67,12 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
* *tail is the pointer to the tail pointer of the list of results
* beforehand, and will be set to the tail pointer of the list of
* results afterward.
+ *
+ * missing_ok is usually false, but when we are adding branch.$name.merge
+ * it is Ok if the branch is not at the remote anymore.
*/
int get_fetch_map(struct ref *remote_refs, const struct refspec *refspec,
- struct ref ***tail);
+ struct ref ***tail, int missing_ok);
struct ref *get_remote_ref(struct ref *remote_refs, const char *name);
^ permalink raw reply related
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
From: Tom Prince @ 2007-10-27 5:33 UTC (permalink / raw)
To: git
In-Reply-To: <20071027052834.GA3115@hermes.priv>
On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:
> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
> > >
> > > +The special exit code 125 should be used when the current source code
> > > +cannot be tested. If the "run" script exits with this code, the
> > > current
> > > +revision will be "skip"ped, see `git bisect skip` above.
> > > [...]
> >
> Also there is:
>
> $ grep 77 /usr/include/sysexits.h
> #define EX_NOPERM 77 /* permission denied */
How about
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
^ permalink raw reply
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
From: Christian Couder @ 2007-10-27 5:02 UTC (permalink / raw)
To: Benoit SIGOURE; +Cc: git list
In-Reply-To: <A43880E9-E496-48AA-BC1C-2C98DFD12370@lrde.epita.fr>
Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
> On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
> >
> > +The special exit code 125 should be used when the current source code
> > +cannot be tested. If the "run" script exits with this code, the
> > current
> > +revision will be "skip"ped, see `git bisect skip` above.
> > [...]
>
> Since exit 77 is already used by automake to mean "skip", wouldn't it
> be better to do the same thing here?
I don't think 77 is better, first because for automake this is to ignore
some non portable test results "in environments where they don't make
sense", so if we "bisect run" the same test script and it returns 77 once,
it will probably returns 77 everytime because the environment will not have
changed after a new revision has been checked out.
Also there is:
$ grep 77 /usr/include/sysexits.h
#define EX_NOPERM 77 /* permission denied */
and a search for "include <sysexits.h>" in http://www.google.com/codesearch
returns a lot of results.
Christian.
^ permalink raw reply
* Re: [PATCH 6/9] git-hash-object: Add --stdin-paths option
From: Junio C Hamano @ 2007-10-27 1:02 UTC (permalink / raw)
To: Brian Downing; +Cc: Adam Roben, git
In-Reply-To: <20071026231902.GC2519@lavos.net>
bdowning@lavos.net (Brian Downing) writes:
> On Fri, Oct 26, 2007 at 02:00:47PM -0700, Junio C Hamano wrote:
>> In addition, if you are enhancing cat-file to spew chunked
>> output out, I suspect that there should be a mode of operation
>> for hash-object that eats that data format. IOW, this pipe
>>
>> git-cat-file --batch <list-of-sha1 |
>> git-hash-object --batch
>>
>> should be an intuitive no-op, shouldn't it?
>
> I think that's an obviously good thing to do. However, given your
> suggested output format (which I also like):
>
>> * git-cat-file --batch <list-of-sha1
>>
>> outputs a record of this form
>>
>> <sha1> SP <type> SP <size> LF <contents> LF
>>
>> for each of the input lines.
>
> What should the input behavior be? Obviously the sha1 will probably
> not be known on the input side. Should that simply be optional (i.e.
> it will accept either "<sha1> SP <type> SP <size>" or "<type> SP <size>"
> or should it only accept the latter, and a dummy sha1 will need to be
> filled in if the sha1 is not known (presumably "000...000")?
Yeah, you caught me ;-)
Either making it optional or requiring a dummy value would work.
If a non-dummy value is given, we could use it to validate it.
But that would not be a useful application anyway. So perhaps
just the sequence of "<type> SP <size> LF <contents> LF" would
be the most sensible thing to do.
^ 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