Git development
 help / color / mirror / Atom feed
* Re: [PATCH] parse-options: fix parsing of "--foobar=" with no value
From: Pierre Habouzit @ 2008-07-22 18:54 UTC (permalink / raw)
  To: Olivier Marin; +Cc: Junio C Hamano, git
In-Reply-To: <1216752267-12138-1-git-send-email-dkr+ml.git@free.fr>

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

On Tue, Jul 22, 2008 at 06:44:27PM +0000, Olivier Marin wrote:
> From: Olivier Marin <dkr@freesurf.fr>
> 
> Before this patch, running a git command with a "--foobar=" argument
> will set the "foobar" option with a random value and continue.
> We should instead, exit with an error if a value is required, or use
> the default one if the value is optional.

  Wrong, --foobar= is the option "foobar" with the argument "" (empty
string). as soon as you use the --foobar=... form, that is the "stuck
form" for long option, there *is* a value.

  IOW --foobar= is not the same as --foobar at all. If like you claim,
--foobar= pass a "random" value to the option then *this* is a bug, it
should pass a pointer to an empty string (IOW a pointer that points to a
NUL byte), but I see nothing in the code that would explain what you
claim.


-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCH] parse-options: fix parsing of "--foobar=" with no value
From: Olivier Marin @ 2008-07-22 19:25 UTC (permalink / raw)
  To: Pierre Habouzit, Olivier Marin, Junio C Hamano, git
In-Reply-To: <20080722185427.GA10453@artemis.madism.org>

Pierre Habouzit a écrit :
> On Tue, Jul 22, 2008 at 06:44:27PM +0000, Olivier Marin wrote:
> 
>   Wrong, --foobar= is the option "foobar" with the argument "" (empty
> string). as soon as you use the --foobar=... form, that is the "stuck
> form" for long option, there *is* a value.

Ah, OK.

I would have find it convenient for things like --foobar=$var where foobar
fallback to default when $var is empty. But I don't care that much.

>   IOW --foobar= is not the same as --foobar at all. If like you claim,
> --foobar= pass a "random" value to the option then *this* is a bug, it
> should pass a pointer to an empty string (IOW a pointer that points to a
> NUL byte), but I see nothing in the code that would explain what you
> claim.

I found the "random bug" while migrating "git init" to parse-options. I
think you can reproduce it with:

$ git clone --template= <repo>
error: ignoring template /var/run/synaptic.socket
fatal: cannot opendir /var/run/sudo

But now, it appears the problem is not in parse-options, sorry.

-- 
Olivier.

^ permalink raw reply

* Re: [PATCH 0/9] Make gitexecdir relative to $(bindir) on Windows
From: Johannes Sixt @ 2008-07-22 19:31 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Junio C Hamano
In-Reply-To: <alpine.DEB.1.00.0807220140170.3407@eeepc-johanness>

On Dienstag, 22. Juli 2008, Johannes Schindelin wrote:
> Hi,
>
> On Mon, 21 Jul 2008, Johannes Sixt wrote:
> > The problem was that argv[0] does not have a path in certain cases.
>
> Note that the same holds true for Linux when calling a program that is in
> the PATH:

Oh, boy!

> I imagine that the proper solution would be to rip out lookup_prog() and
> use it for non-Windows Git, too.  Unless you want to limit the usefulness
> of your patch series to Windows, that is.

This certainly goes beyond what I am prepared to do. It is not my itch. The 
series is already much longer than I wanted, when there is a much simpler 
solution that solves *my* problem: to set bindir = $(gitexecdir).

-- Hannes

^ permalink raw reply

* [PATCH] Build configuration to skip ctime for modification test
From: Alex Riesen @ 2008-07-22 19:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Sixt, git
In-Reply-To: <7vy73tltf5.fsf@gitster.siamese.dyndns.org>

On Windows, the only file attribute we need (executable) cannot be
used, so ctime can be ignored as well. Change time is updated when
file attributes were changed (or it is written to, but in this case,
mtime is updated as well).

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Junio C Hamano, Tue, Jul 22, 2008 19:28:46 +0200:
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
> >> +	if ((changed & DATA_CHANGED) && (ce->ce_size != 0 || S_ISGITLINK(ce->ce_mode)))
> >
> > Does this mean that ce->ce_size is non-zero for gitlinks, at least on
> > Unix? Is this value useful in anyway? I don't think so. Then it shouldn't
> > be a random value that lstat() happens to return.
> 
> These ce_xxx fields are the values we read from lstat(2) when the user
> told us to stage that working tree entity, be it a regular file, a
> symlink, or a directory that is a submodule.  The only thing required for
> them is that they are stable (i.e. if you haven't touched the working tree
> entity, the value stays the same), and changes across modification.  The
> value itself does not have to "mean" anything.

