Git development
 help / color / mirror / Atom feed
* Re: Recent unresolved issues
From: Linus Torvalds @ 2006-04-15 16:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vk69ri5cp.fsf@assigned-by-dhcp.cox.net>



On Sat, 15 Apr 2006, Junio C Hamano wrote:
> 
> 				Pain
> 
> "git log" wants default abbrev (to show Merge: lines and
> "whatchanged -r" output compactly) while "git diff-tree -r" by
> default wants to show full SHA1 unless asked, which means
> "memset(revs, 0, sizeof(*revs))" in revision.c::init_revisions()
> needs to be defeated by the caller.

I'd suggest just moving the call to "init_revisions()" out from 
"setup_revisions()" entirely.

So the calling sequence would be something like this:

	init_revisions(&rev);
	.. any localized setup ..
	setup_revisions(&rev);

which isn't really all that painful, and allows us maximal flexibility for 
different defaults etc.

		Linus

^ permalink raw reply

* Re: Recent unresolved issues
From: Linus Torvalds @ 2006-04-15 17:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604150958140.3701@g5.osdl.org>



On Sat, 15 Apr 2006, Linus Torvalds wrote:
> 
> So the calling sequence would be something like this:
> 
> 	init_revisions(&rev);
> 	.. any localized setup ..
> 	setup_revisions(&rev);

Btw, I can certainly understand if you don't want to do this before 1.3.x. 
Since there's no actual user-visible advantage to it, it's probably worth 
dropping for now.

		Linus

^ permalink raw reply

* [WIP/PATCH] Combined diffstat
From: Johannes Schindelin @ 2006-04-15 18:08 UTC (permalink / raw)
  To: git, junkio


I ended up implementing both proposals for merge diffstats:

Junio)

 pack-objects.c |  923 ++++++++----- ++++++++++++++++++++++++++++------ +++--
 rev-list.c     |    5
 send-pack.c    |   86               +-                                 +
 upload-pack.c  |    7
 4 files changed, 786 insertions(+), 235 deletions(-)

Marco)

 pack-objects.c |   22 ++++++++++++++--------
 rev-list.c     |    0
 send-pack.c    |    0
 upload-pack.c  |    0
 4 files changed, 156 insertions(+), 86 deletions(-)

 pack-objects.c |   56 +++++++++++++++++++++++++++++++++++++++++++++++---------
 send-pack.c    |    4 +++-
 upload-pack.c  |    0
 3 files changed, 532 insertions(+), 103 deletions(-)

 pack-objects.c |    9 ++++++---
 rev-list.c     |    0
 send-pack.c    |    4 +++-
 upload-pack.c  |    0
 4 files changed, 98 insertions(+), 46 deletions(-)

For the moment, I like Junio's better, if only because it was more difficult
to implement.

If you want to try it, I suggest using this as a test case:

	git log --stat f0b0af1b04

To get the output with separate diffstats for each parent, just define the
environment variable NO_COMBINED_DIFFSTAT before calling git.

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

---

 combine-diff.c |  271 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 diff.h         |    1 
 log-tree.c     |    6 +
 3 files changed, 278 insertions(+), 0 deletions(-)

9e802df5d029d44938568060d4d567a4fd130d79
diff --git a/combine-diff.c b/combine-diff.c
index 9bd27f8..b82ee8c 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -148,6 +148,15 @@ static void append_lost(struct sline *sl
 	sline->lost_tail = &lline->next;
 }
 
+struct diffstat_t {
+        struct diffstat_file {
+                char *name;
+                struct diffstat_parent {
+			unsigned int added, deleted;
+		} *parent;
+        } *files, *current;
+};
+
 struct combine_diff_state {
 	struct xdiff_emit_state xm;
 
@@ -557,6 +566,35 @@ static void dump_sline(struct sline *sli
 	}
 }
 
+static void diffstat_sline(struct diffstat_t *diffstat,
+		struct sline *sline, unsigned long cnt, int num_parent)
+{
+	struct diffstat_parent *data = diffstat->current->parent;
+	unsigned long interesting = (1UL<<num_parent);
+	int lno;
+	for (lno = 0; lno <= cnt; lno++) {
+		struct sline *sl = sline + lno;
+		struct lline *ll;
+		int j;
+
+		if (!(sl->flag & interesting))
+			continue;
+
+		
+		for (ll = sl->lost_head; ll; ll = ll->next)
+			for (j = 0; j < num_parent; j++)
+				if (ll->parent_map & (1UL<<j))
+					data[j].deleted++;
+
+		if (cnt < lno)
+			break;
+
+		for (j = 0; j < num_parent; j++)
+			if (sl->flag & (1UL<<j))
+				data[j].added++;
+	}
+}
+
 static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
 			       int i, int j)
 {
@@ -596,6 +634,7 @@ static int show_patch_diff(struct combin
 	int working_tree_file = !memcmp(elem->sha1, null_sha1, 20);
 	int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;
 	mmfile_t result_file;
+	struct diffstat_t *diffstat = opt->diffstat;
 
 	/* Read the result of merge first */
 	if (!working_tree_file)
@@ -686,6 +725,12 @@ static int show_patch_diff(struct combin
 
 	show_hunks = make_hunks(sline, cnt, num_parent, dense);
 
+	if (diffstat) {
+		diffstat->current->name = strdup(elem->path);
+		diffstat_sline(diffstat, sline, cnt, num_parent);
+		show_hunks = 0;
+	}
+
 	if (show_hunks || mode_differs || working_tree_file) {
 		const char *abb;
 
@@ -826,11 +871,213 @@ int show_combined_diff(struct combine_di
 		return 1;
 
 	default:
+	case DIFF_FORMAT_DIFFSTAT:
 	case DIFF_FORMAT_PATCH:
 		return show_patch_diff(p, num_parent, dense, header, opt);
 	}
 }
 
+static const char pluses[] = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
+static const char minuses[]= "----------------------------------------------------------------------";
+
+static void show_stats(struct diffstat_t *diffstat,
+		int num_paths, int num_parent)
+{
+	int show_combined_diffstat = (getenv("NO_COMBINED_DIFFSTAT") == NULL);
+	int i, j;
+	int max_length = 0, max_change = 0;
+	int *parent_max_change;
+	char *prefix = "";
+	int len, add, del, total, adds, dels, total_files, max;
+
+	if (num_paths == 0)
+		return;
+
+	parent_max_change = xcalloc(sizeof(int), num_parent);
+
+	for (i = 0; i < num_paths; i++) {
+		int len;
+		char *name = diffstat->files[i].name;
+		if (0 < (len = quote_c_style(name, NULL, NULL, 0))) {
+			char *qname = xmalloc(len + 1);
+			quote_c_style(name, qname, NULL, 0);
+			free(name);
+			diffstat->files[i].name = name = qname;
+		} else
+			len = strlen(name);
+
+		if (max_length < len)
+			max_length = len;
+
+		for (j = 0; j < num_parent; j++) {
+			struct diffstat_parent *data =
+				diffstat->files[i].parent + j;
+			int change = data->added + data->deleted;
+			if (parent_max_change[j] < change) {
+				parent_max_change[j] = change;
+				if (max_change < change)
+					max_change = change;
+			}
+		}
+	}
+
+	if (max_change == 0)
+		return;
+
+	printf("---\n");
+
+	if (show_combined_diffstat) {
+		char buffer[80];
+		max_change = 0;
+		for (j = 0; j < num_parent; j++)
+			max_change += parent_max_change[j];
+		
+		prefix = "";
+		total_files = num_paths;
+		adds = dels = 0;
+
+		for (i = 0; i < num_paths; i++) {
+			int offset;
+			char *name = diffstat->files[i].name;
+
+			/*
+			 * "scale" the filename
+			 */
+			len = strlen(name);
+			max = max_length;
+			if (max > 50)
+				max = 50;
+			if (len > max) {
+				char *slash;
+				prefix = "...";
+				max -= 3;
+				name += len - max;
+				slash = strchr(name, '/');
+				if (slash)
+					name = slash;
+			}
+			len = max;
+
+			/*
+			 * scale the add/delete
+			 */
+			max = max_change + num_parent - 1;
+			if (max + len > 70)
+				max = 70 - len;
+
+			memset(buffer, ' ', 70);
+			buffer[max + 1] = 0;
+
+			max -= num_parent - 1;
+			offset = add = del = 0;
+			for (j = 0; j < num_parent; j++) {
+				struct diffstat_parent *data =
+					diffstat->files[i].parent + j;
+				int a, d, size;
+
+				size = max * parent_max_change[j] / max_change;
+				if (size == 0)
+					size = 1;
+
+				a = data->added;
+				d = a + data->deleted;
+
+				a = a * size / parent_max_change[j];
+				d = d * size / parent_max_change[j];
+
+				memset(buffer + offset, '+', a);
+				memset(buffer + offset + a, '-', d - a);
+
+				add += data->added;
+				del += data->deleted;
+
+				offset += size + 1;
+			}
+
+			if (add + del == 0) {
+				total_files--;
+				continue;
+			}
+
+			adds += add;
+			dels += del;
+
+			printf(" %s%-*s |%5d %s\n", prefix, len, name,
+					add + del, buffer);
+		}
+		printf(" %d files changed, %d insertions(+), %d deletions(-)\n",
+				total_files, adds, dels);
+	} else {
+		for (j = 0; j < num_parent; j++) {
+			prefix = "";
+			total_files = num_paths;
+			adds = dels = 0;
+
+			for (i = 0; i < num_paths; i++) {
+				char *name = diffstat->files[i].name;
+				struct diffstat_parent *data =
+					diffstat->files[i].parent + j;
+
+				/*
+				 * "scale" the filename
+				 */
+				len = strlen(name);
+				max = max_length;
+				if (max > 50)
+					max = 50;
+				if (len > max) {
+					char *slash;
+					prefix = "...";
+					max -= 3;
+					name += len - max;
+					slash = strchr(name, '/');
+					if (slash)
+						name = slash;
+				}
+				len = max;
+
+				/*
+				 * scale the add/delete
+				 */
+				max = max_change;
+				if (max + len > 70)
+					max = 70 - len;
+
+				add = data->added;
+				del = data->deleted;
+
+				if (add + del == 0) {
+					total_files--;
+					continue;
+				}
+
+				total = add + del;
+				adds += add;
+				dels += del;
+
+				if (max_change > 0) {
+					total = (total * max + max_change / 2) / max_change;
+					add = (add * max + max_change / 2) / max_change;
+					del = total - add;
+				}
+				printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
+						len, name, add + del,
+						add, pluses, del, minuses);
+			}
+			printf(" %d files changed, %d insertions(+), %d deletions(-)\n\n",
+					total_files, adds, dels);
+		}
+	}
+
+	for (i = 0; i < num_paths; i++) {
+		free(diffstat->files[i].parent);
+		free(diffstat->files[i].name);
+	}
+	free(diffstat->files);
+	diffstat->files = NULL;
+	free(parent_max_change);
+}
+
 const char *diff_tree_combined_merge(const unsigned char *sha1,
 			     const char *header, int dense,
 			     struct diff_options *opt)
@@ -840,6 +1087,11 @@ const char *diff_tree_combined_merge(con
 	struct commit_list *parents;
 	struct combine_diff_path *p, *paths = NULL;
 	int num_parent, i, num_paths;
+	struct diffstat_t *diffstat = NULL;
+
+	if (opt->output_format == DIFF_FORMAT_DIFFSTAT)
+		opt->diffstat = diffstat =
+			xcalloc(sizeof(struct diffstat_t), 1);
 
 	diffopts = *opt;
 	diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
@@ -870,6 +1122,15 @@ const char *diff_tree_combined_merge(con
 			num_paths++;
 	}
 	if (num_paths) {
+		if (diffstat) {
+			diffstat->files = xcalloc(sizeof(struct diffstat_file),
+					num_paths);
+			for (i = 0; i < num_paths; i++)
+				diffstat->files[i].parent =
+					xcalloc(sizeof(struct diffstat_parent),
+							num_parent);
+			diffstat->current = diffstat->files;
+		}
 		if (opt->with_raw) {
 			int saved_format = opt->output_format;
 			opt->output_format = DIFF_FORMAT_RAW;
@@ -882,12 +1143,22 @@ const char *diff_tree_combined_merge(con
 			putchar(opt->line_termination);
 		}
 		for (p = paths; p; p = p->next) {
+			if (p->len == 0)
+				continue;
 			if (show_combined_diff(p, num_parent, dense,
 					       header, opt))
 				header = NULL;
+			if (diffstat)
+				diffstat->current++;
 		}
 	}
 
+	if (diffstat) {
+		show_stats(diffstat, num_paths, num_parent);
+		free(diffstat);
+		opt->diffstat = diffstat = NULL;
+	}
+
 	/* Clean things up */
 	while (paths) {
 		struct combine_diff_path *tmp = paths;
diff --git a/diff.h b/diff.h
index f783bae..26e3c02 100644
--- a/diff.h
+++ b/diff.h
@@ -45,6 +45,7 @@ struct diff_options {
 	int *pathlens;
 	change_fn_t change;
 	add_remove_fn_t add_remove;
+	struct diffstat_t *diffstat;
 };
 
 extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
diff --git a/log-tree.c b/log-tree.c
index cb0d0b1..bb46f06 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -232,6 +232,12 @@ int parse_whatchanged_opt(int ac, const 
 			opt->diffopt.output_format = DIFF_FORMAT_PATCH;
 		if (opt->diffopt.output_format == DIFF_FORMAT_PATCH)
 			opt->diffopt.recursive = 1;
+		if (opt->diffopt.output_format == DIFF_FORMAT_DIFFSTAT) {
+			opt->ignore_merges = 0;
+			opt->combine_merges = 1;
+			opt->dense_combined_merges = 1;
+			opt->diffopt.recursive = 1;
+		}
 		if (!wcopt->full_diff && rev->prune_data)
 			diff_tree_setup_paths(rev->prune_data, &opt->diffopt);
 		diff_setup_done(&opt->diffopt);
-- 
1.3.0.rc4.g667c

^ permalink raw reply related

* Support "git cmd --help" syntax
From: Linus Torvalds @ 2006-04-15 18:13 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


The "--help" argument is special, in that it is (along with "--version") 
in that is taken by the "git" program itself rather than the sub-command, 
and thus we've had the syntax "git --help cmd".

However, as anybody who has ever used CVS or some similar devil-spawn 
program, it's confusing as h*ll when options before the sub-command act 
differently from options after the sub-command, so this quick hack just 
makes it acceptable to do "git cmd --help" instead, and get the exact same 
result.

It may be hacky, but it's simple and does the trick.

Of course, this does not help if you use one of the non-builtin commands 
without using the "git" helper. Ie you won't be getting a man-page just 
because you do "git-rev-list --help". Don't expect us to be quite _that_ 
helpful.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/git.c b/git.c
index 78ed403..13c6d51 100644
--- a/git.c
+++ b/git.c
@@ -411,6 +411,12 @@ static void handle_internal_command(int 
 	};
 	int i;
 
+	/* Turn "git cmd --help" into "git help cmd" */
+	if (argc > 1 && !strcmp(argv[1], "--help")) {
+		argv[1] = argv[0];
+		argv[0] = cmd = "help";
+	}
+
 	for (i = 0; i < ARRAY_SIZE(commands); i++) {
 		struct cmd_struct *p = commands+i;
 		if (strcmp(p->cmd, cmd))

^ permalink raw reply related

* Git web broken, or Linus' kernel tree in odd state
From: Tony Luck @ 2006-04-15 18:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Git Mailing List

Git web is showing the "master" tag four commits back from HEAD on
the summary page for Linus' kernel tree, which is unusual (isn't it?).

I don't think that it is a mirror problem (it's been like it at least
an hour, and
shows the same at both www1 & www2.kernel.org)

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=summary

-Tony

^ permalink raw reply

* Re: Git web broken, or Linus' kernel tree in odd state
From: Linus Torvalds @ 2006-04-15 19:03 UTC (permalink / raw)
  To: Tony Luck; +Cc: Git Mailing List
In-Reply-To: <12c511ca0604151155j40c68a21qf684f77d2476605b@mail.gmail.com>



On Sat, 15 Apr 2006, Tony Luck wrote:
>
> Git web is showing the "master" tag four commits back from HEAD on
> the summary page for Linus' kernel tree, which is unusual (isn't it?).

Seems to be some gitweb caching problem.

> I don't think that it is a mirror problem (it's been like it at least
> an hour, and shows the same at both www1 & www2.kernel.org)

It's not a mirroring issue, because if you actually look at the "heads" 
down at the same page, the "master" head points to the right commit (the 
top one). As you can see just from the time ("17 hours ago" right now), 
but also if you just go to the log through there.

		Linus

^ permalink raw reply

* Tentative built-in "git show"
From: Linus Torvalds @ 2006-04-15 19:09 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List


This uses the "--no-walk" flag that I never actually implemented (but I'm 
sure I mentioned it) to make "git show" be essentially the same thing as 
"git whatchanged --no-walk".

It just refuses to add more interesting parents to the revision walking 
history, so you don't actually get any history, you just get the commit 
you asked for.

I was going to add "--no-walk" as a real argument flag to git-rev-list 
too, but I'm not sure anybody actually needs it. Although it might be 
useful for porcelain, so I left the door open.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---

This is obviously against Junio's current "next" branch, which has the 
log/whatchanged unification.

That special-case of

	if (!strcmp(av[0], "show"...

is truly ugly, but it needs to happen after setup_revisions(), for all the 
same reasons that I suggested it might be a good idea to split up 
"init_revisions()" out of setup_revisions().

diff --git a/git.c b/git.c
index 939a34c..c87accf 100644
--- a/git.c
+++ b/git.c
@@ -363,6 +363,20 @@ static int cmd_whatchanged(int ac, const
 	return cmd_log_wc(ac, av, ep, &wcopt);
 }
 
+static int cmd_show(int ac, const char **av, char **ep)
+{
+	struct whatchanged_opt wcopt;
+
+	memset(&wcopt, 0, sizeof(wcopt));
+	wcopt.do_diff = 1;
+	init_log_tree_opt(&wcopt.logopt);
+	wcopt.logopt.ignore_merges = 0;
+	wcopt.logopt.combine_merges = 1;
+	wcopt.logopt.dense_combined_merges = 1;
+	wcopt.logopt.diffopt.recursive = 1;
+	return cmd_log_wc(ac, av, ep, &wcopt);
+}
+
 static void handle_internal_command(int argc, const char **argv, char **envp)
 {
 	const char *cmd = argv[0];
@@ -373,6 +387,7 @@ static void handle_internal_command(int 
 		{ "version", cmd_version },
 		{ "help", cmd_help },
 		{ "log", cmd_log },
+		{ "show", cmd_show },
 		{ "whatchanged", cmd_whatchanged },
 	};
 	int i;
diff --git a/log-tree.c b/log-tree.c
index cb0d0b1..17e976a 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -182,6 +182,8 @@ int parse_whatchanged_opt(int ac, const 
 	int left = 1;
 
 	ac = setup_revisions(ac, av, rev, "HEAD");
+	if (!strcmp(av[0], "show"))
+		rev->no_walk = 1;
 	while (1 < ac) {
 		const char *arg = av[1];
 		if (!strncmp(arg, "--pretty", 8)) {
diff --git a/log-tree.h b/log-tree.h
diff --git a/revision.c b/revision.c
index 0505f3f..0c3c392 100644
--- a/revision.c
+++ b/revision.c
@@ -375,6 +375,9 @@ static void add_parents_to_list(struct r
 	if (revs->prune_fn)
 		revs->prune_fn(revs, commit);
 
+	if (revs->no_walk)
+		return;
+
 	parent = commit->parents;
 	while (parent) {
 		struct commit *p = parent->item;
@@ -714,6 +717,8 @@ int setup_revisions(int argc, const char
 
 void prepare_revision_walk(struct rev_info *revs)
 {
+	if (revs->no_walk)
+		return;
 	sort_by_date(&revs->commits);
 	if (revs->limited)
 		limit_list(revs);
diff --git a/revision.h b/revision.h
index 8970b57..ff2a13e 100644
--- a/revision.h
+++ b/revision.h
@@ -26,6 +26,7 @@ struct rev_info {
 	/* Traversal flags */
 	unsigned int	dense:1,
 			no_merges:1,
+			no_walk:1,
 			remove_empty_trees:1,
 			lifo:1,
 			topo_order:1,

^ permalink raw reply related

* Re: Help please :-)
From: Petr Baudis @ 2006-04-15 19:10 UTC (permalink / raw)
  To: Paolo Ciarrocchi; +Cc: Git Mailing List
In-Reply-To: <4d8e3fd30604150908m565e8aaat8ef9846a85c4036e@mail.gmail.com>

  Hello,

Dear diary, on Sat, Apr 15, 2006 at 06:08:01PM CEST, I got a letter
where Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> said that...
> I'm used to keep updated my linux tree with cg-status,
> I did that this morning but now I see the following:
> paolo@Italia:~/linux-2.6$ cg-status
> Heads:
>    >master      2c5362007bc0a46461a9d94958cdd53bb027004c
>   R origin      2c5362007bc0a46461a9d94958cdd53bb027004c
> 
> ? arch/i386/kernel/smpboot.c.rej
> ? drivers/md/dm-stripe.c.rej
> ? drivers/net/chelsio/sge.c.rej
> ? drivers/net/e100.c.rej
> ? drivers/net/e1000/e1000_main.c.rej
> ? fs/9p/vfs_dir.c.rej
> ? fs/nfsctl.c.rej
> ? kernel/fork.c.rej
> ? kernel/posix-timers.c.rej
> ? kernel/timer.c.rej
> ? mm/memory.c.rej
> ? mm/mempolicy.c.rej
> ? mm/swap.c.rej
> ? net/ieee80211/ieee80211_crypt_ccmp.c.rej
> ? net/ieee80211/ieee80211_rx.c.rej
> ? scripts/kconfig/lkc_defs.h
> ? scripts/mod/modpost.c.rej
> paolo@Italia:~/linux-2.6$ cg-diff
> 
> I'm a bit lost, the tree is correctly updated, no error message but
> why I see all these .rej?

  you apparently had local changes in your working tree, did cg-update
and then the local changes conflicted with the new changes in Linus'
tree. cg-update should have told you further details.

> And how can I fix this problem?
> git reset and cg-reset don't help...

  cg-clean can remove files not recognized by git.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Right now I am having amnesia and deja-vu at the same time.  I think
I have forgotten this before.

^ permalink raw reply

* Re: Git web broken, or Linus' kernel tree in odd state
From: Junio C Hamano @ 2006-04-15 19:15 UTC (permalink / raw)
  To: Tony Luck; +Cc: git, Linus Torvalds
In-Reply-To: <12c511ca0604151155j40c68a21qf684f77d2476605b@mail.gmail.com>

"Tony Luck" <tony.luck@intel.com> writes:

> Git web is showing the "master" tag four commits back from HEAD on
> the summary page for Linus' kernel tree, which is unusual (isn't it?).

I suspect it is related to this:

http://article.gmane.org/gmane.comp.version-control.git/14366

^ permalink raw reply

* Re: Tentative built-in "git show"
From: Junio C Hamano @ 2006-04-15 19:28 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604151203060.3701@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> This uses the "--no-walk" flag that I never actually implemented (but I'm 
> sure I mentioned it) to make "git show" be essentially the same thing as 
> "git whatchanged --no-walk".

I sometimes do "git show -4" myself, and wondered why defaulting
to "-n 1"is insufficient, but if you do something like this to
check the tip of each branch:

	git show master next pu

this may make sense.

Otherwise, it feels to me that (I haven't had caffeine nor
nicotine yet, so I need to re-think this later) log, show and
whatchanged are the same program in disguise with different set
of defaults.

        log		--pretty
        show		--pretty -n1 -p
        whatchanged	--pretty -r

... which implies that some of them might become historical
curiosity and no real reason to teach about each of them in the
tutorial.

^ permalink raw reply

* Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE
From: Junio C Hamano @ 2006-04-15 20:50 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0604151516150.6563@wbgn013.biozentrum.uni-wuerzburg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> This helps debugging tremendously.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

I like what this wants to do.  I am not so sure PAGER=NONE is a
good convention, however.

^ permalink raw reply

* Re: Support "git cmd --help" syntax
From: Junio C Hamano @ 2006-04-15 20:54 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604151054380.3701@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> However, as anybody who has ever used CVS or some similar devil-spawn 
> program, it's confusing as h*ll when options before the sub-command act 
> differently from options after the sub-command, so this quick hack just 
> makes it acceptable to do "git cmd --help" instead, and get the exact same 
> result.
>
> It may be hacky, but it's simple and does the trick.

Tried "git commit --help" with and without the patch?

I am not sure if we want to "help" migrants from CVS or some
similar program by shooting ourselves in the foot.

^ permalink raw reply

* Re: Tentative built-in "git show"
From: Linus Torvalds @ 2006-04-15 20:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v3bgefxkp.fsf@assigned-by-dhcp.cox.net>



On Sat, 15 Apr 2006, Junio C Hamano wrote:
> 
> I sometimes do "git show -4" myself, and wondered why defaulting
> to "-n 1"is insufficient

I detest -n1 for a variety of reasons, and giving multiple refs is just 
one of them.

The reason I like "--no-walk" is that it's conceptually much stronger, and 
more efficient. Remember how we tried to optimize "-1" (as used by gitweb) 
by adding magic special cases to get_revision()? And how they always ended
up being problematic because of how they interact with all the other 
options?

So we don't do it any more, and as a result, "git-rev-list -1 HEAD" will 
actually walk all the parents too.

In contrast, "--no-walk" just does exactly what you tell it: don't start 
walking the parents. It's kind of equivalent to -1 with one argument, but 
in the presense of path limiting it actually does the RightThing(tm), 
unlike -1.

Try this as a replacement for "git show":

	git log -1 kernel/
	git log --no-walk kernel/

on the current kernel source tree to see the difference. "--no-walk" gives 
the right answer (for some definition of "right"). While -1 gives a 
totally random answer that has nothing to do with the current HEAD (except 
that it's _reachable_ from the current HEAD).

So I think "-n 1" is fundamentally incompatible with "git show". Git 
"show" is "show _this_ commit". While "-1" fundamentally means "show the 
_first_ commit when you walk the tree". Which is really really 
fundamentally different.

In contrast "--no-walk" tells you exactly what it is about. Don't walk the 
tree. Show _this_ commit.

(Now, the reason I said 'for _some_ definition of "right"' is that the 
question about path limiting in the absense of commit walking is somewhat 
ambiguous. The current "git show" shows the commit regardless. My 
suggested patch will potentially prune the commit away, and if the 
specified commit does not touch the path, no commit is shown at all. 
Both make sense. While "git-rev-list -1" does _not_ make sense)

			Linus

^ permalink raw reply

* Re: Support "git cmd --help" syntax
From: Linus Torvalds @ 2006-04-15 21:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vsloeef0k.fsf@assigned-by-dhcp.cox.net>



On Sat, 15 Apr 2006, Junio C Hamano wrote:
> 
> Tried "git commit --help" with and without the patch?

I get a usage message without the patch.

With the patch, I get the man-page.

IOW, I don't see your point.

I'd have expected that to be an improvement. You can always get the usage 
message with "git commit --huh?", so it's not like you've lost anything.

Now, if you have _not_ done

	make prefix=/usr/share install-doc

or similar, then yes, you get something less than helpful (along the lines 
of "No manual entry for git-commit"), and I agree that we could/should 
improve on that somehow. 

			Linus

^ permalink raw reply

* [PATCH] diff --stat: do not do its own three-dashes.
From: Junio C Hamano @ 2006-04-15 21:10 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

I missed that "git-diff-* --stat" spits out three-dash separator
on its own without being asked.  Remove it.

When we output commit log followed by diff, perhaps --patch-with-stat,
for downstream consumer, we _would_ want the three-dash between
the message and the diff material, but that logic belongs to the
caller, not diff generator.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---
 * Now the next task is to make "git log" not to do its own
   commit formatting, but let the log_tree_commit() do it, just
   like we do in diff-tree --pretty.  This would open the door
   for us to (optionally) omit log message when there is no
   diff, and honor the --max-count by counting what we actually
   output.

   When that happens, the printf() I moved tentatively to
   cmd_log() should become part of the commit formatting
   log_tree_commit() does, perhaps with --pretty=format-patch.

 diff.c |    2 --
 git.c  |    4 +++-
 2 files changed, 3 insertions(+), 3 deletions(-)

6f4780f9dfd3bc6b23f9ea66b3d49577e0a0c2f9
diff --git a/diff.c b/diff.c
index f1b672d..cda8d20 100644
--- a/diff.c
+++ b/diff.c
@@ -245,8 +245,6 @@ static void show_stats(struct diffstat_t
 	if (data->nr == 0)
 		return;
 
-	printf("---\n");
-
 	for (i = 0; i < data->nr; i++) {
 		struct diffstat_file *file = data->files[i];
 
diff --git a/git.c b/git.c
index 78ed403..61265a8 100644
--- a/git.c
+++ b/git.c
@@ -388,8 +388,10 @@ static int cmd_log(int argc, const char 
 		pretty_print_commit(commit_format, commit, ~0, buf,
 				    LOGSIZE, abbrev);
 		printf("%s\n", buf);
-		if (do_diff)
+		if (do_diff) {
+			printf("---\n");
 			log_tree_commit(&opt, commit);
+		}
 		shown = 1;
 		free(commit->buffer);
 		commit->buffer = NULL;
-- 
1.3.0.rc4.g5a48-dirty

^ permalink raw reply related

* Re: git-svn and Author files question
From: Eric Wong @ 2006-04-15 21:58 UTC (permalink / raw)
  To: Seth Falcon; +Cc: git
In-Reply-To: <m21wvzx5e6.fsf@ziti.fhcrc.org>

Seth Falcon <sethfalcon@gmail.com> wrote:
> Hi all,
> 
> I've been using git to manually track changes to a project that uses
> svn as its primary SCM.
> 
> git-svn looks like it can help me streamline my workflow, but I'm
> getting stuck with the following:
> 
>     mkdir foo
>     cd foo
>     git-svn init $URL  <--- the svn URL
>     git-svn fetch
>     Author: dfcimm3 not defined in  file
> 
> :-(
> 
> Can someone point me to the file and the place that describes what I
> should put in it?  There are many committers to the svn project.  I'm
> hoping that I will not have to enumerate all of their names in some
> file.
> 
> I'm using git version 1.3.0.rc1.g40e9, and BTW, enjoying it very much.

There were some embarassing bugs between the git-svn in rc1 and rc2.
Current versions should work.  Rutger was right about the file format,
same as the other importers.

Sorry about so long to reply to questions this week, left hand/wrist is
wrecked.

@Pavel, Junio: I should have doc updates coming in hopefully in the next
few days, unless anybody wants to help :)

-- 
Eric Wong

^ permalink raw reply

* Re: Support "git cmd --help" syntax
From: Junio C Hamano @ 2006-04-16  1:24 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604151402470.3701@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> I'd have expected that to be an improvement. You can always get the usage 
> message with "git commit --huh?", so it's not like you've lost anything.

Fair enough.  I'd say I am convinced now.

^ permalink raw reply

* Re: git-svn and Author files question
From: Seth Falcon @ 2006-04-16  1:57 UTC (permalink / raw)
  To: git
In-Reply-To: <20060415215850.GB20468@hand.yhbt.net>

Eric Wong <normalperson@yhbt.net> writes:
> There were some embarassing bugs between the git-svn in rc1 and rc2.
> Current versions should work.  Rutger was right about the file format,
> same as the other importers.

Thanks for the explanation (and thanks to Rutger as well for the
reply!).

I managed to get git-svn fetch to work by specifying an author file
with -A.

I'm a bit confused about why I have to do this.  Is there a way around
this?  Or perhaps a way to force a bogus email address based on svn
user name?

[ok, maybe I'm less confused than I'm letting on: the email
requirement is, I think, because that's what suits the main git
"customers".  If I was using git for a project's primary SCM, I would
have no problem with this.  In fact, we started using email addresses
as user names in svn a long time ago.  

But it seems to me that (1) using git to track a project that uses a
less featureful SCM is way cool, and (2) having to manually muck with
an authors file is kinda uncool.]

> Sorry about so long to reply to questions this week, left hand/wrist is
> wrecked.

Hope it heals quickly!


Thanks for listening and again for the help,

+ seth

^ permalink raw reply

* Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE
From: Johannes Schindelin @ 2006-04-16  2:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vwtdqef6u.fsf@assigned-by-dhcp.cox.net>

Hi,

On Sat, 15 Apr 2006, Junio C Hamano wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > This helps debugging tremendously.
> >
> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> 
> I like what this wants to do.  I am not so sure PAGER=NONE is a
> good convention, however.

I am sure it is not.

One solution would be to introduce yet another command line option 
"--no-pager", but I find that ugly.

Another solution would be to check if the environment variable NO_PAGER is 
set.

Wishes?

Ciao,
Dscho

^ permalink raw reply

* [FYI] generated completions
From: Johannes Schindelin @ 2006-04-16  2:05 UTC (permalink / raw)
  To: git

Hi,

I just played around with command line completion in bash, mainly to 
distract me from the work I have to do.

This is a shell script which generates a completion script from the 
documentation. It is very dumb at the moment, but at least a start. I am 
not likely to continue with this in the near future, so everyone who's 
interested: go wild.

--- generate-completions.sh ---
#!/bin/sh

cat << EOF
function gitcomplete ()
{
	case "\$COMP_LINE" in
EOF

cmds=""
for file in Documentation/git-*.txt; do
	cmd=$(expr $file : "Documentation/git-\(.*\).txt")
	cmds="$cmds $cmd"
	echo "	git\ $cmd\ *)"
	echo '		case "$3" in'

	# get all lines which begin with '-' or '<' and end with '::',
	# because they likely contain a command line option
	sed -n "s/^\([-<].*\)::/\1/p" < $file | { \
		opts=""
		while read line; do
			# some lines have the form '-a|--all'
			opt1=$(expr "$line" : '^\([^ |<]*\)')
			opt2=$(expr "$line" : '|\([^ |<]*\)')
			opts="$opts $opt1 $opt2"
			# this is an example how to handle non-simple args:
			# '-m <msg>' means: if the second-last arg is '-m',
			# the current arg is the message.
			test "$(expr "$line" : ".*<msg>")" != 0 &&
				echo "		'$opt1')" &&
				echo '			COMPREPLY=(\"a \"z);;'
		done
		echo "		*)"
		echo "			COMPREPLY=(\$(compgen -W \"$opts\" -- \$2));;"
	}
	echo "		esac;;"
done

cat << EOF
	git\ *\ *)
		COMPREPLY=();;
	git\ *)
		COMPREPLY=(\$(compgen -W '$cmds' -- \$2));;
	esac
}

complete -o default -F gitcomplete git
EOF
--- cut ---

^ permalink raw reply

* Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE
From: Junio C Hamano @ 2006-04-16  2:20 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0604160357460.31461@wbgn013.biozentrum.uni-wuerzburg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi,
>
> On Sat, 15 Apr 2006, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 
>> > This helps debugging tremendously.
>> >
>> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>> 
>> I like what this wants to do.  I am not so sure PAGER=NONE is a
>> good convention, however.
>
> I am sure it is not.
>
> One solution would be to introduce yet another command line option 
> "--no-pager", but I find that ugly.
>
> Another solution would be to check if the environment variable NO_PAGER is 
> set.
>
> Wishes?

Honestly, undecided.  Not that I think people would do
PAGER=NONE to mean a program /usr/bin/NONE.

Right now, the following does not say anything:

	$ PAGER= git log

but I do not think that is a reasonably behaviour, either.  So
detecting PAGER is set to an empty string (not "nonexistence" -
the current behaviour of defaulting to "less" in such a case is
reasonable) is probably a better alternative.

A somewhat related topic; I often set PAGER=cat when I do not
want the --[More]-- prompt and I thing many Emacs users do this.
It might also be good to detect it and omit piping in such a
case, but that is independent, so if you are going to do this as
well, please make it a separate patch.

^ permalink raw reply

* Re: git-svn and Author files question
From: Junio C Hamano @ 2006-04-16  2:22 UTC (permalink / raw)
  To: git
In-Reply-To: <m2ejzys2ns.fsf@ziti.fhcrc.org>

Seth Falcon <sethfalcon@gmail.com> writes:

> I'm a bit confused about why I have to do this.  Is there a way around
> this?  Or perhaps a way to force a bogus email address based on svn
> user name?

I think this is a reasonable request.  IIRC, the original
foreign SCM interface (git-cvsimport) did "foobar <foobar>"
if there is no mapping available, so that might be a good
example to follow.

^ permalink raw reply

* Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE
From: Johannes Schindelin @ 2006-04-16  2:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v4q0udzwg.fsf@assigned-by-dhcp.cox.net>

Hi,

On Sat, 15 Apr 2006, Junio C Hamano wrote:

> A somewhat related topic; I often set PAGER=cat when I do not
> want the --[More]-- prompt and I thing many Emacs users do this.
> It might also be good to detect it and omit piping in such a
> case, but that is independent, so if you are going to do this as
> well, please make it a separate patch.

I was not quite sure if PAGER=cat could be taken as "user does not want 
any pager to be fork()ed", but you are probably right: PAGER=cat means 
that stdout is forwarded to stdout, i.e. we are better off not fork()ing 
and calling "cat":

---
[PATCH] pager: do not fork a pager if PAGER=cat

This helps debugging tremendously.

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

---

 pager.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

4a617a436bba9288cec5d3918d02c5b0e652df98
diff --git a/pager.c b/pager.c
index 1364e15..86e93b3 100644
--- a/pager.c
+++ b/pager.c
@@ -5,9 +5,8 @@ #include "cache.h"
  * something different on Windows, for example.
  */
 
-static void run_pager(void)
+static void run_pager(const char *prog)
 {
-	const char *prog = getenv("PAGER");
 	if (!prog)
 		prog = "less";
 	setenv("LESS", "-S", 0);
@@ -16,10 +15,11 @@ static void run_pager(void)
 
 void setup_pager(void)
 {
+	const char *prog = getenv("PAGER");
 	pid_t pid;
 	int fd[2];
 
-	if (!isatty(1))
+	if (!isatty(1) || (prog != NULL && !strcmp(prog, "cat")))
 		return;
 	if (pipe(fd) < 0)
 		return;
@@ -43,6 +43,6 @@ void setup_pager(void)
 	close(fd[0]);
 	close(fd[1]);
 
-	run_pager();
+	run_pager(prog);
 	exit(255);
 }
-- 
1.3.0.rc4.gb6b20-dirty

^ permalink raw reply related

* Re: Recent unresolved issues
From: Junio C Hamano @ 2006-04-16  8:14 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604151016220.3701@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> Btw, I can certainly understand if you don't want to do this before 1.3.x. 
> Since there's no actual user-visible advantage to it, it's probably worth 
> dropping for now.

Well, I bit the bullet, fixed-up the remaining issues I found in
rev-list in your grand unified version, reverted the revert, and
ported the changes for log/whatchanged/show.

For now this lives in the "next" branch and _will_ not graduate
before 1.3.0, of course.

^ permalink raw reply

* Re: Help please :-)
From: Paolo Ciarrocchi @ 2006-04-16  9:30 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Git Mailing List
In-Reply-To: <20060415191039.GC27689@pasky.or.cz>

On 4/15/06, Petr Baudis <pasky@suse.cz> wrote:
>   Hello,
>
> Dear diary, on Sat, Apr 15, 2006 at 06:08:01PM CEST, I got a letter
> where Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> said that...
> > I'm used to keep updated my linux tree with cg-status,
> > I did that this morning but now I see the following:
> > paolo@Italia:~/linux-2.6$ cg-status
> > Heads:
> >    >master      2c5362007bc0a46461a9d94958cdd53bb027004c
> >   R origin      2c5362007bc0a46461a9d94958cdd53bb027004c
> >
> > ? arch/i386/kernel/smpboot.c.rej
> > ? drivers/md/dm-stripe.c.rej
> > ? drivers/net/chelsio/sge.c.rej
> > ? drivers/net/e100.c.rej
> > ? drivers/net/e1000/e1000_main.c.rej
> > ? fs/9p/vfs_dir.c.rej
> > ? fs/nfsctl.c.rej
> > ? kernel/fork.c.rej
> > ? kernel/posix-timers.c.rej
> > ? kernel/timer.c.rej
> > ? mm/memory.c.rej
> > ? mm/mempolicy.c.rej
> > ? mm/swap.c.rej
> > ? net/ieee80211/ieee80211_crypt_ccmp.c.rej
> > ? net/ieee80211/ieee80211_rx.c.rej
> > ? scripts/kconfig/lkc_defs.h
> > ? scripts/mod/modpost.c.rej
> > paolo@Italia:~/linux-2.6$ cg-diff
> >
> > I'm a bit lost, the tree is correctly updated, no error message but
> > why I see all these .rej?
>
>   you apparently had local changes in your working tree, did cg-update
> and then the local changes conflicted with the new changes in Linus'
> tree. cg-update should have told you further details.

Can this be due an interrupted cg-update?
However, cg-update did not complain.

> > And how can I fix this problem?
> > git reset and cg-reset don't help...
>
>   cg-clean can remove files not recognized by git.

Thanks!

Ciao,
--
Paolo
http://paolociarrocchi.googlepages.com

^ permalink raw reply


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