Git development
 help / color / mirror / Atom feed
* Re: getting started, happy with cmd line on windows [Scanned]
From: Zorba @ 2008-12-27  2:18 UTC (permalink / raw)
  To: git
In-Reply-To: <7v4p0qlcnc.fsf@gitster.siamese.dyndns.org>

> Drop "rm *.*".  Instead, probably what you want is
>
>> $ <import code>
>> $ git init
>> $ git commit
>
> which is a good way to make an initial import.
>
>> $ git tag versionA <commitID>
>> $ hack hack hack
>> ...
>
> and you futzed with the codebase without any intention of committing;
> it is nice to be able to experiment freely.
>
> After you are done experimenting,
>
> $ git reset --hard versionA
>
> if you did not make any commit, or even if you did commit while you were
> experimenting, if you do not want these experimental commits at all.
>
> No need for "rm *.*" anywhere.

Hi Junio,

Yes, I had not considered the possibility of being able to reset to last 
commit (as manual page talked about UNDOing commits). $git reset -hard HEAD 
= This is great, and gives me the functionality I want, get back to the last 
conscious commit after hacking.

I've noticed since discovering this that the Reset function on the Win GUI 
will ONLY let you reset as far as but not beyond the last commit (i.e. 
unable to undo any commits) so I can use that too.

The other functionality I was looking for is being able to handle a changing 
"portfolio" of files from version to version:

e.g.
version A = ABC.txt, AB.txt, AC.txt
version B = ABC.txt, AB.txt
version C = ABC.txt, AC.txt
version D = no files

I'm sure this is a common scenario, for ppl starting out with git as they 
load up versions that till now have been sitting in file systems.

By using git-add and git-rm (or git-commit -a) I was able to have my 
add/remove files to the index in "staging" and in the end the versions in 
the repo match up to real life example. Then I can --hard reset back to any 
of these, and ONLY got the files that were in that version.

Its a shame though that git-commit -a only removes files from the index, and 
doesn't add files to the index, otherwise creating new versions is just a 
case of importing the files needed for eacch version and cranking..

$ git commit -a

repeatedly.

But thanks to all who helped me on this one, and who knows maybe this post 
will help some other pilgrim following after me
:-)
Season's geetings,
CR 

^ permalink raw reply

* [PATCH] Documentation/gitrepository-layout.txt: enhance discussion of objects/[0-9a-f][0-9a-f]
From: jidanni @ 2008-12-27  2:48 UTC (permalink / raw)
  To: git


Signed-off-by: jidanni <jidanni@jidanni.org>

diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index 03c52ff..bf900df 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -46,6 +46,4 @@ objects/[0-9a-f][0-9a-f]::
-	Traditionally, each object is stored in its own file.
-	They are split into 256 subdirectories using the first
-	two letters from its object name to keep the number of
-	directory entries `objects` directory itself needs to
-	hold.  Objects found here are often called 'unpacked'
-	(or 'loose') objects.
+	Each object is stored in its own file. They are split into 256
+	subdirectories to keep directory sizes down. Example: object
+	92b35d66... is stored in .git/object/92/b35d66... Objects
+	found here are often called 'unpacked' (or 'loose') objects.
-- 
1.5.6.5

^ permalink raw reply related

* [JGIT PATCH] Expose the advertised refs to ReceivePack hooks
From: Shawn O. Pearce @ 2008-12-27  3:47 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

Hooks may want to be able to consider what the client was shown, so
they can make decisions based on that information.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../org/spearce/jgit/transport/ReceivePack.java    |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
index 95519b8..76d11c4 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/ReceivePack.java
@@ -155,6 +155,11 @@ public final RevWalk getRevWalk() {
 		return walk;
 	}
 