This reminds me... We can't use the only file attribute we care about
on Windows, so we can as well skip check for ctime. Besides, Google
Desktop Search keeps changing ctime when crawling files (ok, GDS is a
major usability nuance anyway, but the point is - we don't use the
file attribute).

 read-cache.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index a50a851..c4f2718 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -181,8 +181,10 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
 	}
 	if (ce->ce_mtime != (unsigned int) st->st_mtime)
 		changed |= MTIME_CHANGED;
+#ifndef NO_TRUSTABLE_FILEMODE
 	if (ce->ce_ctime != (unsigned int) st->st_ctime)
 		changed |= CTIME_CHANGED;
+#endif
 
 	if (ce->ce_uid != (unsigned int) st->st_uid ||
 	    ce->ce_gid != (unsigned int) st->st_gid)
-- 
1.6.0.rc0.41.g70446

^ permalink raw reply related

* Re: exit status 141 from git-svn
From: Jan Hudec @ 2008-07-22 17:52 UTC (permalink / raw)
  To: Frederik Hohlfeld; +Cc: git
In-Reply-To: <loom.20080623T145909-992@post.gmane.org>

On Mon, Jun 23, 2008 at 15:00:41 +0000, Frederik Hohlfeld wrote:
> Hi

Sorry for late reply. I just noticed your message after returning from
holiday *and* getting time to try to catch up with the list. Hope a reply
might still be useful.

> I have init'ed a git repository with git svn init.
> 
> Now I'm using git svn fetch, but it stops after just a few files/revisions. The
> exit status is 141.
> 
> What does this 141 want to tell me?

Unix trivia: When process dies from a signal, it's return status (as returned
by wait/waitpid(2) is signal_number * 256. However when bourne/POSIX shell
sees this, it will convert it to 128 + signal_number.

Now 141 - 128 = 13 and signal 13 is SIGPIPE. Process gets a SIGPIPE when it's
writing to a pipe (or socket) and it gets closed on the reading end, so it
sounds like a bad redirection somewhere. Aren't you by chance redirecting the
output to less and than quitting that without first scrolling to the bottom?

(That would be the most situation where process gets SIGPIPE -- and the very
reason why SIGPIPE exists, so that simple commands (like cat) are simply
stopped when nobody is interested in their output anymore).

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

^ permalink raw reply

* [FYI PATCH] git wrapper: DWIM mistyped commands
From: Johannes Schindelin @ 2008-07-22 20:01 UTC (permalink / raw)
  To: git


This patch introduces a modified Damerau-Levenshtein algorithm into
Git's code base, and uses it with the following penalties to show some
similar commands when an unknown command was encountered:

	swap = 0, insertion = 1, substitution = 2, deletion = 4

A typical output would now look like this:

	$ git sm
	git: 'sm' is not a git-command. See 'git --help'.

	Did you mean one of these?
		am
		rm

The cut-off is at similarity rating 6, which was empirically determined
to give sensible results.

As a convenience, if there is only one candidate, Git continues under
the assumption that the user mistyped it.  Example:

	$ git reabse
	WARNING: You called a Git program named 'reabse', which does
	not exist.
	Continuing under the assumption that you meant 'rebase'
	[...]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	So I mistyped 'reabse' for the hundred trillionth time, but I
	will never have to correct my mistakes again.

	Note: this patch is _not_ meant for inclusion.

 Makefile      |    2 +
 builtin.h     |    2 +-
 git.c         |    4 ++-
 help.c        |   61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 levenshtein.c |   47 +++++++++++++++++++++++++++++++++++++++++++
 levenshtein.h |    8 +++++++
 6 files changed, 121 insertions(+), 3 deletions(-)
 create mode 100644 levenshtein.c
 create mode 100644 levenshtein.h

diff --git a/Makefile b/Makefile
index 19bdd03..7e114e0 100644
--- a/Makefile
+++ b/Makefile
@@ -347,6 +347,7 @@ LIB_H += git-compat-util.h
 LIB_H += graph.h
 LIB_H += grep.h
 LIB_H += hash.h
+LIB_H += levenshtein.h
 LIB_H += list-objects.h
 LIB_H += ll-merge.h
 LIB_H += log-tree.h
@@ -421,6 +422,7 @@ LIB_OBJS += hash.o
 LIB_OBJS += help.o
 LIB_OBJS += ident.o
 LIB_OBJS += interpolate.o
+LIB_OBJS += levenshtein.o
 LIB_OBJS += list-objects.o
 LIB_OBJS += ll-merge.o
 LIB_OBJS += lockfile.o
diff --git a/builtin.h b/builtin.h
index 0e605d4..fc5f108 100644
--- a/builtin.h
+++ b/builtin.h
@@ -11,7 +11,7 @@ extern const char git_usage_string[];
 extern const char git_more_info_string[];
 
 extern void list_common_cmds_help(void);
