Git development
 help / color / mirror / Atom feed
* Re: Pair Programming Workflow Suggestions
From: Tim Visher @ 2009-09-20 15:37 UTC (permalink / raw)
  To: Nicolas Sebrecht; +Cc: Sean Estabrooks, Git Mailing List
In-Reply-To: <20090916141730.GA24893@vidovic>

On Wed, Sep 16, 2009 at 10:17 AM, Nicolas Sebrecht <nicolas.s.dev@gmx.fr> wrote:
> The 16/09/09, Tim Visher wrote:
>>
>>                         Pairing, on the other hand, is much more
>> tightly integrated than that.  Just like in Brian's post, it's really
>> a situation of Dev1 _&_ Dev2 wrote this feature, but one of them
>> happened to be typing and doing most of the nitty-gritty developing.
>> Changing the authors between committs almost seems to introduce an
>> arbitrary level of distinction where it's no longer _both_ but _one
>> then the other_.  Does that make my question any clearer?
>
> FMPOV (and to follow the Pair Programming purpose), there isn't an "I"
> in "Pair".  So having the same author name and sign-off for each pair is
> what makes most sense. IMHO, "dev1_and_dev2" is actually the best
> option.

That's certainly interesting.  I guess I just assumed, not having too
much practical experience with actually pairing, that the driver would
be doing most of the coding for a given commit…  It's true that that's
not really the case.

Do you guys use Hudson or something similar when you're pairing?
How's your experience regarding how it interoperates with the
dev_1_and_dev_2 naming convention?

-- 

In Christ,

Timmy V.

http://burningones.com/
http://five.sentenc.es/ - Spend less time on e-mail

^ permalink raw reply

* Re: [PATCH] Trivial fix: Make all the builtin usage strings to use  the same pattern.
From: Thiago Farina @ 2009-09-20 14:51 UTC (permalink / raw)
  To: Johannes Gilger; +Cc: Git Mailing List
In-Reply-To: <20090920143526.GA22295@dualtron.vpn.rwth-aachen.de>

On Sun, Sep 20, 2009 at 11:35 AM, Johannes Gilger <heipei@hackvalue.de> wrote:
> On 20/09/09 09:17, Thiago Farina wrote:
>> They follow the pattern of file name:
>> File name pattern: builtin-command-name.c
>> Usage string pattern: builtin_command_name_usage
>> [...]
>> -static char const * const archive_usage[] = {
>> +static const char * const archive_usage[] = {
>>       "git archive [options] <tree-ish> [path...]",
>>       "git archive --list",
>>       "git archive --remote <repo> [--exec <cmd>] [options] <tree-ish> [path...]",
> Looks like you missed a spot ;)
The change here is about 'char const *' to 'const char *', to match
with the definition in api-parse-options.txt. :)
Is there a reason for archive do not has a builtin- in it file name?

^ permalink raw reply

* Re: [PATCH] Trivial fix: Make all the builtin usage strings to use the same pattern.
From: Johannes Gilger @ 2009-09-20 14:35 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Thiago Farina
In-Reply-To: <1253452645-3220-1-git-send-email-tfransosi@gmail.com>

On 20/09/09 09:17, Thiago Farina wrote:
> They follow the pattern of file name:
> File name pattern: builtin-command-name.c
> Usage string pattern: builtin_command_name_usage
> [...]
> -static char const * const archive_usage[] = {
> +static const char * const archive_usage[] = {
>  	"git archive [options] <tree-ish> [path...]",
>  	"git archive --list",
>  	"git archive --remote <repo> [--exec <cmd>] [options] <tree-ish> [path...]",
Looks like you missed a spot ;)

Greetings,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://heipei.net
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

^ permalink raw reply

* Re: merge ignores --no-commit in fast-forward case
From: Paolo Bonzini @ 2009-09-20 14:04 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Greg Price, git
In-Reply-To: <7viqff97l4.fsf@alter.siamese.dyndns.org>

On 09/19/2009 01:05 AM, Junio C Hamano wrote:
> If "surprising" is the problem (and it certainly is), perhaps it would be
> better to rewrite it not to be so surprising, like:
>
>          --no-commit::
>                  Do not create a new commit.

Do not create a new _merge_ commit, and it's perfect.

Paolo

^ permalink raw reply

* [PATCH JGIT] Make it possible to clear a PlotCommitList
From: Jonas Fonseca @ 2009-09-20 13:34 UTC (permalink / raw)
  To: Robin Rosenberg, Shawn O. Pearce; +Cc: git

This allows SwingGraphPanes to be reused by simply clearing and
re-filling. Requires RevObjectList initialization to not call clear()
from its constructor, because this will lead PlotCommitList.clear() to
be called before all variables have been initialized.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 .../org/spearce/jgit/revplot/PlotCommitList.java   |   12 ++++++++++--
 .../org/spearce/jgit/revwalk/RevObjectList.java    |    7 +++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java b/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
index a0959e2..39e4759 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
@@ -64,7 +64,15 @@
 
 	private final TreeSet<Integer> freeLanes = new TreeSet<Integer>();
 
-	private HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+	private final HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+
+	@Override
+	public void clear() {
+		super.clear();
+		lanesAllocated = 0;
+		freeLanes.clear();
+		activeLanes.clear();
+	}
 
 	@Override
 	public void source(final RevWalk w) {
@@ -133,7 +141,7 @@ protected void enter(final int index, final PlotCommit<L> currCommit) {
 				final PlotCommit c = currCommit.children[i];
 				if (activeLanes.remove(c.lane)) {
 					recycleLane((L) c.lane);
-					freeLanes.add(Integer.valueOf(c.lane.position));
+					freeLanes.add(Integer.valueOf(c.lane.getPosition()));
 				}
 			}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
index b95b127..d57c779 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
@@ -50,13 +50,12 @@
 
 	static final int BLOCK_SIZE = 1 << BLOCK_SHIFT;
 
-	Block contents;
+	protected Block contents = new Block(0);
 
-	int size;
+	protected int size = 0;
 
 	/** Create an empty object list. */
 	public RevObjectList() {
-		clear();
 	}
 
 	public void add(final int index, final E element) {
@@ -107,7 +106,7 @@ public void clear() {
 		size = 0;
 	}
 
-	static class Block {
+	protected static class Block {
 		final Object[] contents = new Object[BLOCK_SIZE];
 
 		final int shift;
-- 
1.6.5.rc0.164.g5f6b0

^ permalink raw reply related

* [PATCH] Trivial fix: Make all the builtin usage strings to use the same pattern.
From: Thiago Farina @ 2009-09-20 13:17 UTC (permalink / raw)
  To: git; +Cc: Thiago Farina

They follow the pattern of file name:
File name pattern: builtin-command-name.c
Usage string pattern: builtin_command_name_usage

Signed-off-by: Thiago Farina <tfransosi@gmail.com>
---
 archive.c                    |    2 +-
 builtin-apply.c              |    4 ++--
 builtin-bisect--helper.c     |    6 +++---
 builtin-blame.c              |    9 +++++----
 builtin-cat-file.c           |   12 ++++++------
 builtin-check-attr.c         |    8 ++++----
 builtin-checkout.c           |    4 ++--
 builtin-clean.c              |    2 +-
 builtin-commit-tree.c        |    7 ++++---
 builtin-config.c             |    2 +-
 builtin-count-objects.c      |    6 +++---
 builtin-describe.c           |    4 ++--
 builtin-diff-files.c         |    6 +++---
 builtin-diff-index.c         |    6 +++---
 builtin-diff-tree.c          |    6 +++---
 builtin-fast-export.c        |    8 ++++----
 builtin-fetch-pack.c         |    6 +++---
 builtin-fmt-merge-msg.c      |    6 +++---
 builtin-for-each-ref.c       |   10 +++++-----
 builtin-fsck.c               |    4 ++--
 builtin-grep.c               |    4 ++--
 builtin-init-db.c            |    6 +++---
 builtin-ls-files.c           |    4 ++--
 builtin-ls-remote.c          |    6 +++---
 builtin-ls-tree.c            |    8 ++++----
 builtin-mailinfo.c           |    8 ++++----
 builtin-mailsplit.c          |    6 +++---
 builtin-merge-base.c         |    6 +++---
 builtin-merge-file.c         |    6 +++---
 builtin-mktree.c             |    6 +++---
 builtin-name-rev.c           |    6 +++---
 builtin-pack-objects.c       |   18 +++++++++---------
 builtin-pack-refs.c          |    6 +++---
 builtin-prune-packed.c       |    4 ++--
 builtin-prune.c              |    4 ++--
 builtin-push.c               |    6 +++---
 builtin-read-tree.c          |    4 ++--
 builtin-receive-pack.c       |    8 ++++----
 builtin-reflog.c             |    4 ++--
 builtin-replace.c            |   16 ++++++++--------
 builtin-rerere.c             |    4 ++--
 builtin-reset.c              |    4 ++--
 builtin-rev-list.c           |    6 +++---
 builtin-rev-parse.c          |    2 +-
 builtin-revert.c             |    6 +++---
 builtin-send-pack.c          |    8 ++++----
 builtin-shortlog.c           |    8 ++++----
 builtin-show-branch.c        |    6 +++---
 builtin-show-ref.c           |    4 ++--
 builtin-symbolic-ref.c       |    6 +++---
 builtin-tag.c                |    8 ++++----
 builtin-tar-tree.c           |    4 ++--
 builtin-unpack-objects.c     |    7 ++++---
 builtin-update-index.c       |    4 ++--
 builtin-update-ref.c         |    8 ++++----
 builtin-update-server-info.c |    6 +++---
 builtin-upload-archive.c     |    5 ++---
 builtin-verify-pack.c        |    6 +++---
 builtin-verify-tag.c         |    6 +++---
 builtin-write-tree.c         |    4 ++--
 60 files changed, 184 insertions(+), 182 deletions(-)

diff --git a/archive.c b/archive.c
index 73b8e8a..b74e69f 100644
--- a/archive.c
+++ b/archive.c
@@ -6,7 +6,7 @@
 #include "parse-options.h"
 #include "unpack-trees.h"
 
-static char const * const archive_usage[] = {
+static const char * const archive_usage[] = {
 	"git archive [options] <tree-ish> [path...]",
 	"git archive --list",
 	"git archive --remote <repo> [--exec <cmd>] [options] <tree-ish> [path...]",
diff --git a/builtin-apply.c b/builtin-apply.c
index c8372a0..b653831 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -47,7 +47,7 @@ static int no_add;
 static const char *fake_ancestor;
 static int line_termination = '\n';
 static unsigned int p_context = UINT_MAX;
-static const char * const apply_usage[] = {
+static const char * const builtin_apply_usage[] = {
 	"git apply [options] [<patch>...]",
 	NULL
 };
@@ -3567,7 +3567,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
 		parse_ignorewhitespace_option(apply_default_ignorewhitespace);
 
 	argc = parse_options(argc, argv, prefix, builtin_apply_options,
-			apply_usage, 0);
+			builtin_apply_usage, 0);
 
 	if (apply_with_reject)
 		apply = apply_verbosely = 1;
diff --git a/builtin-bisect--helper.c b/builtin-bisect--helper.c
index 5b22639..41aad99 100644
--- a/builtin-bisect--helper.c
+++ b/builtin-bisect--helper.c
@@ -3,7 +3,7 @@
 #include "parse-options.h"
 #include "bisect.h"
 
-static const char * const git_bisect_helper_usage[] = {
+static const char * const builtin_bisect_helper_usage[] = {
 	"git bisect--helper --next-all",
 	NULL
 };
@@ -18,10 +18,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 	};
 
 	argc = parse_options(argc, argv, prefix, options,
-			     git_bisect_helper_usage, 0);
+			     builtin_bisect_helper_usage, 0);
 
 	if (!next_all)
-		usage_with_options(git_bisect_helper_usage, options);
+		usage_with_options(builtin_bisect_helper_usage, options);
 
 	/* next-all */
 	return bisect_next_all(prefix);
diff --git a/builtin-blame.c b/builtin-blame.c
index 7512773..4adae84 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -21,10 +21,11 @@
 #include "parse-options.h"
 #include "utf8.h"
 
-static char blame_usage[] = "git blame [options] [rev-opts] [rev] [--] file";
+static char builtin_blame_usage[] =
+"git blame [options] [rev-opts] [rev] [--] file";
 
 static const char *blame_opt_usage[] = {
-	blame_usage,
+	builtin_blame_usage,
 	"",
 	"[rev-opts] are documented in git-rev-list(1)",
 	NULL
@@ -1948,10 +1949,10 @@ static void prepare_blame_range(struct scoreboard *sb,
 	if (*term == ',') {
 		term = parse_loc(term + 1, sb, lno, *bottom + 1, top);
 		if (*term)
-			usage(blame_usage);
+			usage(builtin_blame_usage);
 	}
 	if (*term)
-		usage(blame_usage);
+		usage(builtin_blame_usage);
 }
 
 static int git_blame_config(const char *var, const char *value, void *cb)
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 5906842..c4d5c0e 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -200,7 +200,7 @@ static int batch_objects(int print_contents)
 	return 0;
 }
 
-static const char * const cat_file_usage[] = {
+static const char * const builtin_cat_file_usage[] = {
 	"git cat-file (-t|-s|-e|-p|<type>) <object>",
 	"git cat-file (--batch|--batch-check) < <list_of_objects>",
 	NULL
@@ -229,25 +229,25 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	if (argc != 3 && argc != 2)
-		usage_with_options(cat_file_usage, options);
+		usage_with_options(builtin_cat_file_usage, options);
 
-	argc = parse_options(argc, argv, prefix, options, cat_file_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_cat_file_usage, 0);
 
 	if (opt) {
 		if (argc == 1)
 			obj_name = argv[0];
 		else
-			usage_with_options(cat_file_usage, options);
+			usage_with_options(builtin_cat_file_usage, options);
 	}
 	if (!opt && !batch) {
 		if (argc == 2) {
 			exp_type = argv[0];
 			obj_name = argv[1];
 		} else
-			usage_with_options(cat_file_usage, options);
+			usage_with_options(builtin_cat_file_usage, options);
 	}
 	if (batch && (opt || argc)) {
-		usage_with_options(cat_file_usage, options);
+		usage_with_options(builtin_cat_file_usage, options);
 	}
 
 	if (batch)
diff --git a/builtin-check-attr.c b/builtin-check-attr.c
index 8bd0430..3ccce59 100644
--- a/builtin-check-attr.c
+++ b/builtin-check-attr.c
@@ -5,7 +5,7 @@
 #include "parse-options.h"
 
 static int stdin_paths;
-static const char * const check_attr_usage[] = {
+static const char * const builtin_check_attr_usage[] = {
 "git check-attr attr... [--] pathname...",
 "git check-attr --stdin attr... < <list-of-paths>",
 NULL
@@ -70,9 +70,9 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 	const char *errstr = NULL;
 
 	argc = parse_options(argc, argv, prefix, check_attr_options,
-			     check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
+			     builtin_check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
 	if (!argc)
-		usage_with_options(check_attr_usage, check_attr_options);
+		usage_with_options(builtin_check_attr_usage, check_attr_options);
 
 	if (read_cache() < 0) {
 		die("invalid cache");
@@ -98,7 +98,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
 		errstr = "Can't specify files with --stdin";
 	if (errstr) {
 		error("%s", errstr);
-		usage_with_options(check_attr_usage, check_attr_options);
+		usage_with_options(builtin_check_attr_usage, check_attr_options);
 	}
 
 	check = xcalloc(cnt, sizeof(*check));
diff --git a/builtin-checkout.c b/builtin-checkout.c
index d050c37..91d6c5e 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -18,7 +18,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 
-static const char * const checkout_usage[] = {
+static const char * const builtin_checkout_usage[] = {
 	"git checkout [options] <branch>",
 	"git checkout [options] [<branch>] -- <file>...",
 	NULL,
@@ -608,7 +608,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
 	opts.track = BRANCH_TRACK_UNSPECIFIED;
 
-	argc = parse_options(argc, argv, prefix, options, checkout_usage,
+	argc = parse_options(argc, argv, prefix, options, builtin_checkout_usage,
 			     PARSE_OPT_KEEP_DASHDASH);
 
 	if (patch_mode && (opts.track > 0 || opts.new_branch
diff --git a/builtin-clean.c b/builtin-clean.c
index 28cdcd0..562f186 100644
--- a/builtin-clean.c
+++ b/builtin-clean.c
@@ -14,7 +14,7 @@
 
 static int force = -1; /* unset */
 
-static const char *const builtin_clean_usage[] = {
+static const char * const builtin_clean_usage[] = {
 	"git clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...",
 	NULL
 };
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 6467077..2bf4200 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -24,7 +24,8 @@ static void check_valid(unsigned char *sha1, enum object_type expect)
 		    typename(expect));
 }
 
-static const char commit_tree_usage[] = "git commit-tree <sha1> [-p <sha1>]* < changelog";
+static const char builtin_commit_tree_usage[] =
+"git commit-tree <sha1> [-p <sha1>]* < changelog";
 
 static void new_parent(struct commit *parent, struct commit_list **parents_p)
 {
@@ -106,7 +107,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	if (argc < 2)
-		usage(commit_tree_usage);
+		usage(builtin_commit_tree_usage);
 	if (get_sha1(argv[1], tree_sha1))
 		die("Not a valid object name %s", argv[1]);
 
@@ -115,7 +116,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 		const char *a, *b;
 		a = argv[i]; b = argv[i+1];
 		if (!b || strcmp(a, "-p"))
-			usage(commit_tree_usage);
+			usage(builtin_commit_tree_usage);
 
 		if (get_sha1(b, sha1))
 			die("Not a valid object name %s", b);
diff --git a/builtin-config.c b/builtin-config.c
index a2d656e..8db1c4b 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -3,7 +3,7 @@
 #include "color.h"
 #include "parse-options.h"
 
-static const char *const builtin_config_usage[] = {
+static const char * const builtin_config_usage[] = {
 	"git config [options]",
 	NULL
 };
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index 1b0b6c8..fbe0972 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -65,7 +65,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
 	}
 }
 
-static char const * const count_objects_usage[] = {
+static char const * const builtin_count_objects_usage[] = {
 	"git count-objects [-v]",
 	NULL
 };
@@ -83,10 +83,10 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
 		OPT_END(),
 	};
 
-	argc = parse_options(argc, argv, prefix, opts, count_objects_usage, 0);
+	argc = parse_options(argc, argv, prefix, opts, builtin_count_objects_usage, 0);
 	/* we do not take arguments other than flags for now */
 	if (argc)
-		usage_with_options(count_objects_usage, opts);
+		usage_with_options(builtin_count_objects_usage, opts);
 	memcpy(path, objdir, len);
 	if (len && objdir[len-1] != '/')
 		path[len++] = '/';
diff --git a/builtin-describe.c b/builtin-describe.c
index df67a73..46fd6fa 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -9,7 +9,7 @@
 #define SEEN		(1u<<0)
 #define MAX_TAGS	(FLAG_BITS - 1)
 
-static const char * const describe_usage[] = {
+static const char * const builtin_describe_usage[] = {
 	"git describe [options] <committish>*",
 	NULL
 };
@@ -327,7 +327,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
 		OPT_END(),
 	};
 
-	argc = parse_options(argc, argv, prefix, options, describe_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_describe_usage, 0);
 	if (max_candidates < 0)
 		max_candidates = 0;
 	else if (max_candidates > MAX_TAGS)
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 5b64011..edd6127 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -9,7 +9,7 @@
 #include "revision.h"
 #include "builtin.h"
 
-static const char diff_files_usage[] =
+static const char builtin_diff_files_usage[] =
 "git diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
 COMMON_DIFF_OPTIONS_HELP;
 
@@ -34,7 +34,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "-q"))
 			options |= DIFF_SILENT_ON_REMOVED;
 		else
-			usage(diff_files_usage);
+			usage(builtin_diff_files_usage);
 		argv++; argc--;
 	}
 	if (!rev.diffopt.output_format)
@@ -48,7 +48,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	if (rev.pending.nr ||
 	    rev.min_age != -1 || rev.max_age != -1 ||
 	    3 < rev.max_count)
-		usage(diff_files_usage);
+		usage(builtin_diff_files_usage);
 
 	/*
 	 * "diff-files --base -p" should not combine merges because it
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 0483749..dbbbb9a 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -4,7 +4,7 @@
 #include "revision.h"
 #include "builtin.h"
 
-static const char diff_cache_usage[] =
+static const char builtin_diff_index_usage[] =
 "git diff-index [-m] [--cached] "
 "[<common diff options>] <tree-ish> [<path>...]"
 COMMON_DIFF_OPTIONS_HELP;
@@ -27,7 +27,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 		if (!strcmp(arg, "--cached"))
 			cached = 1;
 		else
-			usage(diff_cache_usage);
+			usage(builtin_diff_index_usage);
 	}
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_RAW;
@@ -38,7 +38,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 	 */
 	if (rev.pending.nr != 1 ||
 	    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
-		usage(diff_cache_usage);
+		usage(builtin_diff_index_usage);
 	if (!cached)
 		setup_work_tree();
 	if (read_cache() < 0) {
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 79cedb7..394ed35 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -85,7 +85,7 @@ static int diff_tree_stdin(char *line)
 	return -1;
 }
 
-static const char diff_tree_usage[] =
+static const char builtin_diff_tree_usage[] =
 "git diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
 "[<common diff options>] <tree-ish> [<tree-ish>] [<path>...]\n"
 "  -r            diff recursively\n"
@@ -113,7 +113,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 			read_stdin = 1;
 			continue;
 		}
-		usage(diff_tree_usage);
+		usage(builtin_diff_tree_usage);
 	}
 
 	if (!opt->diffopt.output_format)
@@ -128,7 +128,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
 	switch (nr_sha1) {
 	case 0:
 		if (!read_stdin)
-			usage(diff_tree_usage);
+			usage(builtin_diff_tree_usage);
 		break;
 	case 1:
 		tree1 = opt->pending.objects[0].item;
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index b0a4029..a4a86ba 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -17,7 +17,7 @@
 #include "utf8.h"
 #include "parse-options.h"
 
-static const char *fast_export_usage[] = {
+static const char * const builtin_fast_export_usage[] = {
 	"git fast-export [rev-list-opts]",
 	NULL
 };
@@ -591,7 +591,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 	};
 
 	if (argc == 1)
-		usage_with_options (fast_export_usage, options);
+		usage_with_options(builtin_fast_export_usage, options);
 
 	/* we handle encodings */
 	git_config(git_default_config, NULL);
@@ -601,9 +601,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 	revs.show_source = 1;
 	revs.rewrite_parents = 1;
 	argc = setup_revisions(argc, argv, &revs, NULL);
-	argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_fast_export_usage, 0);
 	if (argc > 1)
-		usage_with_options (fast_export_usage, options);
+		usage_with_options(builtin_fast_export_usage, options);
 
 	if (import_filename)
 		import_marks(import_filename);
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 629735f..d291c19 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -18,7 +18,7 @@ static struct fetch_pack_args args = {
 	/* .uploadpack = */ "git-upload-pack",
 };
 
-static const char fetch_pack_usage[] =
+static const char builtin_fetch_pack_usage[] =
 "git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
 
 #define COMPLETE	(1U << 0)
@@ -734,7 +734,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 				args.no_progress = 1;
 				continue;
 			}
-			usage(fetch_pack_usage);
+			usage(builtin_fetch_pack_usage);
 		}
 		dest = (char *)arg;
 		heads = (char **)(argv + i + 1);
@@ -742,7 +742,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 		break;
 	}
 	if (!dest)
-		usage(fetch_pack_usage);
+		usage(builtin_fetch_pack_usage);
 
 	conn = git_connect(fd, (char *)dest, args.uploadpack,
 			   args.verbose ? CONNECT_VERBOSE : 0);
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 9d52400..0e05038 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -5,7 +5,7 @@
 #include "revision.h"
 #include "tag.h"
 
-static const char * const fmt_merge_msg_usage[] = {
+static const char * const builtin_fmt_merge_msg_usage[] = {
 	"git fmt-merge-msg [--log|--no-log] [--file <file>]",
 	NULL
 };
@@ -360,10 +360,10 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 	int ret;
 
 	git_config(fmt_merge_msg_config, NULL);
-	argc = parse_options(argc, argv, prefix, options, fmt_merge_msg_usage,
+	argc = parse_options(argc, argv, prefix, options, builtin_fmt_merge_msg_usage,
 			     0);
 	if (argc > 0)
-		usage_with_options(fmt_merge_msg_usage, options);
+		usage_with_options(builtin_fmt_merge_msg_usage, options);
 
 	if (inpath && strcmp(inpath, "-")) {
 		in = fopen(inpath, "r");
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index a5a83f1..715d378 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -881,7 +881,7 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
-static char const * const for_each_ref_usage[] = {
+static char const * const builtin_for_each_ref_usage[] = {
 	"git for-each-ref [options] [<pattern>]",
 	NULL
 };
@@ -913,17 +913,17 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
 		OPT_END(),
 	};
 
-	parse_options(argc, argv, prefix, opts, for_each_ref_usage, 0);
+	parse_options(argc, argv, prefix, opts, builtin_for_each_ref_usage, 0);
 	if (maxcount < 0) {
 		error("invalid --count argument: `%d'", maxcount);
-		usage_with_options(for_each_ref_usage, opts);
+		usage_with_options(builtin_for_each_ref_usage, opts);
 	}
 	if (HAS_MULTI_BITS(quote_style)) {
 		error("more than one quoting style?");
-		usage_with_options(for_each_ref_usage, opts);
+		usage_with_options(builtin_for_each_ref_usage, opts);
 	}
 	if (verify_format(format))
-		usage_with_options(for_each_ref_usage, opts);
+		usage_with_options(builtin_for_each_ref_usage, opts);
 
 	if (!sort)
 		sort = default_sort();
diff --git a/builtin-fsck.c b/builtin-fsck.c
index c58b0e3..0857357 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -564,7 +564,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 	return err;
 }
 
-static char const * const fsck_usage[] = {
+static char const * const builtin_fsck_usage[] = {
 	"git fsck [options] [<object>...]",
 	NULL
 };
@@ -591,7 +591,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
 	errors_found = 0;
 	read_replace_refs = 0;
 
-	argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
+	argc = parse_options(argc, argv, prefix, fsck_opts, builtin_fsck_usage, 0);
 	if (write_lost_and_found) {
 		check_full = 1;
 		include_reflogs = 0;
diff --git a/builtin-grep.c b/builtin-grep.c
index 761799d..8eb7534 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -23,7 +23,7 @@
 #endif
 #endif
 
-static char const * const grep_usage[] = {
+static const char * const builtin_grep_usage[] = {
 	"git grep [options] [-e] <pattern> [<rev>...] [[--] path...]",
 	NULL
 };
@@ -813,7 +813,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	 * unrecognized non option is the beginning of the refs list
 	 * that continues up to the -- (if exists), and then paths.
 	 */
-	argc = parse_options(argc, argv, prefix, options, grep_usage,
+	argc = parse_options(argc, argv, prefix, options, builtin_grep_usage,
 			     PARSE_OPT_KEEP_DASHDASH |
 			     PARSE_OPT_STOP_AT_NON_OPTION |
 			     PARSE_OPT_NO_INTERNAL_HELP);
diff --git a/builtin-init-db.c b/builtin-init-db.c
index dd84cae..bf067a9 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -377,7 +377,7 @@ static int shared_callback(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
-static const char *const init_db_usage[] = {
+static const char * const builtin_init_db_usage[] = {
 	"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [directory]",
 	NULL
 };
@@ -406,7 +406,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
+	argc = parse_options(argc, argv, prefix, init_db_options, builtin_init_db_usage, 0);
 
 	if (argc == 1) {
 		int mkdir_tried = 0;
@@ -440,7 +440,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 			die_errno("cannot chdir to %s", argv[0]);
 		}
 	} else if (0 < argc) {
-		usage(init_db_usage[0]);
+		usage(builtin_init_db_usage[0]);
 	}
 	if (is_bare_repository_cfg == 1) {
 		static char git_dir[PATH_MAX+1];
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index f473220..a41356a 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -373,7 +373,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_
 	return errors;
 }
 
-static const char * const ls_files_usage[] = {
+static const char * const builtin_ls_files_usage[] = {
 	"git ls-files [options] [<file>]*",
 	NULL
 };
@@ -482,7 +482,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
-			ls_files_usage, 0);
+			builtin_ls_files_usage, 0);
 	if (show_tag || show_valid_bit) {
 		tag_cached = "H ";
 		tag_unmerged = "M ";
diff --git a/builtin-ls-remote.c b/builtin-ls-remote.c
index 78a88f7..f35d50f 100644
--- a/builtin-ls-remote.c
+++ b/builtin-ls-remote.c
@@ -3,7 +3,7 @@
 #include "transport.h"
 #include "remote.h"
 
-static const char ls_remote_usage[] =
+static const char builtin_ls_remote_usage[] =
 "git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>] <repository> <refs>...";
 
 /*
@@ -66,7 +66,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 				flags |= REF_NORMAL;
 				continue;
 			}
-			usage(ls_remote_usage);
+			usage(builtin_ls_remote_usage);
 		}
 		dest = arg;
 		i++;
@@ -74,7 +74,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 	}
 
 	if (!dest)
-		usage(ls_remote_usage);
+		usage(builtin_ls_remote_usage);
 
 	if (argv[i]) {
 		int j;
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index 22008df..a01eb5e 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -22,8 +22,8 @@ static const char **pathspec;
 static int chomp_prefix;
 static const char *ls_tree_prefix;
 
-static const char ls_tree_usage[] =
-	"git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] <tree-ish> [path...]";
+static const char builtin_ls_tree_usage[] =
+"git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] <tree-ish> [path...]";
 
 static int show_recursive(const char *base, int baselen, const char *pathname)
 {
@@ -172,7 +172,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 			}
 			/* otherwise fallthru */
 		default:
-			usage(ls_tree_usage);
+			usage(builtin_ls_tree_usage);
 		}
 		argc--; argv++;
 	}
@@ -182,7 +182,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 		ls_options |= LS_SHOW_TREES;
 
 	if (argc < 2)
-		usage(ls_tree_usage);
+		usage(builtin_ls_tree_usage);
 	if (get_sha1(argv[1], sha1))
 		die("Not a valid object name %s", argv[1]);
 
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index d498b1c..26c9608 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -1003,8 +1003,8 @@ static int git_mailinfo_config(const char *var, const char *value, void *unused)
 	return 0;
 }
 
-static const char mailinfo_usage[] =
-	"git mailinfo [-k] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] msg patch < mail >info";
+static const char builtin_mailinfo_usage[] =
+"git mailinfo [-k] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] msg patch < mail >info";
 
 int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 {
@@ -1032,12 +1032,12 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 		else if (!strcmp(argv[1], "--no-scissors"))
 			use_scissors = 0;
 		else
-			usage(mailinfo_usage);
+			usage(builtin_mailinfo_usage);
 		argc--; argv++;
 	}
 
 	if (argc != 3)
-		usage(mailinfo_usage);
+		usage(builtin_mailinfo_usage);
 
 	return !!mailinfo(stdin, stdout, argv[1], argv[2]);
 }
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index dfe5b15..ccb26ba 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -9,7 +9,7 @@
 #include "string-list.h"
 #include "strbuf.h"
 
-static const char git_mailsplit_usage[] =
+static const char builtin_mailsplit_usage[] =
 "git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]";
 
 static int is_from_line(const char *line, int len)
@@ -227,7 +227,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 		if ( arg[1] == 'd' ) {
 			nr_prec = strtol(arg+2, NULL, 10);
 			if (nr_prec < 3 || 10 <= nr_prec)
-				usage(git_mailsplit_usage);
+				usage(builtin_mailsplit_usage);
 			continue;
 		} else if ( arg[1] == 'f' ) {
 			nr = strtol(arg+2, NULL, 10);
@@ -259,7 +259,7 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)
 			argp = stdin_only;
 			break;
 		default:
-			usage(git_mailsplit_usage);
+			usage(builtin_mailsplit_usage);
 		}
 	} else {
 		/* New usage: if no more argument, parse stdin */
diff --git a/builtin-merge-base.c b/builtin-merge-base.c
index 54e7ec2..99da43f 100644
--- a/builtin-merge-base.c
+++ b/builtin-merge-base.c
@@ -22,7 +22,7 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 	return 0;
 }
 
-static const char * const merge_base_usage[] = {
+static const char * const builtin_merge_base_usage[] = {
 	"git merge-base [-a|--all] <commit> <commit>...",
 	NULL
 };
@@ -53,9 +53,9 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
 	};
 
 	git_config(git_default_config, NULL);
-	argc = parse_options(argc, argv, prefix, options, merge_base_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_merge_base_usage, 0);
 	if (argc < 2)
-		usage_with_options(merge_base_usage, options);
+		usage_with_options(builtin_merge_base_usage, options);
 	rev = xmalloc(argc * sizeof(*rev));
 	while (argc-- > 0)
 		rev[rev_nr++] = get_commit_reference(*argv++);
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index afd2ea7..42bd479 100644
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
@@ -4,7 +4,7 @@
 #include "xdiff-interface.h"
 #include "parse-options.h"
 
-static const char *const merge_file_usage[] = {
+static const char * const builtin_merge_file_usage[] = {
 	"git merge-file [options] [-L name1 [-L orig [-L name2]]] file1 orig_file file2",
 	NULL
 };
@@ -48,9 +48,9 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 			merge_style = git_xmerge_style;
 	}
 
-	argc = parse_options(argc, argv, prefix, options, merge_file_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_merge_file_usage, 0);
 	if (argc != 3)
-		usage_with_options(merge_file_usage, options);
+		usage_with_options(builtin_merge_file_usage, options);
 	if (quiet) {
 		if (!freopen("/dev/null", "w", stderr))
 			return error("failed to redirect stderr to /dev/null: "
diff --git a/builtin-mktree.c b/builtin-mktree.c
index 098395f..7242a4c 100644
--- a/builtin-mktree.c
+++ b/builtin-mktree.c
@@ -62,7 +62,7 @@ static void write_tree(unsigned char *sha1)
 	write_sha1_file(buf.buf, buf.len, tree_type, sha1);
 }
 
-static const char *mktree_usage[] = {
+static const char * const builtin_mktree_usage[] = {
 	"git mktree [-z] [--missing] [--batch]",
 	NULL
 };
@@ -139,7 +139,7 @@ static void mktree_line(char *buf, size_t len, int line_termination, int allow_m
 	append_to_tree(mode, sha1, path);
 }
 
-int cmd_mktree(int ac, const char **av, const char *prefix)
+int cmd_mktree(int argc, const char **argv, const char *prefix)
 {
 	struct strbuf sb = STRBUF_INIT;
 	unsigned char sha1[20];
@@ -155,7 +155,7 @@ int cmd_mktree(int ac, const char **av, const char *prefix)
 		OPT_END()
 	};
 
-	ac = parse_options(ac, av, prefix, option, mktree_usage, 0);
+	argc = parse_options(argc, argv, prefix, option, builtin_mktree_usage, 0);
 
 	while (!got_eof) {
 		while (1) {
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index 06a38ac..d8913e3 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -171,7 +171,7 @@ static void show_name(const struct object *obj,
 		die("cannot describe '%s'", sha1_to_hex(sha1));
 }
 
-static char const * const name_rev_usage[] = {
+static const char * const builtin_name_rev_usage[] = {
 	"git name-rev [options] ( --all | --stdin | <commit>... )",
 	NULL
 };
@@ -238,10 +238,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
 	};
 
 	git_config(git_default_config, NULL);
-	argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
+	argc = parse_options(argc, argv, prefix, opts, builtin_name_rev_usage, 0);
 	if (!!all + !!transform_stdin + !!argc > 1) {
 		error("Specify either a list, or --all, not both!");
-		usage_with_options(name_rev_usage, opts);
+		usage_with_options(builtin_name_rev_usage, opts);
 	}
 	if (all || transform_stdin)
 		cutoff = 0;
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 02f9246..a778246 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -22,7 +22,7 @@
 #include <pthread.h>
 #endif
 
-static const char pack_usage[] =
+static const char builtin_pack_objects_usage[] =
   "git pack-objects [{ -q | --progress | --all-progress }]\n"
   "        [--max-pack-size=N] [--local] [--incremental]\n"
   "        [--window=N] [--window-memory=N] [--depth=N]\n"
@@ -2166,7 +2166,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			char *end;
 			int level = strtoul(arg+14, &end, 0);
 			if (!arg[14] || *end)
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 			if (level == -1)
 				level = Z_DEFAULT_COMPRESSION;
 			else if (level < 0 || level > Z_BEST_COMPRESSION)
@@ -2179,26 +2179,26 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			pack_size_limit_cfg = 0;
 			pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
 			if (!arg[16] || *end)
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 			continue;
 		}
 		if (!prefixcmp(arg, "--window=")) {
 			char *end;
 			window = strtoul(arg+9, &end, 0);
 			if (!arg[9] || *end)
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 			continue;
 		}
 		if (!prefixcmp(arg, "--window-memory=")) {
 			if (!git_parse_ulong(arg+16, &window_memory_limit))
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 			continue;
 		}
 		if (!prefixcmp(arg, "--threads=")) {
 			char *end;
 			delta_search_threads = strtoul(arg+10, &end, 0);
 			if (!arg[10] || *end || delta_search_threads < 0)
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 #ifndef THREADED_DELTA_SEARCH
 			if (delta_search_threads != 1)
 				warning("no threads support, "
@@ -2210,7 +2210,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			char *end;
 			depth = strtoul(arg+8, &end, 0);
 			if (!arg[8] || *end)
-				usage(pack_usage);
+				usage(builtin_pack_objects_usage);
 			continue;
 		}
 		if (!strcmp("--progress", arg)) {
@@ -2290,7 +2290,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 			grafts_replace_parents = 0;
 			continue;
 		}
-		usage(pack_usage);
+		usage(builtin_pack_objects_usage);
 	}
 
 	/* Traditionally "pack-objects [options] base extra" failed;
@@ -2310,7 +2310,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		base_name = argv[i++];
 
 	if (pack_to_stdout != !base_name)
-		usage(pack_usage);
+		usage(builtin_pack_objects_usage);
 
 	if (!pack_to_stdout && !pack_size_limit)
 		pack_size_limit = pack_size_limit_cfg;
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 091860b..3ec3c2f 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -2,7 +2,7 @@
 #include "parse-options.h"
 #include "pack-refs.h"
 
-static char const * const pack_refs_usage[] = {
+static const char * const builtin_pack_refs_usage[] = {
 	"git pack-refs [options]",
 	NULL
 };
@@ -15,7 +15,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
 		OPT_BIT(0, "prune", &flags, "prune loose refs (default)", PACK_REFS_PRUNE),
 		OPT_END(),
 	};
-	if (parse_options(argc, argv, prefix, opts, pack_refs_usage, 0))
-		usage_with_options(pack_refs_usage, opts);
+	if (parse_options(argc, argv, prefix, opts, builtin_pack_refs_usage, 0))
+		usage_with_options(builtin_pack_refs_usage, opts);
 	return pack_refs(flags);
 }
diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c
index be99eb0..5acc130 100644
--- a/builtin-prune-packed.c
+++ b/builtin-prune-packed.c
@@ -3,7 +3,7 @@
 #include "progress.h"
 #include "parse-options.h"
 
-static const char * const prune_packed_usage[] = {
+static const char * const builtin_prune_packed_usage[] = {
 	"git prune-packed [-n|--dry-run] [-q|--quiet]",
 	NULL
 };
@@ -79,7 +79,7 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
 	};
 
 	argc = parse_options(argc, argv, prefix, prune_packed_options,
-			     prune_packed_usage, 0);
+			     builtin_prune_packed_usage, 0);
 
 	prune_packed_objects(opts);
 	return 0;
diff --git a/builtin-prune.c b/builtin-prune.c
index 8459aec..6cf3555 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -7,7 +7,7 @@
 #include "parse-options.h"
 #include "dir.h"
 
-static const char * const prune_usage[] = {
+static const char * const builtin_prune_usage[] = {
 	"git prune [-n] [-v] [--expire <time>] [--] [<head>...]",
 	NULL
 };
@@ -143,7 +143,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 	read_replace_refs = 0;
 	init_revisions(&revs, prefix);
 
-	argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_prune_usage, 0);
 	while (argc--) {
 		unsigned char sha1[20];
 		const char *name = *argv++;
diff --git a/builtin-push.c b/builtin-push.c
index 3cb1ee4..64b1b6e 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -9,7 +9,7 @@
 #include "transport.h"
 #include "parse-options.h"
 
-static const char * const push_usage[] = {
+static const char * const builtin_push_usage[] = {
 	"git push [--all | --mirror] [-n | --dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
 	NULL,
 };
@@ -191,7 +191,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_push_usage, 0);
 
 	if (tags)
 		add_refspec("refs/tags/*");
@@ -203,7 +203,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 
 	rc = do_push(repo, flags);
 	if (rc == -1)
-		usage_with_options(push_usage, options);
+		usage_with_options(builtin_push_usage, options);
 	else
 		return rc;
 }
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 14c836b..483d083 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -30,7 +30,7 @@ static int list_tree(unsigned char *sha1)
 	return 0;
 }
 
-static const char * const read_tree_usage[] = {
+static const char * const builtin_read_tree_usage[] = {
 	"git read-tree [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>] [-u [--exclude-per-directory=<gitignore>] | -i]]  [--index-output=<file>] <tree-ish1> [<tree-ish2> [<tree-ish3>]]",
 	NULL
 };
@@ -111,7 +111,7 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 	newfd = hold_locked_index(&lock_file, 1);
 
 	argc = parse_options(argc, argv, unused_prefix, read_tree_options,
-			     read_tree_usage, 0);
+			     builtin_read_tree_usage, 0);
 
 	prefix_set = opts.prefix ? 1 : 0;
 	if (1 < opts.merge + opts.reset + prefix_set)
diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index b771fe9..42a21c9 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -9,7 +9,7 @@
 #include "remote.h"
 #include "transport.h"
 
-static const char receive_pack_usage[] = "git receive-pack <git-dir>";
+static const char builtin_receive_pack_usage[] = "git receive-pack <git-dir>";
 
 enum deny_action {
 	DENY_UNCONFIGURED,
@@ -624,14 +624,14 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 
 		if (*arg == '-') {
 			/* Do flag handling here */
-			usage(receive_pack_usage);
+			usage(builtin_receive_pack_usage);
 		}
 		if (dir)
-			usage(receive_pack_usage);
+			usage(builtin_receive_pack_usage);
 		dir = xstrdup(arg);
 	}
 	if (!dir)
-		usage(receive_pack_usage);
+		usage(builtin_receive_pack_usage);
 
 	setup_path();
 
diff --git a/builtin-reflog.c b/builtin-reflog.c
index e23b5ef..940c39a 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -693,7 +693,7 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
  * main "reflog"
  */
 
-static const char reflog_usage[] =
+static const char builtin_reflog_usage[] =
 "git reflog [ show | expire | delete ]";
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
@@ -712,5 +712,5 @@ int cmd_reflog(int argc, const char **argv, const char *prefix)
 		return cmd_reflog_delete(argc - 1, argv + 1, prefix);
 
 	/* Not a recognized reflog command..*/
-	usage(reflog_usage);
+	usage(builtin_reflog_usage);
 }
diff --git a/builtin-replace.c b/builtin-replace.c
index fe3a647..f855437 100644
--- a/builtin-replace.c
+++ b/builtin-replace.c
@@ -13,7 +13,7 @@
 #include "refs.h"
 #include "parse-options.h"
 
-static const char * const git_replace_usage[] = {
+static const char * const builtin_replace_usage[] = {
 	"git replace [-f] <object> <replacement>",
 	"git replace -d <object>...",
 	"git replace -l [<pattern>]",
@@ -121,21 +121,21 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_replace_usage, 0);
 
 	if (list && delete)
 		usage_msg_opt("-l and -d cannot be used together",
-			      git_replace_usage, options);
+			      builtin_replace_usage, options);
 
 	if (force && (list || delete))
 		usage_msg_opt("-f cannot be used with -d or -l",
-			      git_replace_usage, options);
+			      builtin_replace_usage, options);
 
 	/* Delete refs */
 	if (delete) {
 		if (argc < 1)
 			usage_msg_opt("-d needs at least one argument",
-				      git_replace_usage, options);
+				      builtin_replace_usage, options);
 		return for_each_replace_name(argv, delete_replace_ref);
 	}
 
@@ -143,17 +143,17 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 	if (!list && argc) {
 		if (argc != 2)
 			usage_msg_opt("bad number of arguments",
-				      git_replace_usage, options);
+				      builtin_replace_usage, options);
 		return replace_object(argv[0], argv[1], force);
 	}
 
 	/* List refs, even if "list" is not set */
 	if (argc > 1)
 		usage_msg_opt("only one pattern can be given with -l",
-			      git_replace_usage, options);
+			      builtin_replace_usage, options);
 	if (force)
 		usage_msg_opt("-f needs some arguments",
-			      git_replace_usage, options);
+			      builtin_replace_usage, options);
 
 	return list_replace_refs(argv[0]);
 }
diff --git a/builtin-rerere.c b/builtin-rerere.c
index adfb7b5..f19a0d3 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -6,7 +6,7 @@
 #include "xdiff/xdiff.h"
 #include "xdiff-interface.h"
 
-static const char git_rerere_usage[] =
+static const char builtin_rerere_usage[] =
 "git rerere [clear | status | diff | gc]";
 
 /* these values are days */
@@ -129,7 +129,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 			diff_two(rerere_path(name, "preimage"), path, path, path);
 		}
 	else
-		usage(git_rerere_usage);
+		usage(builtin_rerere_usage);
 
 	string_list_clear(&merge_rr, 1);
 	return 0;
diff --git a/builtin-reset.c b/builtin-reset.c
index 73e6022..fe78fbd 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -19,7 +19,7 @@
 #include "branch.h"
 #include "parse-options.h"
 
-static const char * const git_reset_usage[] = {
+static const char * const builtin_reset_usage[] = {
 	"git reset [--mixed | --soft | --hard | --merge] [-q] [<commit>]",
 	"git reset [--mixed] <commit> [--] <paths>...",
 	NULL
@@ -217,7 +217,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
 
 	git_config(git_default_config, NULL);
 
-	argc = parse_options(argc, argv, prefix, options, git_reset_usage,
+	argc = parse_options(argc, argv, prefix, options, builtin_reset_usage,
 						PARSE_OPT_KEEP_DASHDASH);
 	reflog_action = args_to_str(argv);
 	setenv("GIT_REFLOG_ACTION", reflog_action, 0);
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 4ba1c12..983039e 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -8,7 +8,7 @@
 #include "graph.h"
 #include "bisect.h"
 
-static const char rev_list_usage[] =
+static const char builtin_rev_list_usage[] =
 "git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
 "  limiting output:\n"
 "    --max-count=nr\n"
@@ -354,7 +354,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 			read_revisions_from_stdin(&revs);
 			continue;
 		}
-		usage(rev_list_usage);
+		usage(builtin_rev_list_usage);
 
 	}
 	if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
@@ -373,7 +373,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 	     (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
 	      !revs.pending.nr)) ||
 	    revs.diff)
-		usage(rev_list_usage);
+		usage(builtin_rev_list_usage);
 
 	save_commit_buffer = revs.verbose_header ||
 		revs.grep_filter.pattern_list;
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 45bead6..c91b056 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -302,7 +302,7 @@ static const char *skipspaces(const char *s)
 static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 {
 	static int keep_dashdash = 0, stop_at_non_option = 0;
-	static char const * const parseopt_usage[] = {
+	static const char * const parseopt_usage[] = {
 		"git rev-parse --parseopt [options] -- [<args>...]",
 		NULL
 	};
diff --git a/builtin-revert.c b/builtin-revert.c
index 151aa6a..918b3c2 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -25,12 +25,12 @@
  * Copyright (c) 2005 Junio C Hamano
  */
 
-static const char * const revert_usage[] = {
+static const char * const builtin_revert_usage[] = {
 	"git revert [options] <commit-ish>",
 	NULL
 };
 
-static const char * const cherry_pick_usage[] = {
+static const char * const builtin_cherry_pick_usage[] = {
 	"git cherry-pick [options] <commit-ish>",
 	NULL
 };
@@ -46,7 +46,7 @@ static const char *me;
 static void parse_args(int argc, const char **argv)
 {
 	const char * const * usage_str =
-		action == REVERT ?  revert_usage : cherry_pick_usage;
+		action == REVERT ?  builtin_revert_usage : builtin_cherry_pick_usage;
 	unsigned char sha1[20];
 	const char *arg;
 	int noop;
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 37e528e..20a2476 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -6,7 +6,7 @@
 #include "remote.h"
 #include "send-pack.h"
 
-static const char send_pack_usage[] =
+static const char builtin_send_pack_usage[] =
 "git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
 "  --all and explicit <ref> specification are mutually exclusive.";
 
@@ -523,7 +523,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 				args.use_thin_pack = 1;
 				continue;
 			}
-			usage(send_pack_usage);
+			usage(builtin_send_pack_usage);
 		}
 		if (!dest) {
 			dest = arg;
@@ -534,14 +534,14 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
 		break;
 	}
 	if (!dest)
-		usage(send_pack_usage);
+		usage(builtin_send_pack_usage);
 	/*
 	 * --all and --mirror are incompatible; neither makes sense
 	 * with any refspecs.
 	 */
 	if ((refspecs && (send_all || args.send_mirror)) ||
 	    (send_all && args.send_mirror))
-		usage(send_pack_usage);
+		usage(builtin_send_pack_usage);
 
 	if (remote_name) {
 		remote = remote_get(remote_name);
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 4d4a3c8..1ce930a 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -9,7 +9,7 @@
 #include "shortlog.h"
 #include "parse-options.h"
 
-static char const * const shortlog_usage[] = {
+static const char * const builtin_shortlog_usage[] = {
 	"git shortlog [-n] [-s] [-e] [-w] [rev-opts] [--] [<commit-id>... ]",
 	"",
 	"[rev-opts] are documented in git-rev-list(1)",
@@ -267,20 +267,20 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 			    PARSE_OPT_KEEP_ARGV0);
 
 	for (;;) {
-		switch (parse_options_step(&ctx, options, shortlog_usage)) {
+		switch (parse_options_step(&ctx, options, builtin_shortlog_usage)) {
 		case PARSE_OPT_HELP:
 			exit(129);
 		case PARSE_OPT_DONE:
 			goto parse_done;
 		}
-		parse_revision_opt(&rev, &ctx, options, shortlog_usage);
+		parse_revision_opt(&rev, &ctx, options, builtin_shortlog_usage);
 	}
 parse_done:
 	argc = parse_options_end(&ctx);
 
 	if (setup_revisions(argc, argv, &rev, NULL) != 1) {
 		error("unrecognized argument: %s", argv[1]);
-		usage_with_options(shortlog_usage, options);
+		usage_with_options(builtin_shortlog_usage, options);
 	}
 
 	log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 3510a86..d1889ac 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -5,7 +5,7 @@
 #include "color.h"
 #include "parse-options.h"
 
-static const char* show_branch_usage[] = {
+static const char * const builtin_show_branch_usage[] = {
     "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [<rev> | <glob>]...",
     "git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]",
     NULL
@@ -697,7 +697,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 	}
 
 	ac = parse_options(ac, av, prefix, builtin_show_branch_options,
-			   show_branch_usage, PARSE_OPT_STOP_AT_NON_OPTION);
+			   builtin_show_branch_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 	if (all_heads)
 		all_remotes = 1;
 
@@ -706,7 +706,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 		 * independent nor merge-base modes.
 		 */
 		if (independent || merge_base)
-			usage_with_options(show_branch_usage,
+			usage_with_options(builtin_show_branch_usage,
 					   builtin_show_branch_options);
 		if (reflog && ((0 < extra) || all_heads || all_remotes))
 			/*
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index c46550c..41844d1 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -6,7 +6,7 @@
 #include "string-list.h"
 #include "parse-options.h"
 
-static const char * const show_ref_usage[] = {
+static const char * const builtin_show_ref_usage[] = {
 	"git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags] [--heads] [--] [pattern*] ",
 	"git show-ref --exclude-existing[=pattern] < ref-list",
 	NULL
@@ -202,7 +202,7 @@ static const struct option show_ref_options[] = {
 int cmd_show_ref(int argc, const char **argv, const char *prefix)
 {
 	argc = parse_options(argc, argv, prefix, show_ref_options,
-			     show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);
+			     builtin_show_ref_usage, PARSE_OPT_NO_INTERNAL_HELP);
 
 	if (exclude_arg)
 		return exclude_existing(exclude_existing_arg);
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index ca855a5..72b8343 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -3,7 +3,7 @@
 #include "refs.h"
 #include "parse-options.h"
 
-static const char * const git_symbolic_ref_usage[] = {
+static const char * const builtin_symbolic_ref_usage[] = {
 	"git symbolic-ref [options] name [ref]",
 	NULL
 };
@@ -37,7 +37,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, prefix, options,
-			     git_symbolic_ref_usage, 0);
+			     builtin_symbolic_ref_usage, 0);
 	if (msg &&!*msg)
 		die("Refusing to perform update with empty message");
 	switch (argc) {
@@ -51,7 +51,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
 		create_symref(argv[0], argv[1], msg);
 		break;
 	default:
-		usage_with_options(git_symbolic_ref_usage, options);
+		usage_with_options(builtin_symbolic_ref_usage, options);
 	}
 	return 0;
 }
diff --git a/builtin-tag.c b/builtin-tag.c
index c479018..b19562b 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -13,7 +13,7 @@
 #include "run-command.h"
 #include "parse-options.h"
 
-static const char * const git_tag_usage[] = {
+static const char * const builtin_tag_usage[] = {
 	"git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
 	"git tag -d <tagname>...",
 	"git tag -l [-n[<num>]] [<pattern>]",
@@ -404,7 +404,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	git_config(git_tag_config, NULL);
 
-	argc = parse_options(argc, argv, prefix, options, git_tag_usage, 0);
+	argc = parse_options(argc, argv, prefix, options, builtin_tag_usage, 0);
 
 	if (keyid) {
 		sign = 1;
@@ -417,10 +417,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
 
 	if ((annotate || msg.given || msgfile || force) &&
 	    (list || delete || verify))
-		usage_with_options(git_tag_usage, options);
+		usage_with_options(builtin_tag_usage, options);
 
 	if (list + delete + verify > 1)
-		usage_with_options(git_tag_usage, options);
+		usage_with_options(builtin_tag_usage, options);
 	if (list)
 		return list_tags(argv[0], lines == -1 ? 0 : lines,
 				 with_commit);
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 8b3a35e..278ccac 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -7,7 +7,7 @@
 #include "builtin.h"
 #include "quote.h"
 
-static const char tar_tree_usage[] =
+static const char builtin_tar_tree_usage[] =
 "git tar-tree [--remote=<repo>] <tree-ish> [basedir]\n"
 "*** Note that this command is now deprecated; use \"git archive\" instead.";
 
@@ -45,7 +45,7 @@ int cmd_tar_tree(int argc, const char **argv, const char *prefix)
 
 	switch (argc) {
 	default:
-		usage(tar_tree_usage);
+		usage(builtin_tar_tree_usage);
 		break;
 	case 3:
 		/* base-path */
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 685566e..f571131 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -13,7 +13,8 @@
 #include "fsck.h"
 
 static int dry_run, quiet, recover, has_errors, strict;
-static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict] < pack-file";
+static const char builtin_unpack_usage[] =
+"git unpack-objects [-n] [-q] [-r] [--strict] < pack-file";
 
 /* We always read in 4kB chunks. */
 static unsigned char buffer[4096];
@@ -538,11 +539,11 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
 				len = sizeof(*hdr);
 				continue;
 			}
-			usage(unpack_usage);
+			usage(builtin_unpack_usage);
 		}
 
 		/* We don't take any non-flag arguments now.. Maybe some day */
-		usage(unpack_usage);
+		usage(builtin_unpack_usage);
 	}
 	git_SHA1_Init(&ctx);
 	unpack_all();
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 92beaaf..69133d6 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -387,7 +387,7 @@ static void read_index_info(int line_termination)
 	strbuf_release(&uq);
 }
 
-static const char update_index_usage[] =
+static const char builtin_update_index_usage[] =
 "git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
 
 static unsigned char head_sha1[20];
@@ -703,7 +703,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
 				continue;
 			}
 			if (!strcmp(path, "-h") || !strcmp(path, "--help"))
-				usage(update_index_usage);
+				usage(builtin_update_index_usage);
 			die("unknown option %s", path);
 		}
 		setup_work_tree();
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 76ba1d5..ab8f401 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -3,7 +3,7 @@
 #include "builtin.h"
 #include "parse-options.h"
 
-static const char * const git_update_ref_usage[] = {
+static const char * const builtin_update_ref_usage[] = {
 	"git update-ref [options] -d <refname> [<oldval>]",
 	"git update-ref [options]    <refname> <newval> [<oldval>]",
 	NULL
@@ -23,20 +23,20 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
 	};
 
 	git_config(git_default_config, NULL);
-	argc = parse_options(argc, argv, prefix, options, git_update_ref_usage,
+	argc = parse_options(argc, argv, prefix, options, builtin_update_ref_usage,
 			     0);
 	if (msg && !*msg)
 		die("Refusing to perform update with empty message.");
 
 	if (delete) {
 		if (argc < 1 || argc > 2)
-			usage_with_options(git_update_ref_usage, options);
+			usage_with_options(builtin_update_ref_usage, options);
 		refname = argv[0];
 		oldval = argv[1];
 	} else {
 		const char *value;
 		if (argc < 2 || argc > 3)
-			usage_with_options(git_update_ref_usage, options);
+			usage_with_options(builtin_update_ref_usage, options);
 		refname = argv[0];
 		value = argv[1];
 		oldval = argv[2];
diff --git a/builtin-update-server-info.c b/builtin-update-server-info.c
index 2b3fddc..fd6c8aa 100644
--- a/builtin-update-server-info.c
+++ b/builtin-update-server-info.c
@@ -2,7 +2,7 @@
 #include "builtin.h"
 #include "parse-options.h"
 
-static const char * const update_server_info_usage[] = {
+static const char * const builtin_update_server_info_usage[] = {
 	"git update-server-info [--force]",
 	NULL
 };
@@ -17,9 +17,9 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix)
 	};
 
 	argc = parse_options(argc, argv, prefix, options,
-			     update_server_info_usage, 0);
+			     builtin_update_server_info_usage, 0);
 	if (argc > 0)
-		usage_with_options(update_server_info_usage, options);
+		usage_with_options(builtin_update_server_info_usage, options);
 
 	return !!update_server_info(force);
 }
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index c4cd1e1..480a857 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -7,8 +7,7 @@
 #include "pkt-line.h"
 #include "sideband.h"
 
-static const char upload_archive_usage[] =
-	"git upload-archive <repo>";
+static const char builtin_upload_archive_usage[] = "git upload-archive <repo>";
 
 static const char deadchild[] =
 "git upload-archive: archiver died with error";
@@ -27,7 +26,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
 	int len;
 
 	if (argc != 2)
-		usage(upload_archive_usage);
+		usage(builtin_upload_archive_usage);
 
 	if (strlen(argv[1]) + 1 > sizeof(buf))
 		die("insanely long repository name");
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index b6079ae..6759520 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -133,7 +133,7 @@ static int verify_one_pack(const char *path, unsigned int flags)
 	return err;
 }
 
-static const char * const verify_pack_usage[] = {
+static const char * const builtin_verify_pack_usage[] = {
 	"git verify-pack [-v|--verbose] [-s|--stat-only] <pack>...",
 	NULL
 };
@@ -153,9 +153,9 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
 
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, prefix, verify_pack_options,
-			     verify_pack_usage, 0);
+			     builtin_verify_pack_usage, 0);
 	if (argc < 1)
-		usage_with_options(verify_pack_usage, verify_pack_options);
+		usage_with_options(builtin_verify_pack_usage, verify_pack_options);
 	for (i = 0; i < argc; i++) {
 		if (verify_one_pack(argv[i], flags))
 			err = 1;
diff --git a/builtin-verify-tag.c b/builtin-verify-tag.c
index 9f482c2..4f41301 100644
--- a/builtin-verify-tag.c
+++ b/builtin-verify-tag.c
@@ -12,7 +12,7 @@
 #include <signal.h>
 #include "parse-options.h"
 
-static const char * const verify_tag_usage[] = {
+static const char * const builtin_verify_tag_usage[] = {
 		"git verify-tag [-v|--verbose] <tag>...",
 		NULL
 };
@@ -100,9 +100,9 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
 	git_config(git_default_config, NULL);
 
 	argc = parse_options(argc, argv, prefix, verify_tag_options,
-			     verify_tag_usage, PARSE_OPT_KEEP_ARGV0);
+			     builtin_verify_tag_usage, PARSE_OPT_KEEP_ARGV0);
 	if (argc <= i)
-		usage_with_options(verify_tag_usage, verify_tag_options);
+		usage_with_options(builtin_verify_tag_usage, verify_tag_options);
 
 	/* sometimes the program was terminated because this signal
 	 * was received in the process of writing the gpg input: */
diff --git a/builtin-write-tree.c b/builtin-write-tree.c
index b223af4..013de8e 100644
--- a/builtin-write-tree.c
+++ b/builtin-write-tree.c
@@ -9,7 +9,7 @@
 #include "cache-tree.h"
 #include "parse-options.h"
 
-static const char * const write_tree_usage[] = {
+static const char * const builtin_write_tree_usage[] = {
 	"git write-tree [--missing-ok] [--prefix=<prefix>/]",
 	NULL
 };
@@ -35,7 +35,7 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
 
 	git_config(git_default_config, NULL);
 	argc = parse_options(argc, argv, unused_prefix, write_tree_options,
-			     write_tree_usage, 0);
+			     builtin_write_tree_usage, 0);
 
 	ret = write_cache_as_tree(sha1, flags, prefix);
 	switch (ret) {
-- 
1.6.5.rc1.37.gf5c31

^ permalink raw reply related

* [PATCH RESEND] git gui: make current branch default in "remote delete branch" merge check
From: Heiko Voigt @ 2009-09-20  9:47 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
 git-gui/lib/remote_branch_delete.tcl |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/git-gui/lib/remote_branch_delete.tcl b/git-gui/lib/remote_branch_delete.tcl
index 4e02fc0..9b119a7 100644
--- a/git-gui/lib/remote_branch_delete.tcl
+++ b/git-gui/lib/remote_branch_delete.tcl
@@ -248,6 +248,8 @@ method _write_url        {args} { set urltype url    }
 method _write_check_head {args} { set checktype head }
 
 method _write_head_list {args} {
+	global current_branch
+
 	$head_m delete 0 end
 	foreach abr $head_list {
 		$head_m insert end radiobutton \
@@ -256,7 +258,11 @@ method _write_head_list {args} {
 			-variable @check_head
 	}
 	if {[lsearch -exact -sorted $head_list $check_head] < 0} {
-		set check_head {}
+		if {[lsearch -exact -sorted $head_list $current_branch] < 0} {
+			set check_head {}
+		} else {
+			set check_head $current_branch
+		}
 	}
 }
 
-- 
1.6.5.rc1.10.g20f34

^ permalink raw reply related

* [WIP PATCH 5/6] unpack-trees.c: prepare for looking ahead in the index
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

This prepares but does not yet implement a look-ahead in the index entries
when traverse-trees.c decides to give us tree entries in an order that
does not match what is in the index.

A case where a look-ahead in the index is necessary happens when merging
branch B into branch A while the index matches the current branch A, using
a tree O as their common ancestor, and these three trees looks like this:

   O        A       B
   t                t
   t-i      t-i     t-i
   t-j      t-j
            t/1
            t/2

The traverse_trees() function gets "t", "t-i" and "t" from trees O, A and
B first, and notices that A may have a matching "t" behind "t-i" and "t-j"
(indeed it does), and tells A to give that entry instead.  After unpacking
blob "t" from tree B (as it hasn't changed since O in B and A removed it,
it will result in its removal), it descends into directory "t/".

The side that walked index in parallel to the tree traversal used to be
implemented with one pointer, o->pos, that points at the next index entry
to be processed.  When this happens, the pointer o->pos still points at
"t-i" that is the first entry.  We should be able to skip "t-i" and "t-j"
and locate "t/1" from the index while the recursive invocation of
traverse_trees() walks and match entries found there, and later come back
to process "t-i".

While that look-ahead is not implemented yet, this adds a flag bit,
CE_UNPACKED, to mark the entries in the index that has already been
processed.  o->pos pointer has been renamed to o->cache_bottom and it
points at the first entry that may still need to be processed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * t6035 is still broken with this patch, although t7003 is fixed.

 cache.h        |    2 +
 diff-lib.c     |   18 -----
 unpack-trees.c |  214 ++++++++++++++++++++++++++++++++++++++++++--------------
 unpack-trees.h |    2 +-
 4 files changed, 164 insertions(+), 72 deletions(-)

diff --git a/cache.h b/cache.h
index 5fad24c..18a3e13 100644
--- a/cache.h
+++ b/cache.h
@@ -177,6 +177,8 @@ struct cache_entry {
 #define CE_HASHED    (0x100000)
 #define CE_UNHASHED  (0x200000)
 
+#define CE_UNPACKED  (0x400000)
+
 /*
  * Extended on-disk flags
  */
diff --git a/diff-lib.c b/diff-lib.c
index adf1c5f..f759917 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -359,21 +359,6 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 	show_modified(revs, tree, idx, 1, cached, match_missing);
 }
 
-static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
-{
-	int len = ce_namelen(ce);
-	const struct index_state *index = o->src_index;
-
-	while (o->pos < index->cache_nr) {
-		struct cache_entry *next = index->cache[o->pos];
-		if (len != ce_namelen(next))
-			break;
-		if (memcmp(ce->name, next->name, len))
-			break;
-		o->pos++;
-	}
-}
-
 /*
  * The unpack_trees() interface is designed for merging, so
  * the different source entries are designed primarily for
@@ -395,9 +380,6 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
 	struct cache_entry *tree = src[1];
 	struct rev_info *revs = o->unpack_data;
 
-	if (idx && ce_stage(idx))
-		skip_same_name(idx, o);
-
 	/*
 	 * Unpack-trees generates a DF/conflict entry if
 	 * there was a directory in the index and a tree
diff --git a/unpack-trees.c b/unpack-trees.c
index c424bab..a6f2187 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -126,18 +126,109 @@ static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_o
 	return ret;
 }
 
-static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o)
+static void mark_ce_used(struct cache_entry *ce, struct unpack_trees_options *o)
+{
+	ce->ce_flags |= CE_UNPACKED;
+
+	if (o->cache_bottom < o->src_index->cache_nr &&
+	    o->src_index->cache[o->cache_bottom] == ce) {
+		int bottom = o->cache_bottom;
+		while (bottom < o->src_index->cache_nr &&
+		       o->src_index->cache[bottom]->ce_flags & CE_UNPACKED)
+			bottom++;
+		o->cache_bottom = bottom;
+	}
+}
+
+static void mark_all_ce_unused(struct index_state *index)
+{
+	int i;
+	for (i = 0; i < index->cache_nr; i++)
+		index->cache[i]->ce_flags &= ~CE_UNPACKED;
+}
+
+static int locate_in_src_index(struct cache_entry *ce,
+			       struct unpack_trees_options *o)
+{
+	struct index_state *index = o->src_index;
+	int len = ce_namelen(ce);
+	int pos = index_name_pos(index, ce->name, len);
+	if (pos < 0)
+		pos = -1 - pos;
+	return pos;
+}
+
+/*
+ * We call unpack_index_entry() with an unmerged cache entry
+ * only in diff-index, and it wants a single callback.  Skip
+ * the other unmerged entry with the same name.
+ */
+static void mark_ce_used_same_name(struct cache_entry *ce,
+				   struct unpack_trees_options *o)
+{
+	struct index_state *index = o->src_index;
+	int len = ce_namelen(ce);
+	int pos;
+
+	for (pos = locate_in_src_index(ce, o); pos < index->cache_nr; pos++) {
+		struct cache_entry *next = index->cache[pos];
+		if (len != ce_namelen(next) ||
+		    memcmp(ce->name, next->name, len))
+			break;
+		mark_ce_used(next, o);
+	}
+}
+
+static struct cache_entry *next_cache_entry(struct unpack_trees_options *o)
+{
+	const struct index_state *index = o->src_index;
+	int pos = o->cache_bottom;
+
+	while (pos < index->cache_nr) {
+		struct cache_entry *ce = index->cache[pos];
+		if (!(ce->ce_flags & CE_UNPACKED))
+			return ce;
+		pos++;
+	}
+	return NULL;
+}
+
+static void add_same_unmerged(struct cache_entry *ce,
+			      struct unpack_trees_options *o)
+{
+	struct index_state *index = o->src_index;
+	int len = ce_namelen(ce);
+	int pos = index_name_pos(index, ce->name, len);
+
+	if (0 <= pos)
+		die("programming error in a caller of mark_ce_used_same_name");
+	for (pos = -pos - 1; pos < index->cache_nr; pos++) {
+		struct cache_entry *next = index->cache[pos];
+		if (len != ce_namelen(next) ||
+		    memcmp(ce->name, next->name, len))
+			break;
+		add_entry(o, next, 0, 0);
+		mark_ce_used(next, o);
+	}
+}
+
+static int unpack_index_entry(struct cache_entry *ce,
+			      struct unpack_trees_options *o)
 {
 	struct cache_entry *src[5] = { ce, NULL, };
+	int ret;
 
-	o->pos++;
+	mark_ce_used(ce, o);
 	if (ce_stage(ce)) {
 		if (o->skip_unmerged) {
 			add_entry(o, ce, 0, 0);
 			return 0;
 		}
 	}
-	return call_unpack_fn(src, o);
+	ret = call_unpack_fn(src, o);
+	if (ce_stage(ce))
+		mark_ce_used_same_name(ce, o);
+	return ret;
 }
 
 static int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
@@ -212,6 +303,20 @@ static int compare_entry(const struct cache_entry *ce, const struct traverse_inf
 	return ce_namelen(ce) > traverse_path_len(info, n);
 }
 
+static int ce_in_traverse_path(const struct cache_entry *ce,
+			       const struct traverse_info *info)
+{
+	if (!info->prev)
+		return 1;
+	if (do_compare_entry(ce, info->prev, &info->name))
+		return 0;
+	/*
+	 * If ce (blob) is the same name as the path (which is a tree
+	 * we will be descending into), it won't be inside it.
+	 */
+	return (info->pathlen < ce_namelen(ce));
+}
+
 static struct cache_entry *create_ce_entry(const struct traverse_info *info, const struct name_entry *n, int stage)
 {
 	int len = traverse_path_len(info, n);
@@ -300,23 +405,27 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 
 	/* Are we supposed to look at the index too? */
 	if (o->merge) {
-		while (o->pos < o->src_index->cache_nr) {
-			struct cache_entry *ce = o->src_index->cache[o->pos];
-			int cmp = compare_entry(ce, info, p);
+		while (1) {
+			struct cache_entry *ce = next_cache_entry(o);
+			int cmp;
+			if (!ce)
+				break;
+			cmp = compare_entry(ce, info, p);
 			if (cmp < 0) {
 				if (unpack_index_entry(ce, o) < 0)
 					return unpack_failed(o, NULL);
 				continue;
 			}
 			if (!cmp) {
-				o->pos++;
 				if (ce_stage(ce)) {
 					/*
-					 * If we skip unmerged index entries, we'll skip this
-					 * entry *and* the tree entries associated with it!
+					 * If we skip unmerged index
+					 * entries, we'll skip this
+					 * entry *and* the tree
+					 * entries associated with it!
 					 */
 					if (o->skip_unmerged) {
-						add_entry(o, ce, 0, 0);
+						add_same_unmerged(ce, o);
 						return mask;
 					}
 				}
@@ -329,6 +438,13 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 	if (unpack_nondirectories(n, mask, dirmask, src, names, info) < 0)
 		return -1;
 
+	if (src[0]) {
+		if (ce_stage(src[0]))
+			mark_ce_used_same_name(src[0], o);
+		else
+			mark_ce_used(src[0], o);
+	}
+
 	/* Now handle any directories.. */
 	if (dirmask) {
 		unsigned long conflicts = mask & ~dirmask;
@@ -338,22 +454,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 				conflicts |= 1;
 		}
 
-		/* special case: "diff-index --cached" looking at a tree */
-		if (o->diff_index_cached &&
-		    n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
-			int matches;
-			matches = cache_tree_matches_traversal(o->src_index->cache_tree,
-							       names, info);
-			/*
-			 * Everything under the name matches.  Adjust o->pos to
-			 * skip the entire hierarchy.
-			 */
-			if (matches) {
-				o->pos += matches;
-				return mask;
-			}
-		}
-
 		if (traverse_trees_recursive(n, dirmask, conflicts,
 					     names, info) < 0)
 			return -1;
@@ -400,14 +500,33 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 		info.fn = unpack_callback;
 		info.data = o;
 
+		if (o->prefix) {
+			/*
+			 * Unpack existing index entries that sort before the
+			 * prefix the tree is spliced into.  Note that o->merge
+			 * is always true in this case.
+			 */
+			while (1) {
+				struct cache_entry *ce = next_cache_entry(o);
+				if (!ce)
+					break;
+				if (ce_in_traverse_path(ce, &info))
+					break;
+				if (unpack_index_entry(ce, o) < 0)
+					return unpack_failed(o, NULL);
+			}
+		}
+
 		if (traverse_trees(len, t, &info) < 0)
 			return unpack_failed(o, NULL);
 	}
 
 	/* Any left-over entries in the index? */
 	if (o->merge) {
-		while (o->pos < o->src_index->cache_nr) {
-			struct cache_entry *ce = o->src_index->cache[o->pos];
+		while (1) {
+			struct cache_entry *ce = next_cache_entry(o);
+			if (!ce)
+				break;
 			if (unpack_index_entry(ce, o) < 0)
 				return unpack_failed(o, NULL);
 		}
@@ -416,6 +535,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
 	if (o->trivial_merges_only && o->nontrivial_merge)
 		return unpack_failed(o, "Merge requires file-level merging");
 
+	/*
+	 * some callers, most notably "git status -v" runs unpack_trees()
+	 * multiple times; clean everything up after us.
+	 */
+	mark_all_ce_unused(o->src_index);
+
 	o->src_index = NULL;
 	ret = check_updates(o) ? (-2) : 0;
 	if (o->dst_index)
@@ -522,7 +647,9 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
 	 * in that directory.
 	 */
 	namelen = strlen(ce->name);
-	for (i = o->pos; i < o->src_index->cache_nr; i++) {
+	for (i = locate_in_src_index(ce, o);
+	     i < o->src_index->cache_nr;
+	     i++) {
 		struct cache_entry *ce2 = o->src_index->cache[i];
 		int len = ce_namelen(ce2);
 		if (len < namelen ||
@@ -530,12 +657,14 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
 		    ce2->name[namelen] != '/')
 			break;
 		/*
-		 * ce2->name is an entry in the subdirectory.
+		 * ce2->name is an entry in the subdirectory to be
+		 * removed.
 		 */
 		if (!ce_stage(ce2)) {
 			if (verify_uptodate(ce2, o))
 				return -1;
 			add_entry(o, ce2, CE_REMOVE, 0);
+			mark_ce_used(ce2, o);
 		}
 		cnt++;
 	}
@@ -591,7 +720,6 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 		return 0;
 
 	if (!lstat(ce->name, &st)) {
-		int ret;
 		int dtype = ce_to_dtype(ce);
 		struct cache_entry *result;
 
@@ -619,28 +747,8 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 			 * files that are in "foo/" we would lose
 			 * them.
 			 */
-			ret = verify_clean_subdirectory(ce, action, o);
-			if (ret < 0)
-				return ret;
-
-			/*
-			 * If this removed entries from the index,
-			 * what that means is:
-			 *
-			 * (1) the caller unpack_callback() saw path/foo
-			 * in the index, and it has not removed it because
-			 * it thinks it is handling 'path' as blob with
-			 * D/F conflict;
-			 * (2) we will return "ok, we placed a merged entry
-			 * in the index" which would cause o->pos to be
-			 * incremented by one;
-			 * (3) however, original o->pos now has 'path/foo'
-			 * marked with "to be removed".
-			 *
-			 * We need to increment it by the number of
-			 * deleted entries here.
-			 */
-			o->pos += ret;
+			if (verify_clean_subdirectory(ce, action, o) < 0)
+				return -1;
 			return 0;
 		}
 
diff --git a/unpack-trees.h b/unpack-trees.h
index d19df44..9a0733e 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -30,7 +30,7 @@ struct unpack_trees_options {
 		     diff_index_cached,
 		     gently;
 	const char *prefix;
-	int pos;
+	int cache_bottom;
 	struct dir_struct *dir;
 	merge_fn_t fn;
 	struct unpack_trees_error_msgs msgs;
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 6/6] read-tree --debug-unpack
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

Debugging patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-read-tree.c |   36 ++++++++++++++++++++++++++++++++++++
 unpack-trees.c      |   35 +++++++++++++++++++++++++++++++++++
 unpack-trees.h      |    1 +
 3 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 14c836b..a9788e5 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -64,6 +64,34 @@ static int exclude_per_directory_cb(const struct option *opt, const char *arg,
 	return 0;
 }
 
+static void debug_stage(const char *label, struct cache_entry *ce,
+			struct unpack_trees_options *o)
+{
+	printf("%s ", label);
+	if (!ce)
+		printf("(missing)\n");
+	else if (ce == o->df_conflict_entry)
+		printf("(conflict)\n");
+	else
+		printf("%06o #%d %s %.8s\n",
+		       ce->ce_mode, ce_stage(ce), ce->name,
+		       sha1_to_hex(ce->sha1));
+}
+
+static int debug_merge(struct cache_entry **stages, struct unpack_trees_options *o)
+{
+	int i;
+
+	printf("* %d-way merge\n", o->merge_size);
+	debug_stage("index", stages[0], o);
+	for (i = 1; i <= o->merge_size; i++) {
+		char buf[24];
+		sprintf(buf, "ent#%d", i);
+		debug_stage(buf, stages[i], o);
+	}
+	return 0;
+}
+
 static struct lock_file lock_file;
 
 int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
@@ -98,6 +126,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 		  PARSE_OPT_NONEG, exclude_per_directory_cb },
 		OPT_SET_INT('i', NULL, &opts.index_only,
 			    "don't check the working tree after merging", 1),
+		OPT_SET_INT(0, "debug-unpack", &opts.debug_unpack,
+			    "debug unpack-trees", 1),
 		OPT_END()
 	};
 
@@ -165,6 +195,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 			opts.head_idx = 1;
 	}
 
+	if (opts.debug_unpack)
+		opts.fn = debug_merge;
+
 	cache_tree_free(&active_cache_tree);
 	for (i = 0; i < nr_trees; i++) {
 		struct tree *tree = trees[i];
@@ -174,6 +207,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
 	if (unpack_trees(nr_trees, t, &opts))
 		return 128;
 
+	if (opts.debug_unpack)
+		return 0; /* do not write the index out */
+
 	/*
 	 * When reading only one tree (either the most basic form,
 	 * "-m ent" or "--reset ent" form), we can obtain a fully
diff --git a/unpack-trees.c b/unpack-trees.c
index a6f2187..b1ad2d9 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -393,6 +393,38 @@ static int unpack_failed(struct unpack_trees_options *o, const char *message)
 	return -1;
 }
 
+static void debug_path(struct traverse_info *info)
+{
+	if (info->prev) {
+		debug_path(info->prev);
+		if (*info->prev->name.path)
+			putchar('/');
+	}
+	printf("%s", info->name.path);
+}
+
+static void debug_name_entry(int i, struct name_entry *n)
+{
+	printf("ent#%d %06o %s\n", i,
+	       n->path ? n->mode : 0,
+	       n->path ? n->path : "(missing)");
+}
+
+static void debug_unpack_callback(int n,
+				  unsigned long mask,
+				  unsigned long dirmask,
+				  struct name_entry *names,
+				  struct traverse_info *info)
+{
+	int i;
+	printf("* unpack mask %lu, dirmask %lu, cnt %d ",
+	       mask, dirmask, n);
+	debug_path(info);
+	putchar('\n');
+	for (i = 0; i < n; i++)
+		debug_name_entry(i, names + i);
+}
+
 static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
 {
 	struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -403,6 +435,9 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 	while (!p->mode)
 		p++;
 
+	if (o->debug_unpack)
+		debug_unpack_callback(n, mask, dirmask, names, info);
+
 	/* Are we supposed to look at the index too? */
 	if (o->merge) {
 		while (1) {
diff --git a/unpack-trees.h b/unpack-trees.h
index 9a0733e..701dca5 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -28,6 +28,7 @@ struct unpack_trees_options {
 		     skip_unmerged,
 		     initial_checkout,
 		     diff_index_cached,
+		     debug_unpack,
 		     gently;
 	const char *prefix;
 	int cache_bottom;
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 4/6] traverse_trees(): handle D/F conflict case sanely
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

traverse_trees() is supposed to call its callback with all the matching
entries from the given trees.  The current algorithm keeps a pointer to
each of the tree being traversed, and feeds the entry with the earliest
name to the callback.

This breaks down if the trees being traversed looks like this:

    A    B
    t-1  t
    t-2  u
    t/a  v

When we are currently looking at an entry "t-1" in tree A, and tree B has
returned "t", feeding "t" from the B and not feeding anything from A, only
because "t-1" sorts later than "t", will miss an entry for a subtree "t"
behind the current entry in tree A.

This introduces extended_entry_extract() helper function that gives what
name is expected from the tree, and implements a mechanism to look-ahead
in the tree object using it, to make sure such a case is handled sanely.
Traversal in tree A in the above example will first return "t" to match
that of B, and then the next request for an entry to A then returns "t-1".

This roughly corresponds to what Linus's "prepare for one-entry lookahead"
wanted to do, but because this does implement look ahead, t6035 and t7003
reveal that the approach would not work without adjusting the side that
walks the index in unpack_trees() as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 tree-walk.c |  277 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 234 insertions(+), 43 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 02e2aed..08796c2 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -60,13 +60,6 @@ void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1)
 	return buf;
 }
 
-static int entry_compare(struct name_entry *a, struct name_entry *b)
-{
-	return df_name_compare(
-			a->path, tree_entry_len(a->path, a->sha1), a->mode,
-			b->path, tree_entry_len(b->path, b->sha1), b->mode);
-}
-
 static void entry_clear(struct name_entry *a)
 {
 	memset(a, 0, sizeof(*a));
@@ -138,66 +131,264 @@ char *make_traverse_path(char *path, const struct traverse_info *info, const str
 	return path;
 }
 
+struct tree_desc_skip {
+	struct tree_desc_skip *prev;
+	const void *ptr;
+};
+
+struct tree_desc_x {
+	struct tree_desc d;
+	struct tree_desc_skip *skip;
+};
+
+static int name_compare(const char *a, int a_len,
+			const char *b, int b_len)
+{
+	int len = (a_len < b_len) ? a_len : b_len;
+	int cmp = memcmp(a, b, len);
+	if (cmp)
+		return cmp;
+	return (a_len - b_len);
+}
+
+static int check_entry_match(const char *a, int a_len, const char *b, int b_len)
+{
+	/*
+	 * The caller wants to pick *a* from a tree or nothing.
+	 * We are looking at *b* in a tree.
+	 *
+	 * (0) If a and b are the same name, we are trivially happy.
+	 *
+	 * There are three possibilities where *a* could be hiding
+	 * behind *b*.
+	 *
+	 * (1) *a* == "t",   *b* == "ab"  i.e. *b* sorts earlier than *a* no
+	 *                                matter what.
+	 * (2) *a* == "t",   *b* == "t-2" and "t" is a subtree in the tree;
+	 * (3) *a* == "t-2", *b* == "t"   and "t-2" is a blob in the tree.
+	 *
+	 * Otherwise we know *a* won't appear in the tree without
+	 * scanning further.
+	 */
+
+	int cmp = name_compare(a, a_len, b, b_len);
+
+	/* Most common case first -- reading sync'd trees */
+	if (!cmp)
+		return cmp;
+
+	if (0 < cmp) {
+		/* a comes after b; it does not matter if it is case (3)
+		if (b_len < a_len && !memcmp(a, b, b_len) && a[b_len] < '/')
+			return 1;
+		*/
+		return 1; /* keep looking */
+	}
+
+	/* b comes after a; are we looking at case (2)? */
+	if (a_len < b_len && !memcmp(a, b, a_len) && b[a_len] < '/')
+		return 1; /* keep looking */
+
+	return -1; /* a cannot appear in the tree */
+}
+
+/*
+ * From the extended tree_desc, extract the first name entry, while
+ * paying attention to the candidate "first" name.  Most importantly,
+ * when looking for an entry, if there are entries that sorts earlier
+ * in the tree object representation than that name, skip them and
+ * process the named entry first.  We will remember that we haven't
+ * processed the first entry yet, and in the later call skip the
+ * entry we processed early when update_extended_entry() is called.
+ *
+ * E.g. if the underlying tree object has these entries:
+ *
+ *    blob    "t-1"
+ *    blob    "t-2"
+ *    tree    "t"
+ *    blob    "t=1"
+ *
+ * and the "first" asks for "t", remember that we still need to
+ * process "t-1" and "t-2" but extract "t".  After processing the
+ * entry "t" from this call, the caller will let us know by calling
+ * update_extended_entry() that we can remember "t" has been processed
+ * already.
+ */
+
+static void extended_entry_extract(struct tree_desc_x *t,
+				   struct name_entry *a,
+				   const char *first,
+				   int first_len)
+{
+	const char *path;
+	int len;
+	struct tree_desc probe;
+	struct tree_desc_skip *skip;
+
+	/*
+	 * Extract the first entry from the tree_desc, but skip the
+	 * ones that we already returned in earlier rounds.
+	 */
+	while (1) {
+		if (!t->d.size) {
+			entry_clear(a);
+			break; /* not found */
+		}
+		entry_extract(&t->d, a);
+		for (skip = t->skip; skip; skip = skip->prev)
+			if (a->path == skip->ptr)
+				break; /* found */
+		if (!skip)
+			break;
+		/* We have processed this entry already. */
+		update_tree_entry(&t->d);
+	}
+
+	if (!first || !a->path)
+		return;
+
+	/*
+	 * The caller wants "first" from this tree, or nothing.
+	 */
+	path = a->path;
+	len = tree_entry_len(a->path, a->sha1);
+	switch (check_entry_match(first, first_len, path, len)) {
+	case -1:
+		entry_clear(a);
+	case 0:
+		return;
+	default:
+		break;
+	}
+
+	/*
+	 * We need to look-ahead -- we suspect that a subtree whose
+	 * name is "first" may be hiding behind the current entry "path".
+	 */
+	probe = t->d;
+	while (probe.size) {
+		entry_extract(&probe, a);
+		path = a->path;
+		len = tree_entry_len(a->path, a->sha1);
+		switch (check_entry_match(first, first_len, path, len)) {
+		case -1:
+			entry_clear(a);
+		case 0:
+			return;
+		default:
+			update_tree_entry(&probe);
+			break;
+		}
+		/* keep looking */
+	}
+	entry_clear(a);
+}
+
+static void update_extended_entry(struct tree_desc_x *t, struct name_entry *a)
+{
+	if (t->d.entry.path == a->path) {
+		update_tree_entry(&t->d);
+	} else {
+		/* we have returned this entry early */
+		struct tree_desc_skip *skip = xmalloc(sizeof(*skip));
+		skip->ptr = a->path;
+		skip->prev = t->skip;
+		t->skip = skip;
+	}
+}
+
+static void free_extended_entry(struct tree_desc_x *t)
+{
+	struct tree_desc_skip *p, *s;
+
+	for (s = t->skip; s; s = p) {
+		p = s->prev;
+		free(s);
+	}
+}
+
 int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
 {
 	int ret = 0;
 	struct name_entry *entry = xmalloc(n*sizeof(*entry));
+	int i;
+	struct tree_desc_x *tx = xcalloc(n, sizeof(*tx));
+
+	for (i = 0; i < n; i++)
+		tx[i].d = t[i];
 
 	for (;;) {
-		unsigned long mask = 0;
-		unsigned long dirmask = 0;
-		int i, last;
+		unsigned long mask, dirmask;
+		const char *first = NULL;
+		int first_len = 0;
+		struct name_entry *e;
+		int len;
 
-		last = -1;
 		for (i = 0; i < n; i++) {
-			if (!t[i].size)
+			e = entry + i;
+			extended_entry_extract(tx + i, e, NULL, 0);
+		}
+
+		/*
+		 * A tree may have "t-2" at the current location even
+		 * though it may have "t" that is a subtree behind it,
+		 * and another tree may return "t".  We want to grab
+		 * all "t" from all trees to match in such a case.
+		 */
+		for (i = 0; i < n; i++) {
+			e = entry + i;
+			if (!e->path)
 				continue;
-			entry_extract(t+i, entry+i);
-			if (last >= 0) {
-				int cmp = entry_compare(entry+i, entry+last);
-
-				/*
-				 * Is the new name bigger than the old one?
-				 * Ignore it
-				 */
-				if (cmp > 0)
+			len = tree_entry_len(e->path, e->sha1);
+			if (!first) {
+				first = e->path;
+				first_len = len;
+				continue;
+			}
+			if (name_compare(e->path, len, first, first_len) < 0) {
+				first = e->path;
+				first_len = len;
+			}
+		}
+
+		if (first) {
+			for (i = 0; i < n; i++) {
+				e = entry + i;
+				extended_entry_extract(tx + i, e, first, first_len);
+				/* Cull the ones that are not the earliest */
+				if (!e->path)
 					continue;
-				/*
-				 * Is the new name smaller than the old one?
-				 * Ignore all old ones
-				 */
-				if (cmp < 0)
-					mask = 0;
+				len = tree_entry_len(e->path, e->sha1);
+				if (name_compare(e->path, len, first, first_len))
+					entry_clear(e);
 			}
+		}
+
+		/* Now we have in entry[i] the earliest name from the trees */
+		mask = 0;
+		dirmask = 0;
+		for (i = 0; i < n; i++) {
+			if (!entry[i].path)
+				continue;
 			mask |= 1ul << i;
 			if (S_ISDIR(entry[i].mode))
 				dirmask |= 1ul << i;
-			last = i;
 		}
 		if (!mask)
 			break;
-		dirmask &= mask;
-
-		/*
-		 * Clear all the unused name-entries.
-		 */
-		for (i = 0; i < n; i++) {
-			if (mask & (1ul << i))
-				continue;
-			entry_clear(entry + i);
-		}
 		ret = info->fn(n, mask, dirmask, entry, info);
 		if (ret < 0)
 			break;
-		if (ret)
-			mask &= ret;
+		mask &= ret;
 		ret = 0;
-		for (i = 0; i < n; i++) {
+		for (i = 0; i < n; i++)
 			if (mask & (1ul << i))
-				update_tree_entry(t + i);
-		}
+				update_extended_entry(tx + i, entry + i);
 	}
 	free(entry);
+	for (i = 0; i < n; i++)
+		free_extended_entry(tx + i);
+	free(tx);
 	return ret;
 }
 
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 3/6] unpack_callback(): use unpack_failed() consistently
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

When unpack_index_entry() failed, consistently call unpack_failed(),
instead of silently returning -1.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 unpack-trees.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index d174fe0..c424bab 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -277,6 +277,17 @@ static int unpack_nondirectories(int n, unsigned long mask,
 	return 0;
 }
 
+static int unpack_failed(struct unpack_trees_options *o, const char *message)
+{
+	discard_index(&o->result);
+	if (!o->gently) {
+		if (message)
+			return error("%s", message);
+		return -1;
+	}
+	return -1;
+}
+
 static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
 {
 	struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -294,7 +305,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 			int cmp = compare_entry(ce, info, p);
 			if (cmp < 0) {
 				if (unpack_index_entry(ce, o) < 0)
-					return -1;
+					return unpack_failed(o, NULL);
 				continue;
 			}
 			if (!cmp) {
@@ -352,17 +363,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
 	return mask;
 }
 
-static int unpack_failed(struct unpack_trees_options *o, const char *message)
-{
-	discard_index(&o->result);
-	if (!o->gently) {
-		if (message)
-			return error("%s", message);
-		return -1;
-	}
-	return -1;
-}
-
 /*
  * N-way merge "len" trees.  Returns 0 on success, -1 on failure to manipulate the
  * resulting index, -2 on failure to reflect the changes to the work tree.
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 1/6] diff-lib.c: fix misleading comments on oneway_diff()
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

20a16eb (unpack_trees(): fix diff-index regression., 2008-03-10) adjusted
diff-index to the new world order since 34110cd (Make 'unpack_trees()'
have a separate source and destination index, 2008-03-06).  Callbacks are
expected to return anything non-negative as "success", and instead of
reporting how many index entries they have processed, they are expected to
advance o->pos themselves.  The code did so, but a stale comment was left
behind.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff-lib.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 0c74ef5..adf1c5f 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -383,7 +383,7 @@ static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_op
  * For diffing, the index is more important, and we only have a
  * single tree.
  *
- * We're supposed to return how many index entries we want to skip.
+ * We're supposed to advance o->pos to skip what we have already processed.
  *
  * This wrapper makes it all more readable, and takes care of all
  * the fairly complex unpack_trees() semantic requirements, including
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 2/6] unpack-trees: typofix
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git
In-Reply-To: <1253423175-6339-1-git-send-email-gitster@pobox.com>

I am not good at subject-verb concordance.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 unpack-trees.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 720f7a1..d174fe0 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -617,7 +617,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
 			 * found "foo/." in the working tree.
 			 * This is tricky -- if we have modified
 			 * files that are in "foo/" we would lose
-			 * it.
+			 * them.
 			 */
 			ret = verify_clean_subdirectory(ce, action, o);
 			if (ret < 0)
-- 
1.6.5.rc1.90.ga3b1b

^ permalink raw reply related

* [WIP PATCH 0/6] Merging with D/F conflicts
From: Junio C Hamano @ 2009-09-20  5:06 UTC (permalink / raw)
  To: git

I have been working on this on-and-off and it still is not finished, but I
thought it would be a good place to stop, especially since this will not
be part of the upcoming 1.6.5 anyway.

The first three patches are preparatory clean-ups.

The fourth patch roughly corresponds to Linus's 880386c (Prepare
'traverse_trees()' for D/F conflict lookahead, 2009-09-06), but it does
implement multi-entry lookahead.  It reveals why lookahead on the tree
side alone is not sufficient by breaking a few tests.

The fifth one starts to compensate for the change in the tree side by
preparing the side that walks the index for a similar lookahead mechanism,
but it does not actually implement the lookahead yet.

The last one is a debugging patch.

This change has to break the output order (but not content) of the
diff-index somewhat.  If you had this:

    Index    Tree
    b        b-2/c
    b-2      b/d

the expected output order from diff-index is b, b-2, b-2/c, then b/d.  But
if you walk the tree and the index in parallel, we would end up showing b,
b/d, b-2 and then b-2/c.  A sad part of the story is that diff-index
always emits D/F conflicted entries as two independent records, so it is
rather a bad match to the unpack_trees() framework to begin with.

The patches are designed to apply on 79b4fde (Merge branch 'maint',
2009-09-03).

Junio C Hamano (6):
  diff-lib.c: fix misleading comments on oneway_diff()
  unpack-trees: typofix
  unpack_callback(): use unpack_failed() consistently
  traverse_trees(): handle D/F conflict case sanely
  unpack-trees.c: prepare for looking ahead in the index
  read-tree --debug-unpack

 builtin-read-tree.c |   36 +++++++
 cache.h             |    2 +
 diff-lib.c          |   20 +----
 tree-walk.c         |  277 +++++++++++++++++++++++++++++++++++++++++++--------
 unpack-trees.c      |  275 ++++++++++++++++++++++++++++++++++++++------------
 unpack-trees.h      |    3 +-
 6 files changed, 484 insertions(+), 129 deletions(-)

^ permalink raw reply

* Re: Usability question
From: Rob Barrett @ 2009-09-20  2:21 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: git
In-Reply-To: <vpqy6odhn0d.fsf@bauges.imag.fr>

On Thu, Sep 17, 2009 at 8:41 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Well, if you want to get rid of subcommands, why not get rid of
> commands, too?
>
> git --commit
> git --status
> git --svn --rebase
>

Well, granted, that's a sort of heavyweight consistency, but all we
should need to do is to help reduce a _new_ user's confusion about
when the word after a subcommand gets a '--' prefix and when it
doesn't.

And do it in a way that's backwards compatible so it doesn't affect
the usage patterns of seasoned users, existing scripts, crons etc.

Will patch and see how it looks..

Rob

^ permalink raw reply

* Re: Release candidate period
From: Thiago Farina @ 2009-09-20  1:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nicolas Pitre, git
In-Reply-To: <7vab0q76tq.fsf@alter.siamese.dyndns.org>

On Sat, Sep 19, 2009 at 10:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
> And Thiago, don't thank me.  It's not "hey I now have N commits in a high
> profile project" game.
OK, I will remember that.

^ permalink raw reply

* Re: Release candidate period
From: Junio C Hamano @ 2009-09-20  1:17 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: Thiago Farina, git, Junio C Hamano
In-Reply-To: <alpine.LFD.2.00.0909192043060.24133@xanadu.home>

Nicolas Pitre <nico@fluxnic.net> writes:

> On Sat, 19 Sep 2009, Thiago Farina wrote:
>
>> Hi Junio, I saw that you committed two of my trivial patches with your changes.
>> 
>> Thank you for committing my patches.
>> 
>> I have one more trivial patch that I want to send, but we are in -rc
>> freeze, when I can send it?
>> The release candidate period is not defined, no? The period ends so
>> when the mailing list reaches an agreement and agrees that the release
>> candidate is ready?
>
> This is a benevolent dictatorship.  Junio sets the date.

True.

And Thiago, don't thank me.  It's not "hey I now have N commits in a high
profile project" game.  We are all working together to make it better, and
we thank you for your attention of detail.

^ permalink raw reply

* Re: Release candidate period
From: Nicolas Pitre @ 2009-09-20  0:56 UTC (permalink / raw)
  To: Thiago Farina; +Cc: git, Junio C Hamano
In-Reply-To: <a4c8a6d00909191644n131667f2uc7e59d0d56749c42@mail.gmail.com>

On Sat, 19 Sep 2009, Thiago Farina wrote:

> Hi Junio, I saw that you committed two of my trivial patches with your changes.
> 
> Thank you for committing my patches.
> 
> I have one more trivial patch that I want to send, but we are in -rc
> freeze, when I can send it?
> The release candidate period is not defined, no? The period ends so
> when the mailing list reaches an agreement and agrees that the release
> candidate is ready?

This is a benevolent dictatorship.  Junio sets the date.


Nicolas

^ permalink raw reply

* Release candidate period
From: Thiago Farina @ 2009-09-19 23:44 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Hi Junio, I saw that you committed two of my trivial patches with your changes.

Thank you for committing my patches.

I have one more trivial patch that I want to send, but we are in -rc
freeze, when I can send it?
The release candidate period is not defined, no? The period ends so
when the mailing list reaches an agreement and agrees that the release
candidate is ready?

Thanks!

^ permalink raw reply

* Re: shell commands in ReleaseNotes
From: Resul Cetin @ 2009-09-19 22:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7veiq27ekz.fsf@alter.siamese.dyndns.org>

> Resul Cetin <Resul-Cetin@gmx.net> writes:
> > Real nice idea to create an overview about changes in a repository for
> > writing a releasenotes. But how is it real used by the maintainer?
> 
> Open the file, go to the beginning of the scriptlet and mark (\C-SP), go
> to the end (\M->), feed it to shell (\M-| sh RET), open /var/tmp/1 and
> read it over while cutting the updated definition of O=.
> 
> Everything done in Emacs, no need for any extra editor.
Ah, thanks. Looks like a good workflow.

^ permalink raw reply

* Re: shell commands in ReleaseNotes
From: Junio C Hamano @ 2009-09-19 22:30 UTC (permalink / raw)
  To: Resul Cetin; +Cc: git
In-Reply-To: <200909192357.32369.Resul-Cetin@gmx.net>

Resul Cetin <Resul-Cetin@gmx.net> writes:

> Real nice idea to create an overview about changes in a repository for writing 
> a releasenotes. But how is it real used by the maintainer?

Open the file, go to the beginning of the scriptlet and mark (\C-SP), go
to the end (\M->), feed it to shell (\M-| sh RET), open /var/tmp/1 and
read it over while cutting the updated definition of O=.

Everything done in Emacs, no need for any extra editor.

^ permalink raw reply

* shell commands in ReleaseNotes
From: Resul Cetin @ 2009-09-19 21:57 UTC (permalink / raw)
  To: git

Hi,
I noticed that there are small part of commands at the end of a not yet 
released ReleaseNote-*.txt.
 ---
 exec >/var/tmp/1
 O=v1.6.4.1-266-g235db15
 echo O=$(git describe master)
 git shortlog --no-merges $O..master --not maint

As far as I understand it means that the output is redirected to /var/tmp/1.
Then there is O set to the last it which was used to generate a shortlog.
Then the current desciption (tag+suffix) is printed which can then used to 
replace the O= line in the small snipped. Then there will be created a 
shortlog from the last point it was created until master without stuff in 
maint (or reachable by maint? I am not sure about that one).

Real nice idea to create an overview about changes in a repository for writing 
a releasenotes. But how is it real used by the maintainer? My current idea 
would be: Open the editor an copy the snipped. Open a terminal, switch to the 
repository and go paste the snipped into it. After that the terminal has to be 
closed as it isn't really useful anymore. An extra editor will be used to open 
/var/tmp/1 and now the first step is to replace "O=v1.6.4.1-266-g235db15" with 
a new id at the first line in /var/tmp/1. Now the maintainer has to order all 
commits a little bit and write the release notes. After he finished it, he 
just commits it to master and is finished for this period of time.
Is this real how it is done in git.git or is there maybe something I don't see 
right now?

Best regards,
	Resul Cetin

^ permalink raw reply

* Re: How to host a github?
From: daicoden @ 2009-09-19 21:01 UTC (permalink / raw)
  To: git
In-Reply-To: <24713161.post@talk.nabble.com>




jvsrvcs wrote:
> 
> I want to share code with a few co-workers and I want to use git.
> 
> I installed git (cygwin), created a /project/ and then $cd project
> and then $git init
> 
> I have found so much documentation as to what to do next, that
> I'm confused.
> 
> Do I have to create an account on github in order to share code with
> a few local developers?
> 
> Could I run some sort of server on my laptop in order to share code?
> (we only need to share during office hours).  Basically I just
> want to share code but do not want to sign up for an account
> on github.
> 
> How do I work this?
> 
> thanks
> 
> jvsrvcs
> 

Hey,  assuming you have shell access into your laptop, create a user named
git.  You don't have to do this but you want to give everyone access to an
account on the laptop.  You could also create a usergroup and add the
project folder to that group and give all your developers access to that
group.

Either-way once everyone is able to log onto the laptop make a new directory
called project.git.  Then go into that directory and use git --bare init.

Assuming you created a user named git you can then check the code out via

git clone git@localhost:project.git

to start things off from the source you will be working on you can then use:

git init
touch 'Readme'
git add Readme
git commit -m 'Initial Comit'
git remote add origin git@ip:project.git
git push origin master

-- 
View this message in context: http://www.nabble.com/How-to-host-a-github--tp24713161p25525401.html
Sent from the git mailing list archive at Nabble.com.

^ permalink raw reply

* Re: SmartGit, a new GUI front-end for Git
From: Thomas Singer @ 2009-09-19 14:11 UTC (permalink / raw)
  To: git
In-Reply-To: <4AB4AA4A.4080801@syntevo.com>

Hi all,

The new build is uploaded. The ~/.gitconfig file now should be kept and on
Linux the splash screen hides before showing the initial dialog. Sorry for
any inconveniences.

--
Best regards,
Thomas Singer
=============
syntevo GmbH
http://www.syntevo.com
http://blog.syntevo.com


Thomas Singer wrote:
> Hi James,
> 
> Thanks for reporting this serious error. I will try to fix this in the next
> hour and upload a new build.
> 
> --
> Best regards,
> Thomas Singer
> =============
> syntevo GmbH
> http://www.syntevo.com
> http://blog.syntevo.com
> 
> 
> James Sadler wrote:
>> Hi Thomas,
>>
>> I just launched SmartGit, and it ate my ~/.gitconfig.  Luckily I had a
>> backup (full of my own aliases and colour settings etc.).
>>
>> SmartGit replaced mine with a ~/.gitconfig containing _only_ my name
>> and email settings.  Not good.  I would bet that 99% of all people on
>> this list have their own customized version of ~/.gitconfig and
>> SmartGit is probably going to eat it.  If it helps, I am running OS X.
>>
>> James.
>>
>> 2009/9/19 Thomas Singer <thomas.singer@syntevo.com>:
>>> Hi all,
>>>
>>> We would like to announce a new milestone build of our Git client "SmartGit"
>>> (don't be offended by the name, it's historically based) which we feel is
>>> ready now for a broader audience. SmartGit is quite stable and we want to
>>> invite everyone who is interested in giving it a try:
>>>
>>>  http://www.syntevo.com/smartgit/index.html
>>>
>>> Please don't expect all Git features and options implemented. We have
>>> tried to first concentrate on the most important ones - from our rather
>>> novice Git perspective.
>>>
>>> SmartGit runs on all operating systems which support a full Java 1.5
>>> implementation, including virtually all Linux versions, OS X 10.4 - 10.6 and
>>> Windows 2000 or newer. It requires a Git installation, although a couple of
>>> time-critical operations are handled by the JGit library.
>>>
>>> We appreciate your feed-back in our mailing list
>>>
>>>  http://www.syntevo.com/smartgit/community.html
>>>
>>> or directly to us (smartgit@syntevo.com). SmartGit 1.0 is planned to be
>>> released free of charge for non-commercial use or to active members of the
>>> Open Source community. Each pre-release build expires 3 months after the
>>> build-date.
>>>
>>> At this occasion I would also like to express my appreciation to the
>>> community for this great DVCS you have built. Approx. a 3/4 year ago I've
>>> started to use Git. Although I had some starting problems with it using the
>>> Git command line (mostly on Windows), I need to say that over time I really
>>> fell in love with Git and its elaborate foundations and feature set.
>>>
>>> --
>>> Best regards,
>>> Thomas Singer
>>> =============
>>> syntevo GmbH
>>> http://www.syntevo.com
>>> http://blog.syntevo.com
>>>
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe git" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

^ permalink raw reply

* [PATCHv3] git-log --format: Add %B tag with %B(x) option
From: Johannes Gilger @ 2009-09-19  9:58 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Johannes Schindelin, Johannes Gilger
In-Reply-To: <7vtyz083tk.fsf@alter.siamese.dyndns.org>

Since one can simply use spaces to indent any other --pretty field we
should have an option to do that with the body too.

Also the %B flag strips the trailing newlines, to enable more compact
display.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
---
Changes to PATCHv2:
- Make %B() strict: Only nonnegative integers are allowed between the brackets, 
  everything else yields the placemark itself as output to indicate a wrong 
  argument. This also goes for an empty argument.

 Documentation/pretty-formats.txt |    2 ++
 pretty.c                         |   29 ++++++++++++++++++++++++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 2a845b1..533bc5e 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -123,6 +123,8 @@ The placeholders are:
 - '%s': subject
 - '%f': sanitized subject line, suitable for a filename
 - '%b': body
+- '%B': body without trailing newline
+- '%B(x)': body indented by x spaces
 - '%Cred': switch color to red
 - '%Cgreen': switch color to green
 - '%Cblue': switch color to blue
diff --git a/pretty.c b/pretty.c
index f5983f8..8970378 100644
--- a/pretty.c
+++ b/pretty.c
@@ -605,13 +605,17 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 	int h1, h2;
 
 	/* these are independent of the commit */
+
+	const char *body = msg + c->body_off;
+	const char *end = NULL;
+	/* check if we have arguments to the placeholder */
+	if (placeholder[1] == '(')
+		end = strchr(placeholder + 2, ')');
+
 	switch (placeholder[0]) {
 	case 'C':
-		if (placeholder[1] == '(') {
-			const char *end = strchr(placeholder + 2, ')');
+		if (end) {
 			char color[COLOR_MAXLEN];
-			if (!end)
-				return 0;
 			color_parse_mem(placeholder + 2,
 					end - (placeholder + 2),
 					"--pretty format", color);
@@ -733,7 +737,20 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 		format_sanitized_subject(sb, msg + c->subject_off);
 		return 1;
 	case 'b':	/* body */
-		strbuf_addstr(sb, msg + c->body_off);
+		strbuf_addstr(sb, body);
+		return 1;
+	case 'B':	/* body without trailing newline */
+		if (end) {
+			char *endp = NULL;
+			int indent = strtol(placeholder + 2, &endp, 10);
+			if (placeholder + 2 == endp || *endp != ')' || indent < 0)
+				return 0;
+			pp_remainder(CMIT_FMT_MEDIUM, &body, sb, indent);
+			strbuf_rtrim(sb);
+			return end - placeholder + 1;
+		}
+		strbuf_addstr(sb, body);
+		strbuf_rtrim(sb);
 		return 1;
 	}
 	return 0;	/* unknown placeholder */
@@ -875,6 +892,8 @@ void pp_remainder(enum cmit_fmt fmt,
 		}
 		first = 0;
 
+		if (indent < 0)
+			indent = 0;
 		strbuf_grow(sb, linelen + indent + 20);
 		if (indent) {
 			memset(sb->buf + sb->len, ' ', indent);
-- 
1.6.5.rc1.20.geb7d9

^ 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