+	/** @return all refs which were advertised to the client. */
+	public final Map<String, Ref> getAdvertisedRefs() {
+		return refs;
+	}
+
 	/**
 	 * @return true if this instance will verify received objects are formatted
 	 *         correctly. Validating objects requires more CPU time on this side
-- 
1.6.1.302.gccd4d

^ permalink raw reply related

* [PATCH] parse-opt: migrate builtin-apply.
From: Miklos Vajna @ 2008-12-27  4:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

The only notable user-visible/incompatible change is that the
--build-fake-ancestor option now conforms to gitcli(7).

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

I know that we do care about incompatible changes a lot, though I think
this is the right direction and probably --build-fake-ancestor is not a
heavily used switch, so I hope that part is OK.

 Documentation/git-apply.txt |    4 +-
 builtin-apply.c             |  360 ++++++++++++++++++++++++++++---------------
 2 files changed, 234 insertions(+), 130 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index e726510..9400f6a 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git apply' [--stat] [--numstat] [--summary] [--check] [--index]
-	  [--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
+	  [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse]
 	  [--allow-binary-replacement | --binary] [--reject] [-z]
 	  [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
 	  [--whitespace=<nowarn|warn|fix|error|error-all>]
@@ -64,7 +64,7 @@ OPTIONS
 	cached data, apply the patch, and store the result in the index,
 	without using the working tree. This implies '--index'.
 
---build-fake-ancestor <file>::
+--build-fake-ancestor=<file>::
 	Newer 'git-diff' output has embedded 'index information'
 	for each blob to help identify the original version that
 	the patch applies to.  When this flag is given, and if
diff --git a/builtin-apply.c b/builtin-apply.c
index 07244b0..c2a587f 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -14,6 +14,7 @@
 #include "builtin.h"
 #include "string-list.h"
 #include "dir.h"
+#include "parse-options.h"
 
 /*
  *  --check turns on checking that the working tree matches the
@@ -46,8 +47,10 @@ static int no_add;
 static const char *fake_ancestor;
 static int line_termination = '\n';
 static unsigned long p_context = ULONG_MAX;
-static const char apply_usage[] =
-"git apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...";
+static const char * const apply_usage[] = {
+	"git apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...",
+	NULL
+};
 
 static enum ws_error_action {
 	nowarn_ws_error,
@@ -61,6 +64,8 @@ static int applied_after_fixing_ws;
 static const char *patch_input_file;
 static const char *root;
 static int root_len;
+static int read_stdin = 1;
+static int options;
 
 static void parse_whitespace_option(const char *option)
 {
@@ -3135,150 +3140,249 @@ static int git_apply_config(const char *var, const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }
 
+static int option_parse_stdin(const struct option *opt,
+			      const char *arg, int unset)
+{
+	int *errs = opt->value;
+
+	*errs |= apply_patch(0, "<stdin>", options);
+	read_stdin = 0;
+	return 0;
+}
+
+static int option_parse_exclude(const struct option *opt,
+				const char *arg, int unset)
+{
+	add_name_limit(arg, 1);
+	return 0;
+}
+
+static int option_parse_include(const struct option *opt,
+				const char *arg, int unset)
+{
+	add_name_limit(arg, 0);
+	has_include = 1;
+	return 0;
+}
+
+static int option_parse_p(const struct option *opt,
+			  const char *arg, int unset)
+{
+	p_value = atoi(arg);
+	p_value_known = 1;
+	return 0;
+}
+
+static int option_parse_stat(const struct option *opt,
+			     const char *arg, int unset)
+{
+	apply = 0;
+	diffstat = 1;
+	return 0;
+}
+
+static int option_parse_numstat(const struct option *opt,
+				const char *arg, int unset)
+{
+	apply = 0;
+	numstat = 1;
+	return 0;
+}
+
+static int option_parse_summary(const struct option *opt,
+				const char *arg, int unset)
+{
+	apply = 0;
+	summary = 1;
+	return 0;
+}
+
+static int option_parse_check(const struct option *opt,
+			      const char *arg, int unset)
+{
+	apply = 0;
+	check = 1;
+	return 0;
+}
+
+static int option_parse_index(const struct option *opt,
+			      const char *arg, int unset)
+{
+	int *is_not_gitdir = opt->value;
+
+	if (*is_not_gitdir)
+		die("--index outside a repository");
+	check_index = 1;
+	return 0;
+}
+
+static int option_parse_cached(const struct option *opt,
+			       const char *arg, int unset)
+{
+	int *is_not_gitdir = opt->value;
+
+	if (*is_not_gitdir)
+		die("--cached outside a repository");
+	check_index = 1;
+	cached = 1;
+	return 0;
+}
+
+static int option_parse_ancestor(const struct option *opt,
+				 const char *arg, int unset)
+{
+	apply = 0;
+	fake_ancestor = arg;
+	return 0;
+}
+
+static int option_parse_z(const struct option *opt,
+			  const char *arg, int unset)
+{
+	if (unset)
+		line_termination = '\n';
+	else
+		line_termination = 0;
+	return 0;
+}
+
+static int option_parse_whitespace(const struct option *opt,
+				   const char *arg, int unset)
+{
+	const char **whitespace_option = opt->value;
+
+	*whitespace_option = arg;
+	parse_whitespace_option(arg);
+	return 0;
+}
+
+static int option_parse_reject(const struct option *opt,
+			       const char *arg, int unset)
+{
+	apply = apply_with_reject = apply_verbosely = 1;
+	return 0;
+}
+
+static int option_parse_inaccurate(const struct option *opt,
+				   const char *arg, int unset)
+{
+	options |= INACCURATE_EOF;
+	return 0;
+}
+
+static int option_parse_recount(const struct option *opt,
+				const char *arg, int unset)
+{
+	options |= RECOUNT;
+	return 0;
+}
+
+static int option_parse_directory(const struct option *opt,
+				  const char *arg, int unset)
+{
+	root_len = strlen(arg);
+	if (root_len && arg[root_len - 1] != '/') {
+		char *new_root;
+		root = new_root = xmalloc(root_len + 2);
+		strcpy(new_root, arg);
+		strcpy(new_root + root_len++, "/");
+	} else
+		root = arg;
+	return 0;
+}
 
 int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 {
 	int i;
-	int read_stdin = 1;
-	int options = 0;
 	int errs = 0;
 	int is_not_gitdir;
+	int binary;
 
 	const char *whitespace_option = NULL;
 
+	struct option builtin_apply_options[] = {
+		{ OPTION_CALLBACK, '-', NULL, &errs, NULL,
+			"read the patch from the standard input",
+			PARSE_OPT_NOARG, option_parse_stdin },
+		{ OPTION_CALLBACK, 0, "exclude", NULL, "path",
+			"don´t apply changes matching the given path",
+			0, option_parse_exclude },
+		{ OPTION_CALLBACK, 0, "include", NULL, "path",
+			"apply changes matching the given path",
+			0, option_parse_include },
+		{ OPTION_CALLBACK, 'p', NULL, NULL, "num",
+			"remove <num> leading slashes from traditional diff paths",
+			0, option_parse_p },
+		OPT_BOOLEAN(0, "no-add", &no_add,
+			"ignore additions made by the patch"),
+		{ OPTION_CALLBACK, 0, "stat", NULL, NULL,
+			"instead of applying the patch, output diffstat for the input",
+			PARSE_OPT_NOARG, option_parse_stat },
+		OPT_BOOLEAN(0, "allow-binary-replacement", &binary,
+			"now no-op"),
+		OPT_BOOLEAN(0, "binary", &binary,
+			"now no-op"),
+		{ OPTION_CALLBACK, 0, "numstat", NULL, NULL,
+			"shows number of added and deleted lines in decimal notation",
+			PARSE_OPT_NOARG, option_parse_numstat },
+		{ OPTION_CALLBACK, 0, "summary", NULL, NULL,
+			"instead of applying the patch, output a summary for the input",
+			PARSE_OPT_NOARG, option_parse_summary },
+		{ OPTION_CALLBACK, 0, "check", NULL, NULL,
+			"instead of applying the patch, see if the patch is applicable",
+			PARSE_OPT_NOARG, option_parse_check },
+		{ OPTION_CALLBACK, 0, "index", &is_not_gitdir, NULL,
+			"make sure the patch is applicable to the current index",
+			PARSE_OPT_NOARG, option_parse_index },
+		{ OPTION_CALLBACK, 0, "cached", &is_not_gitdir, NULL,
+			"apply a patch without touching the working tree",
+			PARSE_OPT_NOARG, option_parse_cached },
+		OPT_BOOLEAN(0, "apply", &apply,
+			"also apply the patch (use with --stat/--summary/--check)"),
+		{ OPTION_CALLBACK, 0, "build-fake-ancestor", NULL, "file",
+			"build a temporary index based on embedded index information",
+			0, option_parse_ancestor },
+		{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
+			"paths are separated with NUL character",
+			PARSE_OPT_NOARG, option_parse_z },
+		OPT_INTEGER('C', NULL, &p_context,
+				"ensure at least <n> lines of context match"),
+		{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, "action",
+			"detect new or modified lines that have whitespace errors",
+			0, option_parse_whitespace },
+		OPT_BOOLEAN('R', "reverse", &apply_in_reverse,
+			"apply the patch in reverse"),
+		OPT_BOOLEAN(0, "unidiff-zero", &unidiff_zero,
+			"don't expect at least one line of context"),
+		{ OPTION_CALLBACK, 0, "reject", NULL, NULL,
+			"leave the rejected hunks in corresponding *.rej files",
+			PARSE_OPT_NOARG, option_parse_reject },
+		OPT__VERBOSE(&apply_verbosely),
+		{ OPTION_CALLBACK, 0, "inaccurate-eof", NULL, NULL,
+			"tolerate incorrectly detected missing new-line at the end of file",
+			PARSE_OPT_NOARG, option_parse_inaccurate },
+		{ OPTION_CALLBACK, 0, "recount", NULL, NULL,
+			"do not trust the line counts in the hunk headers",
+			PARSE_OPT_NOARG, option_parse_recount },
+		{ OPTION_CALLBACK, 0, "directory", NULL, "root",
+			"prepend <root> to all filenames",
+			0, option_parse_directory },
+		OPT_END()
+	};
+
 	prefix = setup_git_directory_gently(&is_not_gitdir);
 	prefix_length = prefix ? strlen(prefix) : 0;
 	git_config(git_apply_config, NULL);
 	if (apply_default_whitespace)
 		parse_whitespace_option(apply_default_whitespace);
 
-	for (i = 1; i < argc; i++) {
+	argc = parse_options(argc, argv, builtin_apply_options,
+			apply_usage, 0);
+
+	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
-		char *end;
 		int fd;
 
-		if (!strcmp(arg, "-")) {
-			errs |= apply_patch(0, "<stdin>", options);
-			read_stdin = 0;
-			continue;
-		}
-		if (!prefixcmp(arg, "--exclude=")) {
-			add_name_limit(arg + 10, 1);
-			continue;
-		}
-		if (!prefixcmp(arg, "--include=")) {
-			add_name_limit(arg + 10, 0);
-			has_include = 1;
-			continue;
-		}
-		if (!prefixcmp(arg, "-p")) {
-			p_value = atoi(arg + 2);
-			p_value_known = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--no-add")) {
-			no_add = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--stat")) {
-			apply = 0;
-			diffstat = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--allow-binary-replacement") ||
-		    !strcmp(arg, "--binary")) {
-			continue; /* now no-op */
-		}
-		if (!strcmp(arg, "--numstat")) {
-			apply = 0;
-			numstat = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--summary")) {
-			apply = 0;
-			summary = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--check")) {
-			apply = 0;
-			check = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--index")) {
-			if (is_not_gitdir)
-				die("--index outside a repository");
-			check_index = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--cached")) {
-			if (is_not_gitdir)
-				die("--cached outside a repository");
-			check_index = 1;
-			cached = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--apply")) {
-			apply = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--build-fake-ancestor")) {
-			apply = 0;
-			if (++i >= argc)
-				die ("need a filename");
-			fake_ancestor = argv[i];
-			continue;
-		}
-		if (!strcmp(arg, "-z")) {
-			line_termination = 0;
-			continue;
-		}
-		if (!prefixcmp(arg, "-C")) {
-			p_context = strtoul(arg + 2, &end, 0);
-			if (*end != '\0')
-				die("unrecognized context count '%s'", arg + 2);
-			continue;
-		}
-		if (!prefixcmp(arg, "--whitespace=")) {
-			whitespace_option = arg + 13;
-			parse_whitespace_option(arg + 13);
-			continue;
-		}
-		if (!strcmp(arg, "-R") || !strcmp(arg, "--reverse")) {
-			apply_in_reverse = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--unidiff-zero")) {
-			unidiff_zero = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--reject")) {
-			apply = apply_with_reject = apply_verbosely = 1;
-			continue;
-		}
-		if (!strcmp(arg, "-v") || !strcmp(arg, "--verbose")) {
-			apply_verbosely = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--inaccurate-eof")) {
-			options |= INACCURATE_EOF;
-			continue;
-		}
-		if (!strcmp(arg, "--recount")) {
-			options |= RECOUNT;
-			continue;
-		}
-		if (!prefixcmp(arg, "--directory=")) {
-			arg += strlen("--directory=");
-			root_len = strlen(arg);
-			if (root_len && arg[root_len - 1] != '/') {
-				char *new_root;
-				root = new_root = xmalloc(root_len + 2);
-				strcpy(new_root, arg);
-				strcpy(new_root + root_len++, "/");
-			} else
-				root = arg;
-			continue;
-		}
 		if (0 < prefix_length)
 			arg = prefix_filename(prefix, prefix_length, arg);
 
-- 
1.6.1.rc1.35.gae26e.dirty

^ permalink raw reply related

* Re: [PATCH] parse-opt: migrate builtin-apply.
From: Junio C Hamano @ 2008-12-27  7:29 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: git
In-Reply-To: <1230351727-20116-1-git-send-email-vmiklos@frugalware.org>

Miklos Vajna <vmiklos@frugalware.org> writes:

> The only notable user-visible/incompatible change is that the
> --build-fake-ancestor option now conforms to gitcli(7).
>
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>
> I know that we do care about incompatible changes a lot, though I think
> this is the right direction and probably --build-fake-ancestor is not a
> heavily used switch, so I hope that part is OK.

An acceptable justification for such a plumbing change is if (1) the old
syntax is still supported the same way as the original implementation,
*and* if (2) the new syntax is something that could not possibly have been
a valid input to the original implementation with a different meaning.

I think the condition (1) holds but (2) does not hold for your patch; even
though I think the latter breakage is excusable in this particular case,
it is not for the reason you cited.

That is,

 (1) The parseopt parser allows both of these forms:

	$ git apply --build-fake-ancestor file <input
        $ git apply --build-fake-ancestor=file <input

     The former has been how existing scripts that use the plumbing have
     been feeding the file, and it is still supported.

 (2) A script that used "git apply" and relied on the behaviour of 
     the original implementation could have fed a patch from a file
     whose name is "--build-fake-ancestor=some-string", with this command
     line:

        $ git apply --build-fake-ancestor=file

     Now such a script would break with the new parser.

The reason you are excused to break such an insane script is definitely
not because --build-fake-ancestor is a rarely used option.  The whole
defence depends on the fact that --build-fake-ancestor=something is a very
unlikely name for any sane script to be using for its temporary file.  It
could still be an end user input, but at that point you could simply doubt
the sanity of the end user and dismiss the issue away.

I am not fundamentally opposed to using parseopt in git-apply, and I think
the change to add a new and saner meaning to "--build-fake-ancestor=file"
on the command line is a good thing in the longer term.  But your
justification for such a change should be given in such a way to show
clearly that you have thought things through.  It has to be much better
than "it is not a heavily used switch anyway".

The saddest part of the story that pisses me off about this patch is that
you did not seem to have even run the test suite before sending it.  t4105
and t4252 fail for me, at least.

I did not look at the patch very closely, but do you really need that many
option callbacks?  My gut feeling is that many of them should be just
setting a boolean flag, and you can postprocess to get the correct "apply"
behaviour.

For example, you start with "apply" set to true, and let parseopt set
"diffstat" upon seeing "--stat", and set "cmdline_apply" upon seeing
"--apply".  After parseopt returns, you determine the final value of
"apply" by using "diffstat" (and friends that would normally drop "apply")
and "cmdline_apply" (which would override such droppages).  That way I
think you can lose many callback functions whose sole purpose is to drop
"apply" option, no?

^ permalink raw reply

* [PATCH 2/2] grep: grep cache entries if they are "assume unchanged"
From: Nguyễn Thái Ngọc Duy @ 2008-12-27  8:21 UTC (permalink / raw)
  To: Junio C Hamano, git, Daniel Barkalow
  Cc: Nguyễn Thái Ngọc Duy

"Assume unchanged" bit means "please pretend that I have never touched
this file", so  if user removes the file, we should not care.

This patch teaches "git grep" to use cache version in such
situations. External grep case has not been fixed yet. But given that
on the platform that CE_VALID bit may be used like Windows, external
grep is not available anyway, I would wait for people to raise their
hands before touching it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 I will do git-grep fixes for sparse checkout later because it will require
 nd/narrow. This series does not, so it can be applied separatedly.

 builtin-grep.c  |    7 ++++++-
 t/t7002-grep.sh |    7 +++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/builtin-grep.c b/builtin-grep.c
index 3c97c2c..bebf15c 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -404,7 +404,12 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
 			continue;
 		if (!pathspec_matches(paths, ce->name))
 			continue;
-		if (cached) {
+		/*
+		 * If CE_VALID is on, we assume worktree file and its cache entry
+		 * are identical, even if worktree file has been modified, so use
+		 * cache version instead
+		 */
+		if (cached || (ce->ce_flags & CE_VALID)) {
 			if (ce_stage(ce))
 				continue;
 			hit |= grep_sha1(opt, ce->sha1, ce->name, 0);
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 18fe6f2..e12b5dc 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -161,7 +161,14 @@ test_expect_success 'log grep (6)' '
 	git log --author=-0700  --pretty=tformat:%s >actual &&
 	>expect &&
 	test_cmp expect actual
+'
 
+test_expect_success 'grep with CE_VALID file' '
+	git update-index --assume-unchanged t/t &&
+	rm t/t &&
+	test "$(git grep --no-ext-grep t)" = "t/t:test" &&
+	git update-index --no-assume-unchanged t/t &&
+	git checkout t/t
 '
 
 test_done
-- 
1.6.0.4.1116.g25b13

^ permalink raw reply related

* [PATCH 1/2] grep: support --no-ext-grep to test builtin grep
From: Nguyễn Thái Ngọc Duy @ 2008-12-27  8:21 UTC (permalink / raw)
  To: Junio C Hamano, git, Daniel Barkalow
  Cc: Nguyễn Thái Ngọc Duy
In-Reply-To: <1230366064-1306-1-git-send-email-pclouds@gmail.com>


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 used by the next patch

 builtin-grep.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/builtin-grep.c b/builtin-grep.c
index 624f86e..3c97c2c 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -20,6 +20,8 @@
 #endif
 #endif
 
+static int builtin_grep;
+
 /*
  * git grep pathspecs are somewhat different from diff-tree pathspecs;
  * pathname wildcards are allowed.
@@ -389,7 +391,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
 	 * we grep through the checked-out files. It tends to
 	 * be a lot more optimized
 	 */
-	if (!cached) {
+	if (!cached && !builtin_grep) {
 		hit = external_grep(opt, paths, cached);
 		if (hit >= 0)
 			return hit;
@@ -545,6 +547,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 			cached = 1;
 			continue;
 		}
+		if (!strcmp("--no-ext-grep", arg)) {
+			builtin_grep = 1;
+			continue;
+		}
 		if (!strcmp("-a", arg) ||
 		    !strcmp("--text", arg)) {
 			opt.binary = GREP_BINARY_TEXT;
-- 
1.6.0.4.1116.g25b13

^ permalink raw reply related

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff.
From: Adeodato Simó @ 2008-12-27  8:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin
In-Reply-To: <7vabaijvxl.fsf@gitster.siamese.dyndns.org>

* Junio C Hamano [Fri, 26 Dec 2008 16:36:38 -0800]:

> Adeodato Simó <dato@net.com.org.es> writes:

> > ... I'd
> > still like to hear if my patch would be suitable for inclusion, because
> > it's much more straightforward to use (and to discover).

> But "straightforward to discover" is not an advantage in this case.

> As long as it comes with documentation that clearly explains why this
> feature should not be used blindly in order to avoid diluting the value of
> S-o-b, I think the feature itself is not a harmful thing to have.  Dscho's
> argument in the quoted thread that says it should be a conscious act to
> add S-o-b (except for the part he misunderstands what S-o-b attests), is a
> good one and still is valid.

Does this sound good? If so, I'll send an amended patch (or should I send an
incremental/extra one instead?):

+commit.signoff::
+       If set, 'git-commit' will always add a Signed-off-by line.
+       Please use this option with care: by enabling it, you're stating
+       that all your commits will invariably meet the S-o-b
+       requirements for any project you send patches to. It's probably
+       best to only use it from your private repositories' .git/config
+       file, and only for projects who require a S-o-b as proof of
+       provenance of the patch, and not of its correctness or quality.

> By the way, please do not deflect away responses meant to you by using a
> Mail-Followup-To header that points at the git mailing list.  It is rude.

I set a M-F-T header because I prefer not to be CC'ed. I have other
mechanisms in place that prevent me from missing replies to my messages
(based on In-Reply-To/References headers).

Nevertheless, if the list normally operates CC-based, I can see how pressing
Reply-to-all and not seing the original autor in the recipient list can be
offputting, so I'll stop setting M-F-T in my messages to git@. (Hopefully
starting with this message already.)

I didn't mean for it to be rude in any way.

Thanks,

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
A conference is a gathering of important people who singly can do nothing
but together can decide that nothing can be done.
                -- Fred Allen

^ permalink raw reply

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff.
From: Junio C Hamano @ 2008-12-27  8:44 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: git, Johannes Schindelin
In-Reply-To: <20081227082620.GA5230@chistera.yi.org>

Adeodato Simó <dato@net.com.org.es> writes:

> Does this sound good? If so, I'll send an amended patch (or should I send an
> incremental/extra one instead?):
>
> +commit.signoff::
> +       If set, 'git-commit' will always add a Signed-off-by line.

It is not a big deal, but my first reaction to the above was "S-o-b by
whom?  It misses details and does not say where to find them".

How about "if set, 'git commit' will behave as if '-s' option was given",
so that we can leave the details of whose S-o-b line to generate and such
to the description of "git commit -s" manual page?

> +       Please use this option with care: by enabling it, you're stating
> +       that all your commits will invariably meet the S-o-b
> +       requirements for any project you send patches to. It's probably
> +       best to only use it from your private repositories' .git/config
> +       file, and only for projects who require a S-o-b as proof of
> +       provenance of the patch, and not of its correctness or quality.

Yeah, many projects do not even have S-o-b convention.

>> By the way, please do not deflect away responses meant to you by using a
>> Mail-Followup-To header that points at the git mailing list.  It is rude.
>
> I set a M-F-T header because I prefer not to be CC'ed. I have other
> mechanisms in place that prevent me from missing replies to my messages
> (based on In-Reply-To/References headers).
>
> Nevertheless, if the list normally operates CC-based, I can see how pressing
> Reply-to-all and not seing the original autor in the recipient list can be
> offputting, so I'll stop setting M-F-T in my messages to git@. (Hopefully
> starting with this message already.)

Thanks.

Another problem that you seem to have missed about M-F-T is that while you
solicited responses from general public by CC'ing the list (which allowed
me to respond to you), by forcing the response go only to the list, you
excluded people on the To: and Cc: list of your original message from my
response.  You required them to be subscribed to the list, if they want to
be kept in the loop.

^ permalink raw reply

* [PATCH] git-send-email.txt: move --format-patch paragraph to a proper location
From: Adeodato Simó @ 2008-12-27  8:50 UTC (permalink / raw)
  To: git, gitster; +Cc: Adeodato Simó

When introducing --format-patch, its documentation was accidentally inserted
in the middle of documentation for --validate.

Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---
 Documentation/git-send-email.txt |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 1278866..b69846e 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -197,12 +197,6 @@ Administering
 --[no-]validate::
 	Perform sanity checks on patches.
 	Currently, validation means the following:
-
---[no-]format-patch::
-	When an argument may be understood either as a reference or as a file name,
-	choose to understand it as a format-patch argument ('--format-patch')
-	or as a file name ('--no-format-patch'). By default, when such a conflict
-	occurs, git send-email will fail.
 +
 --
 		*	Warn of patches that contain lines longer than 998 characters; this
@@ -212,6 +206,12 @@ Administering
 Default is the value of 'sendemail.validate'; if this is not set,
 default to '--validate'.
 
+--[no-]format-patch::
+	When an argument may be understood either as a reference or as a file name,
+	choose to understand it as a format-patch argument ('--format-patch')
+	or as a file name ('--no-format-patch'). By default, when such a conflict
+	occurs, git send-email will fail.
+
 
 CONFIGURATION
 -------------
-- 
1.6.1.307.g07803

^ permalink raw reply related

* [PATCH] Add a commit.signoff configuration variable to always use --signoff
From: Adeodato Simó @ 2008-12-27  9:03 UTC (permalink / raw)
  To: git, gitster; +Cc: Adeodato Simó
In-Reply-To: <7v63l6f1mc.fsf@gitster.siamese.dyndns.org>

Signed-off-by: Adeodato Simó <dato@net.com.org.es>
---

* Junio C Hamano [Sat, 27 Dec 2008 00:44:59 -0800]:

> > +commit.signoff::
> > +       If set, 'git-commit' will always add a Signed-off-by line.

> It is not a big deal, but my first reaction to the above was "S-o-b by
> whom?  It misses details and does not say where to find them".

> How about "if set, 'git commit' will behave as if '-s' option was given",
> so that we can leave the details of whose S-o-b line to generate and such
> to the description of "git commit -s" manual page?

Changed.

> > I'll send an amended patch (or should I send an incremental/extra
> > one instead?)

I didn't get an answer to this, so I'm sending an amended one, hoping
that's the correct thing to do in this land.

> Another problem that you seem to have missed about M-F-T is that while you
> solicited responses from general public by CC'ing the list (which allowed
> me to respond to you), by forcing the response go only to the list, you
> excluded people on the To: and Cc: list of your original message from my
> response.  You required them to be subscribed to the list, if they want to
> be kept in the loop.

No, not really, because Mutt will add to the M-F-T header all addresses
that appear on the To or Cc headers.

 Documentation/config.txt     |    9 +++++++++
 Documentation/git-commit.txt |    3 ++-
 builtin-commit.c             |    5 +++++
 3 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 52786c7..4d0a79b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -591,6 +591,15 @@ color.ui::
 commit.template::
 	Specify a file to use as the template for new commit messages.
 
+commit.signoff::
+	If set, 'git commit' will behave as if '-s' option was given.
+	Please use this option with care: by enabling it, you're stating
+	that all your commits will invariably meet the S-o-b
+	requirements for any project you send patches to. It's probably
+	best to only use it from your private repositories' .git/config
+	file, and only for projects who require a S-o-b as proof of
+	provenance of the patch, and not of its correctness or quality.
+
 diff.autorefreshindex::
 	When using 'git-diff' to compare with work tree
 	files, do not consider stat-only change as changed.
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index b5d81be..abab839 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -96,7 +96,8 @@ OPTIONS
 -s::
 --signoff::
 	Add Signed-off-by line by the committer at the end of the commit
-	log message.
+	log message. This overrides the `commit.signoff` configuration
+	variable.
 
 -n::
 --no-verify::
diff --git a/builtin-commit.c b/builtin-commit.c
index e88b78f..fc09539 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -929,6 +929,11 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 	if (!strcmp(k, "commit.template"))
 		return git_config_string(&template_file, k, v);
 
+	if (!strcmp(k, "commit.signoff")) {
+		signoff = git_config_bool(k, v);
+		return 0;
+	}
+
 	return git_status_config(k, v, cb);
 }
 
-- 
1.6.1.307.g07803

^ permalink raw reply related

* [PATCH] gitweb: Fix export check in git_get_projects_list
From: Devin Doucette @ 2008-12-27  9:39 UTC (permalink / raw)
  To: git; +Cc: Petr Baudis, Jakub Narebski

When $filter was empty, the path passed to check_export_ok would
contain an extra '/', which some implementations of export_auth_hook
are sensitive to.

It makes more sense to fix this here than to handle the special case
in each implementation of export_auth_hook.

Signed-off-by: Devin Doucette <devin@doucette.cc>
---
 gitweb/gitweb.perl |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8f574c7..99f71b4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2147,8 +2147,9 @@ sub git_get_projects_list {

 				my $subdir = substr($File::Find::name, $pfxlen + 1);
 				# we check related file in $projectroot
-				if (check_export_ok("$projectroot/$filter/$subdir")) {
-					push @list, { path => ($filter ? "$filter/" : '') . $subdir };
+				my $path = ($filter ? "$filter/" : '') . $subdir;
+				if (check_export_ok("$projectroot/$path")) {
+					push @list, { path => $path };
 					$File::Find::prune = 1;
 				}
 			},
-- 
1.6.1.rc4

^ permalink raw reply related

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff
From: Thomas Rast @ 2008-12-27 11:04 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: git, gitster
In-Reply-To: <1230368596-6865-1-git-send-email-dato@net.com.org.es>

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

Adeodato Simó wrote:
> +commit.signoff::
> +	If set, 'git commit' will behave as if '-s' option was given.
> +	Please use this option with care: by enabling it, you're stating
> +	that all your commits will invariably meet the S-o-b
> +	requirements for any project you send patches to. It's probably
> +	best to only use it from your private repositories' .git/config
> +	file, and only for projects who require a S-o-b as proof of
                           ^^^^^^^^^^^^

"projects which ..." or "projects that ...".  "Who" can only stand for
people, not objects.

> +	provenance of the patch, and not of its correctness or quality.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch






[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff
From: Adeodato Simó @ 2008-12-27 11:05 UTC (permalink / raw)
  To: Thomas Rast; +Cc: git, gitster
In-Reply-To: <200812271204.15268.trast@student.ethz.ch>

* Thomas Rast [Sat, 27 Dec 2008 12:04:11 +0100]:

> Adeodato Simó wrote:
> > +commit.signoff::
> > +	If set, 'git commit' will behave as if '-s' option was given.
> > +	Please use this option with care: by enabling it, you're stating
> > +	that all your commits will invariably meet the S-o-b
> > +	requirements for any project you send patches to. It's probably
> > +	best to only use it from your private repositories' .git/config
> > +	file, and only for projects who require a S-o-b as proof of
>                            ^^^^^^^^^^^^

> "projects which ..." or "projects that ...".  "Who" can only stand for
> people, not objects.

Good catch, thank you. Hopefully Junio can amend.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
                                   Listening to: Miguel Bosé - Puede que

^ permalink raw reply

* [ANNOUNCE] MSYSGIT 1.6.1
From: Steffen Prohaska @ 2008-12-27 10:31 UTC (permalink / raw)
  To: Git Mailing List, msysGit; +Cc: Junio C Hamano
In-Reply-To: <7v7i5odams.fsf@gitster.siamese.dyndns.org>


On Dec 25, 2008, at 7:36 AM, Junio C Hamano wrote:

> The latest feature release GIT 1.6.1 is available at the usual
> places:


The msysgit installer is available at

     http://code.google.com/p/msysgit/downloads

	Steffen

^ permalink raw reply

* Re: [PATCH] git-shortlog.txt: improve documentation about .mailmap files
From: Junio C Hamano @ 2008-12-27 11:48 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: git
In-Reply-To: <1230292553-7613-1-git-send-email-dato@net.com.org.es>

Adeodato Simó <dato@net.com.org.es> writes:

> The previous .mailmap example made it seem like .mailmap files are only
> useful for commits with a wrong address for an author, when they are about
> fixing the real name. Explained this better in the text, and replaced the
> existing example with a new one that hopefully makes things clearer.

Thanks.

> -If the file `.mailmap` exists, it will be used for mapping author
> -email addresses to a real author name. One mapping per line, first
> -the author name followed by the email address enclosed by
> -'<' and '>'. Use hash '#' for comments. Example:
> +If a file `.mailmap` exists in the toplevel directory of the repository,
> +it will be used for mapping author email addresses to a canonical real
> +name. This can be used to coalesce together commits by the same person
> +where their name was spelled differently (whether with the same email
> +address or not).

We didn't stress "the toplevel" earlier, partly because it is obvious that
the file cannot be anything but project-tree wide (as opposed to being per
subdirectory, similar to .gitignore and .gitattributes).  I guess it would
not hurt to be explicit, even though it feels slightly silly.

"..., it is used to map author email addresses to..." would flow easier.

> +The format of the file is one mapping per line, first the desired author
> +name followed by the email address enclosed by '<' and '>'. Use hash '#'
> +for comments.

You already introduced the term "a canonical real name" in the earlier
description.  It would be easier to read if you stick to it and say "Each
line consists of the canonical real name of an author, whitespaces, and an
email address, enclosed by '<' and '>', to map to the name".

Can a hash '#' character be anywhere on a line?  E.g. how is an entry like
this processed?

	Jane Doe <jane@desktop.(none)> # early mistake...

> +... For example, if your history contains commits by these
> +committers:

I think you meant "authors", not "committers".

> +------------
> +Author: Joe Developer <joe@random.com>
> +Author: Joe R. Developer <joe@random.com>
> +Author: Jane Doe <jane@the-does.name>
> +Author: Jane Doe <jane@laptop.(none)>
> +Author: Jane D. <jane@desktop.(none)>
> +------------

I'd suggest dropping "Author: ".  You said you are listing people.

Isn't random.com a real domain (the same goes for the-does.name)?  It
would be preferrable to use addresses from .example (or .xz) top-level
domain.

Clarify that there are actually two people in the list above, and explain
that they are one Joe with two spellings who prefers to be referred to
with his middle initial, and one Jane with three spellings who prefers to
show the family name fully spelled out.  Do not force your readers guess
which spelling is preferred for each person in the example.  It would make
it easier for them to understand the example you will give them next and
to agree that the mailmap is "proper".

> +Then a proper `.mailmap` file would be:
>
>  ------------
> -# Keep alphabetized
> -Adam Morrow <adam@localhost.localdomain>
> -Eve Jones <eve@laptop.(none)>
> +# Note how we don't need an entry for <jane@laptop.(none)>, because the
> +# real name of that author is correct already, and coalesced directly.
> +Jane Doe <jane@desktop.(none)>
> +Joe R. Developer <joe@random.com>
>  ------------

^ permalink raw reply

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff
From: Junio C Hamano @ 2008-12-27 11:53 UTC (permalink / raw)
  To: Adeodato Simó; +Cc: git
In-Reply-To: <1230368596-6865-1-git-send-email-dato@net.com.org.es>

Adeodato Simó <dato@net.com.org.es> writes:

> +commit.signoff::
> +	If set, 'git commit' will behave as if '-s' option was given.
> +	Please use this option with care: by enabling it, you're stating
> +	that all your commits will invariably meet the S-o-b
> +	requirements for any project you send patches to. It's probably

This is true only if you set it in your global configuration.  A more sane
usage would be to have it per repository as you recommend in a later
sentence, and "for any project" part is untrue when the reader does so.

> diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
> index b5d81be..abab839 100644
> --- a/Documentation/git-commit.txt
> +++ b/Documentation/git-commit.txt
> @@ -96,7 +96,8 @@ OPTIONS
>  -s::
>  --signoff::
>  	Add Signed-off-by line by the committer at the end of the commit
> -	log message.
> +	log message. This overrides the `commit.signoff` configuration
> +	variable.

Good and careful thinking.  I like it.

^ permalink raw reply

* Re: RFE: git-import-dsc should support http-links
From: Guido Günther @ 2008-12-27 11:49 UTC (permalink / raw)
  To: Rolf Leggewie; +Cc: git, Junio C Hamano
In-Reply-To: <7vk59n93x7.fsf@gitster.siamese.dyndns.org>

Hi Rolf, Hi Junio,
On Thu, Dec 25, 2008 at 04:27:16PM -0800, Junio C Hamano wrote:
> Rolf Leggewie <no2spam@nospam.arcornews.de> writes:
> 
> > merry Christmas everyone.  I hope this is the right place for this, I
> > looked around and it seemed to me it was, so here it goes.
> 
> Sorry, I have never heard of git-import-dsc and had to google for it, only
> to find that it is one [*1*] of a set [*2*] of debian local tools somebody
> I've never heard of (Cc'ed) on this list has written.
> 
> > It would be nice if the following just worked:
> >
> > "git-import-dsc
> > http://ftp.de.debian.org/debian/pool/main/g/gnucash/gnucash_2.2.6-2.dsc"
> > Regards

dget http://ftp.de.debian.org/debian/pool/main/g/gnucash/gnucash_2.2.6-2.dsc
git-import-dsc gnucash_2.2.6-2.dsc

is what I'm using but having this in git-import-dsc itself is fine by me
if someone sends a patch.

> > PS: How about some kind of official bug tracker for git?
The Debian BTS (bugs.debian.org) is the official bugtracker for
git-buildpackage.
Cheers,
 -- Guido

^ permalink raw reply

* Re: [PATCH] Add a commit.signoff configuration variable to always use --signoff
From: Adeodato Simó @ 2008-12-27 12:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v8wq1esvo.fsf@gitster.siamese.dyndns.org>

* Junio C Hamano [Sat, 27 Dec 2008 03:53:47 -0800]:

> Adeodato Simó <dato@net.com.org.es> writes:

> > +commit.signoff::
> > +	If set, 'git commit' will behave as if '-s' option was given.
> > +	Please use this option with care: by enabling it, you're stating
> > +	that all your commits will invariably meet the S-o-b
> > +	requirements for any project you send patches to. It's probably

> This is true only if you set it in your global configuration.  A more sane
> usage would be to have it per repository as you recommend in a later
> sentence, and "for any project" part is untrue when the reader does so.

How about:

  Please use this option with care: by enabling it globally, you'd be
  stating...

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
                              Listening to: Niza - Solsticio de invierno

^ permalink raw reply

* [git-new-workdir RFC] Backlinking $workdir/logs/HEAD to $GIT_DIR/logs/workdir?
From: Adeodato Simó @ 2008-12-27 12:15 UTC (permalink / raw)
  To: git

Hello,

I use git new-workdir for some of my projects. Apart from the usual
caveat "don't checkout the same branch twice", I found another small
issue, surely known: the reflog for HEAD in the workidirs does not exist
in the source git repo, hence git-gc will happily prune what it believes
to be dangling commits.

Would it be, perhaps, be okay to create a logs/workdir/<name>/HEAD
symlink pointing to $workdir/logs/HEAD, so that this does not happen?

Comments welcome.

-- 
Adeodato Simó                                     dato at net.com.org.es
Debian Developer                                  adeodato at debian.org
 
                                            Listening to: Niza - Parasol

^ permalink raw reply

* [STGIT][PATCH] new: translate non word characters in patch name to '-'
From: Hannes Eder @ 2008-12-27 12:37 UTC (permalink / raw)
  To: git

This allows following usage:

$ stg new full/path/file-fix-foobar
Now at patch "full-path-file-fix-foobar"

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---

I ran into as a '/' in a patch messed up stgit.

I find this useful as 'stg uncommit' does the same translation.

 stgit/commands/new.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stgit/commands/new.py b/stgit/commands/new.py
index 151cfe9..ab09476 100644
--- a/stgit/commands/new.py
+++ b/stgit/commands/new.py
@@ -58,7 +58,7 @@ def func(parser, options, args):
     if len(args) == 0:
         name = None
     elif len(args) == 1:
-        name = args[0]
+        name = utils.patch_name_from_msg(args[0])
         if stack.patches.exists(name):
             raise common.CmdException('%s: patch already exists' % name)
     else:

^ permalink raw reply related

* Git (svn) merge - but ignore certain commits?
From: "Peter Valdemar Mørch (Lists)" @ 2008-12-27 13:02 UTC (permalink / raw)
  To: git

Hi,

I'm wondering how to merge a branch back to a master/svn trunk, getting 
"almost" all the commits on the branch. I've experimented with "git 
merge -s ours" unsuccessfully and don't know how else to proceed.

Background: Our svn trunk has had many solid commits, and a few that 
aren't ready yet. We need to make a new release without these unready 
commits but with some new functionality.

Externally to git, a branch was made off of trunk's HEAD. Call it 
"newbranch".

The idea is to:

* Create a git branch off of svn "newbranch", call it "gitnewbranch".

* "git revert" the "few unready" commits on "gitnewbranch" so we have a 
solid foundation

* add the new functionality to "gitnewbranch"

* "git svn dcommit" to get the new functionality on svn's "newbranch"

* And now the trick: "git merge" "gitnewbranch" back to master. But I 
want to avoid the "git revert" of the few commits that weren't ready yet.

* "git svn dcommit" master to get the new functionality into svn trunk.

How do I "git merge" all of "gitnewbranch" except the reverts?

I tried doing just the revert step, and then
"git merge -s ours gitnewbranch"
on master, and that seemed to work. Annoyingly (to me :-D) "git log 
master" does show the reverts that happened on gitnewbranch, but the 
files in master were not changed. However, when I "git svn rebase", it 
fails with a
"CONFLICT (content): Merge conflict in <file>".
And hence, "git svn dcommit" fails too.

Is there a way to "git merge gitnewbranch" excluding the reverts, just 
the "new functionality", so the log of master doesn't even mention the 
reverts and so "git svn rebase" and "git svn dcommit" work properly?

I guess I could git cherry-pick all the "new functionality" commits from 
gitnewbranch to master, but it sort of defeats the coolness of gits 
branch handling if I have to keep track of the cherry-picked commits 
manually.

How do I do this "properly"?

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com

^ permalink raw reply

* Re: [JGIT PATCH 11/23] Rewrite WindowCache to use a hash table
From: Robin Rosenberg @ 2008-12-27 13:30 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1230171079-17156-12-git-send-email-spearce@spearce.org>

torsdag 25 december 2008 03:11:07 skrev Shawn O. Pearce:
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java
> index f617845..f478f04 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowCache.java
> @@ -41,11 +41,7 @@
>  import java.io.IOException;
>  import java.lang.ref.ReferenceQueue;
>  
> -/**
> - * The WindowCache manages reusable <code>Windows</code> and inflaters used by
> - * the other windowed file access classes.
> - */
> -public class WindowCache {
> +class WindowCache {

This breaks the Eclipse plugin which want to call WindowCache.reconfigure. Package level
class can also have javadocs. Even though we do not require it, I still thinks it's a good idea. Not
sure how useful that one was.

-- robin

^ permalink raw reply

* Re: [PATCH] parse-opt: migrate builtin-apply.
From: Miklos Vajna @ 2008-12-27 14:05 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vtz8qgjo9.fsf@gitster.siamese.dyndns.org>

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

On Fri, Dec 26, 2008 at 11:29:42PM -0800, Junio C Hamano <gitster@pobox.com> wrote:
> Miklos Vajna <vmiklos@frugalware.org> writes:
> 
> > The only notable user-visible/incompatible change is that the
> > --build-fake-ancestor option now conforms to gitcli(7).
> >
> > Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> > ---
> >
> > I know that we do care about incompatible changes a lot, though I think
> > this is the right direction and probably --build-fake-ancestor is not a
> > heavily used switch, so I hope that part is OK.
> 
> An acceptable justification for such a plumbing change is if (1) the old
> syntax is still supported the same way as the original implementation,
> *and* if (2) the new syntax is something that could not possibly have been
> a valid input to the original implementation with a different meaning.
> 
> I think the condition (1) holds but (2) does not hold for your patch; even
> though I think the latter breakage is excusable in this particular case,
> it is not for the reason you cited.
> 
> That is,
> 
>  (1) The parseopt parser allows both of these forms:
> 
> 	$ git apply --build-fake-ancestor file <input
>         $ git apply --build-fake-ancestor=file <input
> 
>      The former has been how existing scripts that use the plumbing have
>      been feeding the file, and it is still supported.
> 
>  (2) A script that used "git apply" and relied on the behaviour of 
>      the original implementation could have fed a patch from a file
>      whose name is "--build-fake-ancestor=some-string", with this command
>      line:
> 
>         $ git apply --build-fake-ancestor=file
> 
>      Now such a script would break with the new parser.
> 
> The reason you are excused to break such an insane script is definitely
> not because --build-fake-ancestor is a rarely used option.  The whole
> defence depends on the fact that --build-fake-ancestor=something is a very
> unlikely name for any sane script to be using for its temporary file.  It
> could still be an end user input, but at that point you could simply doubt
> the sanity of the end user and dismiss the issue away.
> 
> I am not fundamentally opposed to using parseopt in git-apply, and I think
> the change to add a new and saner meaning to "--build-fake-ancestor=file"
> on the command line is a good thing in the longer term.  But your
> justification for such a change should be given in such a way to show
> clearly that you have thought things through.  It has to be much better
> than "it is not a heavily used switch anyway".

I was not aware about parsepont allows both options, I just -
incorrectly - thought git-log uses paseopt and there I remember
--since=foo works, but not --since foo. So actually the commit message
is incorrect, the backwards-incompatible change is not to accept a patch
file named --build-fake-ancestor=something without passing '--' first.

> The saddest part of the story that pisses me off about this patch is that
> you did not seem to have even run the test suite before sending it.  t4105
> and t4252 fail for me, at least.

Hm, I did:

$ ./t4105-apply-fuzz.sh
*   ok 1: setup
*   ok 2: unmodified patch
*   ok 3: minus offset
*   ok 4: plus offset
*   ok 5: big offset
*   ok 6: fuzz with no offset
*   ok 7: fuzz with minus offset
*   ok 8: fuzz with plus offset
*   ok 9: fuzz with big offset
* passed all 9 test(s)

$ ./t4252-am-options.sh
*   ok 1: setup
*   ok 2: interrupted am --whitespace=fix
*   ok 3: interrupted am -C1
*   ok 4: interrupted am -p2
*   ok 5: interrupted am -C1 -p2
* passed all 5 test(s)

$ git show -s --pretty=oneline
05d26caf212b58998b7e559991f3a25fd8cbf3f0 parse-opt: migrate builtin-apply.

What testcases did fail for you?

> I did not look at the patch very closely, but do you really need that many
> option callbacks?  My gut feeling is that many of them should be just
> setting a boolean flag, and you can postprocess to get the correct "apply"
> behaviour.
> 
> For example, you start with "apply" set to true, and let parseopt set
> "diffstat" upon seeing "--stat", and set "cmdline_apply" upon seeing
> "--apply".  After parseopt returns, you determine the final value of
> "apply" by using "diffstat" (and friends that would normally drop "apply")
> and "cmdline_apply" (which would override such droppages).  That way I
> think you can lose many callback functions whose sole purpose is to drop
> "apply" option, no?

Yes, you are right. I'll send an updated patch in a bit.

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

^ permalink raw reply

* [PATCH v2] parse-opt: migrate builtin-apply.
From: Miklos Vajna @ 2008-12-27 14:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20081227140533.GX21154@genesis.frugalware.org>

The only incompatible change is that the user how have to use '--'
before a patch named --build-fake-ancestor=something.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---

Diffstat against v1:

 builtin-apply.c |  125 +++++++++++++------------------------------------------
 1 files changed, 29 insertions(+), 96 deletions(-)

due to the removal of option_parse_stat, option_parse_numstat,
option_parse_summary, option_parse_check, option_parse_index,
option_parse_cached, option_parse_ancestor and option_parse_reject.

 Documentation/git-apply.txt |    4 +-
 builtin-apply.c             |  293 ++++++++++++++++++++++++-------------------
 2 files changed, 167 insertions(+), 130 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index e726510..9400f6a 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git apply' [--stat] [--numstat] [--summary] [--check] [--index]
-	  [--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
+	  [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse]
 	  [--allow-binary-replacement | --binary] [--reject] [-z]
 	  [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
 	  [--whitespace=<nowarn|warn|fix|error|error-all>]
@@ -64,7 +64,7 @@ OPTIONS
 	cached data, apply the patch, and store the result in the index,
 	without using the working tree. This implies '--index'.
 
---build-fake-ancestor <file>::
+--build-fake-ancestor=<file>::
 	Newer 'git-diff' output has embedded 'index information'
 	for each blob to help identify the original version that
 	the patch applies to.  When this flag is given, and if
diff --git a/builtin-apply.c b/builtin-apply.c
index 07244b0..98a988c 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -14,6 +14,7 @@
 #include "builtin.h"
 #include "string-list.h"
 #include "dir.h"
+#include "parse-options.h"
 
 /*
  *  --check turns on checking that the working tree matches the
@@ -46,8 +47,10 @@ static int no_add;
 static const char *fake_ancestor;
 static int line_termination = '\n';
 static unsigned long p_context = ULONG_MAX;
-static const char apply_usage[] =
-"git apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...";
+static const char * const apply_usage[] = {
+	"git apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...",
+	NULL
+};
 
 static enum ws_error_action {
 	nowarn_ws_error,
@@ -61,6 +64,8 @@ static int applied_after_fixing_ws;
 static const char *patch_input_file;
 static const char *root;
 static int root_len;
+static int read_stdin = 1;
+static int options;
 
 static void parse_whitespace_option(const char *option)
 {
@@ -3135,150 +3140,182 @@ static int git_apply_config(const char *var, const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }
 
+static int option_parse_stdin(const struct option *opt,
+			      const char *arg, int unset)
+{
+	int *errs = opt->value;
+
+	*errs |= apply_patch(0, "<stdin>", options);
+	read_stdin = 0;
+	return 0;
+}
+
+static int option_parse_exclude(const struct option *opt,
+				const char *arg, int unset)
+{
+	add_name_limit(arg, 1);
+	return 0;
+}
+
+static int option_parse_include(const struct option *opt,
+				const char *arg, int unset)
+{
+	add_name_limit(arg, 0);
+	has_include = 1;
+	return 0;
+}
+
+static int option_parse_p(const struct option *opt,
+			  const char *arg, int unset)
+{
+	p_value = atoi(arg);
+	p_value_known = 1;
+	return 0;
+}
+
+static int option_parse_z(const struct option *opt,
+			  const char *arg, int unset)
+{
+	if (unset)
+		line_termination = '\n';
+	else
+		line_termination = 0;
+	return 0;
+}
+
+static int option_parse_whitespace(const struct option *opt,
+				   const char *arg, int unset)
+{
+	const char **whitespace_option = opt->value;
+
+	*whitespace_option = arg;
+	parse_whitespace_option(arg);
+	return 0;
+}
+
+static int option_parse_inaccurate(const struct option *opt,
+				   const char *arg, int unset)
+{
+	options |= INACCURATE_EOF;
+	return 0;
+}
+
+static int option_parse_recount(const struct option *opt,
+				const char *arg, int unset)
+{
+	options |= RECOUNT;
+	return 0;
+}
+
+static int option_parse_directory(const struct option *opt,
+				  const char *arg, int unset)
+{
+	root_len = strlen(arg);
+	if (root_len && arg[root_len - 1] != '/') {
+		char *new_root;
+		root = new_root = xmalloc(root_len + 2);
+		strcpy(new_root, arg);
+		strcpy(new_root + root_len++, "/");
+	} else
+		root = arg;
+	return 0;
+}
 
 int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 {
 	int i;
-	int read_stdin = 1;
-	int options = 0;
 	int errs = 0;
 	int is_not_gitdir;
+	int binary;
+	int force_apply = 0;
 
 	const char *whitespace_option = NULL;
 
+	struct option builtin_apply_options[] = {
+		{ OPTION_CALLBACK, '-', NULL, &errs, NULL,
+			"read the patch from the standard input",
+			PARSE_OPT_NOARG, option_parse_stdin },
+		{ OPTION_CALLBACK, 0, "exclude", NULL, "path",
+			"don´t apply changes matching the given path",
+			0, option_parse_exclude },
+		{ OPTION_CALLBACK, 0, "include", NULL, "path",
+			"apply changes matching the given path",
+			0, option_parse_include },
+		{ OPTION_CALLBACK, 'p', NULL, NULL, "num",
+			"remove <num> leading slashes from traditional diff paths",
+			0, option_parse_p },
+		OPT_BOOLEAN(0, "no-add", &no_add,
+			"ignore additions made by the patch"),
+		OPT_BOOLEAN(0, "stat", &diffstat,
+			"instead of applying the patch, output diffstat for the input"),
+		OPT_BOOLEAN(0, "allow-binary-replacement", &binary,
+			"now no-op"),
+		OPT_BOOLEAN(0, "binary", &binary,
+			"now no-op"),
+		OPT_BOOLEAN(0, "numstat", &numstat,
+			"shows number of added and deleted lines in decimal notation"),
+		OPT_BOOLEAN(0, "summary", &summary,
+			"instead of applying the patch, output a summary for the input"),
+		OPT_BOOLEAN(0, "check", &check,
+			"instead of applying the patch, see if the patch is applicable"),
+		OPT_BOOLEAN(0, "index", &check_index,
+			"make sure the patch is applicable to the current index"),
+		OPT_BOOLEAN(0, "cached", &cached,
+			"apply a patch without touching the working tree"),
+		OPT_BOOLEAN(0, "apply", &force_apply,
+			"also apply the patch (use with --stat/--summary/--check)"),
+		OPT_STRING(0, "build-fake-ancestor", &fake_ancestor, "file",
+			"build a temporary index based on embedded index information"),
+		{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,
+			"paths are separated with NUL character",
+			PARSE_OPT_NOARG, option_parse_z },
+		OPT_INTEGER('C', NULL, &p_context,
+				"ensure at least <n> lines of context match"),
+		{ OPTION_CALLBACK, 0, "whitespace", &whitespace_option, "action",
+			"detect new or modified lines that have whitespace errors",
+			0, option_parse_whitespace },
+		OPT_BOOLEAN('R', "reverse", &apply_in_reverse,
+			"apply the patch in reverse"),
+		OPT_BOOLEAN(0, "unidiff-zero", &unidiff_zero,
+			"don't expect at least one line of context"),
+		OPT_BOOLEAN(0, "reject", &apply_with_reject,
+			"leave the rejected hunks in corresponding *.rej files"),
+		OPT__VERBOSE(&apply_verbosely),
+		{ OPTION_CALLBACK, 0, "inaccurate-eof", NULL, NULL,
+			"tolerate incorrectly detected missing new-line at the end of file",
+			PARSE_OPT_NOARG, option_parse_inaccurate },
+		{ OPTION_CALLBACK, 0, "recount", NULL, NULL,
+			"do not trust the line counts in the hunk headers",
+			PARSE_OPT_NOARG, option_parse_recount },
+		{ OPTION_CALLBACK, 0, "directory", NULL, "root",
+			"prepend <root> to all filenames",
+			0, option_parse_directory },
+		OPT_END()
+	};
+
 	prefix = setup_git_directory_gently(&is_not_gitdir);
 	prefix_length = prefix ? strlen(prefix) : 0;
 	git_config(git_apply_config, NULL);
 	if (apply_default_whitespace)
 		parse_whitespace_option(apply_default_whitespace);
 
-	for (i = 1; i < argc; i++) {
+	argc = parse_options(argc, argv, builtin_apply_options,
+			apply_usage, 0);
+	if (apply_with_reject)
+		apply = apply_verbosely = 1;
+	if (!force_apply && (diffstat || numstat || summary || check || fake_ancestor))
+		apply = 0;
+	if (check_index && is_not_gitdir)
+		die("--index outside a repository");
+	if (cached) {
+		if (is_not_gitdir)
+			die("--cached outside a repository");
+		check_index = 1;
+	}
+	for (i = 0; i < argc; i++) {
 		const char *arg = argv[i];
-		char *end;
 		int fd;
 
-		if (!strcmp(arg, "-")) {
-			errs |= apply_patch(0, "<stdin>", options);
-			read_stdin = 0;
-			continue;
-		}
-		if (!prefixcmp(arg, "--exclude=")) {
-			add_name_limit(arg + 10, 1);
-			continue;
-		}
-		if (!prefixcmp(arg, "--include=")) {
-			add_name_limit(arg + 10, 0);
-			has_include = 1;
-			continue;
-		}
-		if (!prefixcmp(arg, "-p")) {
-			p_value = atoi(arg + 2);
-			p_value_known = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--no-add")) {
-			no_add = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--stat")) {
-			apply = 0;
-			diffstat = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--allow-binary-replacement") ||
-		    !strcmp(arg, "--binary")) {
-			continue; /* now no-op */
-		}
-		if (!strcmp(arg, "--numstat")) {
-			apply = 0;
-			numstat = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--summary")) {
-			apply = 0;
-			summary = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--check")) {
-			apply = 0;
-			check = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--index")) {
-			if (is_not_gitdir)
-				die("--index outside a repository");
-			check_index = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--cached")) {
-			if (is_not_gitdir)
-				die("--cached outside a repository");
-			check_index = 1;
-			cached = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--apply")) {
-			apply = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--build-fake-ancestor")) {
-			apply = 0;
-			if (++i >= argc)
-				die ("need a filename");
-			fake_ancestor = argv[i];
-			continue;
-		}
-		if (!strcmp(arg, "-z")) {
-			line_termination = 0;
-			continue;
-		}
-		if (!prefixcmp(arg, "-C")) {
-			p_context = strtoul(arg + 2, &end, 0);
-			if (*end != '\0')
-				die("unrecognized context count '%s'", arg + 2);
-			continue;
-		}
-		if (!prefixcmp(arg, "--whitespace=")) {
-			whitespace_option = arg + 13;
-			parse_whitespace_option(arg + 13);
-			continue;
-		}
-		if (!strcmp(arg, "-R") || !strcmp(arg, "--reverse")) {
-			apply_in_reverse = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--unidiff-zero")) {
-			unidiff_zero = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--reject")) {
-			apply = apply_with_reject = apply_verbosely = 1;
-			continue;
-		}
-		if (!strcmp(arg, "-v") || !strcmp(arg, "--verbose")) {
-			apply_verbosely = 1;
-			continue;
-		}
-		if (!strcmp(arg, "--inaccurate-eof")) {
-			options |= INACCURATE_EOF;
-			continue;
-		}
-		if (!strcmp(arg, "--recount")) {
-			options |= RECOUNT;
-			continue;
-		}
-		if (!prefixcmp(arg, "--directory=")) {
-			arg += strlen("--directory=");
-			root_len = strlen(arg);
-			if (root_len && arg[root_len - 1] != '/') {
-				char *new_root;
-				root = new_root = xmalloc(root_len + 2);
-				strcpy(new_root, arg);
-				strcpy(new_root + root_len++, "/");
-			} else
-				root = arg;
-			continue;
-		}
 		if (0 < prefix_length)
 			arg = prefix_filename(prefix, prefix_length, arg);
 
-- 
1.6.1.rc1.35.gae26e.dirty

^ 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