-extern void help_unknown_cmd(const char *cmd);
+extern const char *help_unknown_cmd(const char *cmd);
 extern void prune_packed_objects(int);
 extern int read_line_with_nul(char *buf, int size, FILE *file);
 extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
diff --git a/git.c b/git.c
index 1bfd271..d7510ef 100644
--- a/git.c
+++ b/git.c
@@ -500,7 +500,9 @@ int main(int argc, const char **argv)
 				cmd, argv[0]);
 			exit(1);
 		}
-		help_unknown_cmd(cmd);
+		argv[0] = help_unknown_cmd(cmd);
+		handle_internal_command(argc, argv);
+		execv_dashed_external(argv);
 	}
 
 	fprintf(stderr, "Failed to run command '%s': %s\n",
diff --git a/help.c b/help.c
index bfc84ae..480befe 100644
--- a/help.c
+++ b/help.c
@@ -9,6 +9,7 @@
 #include "common-cmds.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "levenshtein.h"
 
 static struct man_viewer_list {
 	struct man_viewer_list *next;
@@ -666,9 +667,67 @@ static void show_html_page(const char *git_cmd)
 	open_html(page_path.buf);
 }
 
-void help_unknown_cmd(const char *cmd)
+static const char *levenshtein_cmd;
+static int similarity(const char *cmd) {
+	return levenshtein(levenshtein_cmd, cmd, 0, 2, 1, 4);
+}
+
+static int levenshtein_compare(const void *p1, const void *p2)
+{
+	const struct cmdname *const *c1 = p1, *const *c2 = p2;
+	const char *s1 = (*c1)->name, *s2 = (*c2)->name;
+	int l1 = similarity(s1);
+	int l2 = similarity(s2);
+	return l1 != l2 ? l1 - l2 : strcmp(s1, s2);
+}
+
+const char *help_unknown_cmd(const char *cmd)
 {
+	int i, best_similarity = 0;
+	char cwd[PATH_MAX];
+
+	if (!getcwd(cwd, sizeof(cwd))) {
+		error("Could not get current working directory");
+		cwd[0] = '\0';
+	}
+
+	load_command_list();
+	ALLOC_GROW(main_cmds.names, main_cmds.cnt + other_cmds.cnt,
+			main_cmds.alloc);
+	memcpy(main_cmds.names + main_cmds.cnt, other_cmds.names,
+		other_cmds.cnt * sizeof(other_cmds.names[0]));
+	main_cmds.cnt += other_cmds.cnt;
+
+	levenshtein_cmd = cmd;
+	qsort(main_cmds.names, main_cmds.cnt,
+	      sizeof(*main_cmds.names), levenshtein_compare);
+
+	if (!main_cmds.cnt)
+		die ("Uh oh.  Your system reports no Git commands at all.");
+	best_similarity = similarity(main_cmds.names[0]->name);
+	if (main_cmds.cnt < 2 || best_similarity <
+			similarity(main_cmds.names[1]->name)) {
+		if (!*cwd)
+			exit(1);
+		if (chdir(cwd))
+			die ("Could not change directory back to '%s'", cwd);
+		fprintf(stderr, "WARNING: You called a Git program named '%s', "
+			"which does not exist.\n"
+			"Continuing under the assumption that you meant '%s'\n",
+			cmd, main_cmds.names[0]->name);
+		return main_cmds.names[0]->name;
+	}
+
 	fprintf(stderr, "git: '%s' is not a git-command. See 'git --help'.\n", cmd);
+
+	if (best_similarity < 6) {
+		fprintf(stderr, "\nDid you mean one of these?\n");
+
+		for (i = 0; i < main_cmds.cnt && best_similarity ==
+				similarity(main_cmds.names[i]->name); i++)
+			fprintf(stderr, "\t%s\n", main_cmds.names[i]->name);
+	}
+
 	exit(1);
 }
 
diff --git a/levenshtein.c b/levenshtein.c
new file mode 100644
index 0000000..db52f2c
--- /dev/null
+++ b/levenshtein.c
@@ -0,0 +1,47 @@
+#include "cache.h"
+#include "levenshtein.h"
+
+int levenshtein(const char *string1, const char *string2,
+		int w, int s, int a, int d)
+{
+	int len1 = strlen(string1), len2 = strlen(string2);
+	int *row0 = xmalloc(sizeof(int) * (len2 + 1));
+	int *row1 = xmalloc(sizeof(int) * (len2 + 1));
+	int *row2 = xmalloc(sizeof(int) * (len2 + 1));
+	int i, j;
+
+	for (j = 0; j <= len2; j++)
+		row1[j] = j * a;
+	for (i = 0; i < len1; i++) {
+		int *dummy;
+
+		row2[0] = (i + 1) * d;
+		for (j = 0; j < len2; j++) {
+			/* substitution */
+			row2[j + 1] = row1[j] + s * (string1[i] != string2[j]);
+			/* swap */
+			if (i > 0 && j > 0 && string1[i - 1] == string2[j] &&
+					string1[i] == string2[j - 1] &&
+					row2[j + 1] > row0[j - 1] + w)
+				row2[j + 1] = row0[j - 1] + w;
+			/* deletion */
+			if (j + 1 < len2 && row2[j + 1] > row1[j + 1] + d)
+				row2[j + 1] = row1[j + 1] + d;
+			/* insertion */
+			if (row2[j + 1] > row2[j] + a)
+				row2[j + 1] = row2[j] + a;
+		}
+
+		dummy = row0;
+		row0 = row1;
+		row1 = row2;
+		row2 = dummy;
+	}
+
+	i = row1[len2];
+	free(row0);
+	free(row1);
+	free(row2);
+
+	return i;
+}
diff --git a/levenshtein.h b/levenshtein.h
new file mode 100644
index 0000000..0173abe
--- /dev/null
+++ b/levenshtein.h
@@ -0,0 +1,8 @@
+#ifndef LEVENSHTEIN_H
+#define LEVENSHTEIN_H
+
+int levenshtein(const char *string1, const char *string2,
+	int swap_penalty, int substition_penalty,
+	int insertion_penalty, int deletion_penalty);
+
+#endif
-- 
1.6.0.rc0.21.g91175

^ permalink raw reply related

* Re: [PATCH] parse-options: fix parsing of "--foobar=" with no value
From: Johannes Schindelin @ 2008-07-22 20:05 UTC (permalink / raw)
  To: Olivier Marin; +Cc: Pierre Habouzit, Junio C Hamano, git
In-Reply-To: <48863436.50309@free.fr>

Hi,

On Tue, 22 Jul 2008, Olivier Marin wrote:

> I would have find it convenient for things like --foobar=$var where foobar
> fallback to default when $var is empty.

--foobar=${var:-default} will expand to --foobar=default when $var is 
empty.

Hth,
Dscho

^ permalink raw reply

* Re: [PATCH] parse-options: fix parsing of "--foobar=" with no value
From: Jeff King @ 2008-07-22 20:09 UTC (permalink / raw)
  To: Olivier Marin; +Cc: Pierre Habouzit, Junio C Hamano, git
In-Reply-To: <48863436.50309@free.fr>

On Tue, Jul 22, 2008 at 09:25:42PM +0200, Olivier Marin wrote:

> I found the "random bug" while migrating "git init" to parse-options. I
> think you can reproduce it with:
> 
> $ git clone --template= <repo>
> error: ignoring template /var/run/synaptic.socket
> fatal: cannot opendir /var/run/sudo
> 
> But now, it appears the problem is not in parse-options, sorry.

Yes, the problem is that copy_templates in builtin-init-db.c is totally
broken for an empty template name. It writes past the beginning of the
string, and then starts copying at "/". Oops.

Maybe something like this is better? It should define --template= to
mean "don't copy any templates" (and I haven't tested it at all).

diff --git a/builtin-init-db.c b/builtin-init-db.c
index 38b4fcb..baf0d09 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -117,6 +117,8 @@ static void copy_templates(const char *template_dir)
 		template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
 	if (!template_dir)
 		template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
+	if (!template_dir[0])
+		return;
 	strcpy(template_path, template_dir);
 	template_len = strlen(template_path);
 	if (template_path[template_len-1] != '/') {

^ permalink raw reply related

* [SCNR] Re: [FYI PATCH] git wrapper: DWIM mistyped commands
From: Pierre Habouzit @ 2008-07-22 20:16 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0807222100150.8986@racer>

[-- Attachment #1: Type: text/plain, Size: 1627 bytes --]

On Tue, Jul 22, 2008 at 08:01:29PM +0000, Johannes Schindelin wrote:
> 
> This patch introduces a modified Damerau-Levenshtein algorithm into
> Git's code base, and uses it with the following penalties to show some
> similar commands when an unknown command was encountered:
> 
> 	swap = 0, insertion = 1, substitution = 2, deletion = 4
> 
> A typical output would now look like this:
> 
> 	$ git sm
> 	git: 'sm' is not a git-command. See 'git --help'.
> 
> 	Did you mean one of these?
> 		am
> 		rm
> 
> The cut-off is at similarity rating 6, which was empirically determined
> to give sensible results.
> 
> As a convenience, if there is only one candidate, Git continues under
> the assumption that the user mistyped it.  Example:
> 
> 	$ git reabse
> 	WARNING: You called a Git program named 'reabse', which does
> 	not exist.
> 	Continuing under the assumption that you meant 'rebase'
> 	[...]

<SCNR>
    Or use a decent shell:

    When typing e.g.: git tsa<tab>, it yields:
    $ git status
    ---- corrections (errors 1)
    status        -- show working-tree's status
    tag           -- create tag object signed with GPG
    tar-tree      -- create tar archive of the files in the named tree
    ---- original
    tsa

    and it even works for non git commands ;)
</SCNR>

Despite that, I really like your idea. **hint hint** One could even hook that
for long options into parse-options.

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCH] Build configuration to skip ctime for modification test
From: Johannes Schindelin @ 2008-07-22 20:17 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, Johannes Sixt, git
In-Reply-To: <20080722193901.GA5113@blimp.local>

Hi,

On Tue, 22 Jul 2008, Alex Riesen wrote:

> +#ifndef NO_TRUSTABLE_FILEMODE
>  	if (ce->ce_ctime != (unsigned int) st->st_ctime)
>  		changed |= CTIME_CHANGED;
> +#endif

Surely you meant trust_executable_bit instead, right?

Otherwise, if you really want to tell at compile time,I think for clarity 
you have to introduce another #define, since NO_TRUSTABLE_FILEMODE 
definitely says something different than CTIME_IS_USELESS.

Ciao,
Dscho

^ permalink raw reply

* Re: [SCNR] Re: [FYI PATCH] git wrapper: DWIM mistyped commands
From: Johannes Schindelin @ 2008-07-22 20:19 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: git
In-Reply-To: <20080722201648.GB11831@artemis.madism.org>

Hi,

On Tue, 22 Jul 2008, Pierre Habouzit wrote:

> <SCNR>
>     Or use a decent shell:

I tried that:

	git reab<tab><tab><TAB><TTAAABBB!>

> Despite that, I really like your idea. **hint hint**

I said that _I_ did not mean it for inclusion.  **hint hint**

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH] Build configuration to skip ctime for modification test
From: Alex Riesen @ 2008-07-22 20:31 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, Johannes Sixt, git
In-Reply-To: <alpine.DEB.1.00.0807222115440.8986@racer>

Johannes Schindelin, Tue, Jul 22, 2008 22:17:21 +0200:
> Hi,
> 
> On Tue, 22 Jul 2008, Alex Riesen wrote:
> 
> > +#ifndef NO_TRUSTABLE_FILEMODE
> >  	if (ce->ce_ctime != (unsigned int) st->st_ctime)
> >  		changed |= CTIME_CHANGED;
> > +#endif
> 
> Surely you meant trust_executable_bit instead, right?

No. Just what I said: we don't have filemode (like "at all") - so no
ctime as well. But maybe you're right, and trust_executable_bit is
more flexible. Or maybe both (the #ifdef _and_ trust_executable_bit)
and must be used...

> Otherwise, if you really want to tell at compile time,I think for clarity 
> you have to introduce another #define, since NO_TRUSTABLE_FILEMODE 
> definitely says something different than CTIME_IS_USELESS.

I had that at first (NO_DEPENDABLE_CTIME, than IGNORE_CTIME), than
deemed it excessive.

^ permalink raw reply

* Re: [SCNR] Re: [FYI PATCH] git wrapper: DWIM mistyped commands
From: Pierre Habouzit @ 2008-07-22 20:34 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0807222118030.8986@racer>

[-- Attachment #1: Type: text/plain, Size: 934 bytes --]

On Tue, Jul 22, 2008 at 08:19:13PM +0000, Johannes Schindelin wrote:
> Hi,
> 
> On Tue, 22 Jul 2008, Pierre Habouzit wrote:
> 
> > <SCNR>
> >     Or use a decent shell:
> 
> I tried that:
> 
> 	git reab<tab><tab><TAB><TTAAABBB!>

It yields the following here:

    $ git read-tree
    ---- corrections (errors 1)
    read-tree  -- read tree information into the directory index
    rebase     -- rebase local commits to new upstream head
    ---- original
    reab

and indeed, it should really suggest rebase first, I suppose I should reorder
my zsh completion error weights. but oh well...

> > Despite that, I really like your idea. **hint hint**
> 
> I said that _I_ did not mean it for inclusion.  **hint hint**

Damn...

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [FYI PATCH] git wrapper: DWIM mistyped commands
From: Alex Riesen @ 2008-07-22 20:37 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0807222100150.8986@racer>

Johannes Schindelin, Tue, Jul 22, 2008 22:01:29 +0200:
> As a convenience, if there is only one candidate, Git continues under
> the assumption that the user mistyped it.  Example:
> 
> 	$ git reabse
> 	WARNING: You called a Git program named 'reabse', which does
> 	not exist.
> 	Continuing under the assumption that you meant 'rebase'
> 	[...]

Oh, that would make me suspicios (and I hit Ctrl-C fast when I get
suspicios about what happens to my precious data). Could it be
configurable? For example, BASH's cdspell is configurable and even off
by default.

P.S. I'm still using your first patch and am forced to like it every day :)

^ permalink raw reply

* Difficulty with getting an accurate changelog after cherry-picking and merging.
From: Luuk Paulussen @ 2008-07-22 20:38 UTC (permalink / raw)
  To: git

Hi,

I'm trying to generate an accurate changelog of changes between 2 tags
on a branch.  There is a merge between these 2 points which includes
changes that were cherry-picked before the start point.  This causes
the changelog to show these changes, despite them already existing
before the start point of the log.

I've included a test script below that creates a repository that shows
a simplified version of the issue.  Basically, I want the changelog to
only show the changes between the start and end tags, which are test4
and test5, but I get a list that also includes other commits.  I have
tried git-cherry and git-log with --cherry-pick and various things
with git-rev-list and git-merge-base.

#!/bin/sh
mkdir testrepo
cd testrepo
git init
echo initial > testfile
git add testfile
git commit -m initial
git branch stable
for f in $(seq 1 5)
do
    echo test$f >> testfile
    git commit -a -m test$f
done
#without this sleep the cherry-picks end up with the same hash as
their original commit...
sleep 1
git checkout stable
git cherry-pick :/test1
git cherry-pick :/test2
git cherry-pick :/test3
git tag start
git cherry-pick :/test4
git merge master
#Clean up the merge error.
if [ ! $? -eq 0 ]
then
    sed -i "/[:=]/ d" testfile
    git commit -a -m "Merge branch 'master' into stable"
fi
git tag end
##########################

Thanks,
Luuk

^ permalink raw reply

* [PATCH] builtin-commit: Two trivial style-cleanups
From: Johannes Schindelin @ 2008-07-22 20:40 UTC (permalink / raw)
  To: git, gitster


Pierre Habouzit noticed that two variables were not static which should
have been, and that adding "\n\n" is better than adding '\n' twice.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	This was in my queue for half an eternity.

	Oh, and it _is_ meant for inclusion.  On top of master.

 builtin-commit.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 97e64de..7434797 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -68,8 +68,8 @@ static enum {
 static char *cleanup_arg;
 
 static int use_editor = 1, initial_commit, in_merge;
-const char *only_include_assumed;
-struct strbuf message;
+static const char *only_include_assumed;
+static struct strbuf message;
 
 static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 {
@@ -78,8 +78,7 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
 		strbuf_setlen(buf, 0);
 	else {
 		strbuf_addstr(buf, arg);
-		strbuf_addch(buf, '\n');
-		strbuf_addch(buf, '\n');
+		strbuf_addstr(buf, "\n\n");
 	}
 	return 0;
 }
-- 
1.6.0.rc0.22.gf2096d.dirty

^ permalink raw reply related

* [PATCH] Add help.autocorrect to enable/disable autocorrecting
From: Alex Riesen @ 2008-07-22 21:03 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <20080722203730.GC5113@blimp.local>

It is off by default, to avoid scaring people unless they asked to.

---

Alex Riesen, Tue, Jul 22, 2008 22:37:30 +0200:
> Johannes Schindelin, Tue, Jul 22, 2008 22:01:29 +0200:
> > As a convenience, if there is only one candidate, Git continues under
> > the assumption that the user mistyped it.  Example:
> > 
> > 	$ git reabse
> > 	WARNING: You called a Git program named 'reabse', which does
> > 	not exist.
> > 	Continuing under the assumption that you meant 'rebase'
> > 	[...]
> 
> Oh, that would make me suspicios (and I hit Ctrl-C fast when I get
> suspicios about what happens to my precious data). Could it be
> configurable? For example, BASH's cdspell is configurable and even off
> by default.
> 

Like this, perhaps?

 help.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/help.c b/help.c
index 480befe..f08eb9d 100644
--- a/help.c
+++ b/help.c
@@ -28,6 +28,7 @@ enum help_format {
 	HELP_FORMAT_WEB,
 };
 
+static int autocorrect;
 static int show_all = 0;
 static enum help_format help_format = HELP_FORMAT_MAN;
 static struct option builtin_help_options[] = {
@@ -269,6 +270,8 @@ static int git_help_config(const char *var, const char *value, void *cb)
 	}
 	if (!prefixcmp(var, "man."))
 		return add_man_viewer_info(var, value);
+	if (!strcmp(var, "help.autocorrect"))
+		autocorrect = git_config_bool(var,value);
 
 	return git_default_config(var, value, cb);
 }
@@ -704,9 +707,10 @@ const char *help_unknown_cmd(const char *cmd)
 
 	if (!main_cmds.cnt)
 		die ("Uh oh.  Your system reports no Git commands at all.");
+	git_config(git_help_config, NULL);
 	best_similarity = similarity(main_cmds.names[0]->name);
-	if (main_cmds.cnt < 2 || best_similarity <
-			similarity(main_cmds.names[1]->name)) {
+	if (autocorrect && (main_cmds.cnt < 2 ||
+		best_similarity < similarity(main_cmds.names[1]->name))) {
 		if (!*cwd)
 			exit(1);
 		if (chdir(cwd))
-- 
1.6.0.rc0.48.g6dda.dirty

^ permalink raw reply related

* Re: [PATCH] Add help.autocorrect to enable/disable autocorrecting
From: Johannes Schindelin @ 2008-07-22 21:08 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git
In-Reply-To: <20080722210354.GD5113@blimp.local>

Hi,

On Tue, 22 Jul 2008, Alex Riesen wrote:

> +	if (autocorrect && (main_cmds.cnt < 2 ||
> +		best_similarity < similarity(main_cmds.names[1]->name))) {
>  		if (!*cwd)
>  			exit(1);
>  		if (chdir(cwd))

In that case, you need to put in the "one of these" / "this" conditional 
again, which I ripped out because I do not need it any more.

Ciao,
Dscho

^ permalink raw reply

* Re: Difficulty with getting an accurate changelog after cherry-picking and merging.
From: Alex Riesen @ 2008-07-22 21:09 UTC (permalink / raw)
  To: luuk; +Cc: git
In-Reply-To: <7dc909980807221338g707d6104ob8b1534cdf02a77a@mail.gmail.com>

Luuk Paulussen, Tue, Jul 22, 2008 22:38:19 +0200:
> I'm trying to generate an accurate changelog of changes between 2 tags
> on a branch.  There is a merge between these 2 points which includes
> changes that were cherry-picked before the start point.  This causes
> the changelog to show these changes, despite them already existing
> before the start point of the log.

Cherry-picked commits are completely new commits and have no relation
to the original commits whatsoever. Of course, they will be shown.
It is literally a change made again, as if you typed it all in and
committed.

^ permalink raw reply

* Re: Difficulty with getting an accurate changelog after cherry-picking and merging.
From: Johannes Schindelin @ 2008-07-22 21:14 UTC (permalink / raw)
  To: Luuk Paulussen; +Cc: git
In-Reply-To: <7dc909980807221338g707d6104ob8b1534cdf02a77a@mail.gmail.com>

Hi,

On Wed, 23 Jul 2008, Luuk Paulussen wrote:

> I'm trying to generate an accurate changelog of changes between 2 tags 
> on a branch.  There is a merge between these 2 points which includes 
> changes that were cherry-picked before the start point.  This causes the 
> changelog to show these changes, despite them already existing before 
> the start point of the log.
>
> [...]
> 
> I have tried git-cherry and git-log with --cherry-pick and various 
> things with git-rev-list and git-merge-base.

cherry and --cherry-pick will only skip patches that are on the 
uninteresting side of a "..." range.

I guess that

	$ git log --cherry-pick master...HEAD^

should filter the commits out, but I haven't tried.

> git cherry-pick :/test1

Heh, that is the first time I see :/ in the wild.  I do not use it 
anymore, and in your case, I would have written "git cherry-pick master^4" 
to be more precise (and not accidentally pick up a wrong one).

Ciao,
Dscho

^ permalink raw reply

* Patches for test suite on sunos
From: Brandon Casey @ 2008-07-22 21:15 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano


The following set of patches is a subset of patches I created
while trying to compile on solaris and get the test suite running.
Except for the patches to the perl modules section, the rest all
deal with the test suite. I think these are general improvements
(or benign changes) and so I am submitting them.

With these patches and the others which I will maintain privately,
I can compile git on solaris using the native c compiler and pass
nearly all of the test suite with the native shell in /usr/xpg4/bin/sh
(i.e. ksh). The remaining bits of the test suite that do not pass are
related to a broken iconv or an ancient build environment.

Here are the tests I am skipping:

GIT_SKIP_TESTS='
   t3900.1[0-289] t3900.2[023]
   t3901.*
   t5000.1[0-24-689] t5000.2[01]
   t5100.[56] t5100.10
   t6030.1[2-9] t6030.2[0-9]
   t9301.4
'

-brandon

^ permalink raw reply

* [PATCH] perl/Makefile: update NO_PERL_MAKEMAKER section
From: Brandon Casey @ 2008-07-22 21:15 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano
In-Reply-To: <0GfECozN3g0ZvAESKMi76RyOVHEb2OhhwET9GWmEm7pbzYQJub50UlWpZtBa7MGn1UGb-7mzbzE@cipher.nrlssc.navy.mil>

The perl modules must be copied to blib/lib so they are available for
testing.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 perl/Makefile |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/perl/Makefile b/perl/Makefile
index 5e079ad..2b0d3d5 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -22,8 +22,11 @@ clean:
 ifdef NO_PERL_MAKEMAKER
 instdir_SQ = $(subst ','\'',$(prefix)/lib)
 $(makfile): ../GIT-CFLAGS Makefile
-	echo all: > $@
-	echo '	:' >> $@
+	echo all: private-Error.pm Git.pm > $@
+	echo '	mkdir -p blib/lib' >> $@
+	echo '	$(RM) blib/lib/Git.pm; cp Git.pm blib/lib/' >> $@
+	echo '	$(RM) blib/lib/Error.pm; \
+	cp private-Error.pm blib/lib/Error.pm' >> $@
 	echo install: >> $@
 	echo '	mkdir -p $(instdir_SQ)' >> $@
 	echo '	$(RM) $(instdir_SQ)/Git.pm; cp Git.pm $(instdir_SQ)' >> $@
-- 
1.6.0.rc0.38.g8b8fb7

^ permalink raw reply related

* [PATCH] t9700/test.pl: backwards compatibility improvements
From: Brandon Casey @ 2008-07-22 21:16 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano
In-Reply-To: <0GfECozN3g0ZvAESKMi76RyOVHEb2OhhwET9GWmEm7pbzYQJub50UlWpZtBa7MGn1UGb-7mzbzE@cipher.nrlssc.navy.mil>

Some versions of perl complain when 'STDERR' is used as the third argument
in the 3-argument form of open(). Convert to the 2-argument form which is
described for duping STDERR in my second edition camel book.

The object oriented version of File::Temp is a rather new incarnation it
seems. The File::Temp man page for v5.8.0 says "(NOT YET IMPLEMENTED)" in
the 'Objects' section. These can be converted to use File::Temp::tempfile().

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t9700/test.pl |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 4d23125..70f9836 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -38,7 +38,7 @@ is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
 # Failure cases for config:
 # Save and restore STDERR; we will probably extract this into a
 # "dies_ok" method and possibly move the STDERR handling to Git.pm.
-open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR;
+open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
 eval { $r->config("test.dupstring") };
 ok($@, "config: duplicate entry in scalar context fails");
 eval { $r->config_bool("test.boolother") };
@@ -69,18 +69,18 @@ is($r->ident_person("Name", "email", "123 +0000"), "Name <email>",
 
 # objects and hashes
 ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)");
-our $tmpfile = File::Temp->new;
+our ($tmpfile, $tmpnam) = File::Temp::tempfile();
 is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size");
 our $blobcontents;
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, "changed file 1\n", "cat_blob: data");
 seek $tmpfile, 0, 0;
-is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip");
-$tmpfile = File::Temp->new();
+is(Git::hash_object("blob", $tmpnam), $file1hash, "hash_object: roundtrip");
+($tmpfile, $tmpnam) = File::Temp::tempfile();
 print $tmpfile my $test_text = "test blob, to be inserted\n";
-like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,
+like(our $newhash = $r->hash_and_insert_object($tmpnam), qr/[0-9a-fA-F]{40}/,
      "hash_and_insert_object: returns hash");
-$tmpfile = File::Temp->new;
+$tmpfile = File::Temp::tempfile();
 is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size");
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, $test_text, "cat_blob: roundtrip data");
-- 
1.6.0.rc0.38.g8b8fb7

^ permalink raw reply related

* [PATCH] t4116-apply-reverse.sh: use $TAR rather than tar
From: Brandon Casey @ 2008-07-22 21:16 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano
In-Reply-To: <0GfECozN3g0ZvAESKMi76RyOVHEb2OhhwET9GWmEm7pbzYQJub50UlWpZtBa7MGn1UGb-7mzbzE@cipher.nrlssc.navy.mil>

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t4116-apply-reverse.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 1459a90..2298ece 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -48,12 +48,12 @@ test_expect_success 'apply in reverse' '
 
 test_expect_success 'setup separate repository lacking postimage' '
 
-	git tar-tree initial initial | tar xf - &&
+	git tar-tree initial initial | $TAR xf - &&
 	(
 		cd initial && git init && git add .
 	) &&
 
-	git tar-tree second second | tar xf - &&
+	git tar-tree second second | $TAR xf - &&
 	(
 		cd second && git init && git add .
 	)
-- 
1.6.0.rc0.38.g8b8fb7

^ permalink raw reply related

* [PATCH] t3200,t7201: replace '!' with test_must_fail
From: Brandon Casey @ 2008-07-22 21:16 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano
In-Reply-To: <0GfECozN3g0ZvAESKMi76RyOVHEb2OhhwET9GWmEm7pbzYQJub50UlWpZtBa7MGn1UGb-7mzbzE@cipher.nrlssc.navy.mil>

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t3200-branch.sh |    2 +-
 t/t7201-co.sh     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 7c583c8..7a83fbf 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -200,7 +200,7 @@ test_expect_success \
 
 test_expect_success \
     'branch from non-branch HEAD w/--track causes failure' \
-    '!(git branch --track my10 HEAD^)'
+    'test_must_fail git branch --track my10 HEAD^'
 
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 3111baa..9ad5d63 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -335,6 +335,6 @@ test_expect_success \
     git checkout -b delete-me master &&
     rm .git/refs/heads/delete-me &&
     test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
-    !(git checkout --track -b track)'
+    test_must_fail git checkout --track -b track'
 
 test_done
-- 
1.6.0.rc0.38.g8b8fb7

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox