* [PATCH 0/3] Add a testsuite to stgit
From: Yann Dirson @ 2006-04-12 21:16 UTC (permalink / raw)
To: git
The following steals the testsuite system from git-core and adapts it to stgit,
adds a couple of items to the TODO file, and adds a first testsuite to
demonstrate a problem with branch renaming, to serve as a non-reg test.
To run the testsuite, just "make -C t", there is no integration in the python-generated
toplevel Makefile.
--
Yann Dirson <ydirson@altern.org> |
Debian-related: <dirson@debian.org> | Support Debian GNU/Linux:
| Freedom, Power, Stability, Gratis
http://ydirson.free.fr/ | Check <http://www.debian.org/>
^ permalink raw reply
* [PATCH 2/3] Add list of bugs to TODO
From: Yann Dirson @ 2006-04-12 21:21 UTC (permalink / raw)
To: git
In-Reply-To: <20060412211633.14579.98008.stgit@gandelf.nowhere.earth>
From: <>
---
TODO | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index e5affe0..a9a8b1f 100644
--- a/TODO
+++ b/TODO
@@ -17,3 +17,12 @@ The future, when time allows or if someo
synchronising with other patches (diff format or in other
repositories)
- write bash-completion script for the StGIT commands
+- support for branches with / in names
+ (ml: "Handle branch names with slashes")
+- "pull" argument should default to a sane value, "origin" is wrong in
+ many cases
+
+Bugs:
+
+- the following commands break in subdirs:
+ - refresh (ml: "Running StGIT in subdirectories")
^ permalink raw reply related
* [PATCH 3/3] Add testcase for branch -r problem
From: Yann Dirson @ 2006-04-12 21:21 UTC (permalink / raw)
To: git
In-Reply-To: <20060412211633.14579.98008.stgit@gandelf.nowhere.earth>
From: <>
---
TODO | 1 +
t/t1000-branch.sh | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/TODO b/TODO
index a9a8b1f..365ecd4 100644
--- a/TODO
+++ b/TODO
@@ -26,3 +26,4 @@ Bugs:
- the following commands break in subdirs:
- refresh (ml: "Running StGIT in subdirectories")
+- branch renaming leaves junk behind
diff --git a/t/t1000-branch.sh b/t/t1000-branch.sh
new file mode 100755
index 0000000..4c790f5
--- /dev/null
+++ b/t/t1000-branch.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Yann Dirson
+#
+
+test_description='dummy test.
+
+Only to test the testing environment.
+'
+
+. ./test-lib.sh
+
+test_stg_init
+
+test_expect_success \
+ 'Create an stgit branch from scratch' \
+ 'stg branch -c foo &&
+ stg new p1 -m "p1"
+'
+
+test_expect_failure \
+ 'Rename the current stgit branch' \
+ 'stg branch -r foo bar
+'
+
+test_expect_success \
+ 'Rename an stgit branch' \
+ 'stg branch -c buz &&
+ stg branch -r foo bar &&
+ test -z `find .git -name foo`
+'
+
+test_done
^ permalink raw reply related
* [PATCH 1/3] Add a testsuite framework copied from git-core
From: Yann Dirson @ 2006-04-12 21:21 UTC (permalink / raw)
To: git
In-Reply-To: <20060412211633.14579.98008.stgit@gandelf.nowhere.earth>
From: <>
---
t/Makefile | 25 ++++++
t/t0000-dummy.sh | 17 ++++
t/test-lib.sh | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 251 insertions(+), 0 deletions(-)
diff --git a/t/Makefile b/t/Makefile
new file mode 100644
index 0000000..d5d7b6f
--- /dev/null
+++ b/t/Makefile
@@ -0,0 +1,25 @@
+# Run tests
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+#GIT_TEST_OPTS=--verbose --debug
+SHELL_PATH ?= $(SHELL)
+TAR ?= $(TAR)
+
+# Shell quote;
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+
+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
+
+all: $(T) clean
+
+$(T):
+ @echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
+
+clean:
+ rm -fr trash
+
+.PHONY: $(T) clean
+.NOPARALLEL:
+
diff --git a/t/t0000-dummy.sh b/t/t0000-dummy.sh
new file mode 100755
index 0000000..ae4f838
--- /dev/null
+++ b/t/t0000-dummy.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Yann Dirson
+#
+
+test_description='dummy test.
+
+Only to test the testing environment.
+'
+
+. ./test-lib.sh
+
+test_expect_success \
+ 'check stgit can be run' \
+ 'stg version'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
new file mode 100755
index 0000000..b1ac350
--- /dev/null
+++ b/t/test-lib.sh
@@ -0,0 +1,209 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+# Copyright (c) 2006 Yann Dirson
+#
+
+# For repeatability, reset the environment to known value.
+LANG=C
+LC_ALL=C
+PAGER=cat
+TZ=UTC
+export LANG LC_ALL PAGER TZ
+unset AUTHOR_DATE
+unset AUTHOR_EMAIL
+unset AUTHOR_NAME
+unset COMMIT_AUTHOR_EMAIL
+unset COMMIT_AUTHOR_NAME
+unset GIT_ALTERNATE_OBJECT_DIRECTORIES
+unset GIT_AUTHOR_DATE
+GIT_AUTHOR_EMAIL=author@example.com
+GIT_AUTHOR_NAME='A U Thor'
+unset GIT_COMMITTER_DATE
+GIT_COMMITTER_EMAIL=committer@example.com
+GIT_COMMITTER_NAME='C O Mitter'
+unset GIT_DIFF_OPTS
+unset GIT_DIR
+unset GIT_EXTERNAL_DIFF
+unset GIT_INDEX_FILE
+unset GIT_OBJECT_DIRECTORY
+unset SHA1_FILE_DIRECTORIES
+unset SHA1_FILE_DIRECTORY
+export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
+
+# Each test should start with something like this, after copyright notices:
+#
+# test_description='Description of this test...
+# This test checks if command xyzzy does the right thing...
+# '
+# . ./test-lib.sh
+
+error () {
+ echo "* error: $*"
+ trap - exit
+ exit 1
+}
+
+say () {
+ echo "* $*"
+}
+
+test "${test_description}" != "" ||
+error "Test script did not set test_description."
+
+while test "$#" -ne 0
+do
+ case "$1" in
+ -d|--d|--de|--deb|--debu|--debug)
+ debug=t; shift ;;
+ -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
+ immediate=t; shift ;;
+ -h|--h|--he|--hel|--help)
+ echo "$test_description"
+ exit 0 ;;
+ -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
+ verbose=t; shift ;;
+ *)
+ break ;;
+ esac
+done
+
+exec 5>&1
+if test "$verbose" = "t"
+then
+ exec 4>&2 3>&1
+else
+ exec 4>/dev/null 3>/dev/null
+fi
+
+test_failure=0
+test_count=0
+
+trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
+
+
+# You are not expected to call test_ok_ and test_failure_ directly, use
+# the text_expect_* functions instead.
+
+test_ok_ () {
+ test_count=$(expr "$test_count" + 1)
+ say " ok $test_count: $@"
+}
+
+test_failure_ () {
+ test_count=$(expr "$test_count" + 1)
+ test_failure=$(expr "$test_failure" + 1);
+ say "FAIL $test_count: $1"
+ shift
+ echo "$@" | sed -e 's/^/ /'
+ test "$immediate" = "" || { trap - exit; exit 1; }
+}
+
+
+test_debug () {
+ test "$debug" = "" || eval "$1"
+}
+
+test_run_ () {
+ eval >&3 2>&4 "$1"
+ eval_ret="$?"
+ return 0
+}
+
+test_expect_failure () {
+ test "$#" = 2 ||
+ error "bug in the test script: not 2 parameters to test-expect-failure"
+ say >&3 "expecting failure: $2"
+ test_run_ "$2"
+ if [ "$?" = 0 -a "$eval_ret" != 0 ]
+ then
+ test_ok_ "$1"
+ else
+ test_failure_ "$@"
+ fi
+}
+
+test_expect_success () {
+ test "$#" = 2 ||
+ error "bug in the test script: not 2 parameters to test-expect-success"
+ say >&3 "expecting success: $2"
+ test_run_ "$2"
+ if [ "$?" = 0 -a "$eval_ret" = 0 ]
+ then
+ test_ok_ "$1"
+ else
+ test_failure_ "$@"
+ fi
+}
+
+test_expect_code () {
+ test "$#" = 3 ||
+ error "bug in the test script: not 3 parameters to test-expect-code"
+ say >&3 "expecting exit code $1: $3"
+ test_run_ "$3"
+ if [ "$?" = 0 -a "$eval_ret" = "$1" ]
+ then
+ test_ok_ "$2"
+ else
+ test_failure_ "$@"
+ fi
+}
+
+# Most tests can use the created repository, but some amy need to create more.
+# Usage: test_create_repo <directory>
+test_create_repo () {
+ test "$#" = 1 ||
+ error "bug in the test script: not 1 parameter to test-create-repo"
+ owd=`pwd`
+ repo="$1"
+ mkdir "$repo"
+ cd "$repo" || error "Cannot setup test environment"
+ git-init-db 2>/dev/null ||
+ error "cannot run git-init-db -- have you installed git-core?"
+ mv .git/hooks .git/hooks-disabled
+ cd "$owd"
+}
+
+test_stg_init () {
+ touch .empty
+ git-update-index --add .empty
+ git-commit -m "nearly empty start" 2>/dev/null ||
+ error "cannot run git-commit -- is your git-core funtionning?"
+ stg init ||
+ error "cannot run stg init -- have you built things yet?"
+}
+
+test_done () {
+ trap - exit
+ case "$test_failure" in
+ 0)
+ # We could:
+ # cd .. && rm -fr trash
+ # but that means we forbid any tests that use their own
+ # subdirectory from calling test_done without coming back
+ # to where they started from.
+ # The Makefile provided will clean this test area so
+ # we will leave things as they are.
+
+ say "passed all $test_count test(s)"
+ exit 0 ;;
+
+ *)
+ say "failed $test_failure among $test_count test(s)"
+ exit 1 ;;
+
+ esac
+}
+
+# Test the binaries we have just built. The tests are kept in
+# t/ subdirectory and are run in trash subdirectory.
+PATH=$(pwd)/..:$PATH
+export PATH
+
+
+# Test repository
+test=trash
+rm -fr "$test"
+test_create_repo $test
+cd "$test"
^ permalink raw reply related
* [PATCH] diff-options: add --stat
From: Johannes Schindelin @ 2006-04-13 1:02 UTC (permalink / raw)
To: git, junkio
Now you can say "git diff --stat" (to get an idea how many changes are
uncommitted), or "git log --stat" (to get an idea how many changes were
committed).
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Probably it would be nicer to pass down the diff_options to
builtin_diff(), run_diff() and run_diff_cmd(), but I am *way*
too tired to change that now.
It would have been nice to not just rip out and modify the diffstat
code from apply.c, but I did not want to fake patch structures.
Maybe someone more intelligent than me wants to fix this...
Documentation/diff-options.txt | 3
diff.c | 250 ++++++++++++++++++++++++++++++++++------
diff.h | 3
git-diff.sh | 6 +
4 files changed, 222 insertions(+), 40 deletions(-)
c706aa10bc5e2e2e22fb07aeaff1418f3d4caee0
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 338014c..447e522 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -7,6 +7,9 @@
--patch-with-raw::
Generate patch but keep also the default raw diff output.
+--stat::
+ Generate a diffstat instead of a patch.
+
-z::
\0 line termination on output
diff --git a/diff.c b/diff.c
index a14e664..7f2b652 100644
--- a/diff.c
+++ b/diff.c
@@ -177,6 +177,7 @@ static int fill_mmfile(mmfile_t *mf, str
struct emit_callback {
const char **label_path;
+ struct diffstat_t *diffstat;
};
static int fn_out(void *priv, mmbuffer_t *mb, int nbuf)
@@ -195,6 +196,150 @@ static int fn_out(void *priv, mmbuffer_t
return 0;
}
+struct diffstat_t {
+ int nr;
+ int alloc;
+ struct diffstat_file {
+ char *name;
+ unsigned int added, deleted;
+ } **files;
+};
+
+static int fn_diffstat(void *priv, mmbuffer_t *mb, int nbuf)
+{
+ int i;
+ struct emit_callback *data = priv;
+ struct diffstat_file *x;
+ struct diffstat_t *diffstat = data->diffstat;
+
+ if (data->label_path[0]) {
+ x = xcalloc(sizeof (*x), 1);
+ if (diffstat->nr == diffstat->alloc) {
+ diffstat->alloc = alloc_nr(diffstat->alloc);
+ diffstat->files = xrealloc(diffstat->files,
+ diffstat->alloc * sizeof(x));
+ }
+ diffstat->files[diffstat->nr++] = x;
+ x->name = strdup(data->label_path[0] + 2);
+ data->label_path[0] = data->label_path[1] = NULL;
+ } else
+ x = diffstat->files[diffstat->nr - 1];
+
+ for (i = 0; i < nbuf; i++)
+ if (mb[i].ptr[0] == '+')
+ x->added++;
+ else if (mb[i].ptr[0] == '-')
+ x->deleted++;
+ return 0;
+}
+
+static void diffstat_binary(struct diffstat_t *diffstat, const char *name)
+{
+ struct diffstat_file *x = xcalloc(sizeof (*x), 1);
+ if (diffstat->nr == diffstat->alloc) {
+ diffstat->alloc = alloc_nr(diffstat->alloc);
+ diffstat->files = xrealloc(diffstat->files,
+ diffstat->alloc * sizeof(x));
+ }
+ diffstat->files[diffstat->nr++] = x;
+ x->name = strdup(name + 2);
+ x->added = -1;
+}
+
+static const char pluses[] = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
+static const char minuses[]= "----------------------------------------------------------------------";
+
+static void show_stats(struct diffstat_t* data)
+{
+ char *prefix = "";
+ int i, len, add, del, total, adds = 0, dels = 0;
+ int max, max_change = 0, max_len = 0;
+ int total_files = data->nr;
+
+ if (data->nr == 0)
+ return;
+
+ printf("---\n");
+
+ for (i = 0; i < data->nr; i++) {
+ struct diffstat_file *file = data->files[i];
+
+ if (max_change < file->added + file->deleted)
+ max_change = file->added + file->deleted;
+ len = strlen(file->name);
+ if (max_len < len)
+ max_len = len;
+ }
+
+ for (i = 0; i < data->nr; i++) {
+ char *name = data->files[i]->name;
+ int added = data->files[i]->added;
+ int deleted = data->files[i]->deleted;
+
+ if (0 < (len = quote_c_style(name, NULL, NULL, 0))) {
+ char *qname = xmalloc(len + 1);
+ quote_c_style(name, qname, NULL, 0);
+ free(name);
+ name = qname;
+ }
+
+ /*
+ * "scale" the filename
+ */
+ len = strlen(name);
+ max = max_len;
+ 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;
+
+ if (added < 0) {
+ /* binary file */
+ printf(" %s%-*s | Bin\n", prefix, len, name);
+ continue;
+ } else if (added + deleted == 0) {
+ total_files--;
+ continue;
+ }
+
+ add = added;
+ del = deleted;
+ 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;
+ }
+ /* TODO: binary */
+ printf(" %s%-*s |%5d %.*s%.*s\n", prefix,
+ len, name, added + deleted,
+ add, pluses, del, minuses);
+ free(name);
+ free(data->files[i]);
+ }
+ free(data->files);
+ printf(" %d files changed, %d insertions(+), %d deletions(-)\n",
+ total_files, adds, dels);
+}
+
#define FIRST_FEW_BYTES 8000
static int mmfile_is_binary(mmfile_t *mf)
{
@@ -211,7 +356,8 @@ static void builtin_diff(const char *nam
struct diff_filespec *one,
struct diff_filespec *two,
const char *xfrm_msg,
- int complete_rewrite)
+ int complete_rewrite,
+ struct diffstat_t* diffstat)
{
mmfile_t mf1, mf2;
const char *lbl[2];
@@ -221,43 +367,49 @@ static void builtin_diff(const char *nam
b_two = quote_two("b/", name_b);
lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null";
- printf("diff --git %s %s\n", a_one, b_two);
- if (lbl[0][0] == '/') {
- /* /dev/null */
- printf("new file mode %06o\n", two->mode);
- if (xfrm_msg && xfrm_msg[0])
- puts(xfrm_msg);
- }
- else if (lbl[1][0] == '/') {
- printf("deleted file mode %06o\n", one->mode);
- if (xfrm_msg && xfrm_msg[0])
- puts(xfrm_msg);
- }
- else {
- if (one->mode != two->mode) {
- printf("old mode %06o\n", one->mode);
- printf("new mode %06o\n", two->mode);
+ if (!diffstat) {
+ printf("diff --git %s %s\n", a_one, b_two);
+ if (lbl[0][0] == '/') {
+ /* /dev/null */
+ printf("new file mode %06o\n", two->mode);
+ if (xfrm_msg && xfrm_msg[0])
+ puts(xfrm_msg);
}
- if (xfrm_msg && xfrm_msg[0])
- puts(xfrm_msg);
- /*
- * we do not run diff between different kind
- * of objects.
- */
- if ((one->mode ^ two->mode) & S_IFMT)
- goto free_ab_and_return;
- if (complete_rewrite) {
- emit_rewrite_diff(name_a, name_b, one, two);
- goto free_ab_and_return;
+ else if (lbl[1][0] == '/') {
+ printf("deleted file mode %06o\n", one->mode);
+ if (xfrm_msg && xfrm_msg[0])
+ puts(xfrm_msg);
}
+ else {
+ if (one->mode != two->mode) {
+ printf("old mode %06o\n", one->mode);
+ printf("new mode %06o\n", two->mode);
+ }
+ if (xfrm_msg && xfrm_msg[0])
+ puts(xfrm_msg);
+ /*
+ * we do not run diff between different kind
+ * of objects.
+ */
+ if ((one->mode ^ two->mode) & S_IFMT)
+ goto free_ab_and_return;
+ if (complete_rewrite) {
+ emit_rewrite_diff(name_a, name_b, one, two);
+ goto free_ab_and_return;
+ }
+ }
}
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");
- if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2))
- printf("Binary files %s and %s differ\n", lbl[0], lbl[1]);
- else {
+ if (mmfile_is_binary(&mf1) || mmfile_is_binary(&mf2)) {
+ if (diffstat)
+ diffstat_binary(diffstat, lbl[0]);
+ else
+ printf("Binary files %s and %s differ\n",
+ lbl[0], lbl[1]);
+ } else {
/* Crazy xdl interfaces.. */
const char *diffopts = getenv("GIT_DIFF_OPTS");
xpparam_t xpp;
@@ -266,6 +418,7 @@ static void builtin_diff(const char *nam
struct emit_callback ecbdata;
ecbdata.label_path = lbl;
+ ecbdata.diffstat = diffstat;
xpp.flags = XDF_NEED_MINIMAL;
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_FUNCNAMES;
@@ -275,7 +428,7 @@ static void builtin_diff(const char *nam
xecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);
else if (!strncmp(diffopts, "-u", 2))
xecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);
- ecb.outf = fn_out;
+ ecb.outf = diffstat ? fn_diffstat : fn_out;
ecb.priv = &ecbdata;
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
}
@@ -690,16 +843,19 @@ static void run_diff_cmd(const char *pgm
struct diff_filespec *one,
struct diff_filespec *two,
const char *xfrm_msg,
- int complete_rewrite)
+ int complete_rewrite,
+ struct diffstat_t *diffstat)
{
if (pgm) {
+ if (diffstat)
+ die ("Cannot use diffstat with external diff");
run_external_diff(pgm, name, other, one, two, xfrm_msg,
complete_rewrite);
return;
}
if (one && two)
builtin_diff(name, other ? other : name,
- one, two, xfrm_msg, complete_rewrite);
+ one, two, xfrm_msg, complete_rewrite, diffstat);
else
printf("* Unmerged path %s\n", name);
}
@@ -733,7 +889,8 @@ static void run_diff(struct diff_filepai
if (DIFF_PAIR_UNMERGED(p)) {
/* unmerged */
- run_diff_cmd(pgm, p->one->path, NULL, NULL, NULL, NULL, 0);
+ run_diff_cmd(pgm, p->one->path, NULL, NULL, NULL, NULL, 0,
+ o->diffstat);
return;
}
@@ -805,15 +962,17 @@ static void run_diff(struct diff_filepai
* needs to be split into deletion and creation.
*/
struct diff_filespec *null = alloc_filespec(two->path);
- run_diff_cmd(NULL, name, other, one, null, xfrm_msg, 0);
+ run_diff_cmd(NULL, name, other, one, null, xfrm_msg, 0,
+ o->diffstat);
free(null);
null = alloc_filespec(one->path);
- run_diff_cmd(NULL, name, other, null, two, xfrm_msg, 0);
+ run_diff_cmd(NULL, name, other, null, two, xfrm_msg, 0,
+ o->diffstat);
free(null);
}
else
run_diff_cmd(pgm, name, other, one, two, xfrm_msg,
- complete_rewrite);
+ complete_rewrite, o->diffstat);
free(name_munged);
free(other_munged);
@@ -866,6 +1025,8 @@ int diff_opt_parse(struct diff_options *
options->output_format = DIFF_FORMAT_PATCH;
options->with_raw = 1;
}
+ else if (!strcmp(arg, "--stat"))
+ options->output_format = DIFF_FORMAT_DIFFSTAT;
else if (!strcmp(arg, "-z"))
options->line_termination = 0;
else if (!strncmp(arg, "-l", 2))
@@ -1291,6 +1452,7 @@ static void flush_one_pair(struct diff_f
break;
default:
switch (diff_output_format) {
+ case DIFF_FORMAT_DIFFSTAT:
case DIFF_FORMAT_PATCH:
diff_flush_patch(p, options);
break;
@@ -1316,6 +1478,12 @@ void diff_flush(struct diff_options *opt
struct diff_queue_struct *q = &diff_queued_diff;
int i;
int diff_output_format = options->output_format;
+ struct diffstat_t *diffstat = NULL;
+
+ if (diff_output_format == DIFF_FORMAT_DIFFSTAT) {
+ diffstat = xcalloc(sizeof (struct diffstat_t), 1);
+ options->diffstat = diffstat;
+ }
if (options->with_raw) {
for (i = 0; i < q->nr; i++) {
@@ -1329,6 +1497,12 @@ void diff_flush(struct diff_options *opt
flush_one_pair(p, diff_output_format, options);
diff_free_filepair(p);
}
+
+ if (diffstat) {
+ show_stats(diffstat);
+ free(diffstat);
+ }
+
free(q->queue);
q->queue = NULL;
q->nr = q->alloc = 0;
diff --git a/diff.h b/diff.h
index 236095f..5c1526c 100644
--- a/diff.h
+++ b/diff.h
@@ -44,6 +44,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 *);
@@ -119,6 +120,7 @@ #define COMMON_DIFF_OPTIONS_HELP \
" -u synonym for -p.\n" \
" --patch-with-raw\n" \
" output both a patch and the diff-raw format.\n" \
+" --stat show diffstat instead of patch.\n" \
" --name-only show only names of changed files.\n" \
" --name-status show names and status of changed files.\n" \
" --full-index show full object name on index lines.\n" \
@@ -142,6 +144,7 @@ #define DIFF_FORMAT_PATCH 2
#define DIFF_FORMAT_NO_OUTPUT 3
#define DIFF_FORMAT_NAME 4
#define DIFF_FORMAT_NAME_STATUS 5
+#define DIFF_FORMAT_DIFFSTAT 6
extern void diff_flush(struct diff_options*);
diff --git a/git-diff.sh b/git-diff.sh
index dc0dd31..0fe6770 100755
--- a/git-diff.sh
+++ b/git-diff.sh
@@ -30,9 +30,11 @@ case " $flags " in
cc_or_p=--cc ;;
esac
-# If we do not have --name-status, --name-only, -r, or -c default to --cc.
+# If we do not have --name-status, --name-only, -r, -c or --stat,
+# default to --cc.
case " $flags " in
-*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* | *" '-c' "* )
+*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* | *" '-c' "* | \
+*" '--stat' "*)
;;
*)
flags="$flags'$cc_or_p' " ;;
--
1.2.0.gd507-dirty
^ permalink raw reply related
* Re: [PATCH] diff-options: add --stat
From: Johannes Schindelin @ 2006-04-13 1:15 UTC (permalink / raw)
To: git, junkio
In-Reply-To: <Pine.LNX.4.63.0604130301240.28688@wbgn013.biozentrum.uni-wuerzburg.de>
Hi,
I just realized that something is wrong with this patch: the first file
of the patchset seems to be ignored. I'll fix it tomorrow.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] diff-options: add --stat
From: Johannes Schindelin @ 2006-04-13 1:32 UTC (permalink / raw)
To: git, junkio
In-Reply-To: <Pine.LNX.4.63.0604130308150.11360@wbgn013.biozentrum.uni-wuerzburg.de>
Hi,
On Thu, 13 Apr 2006, Johannes Schindelin wrote:
> I just realized that something is wrong with this patch: the first file
> of the patchset seems to be ignored. I'll fix it tomorrow.
Okay, so I lied: I fixed it today.
diff --git a/diff-tree.c b/diff-tree.c
index 2b79dd0..536da8e 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -117,7 +117,8 @@ int main(int argc, const char **argv)
if (opt->dense_combined_merges)
opt->diffopt.output_format = DIFF_FORMAT_PATCH;
- if (opt->diffopt.output_format == DIFF_FORMAT_PATCH)
+ if (opt->diffopt.output_format == DIFF_FORMAT_DIFFSTAT ||
+ opt->diffopt.output_format == DIFF_FORMAT_PATCH)
opt->diffopt.recursive = 1;
diff_tree_setup_paths(get_pathspec(prefix, argv), opt);
diff --git a/git.c b/git.c
index 5cb0d32..e4fcf92 100644
--- a/git.c
+++ b/git.c
@@ -344,7 +344,8 @@ static int cmd_log(int argc, const char
opt.ignore_merges = 0;
if (opt.dense_combined_merges)
opt.diffopt.output_format = DIFF_FORMAT_PATCH;
- if (opt.diffopt.output_format == DIFF_FORMAT_PATCH)
+ if (opt.diffopt.output_format == DIFF_FORMAT_DIFFSTAT ||
+ opt.diffopt.output_format == DIFF_FORMAT_PATCH)
opt.diffopt.recursive = 1;
if (!full_diff && rev.prune_data)
diff_tree_setup_paths(rev.prune_data, &opt.diffopt);
^ permalink raw reply related
* Common option parsing..
From: Linus Torvalds @ 2006-04-13 1:48 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
Junio,
right now we actually haev very consistent command line options for git,
but we have two (and in your "next" branch, three) different structures
that they get parsed into, and lots of it is duplicated. We have
"diff_options", "rev_info" and now "log_info".
To make matters worse, some things aren't actually in any of them, ie
"--cc", "--abbrev" and friends actually end up being parsed into their own
private flags in diff-files. Some are in _both_ rev_info and diff_options
(the "--pretty" parsing), because both diff and rev-parse supported that
option set.
And almost all commands that take any of those options at all end up
actually taking the combination of them these days. Yeah, git-rev-parse
doesn't, but quite frankly, with your "git log --diff" changes, that's
actually the odd man out, and I think we should just make git-rev-parse
basically do it too.
And some things, like doing a builtin "git diff" would actually be quite
easy to do, except for the fact that having three different option parsers
_and_ having some options you parse by hand on top of that is just crazy
("git diff" wants even the stage diff flags that git-diff-files takes).
The easiest way to just solve all this mess would be to
- add the diff-options into "struct rev_list" and make the
"setup_revisions()" parser parse the diff flags too.
- get rid of "log_info" and "diff_options"
- possibly rename the resulting super-options structure as "struct
git_options" or something if we want to.
At that point, it would become a lot easier to do things like a built-in
"git diff", where command line parsing really is the biggest deal. It
would become something like this:
struct rev_info revs;
struct commit *src, *dst;
if (setup_revisions(&revs))
die(git_diff_usage);
/* No revision arguments: git-diff-files */
if (!revs->commits)
return diff_files(&revs);
src = revs->commits->item;
revs->commits = revs->commits->next;
/* Just one rev: git-diff-index against that */
if (!revs->commits)
return diff_index(&revs, src);
dst = revs->commits->item;
revs->commits = revs->commits->next;
/*
* More than two revs? Maybe that means a combined diff?
* Some day.. In the meantime, just make it an error.
*/
if (revs->commits->next)
die(git_diff_usage);
/*
* If it was "a..b" using git-rev-parse, the second commit
* on the list is the initial (and uninteresting) one, we
* need to make that the source..
*/
if (dst->object.flags & UNINTERESTING) {
struct commit *tmp = dst;
dst = src;
src = tmp;
}
return diff_trees(&revs, src, dst);
where obviously we'd need to do some minor moving-around to make
"diff_files()" be a function interface, but I actually did that, and it
was really trivial. The bigger part would be to just change the structures
around (which could be done first as a fairly big but trivial patch, kind
of the same way the initial "struct rev_info" was done when the
"revision.c" file was split away).
What do you think?
Linus
^ permalink raw reply
* Re: [PATCH] diff-options: add --stat
From: Junio C Hamano @ 2006-04-13 4:54 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.63.0604130301240.28688@wbgn013.biozentrum.uni-wuerzburg.de>
Interesting.
I wonder if you can also make this an independent option that
prepends diffstat in front of the patch, just like the way the
new flag --patch-with-raw flag prepends raw output in front of
the patch.
By the way, I've been wondering if anybody uses the
GIT_EXTERNAL_DIFF interface. Does anybody miss it if we did so?
^ permalink raw reply
* Re: Common option parsing..
From: Junio C Hamano @ 2006-04-13 5:03 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0604121828370.14565@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> The easiest way to just solve all this mess would be to
> - add the diff-options into "struct rev_list" and make the
> "setup_revisions()" parser parse the diff flags too.
> - get rid of "log_info" and "diff_options"
> - possibly rename the resulting super-options structure as "struct
> git_options" or something if we want to.
>...
> What do you think?
I think it all makes sense. And once this kind of clean-up is
done, I suspect the implementations of "git diff", "git log" and
"git show" would become quite similar -- one notable difference
being "git diff" with a single rev and "git show" with a single
rev would be quite different, but that is just how the arguments
are interpreted, not parsed.
However, I am not sure about the two-revs case. I suspect the
incoming items are sorted in the revs->commits list, and we
wouldn't be able to tell which is src and which is dst when
setup_revisions() returns.
^ permalink raw reply
* Re: how to make a git-format patch
From: Aubrey @ 2006-04-13 5:36 UTC (permalink / raw)
To: Mathieu Chouquet-Stringer; +Cc: git
In-Reply-To: <m3sloiriu7.fsf@localhost.localdomain>
On 12 Apr 2006 16:04:16 +0200, Mathieu Chouquet-Stringer
<ml2news@free.fr> wrote:
> I believe you're talking about 'git whatchanged -p' which not only displays
> the diffs but also the commit comments.
git whatchanged -p didn't include the signoff and howmany lines
changed which git-format-patch seems not include commit comments.
Is there one command to merge the two kind of message?
Thanks,
-Aubrey
^ permalink raw reply
* Re: how to make a git-format patch
From: Junio C Hamano @ 2006-04-13 5:53 UTC (permalink / raw)
To: Aubrey; +Cc: git
In-Reply-To: <6d6a94c50604122236i47f3c2e9s7656118eda95a2cd@mail.gmail.com>
Aubrey <aubreylee@gmail.com> writes:
> git whatchanged -p didn't include the signoff and howmany lines
> changed which git-format-patch seems not include commit comments.
>
> Is there one command to merge the two kind of message?
I think you already guessed it, judging from the Subject: line,
but the command is called "git-format-patch", and was around for
a long time.
^ permalink raw reply
* [RFH] shifting xdiff hunks?
From: Junio C Hamano @ 2006-04-13 6:30 UTC (permalink / raw)
To: Davide Libenzi; +Cc: git
I was looking at one diff produced from my work-in-progress,
which looked like this...
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 06b2e53..f72abfc 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -265,6 +265,9 @@ gitlink:git-checkout[1]::
gitlink:git-cherry-pick[1]::
Cherry-pick the effect of an existing commit.
+gitlink:git-clean[1]::
+ Remove untracked files from the working tree.
+
gitlink:git-clone[1]::
Clones a repository into a new directory.
@@ -318,6 +321,9 @@ gitlink:git-resolve[1]::
gitlink:git-revert[1]::
Revert an existing commit.
+
+gitlink:git-rm[1]::
+ Remove files from the working tree and from the index.
gitlink:git-shortlog[1]::
Summarizes 'git log' output.
The first hunk begins by an addition of a couple of non-blank
line followed by an addition of a blank line. The second hunk,
while it does the same thing, is shown differently.
Now, from correctness point of view, this is not a problem at
all, but I am wondering if xdiff can help to always shift the
hunk down or up to consistently produce one way or another
(personally I feel the former is easier to read).
Here is a rough sketch of what I think I want. When we have
additions, as long as the first line added happens to match the
first line that is common between the versions that comes after
the added hunk (that is, in the case of the second hunk above,
the empty line before "gitlink:git-rm[1]" happens to match the
empty line after the added three lines), roll the hunk down by
one, until you cannot roll it down anymore.
Just in case I get misinterpreted, I am not talking about
treating empty lines in any special way. It is more about
"starting the hunk with actually changed line". The first hunk
above clearly begins with something added, while the second one
does not.
Is this something easy to do with the xdiff code?
^ permalink raw reply
* Re: [RFH] shifting xdiff hunks?
From: Davide Libenzi @ 2006-04-13 6:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vmzeqyolw.fsf@assigned-by-dhcp.cox.net>
On Wed, 12 Apr 2006, Junio C Hamano wrote:
> The first hunk begins by an addition of a couple of non-blank
> line followed by an addition of a blank line. The second hunk,
> while it does the same thing, is shown differently.
>
> Now, from correctness point of view, this is not a problem at
> all, but I am wondering if xdiff can help to always shift the
> hunk down or up to consistently produce one way or another
> (personally I feel the former is easier to read).
Next on your screens, Junio and Linus in the new commedy "Pickier and Pickiest" :)
> Here is a rough sketch of what I think I want. When we have
> additions, as long as the first line added happens to match the
> first line that is common between the versions that comes after
> the added hunk (that is, in the case of the second hunk above,
> the empty line before "gitlink:git-rm[1]" happens to match the
> empty line after the added three lines), roll the hunk down by
> one, until you cannot roll it down anymore.
>
> Just in case I get misinterpreted, I am not talking about
> treating empty lines in any special way. It is more about
> "starting the hunk with actually changed line". The first hunk
> above clearly begins with something added, while the second one
> does not.
>
> Is this something easy to do with the xdiff code?
Yes, this is what GNU diff does. It's a post-process of the edit script.
Not a problem at all. Till this weekend (included) I'm pretty booked, but
I'll do that in the following days.
- Davide
^ permalink raw reply
* Re: [PATCH] diff-options: add --stat
From: Junio C Hamano @ 2006-04-13 6:53 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <7vy7ya13e3.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
> I wonder if you can also make this an independent option that
> prepends diffstat in front of the patch, just like the way the
> new flag --patch-with-raw flag prepends raw output in front of
> the patch.
Clarification.
Traditionally, we had diff-raw and diff-patch formats.
We can think of --name-status and --name-only variants of
diff-raw (just like different --abbrev settings give different
visuals for diff-raw). Until very recently, these were either-or
output formats, but for Cogito we added an option to show both.
We could reorganize the output format options to:
- diff-raw and its name variants
- diff-stat
- diff-patch
and have (internally) three bools to specify which ones to
output, in the above order. The recent --patch-with-raw would
flip bit #0 (show raw) and bit #2 (show patch) on. It is very
likely that diff-stat followed by diff-patch would be a popular
format (that is what git-format-patch does), and it also is
conceivable that diff-raw with diff-stat but without diff-patch
might turn out to be useful for some people.
Also, I forgot to mention, but would it be useful to have a
diffstat to show --cc? It is unclear, without much thinking,
what the numbers would mean, though...
^ permalink raw reply
* Re: [PATCH] diff-options: add --stat
From: Johannes Schindelin @ 2006-04-13 6:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vy7ya13e3.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 12 Apr 2006, Junio C Hamano wrote:
> By the way, I've been wondering if anybody uses the
> GIT_EXTERNAL_DIFF interface. Does anybody miss it if we did so?
Yes. I use it regularly with a patched wdiff (word-by-word diff).
Ciao,
Dscho
^ permalink raw reply
* Re: [RFH] shifting xdiff hunks?
From: Jakub Narebski @ 2006-04-13 7:44 UTC (permalink / raw)
To: git
In-Reply-To: <7vmzeqyolw.fsf@assigned-by-dhcp.cox.net>
Junio C. Hamano wrote:
> Now, from correctness point of view, this is not a problem at
> all, but I am wondering if xdiff can help to always shift the
> hunk down or up to consistently produce one way or another
> (personally I feel the former is easier to read).
This would also help with adding new functions, as sometimes diff begins
with the closing brace of the preceding function, instead of ending with
closing brace of the added function.
Just my own 0.2 eurocents.
--
Jakub Narebski
Warsaw, Poland
^ permalink raw reply
* Test fails on ubuntu breezy
From: Aneesh Kumar @ 2006-04-13 7:53 UTC (permalink / raw)
To: Git Mailing List
kvaneesh@home:~/git-work/git.build/t$ ./t3600-rm.sh
Committing initial tree e5c556e46aae6124ff4a2a466c95004e92d9a2e4
* ok 1: Pre-check that foo exists and is in index before git-rm foo
* ok 2: Test that git-rm foo succeeds
* ok 3: Post-check that foo exists but is not in index after git-rm foo
* ok 4: Pre-check that bar exists and is in index before "git-rm -f bar"
* ok 5: Test that "git-rm -f bar" succeeds
* ok 6: Post-check that bar does not exist and is not in index after
"git-rm -f bar"
* ok 7: Test that "git-rm -- -q" succeeds (remove a file that looks
like an option)
* ok 8: Test that "git-rm -f" succeeds with embedded space, tab, or
newline characters.
* FAIL 9: Test that "git-rm -f" fails if its rm fails
git-rm -f baz
* ok 10: When the rm in "git-rm -f" fails, it should not remove the
file from the index
* failed 1 among 10 test(s)
kvaneesh@home:~/git-work/git.build/t$
-aneesh
^ permalink raw reply
* Re: [PATCH] diff-options: add --stat
From: Johannes Schindelin @ 2006-04-13 8:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vek02ynif.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 12 Apr 2006, Junio C Hamano wrote:
> Junio C Hamano <junkio@cox.net> writes:
>
> > I wonder if you can also make this an independent option that
> > prepends diffstat in front of the patch, just like the way the
> > new flag --patch-with-raw flag prepends raw output in front of
> > the patch.
>
> Clarification.
>
> Traditionally, we had diff-raw and diff-patch formats.
> We can think of --name-status and --name-only variants of
> diff-raw (just like different --abbrev settings give different
> visuals for diff-raw). Until very recently, these were either-or
> output formats, but for Cogito we added an option to show both.
>
> We could reorganize the output format options to:
>
> - diff-raw and its name variants
> - diff-stat
> - diff-patch
>
> and have (internally) three bools to specify which ones to
> output, in the above order. The recent --patch-with-raw would
> flip bit #0 (show raw) and bit #2 (show patch) on. It is very
> likely that diff-stat followed by diff-patch would be a popular
> format (that is what git-format-patch does), and it also is
> conceivable that diff-raw with diff-stat but without diff-patch
> might turn out to be useful for some people.
That sounds plausible. Note that if diff-stat and diff-patch are turned
on, the patch generating code will be called twice. I do not think it is
sensible (or robust, for that matter) to cache the patch for this case.
> Also, I forgot to mention, but would it be useful to have a
> diffstat to show --cc? It is unclear, without much thinking,
> what the numbers would mean, though...
I thought long and hard about that. But how would you display it? You can
have lines starting with "+ ", " +", "--", etc. The only half-way
reasonable approach I found was to display the diffstat against each
parent individually. Since it would be a bit involved to implement that, I
wanted to think about it a bit longer, if it really makes sense.
Ciao,
Dscho
^ permalink raw reply
* Re: Test fails on ubuntu breezy
From: Peter Eriksen @ 2006-04-13 10:20 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <cc723f590604130053k6896c0cfkd8ea648e91d50d0e@mail.gmail.com>
On Thu, Apr 13, 2006 at 01:23:07PM +0530, Aneesh Kumar wrote:
> kvaneesh@home:~/git-work/git.build/t$ ./t3600-rm.sh
> Committing initial tree e5c556e46aae6124ff4a2a466c95004e92d9a2e4
> * ok 1: Pre-check that foo exists and is in index before git-rm foo
> * ok 2: Test that git-rm foo succeeds
> * ok 3: Post-check that foo exists but is not in index after git-rm foo
> * ok 4: Pre-check that bar exists and is in index before "git-rm -f bar"
> * ok 5: Test that "git-rm -f bar" succeeds
> * ok 6: Post-check that bar does not exist and is not in index after
> "git-rm -f bar"
> * ok 7: Test that "git-rm -- -q" succeeds (remove a file that looks
> like an option)
> * ok 8: Test that "git-rm -f" succeeds with embedded space, tab, or
> newline characters.
> * FAIL 9: Test that "git-rm -f" fails if its rm fails
> git-rm -f baz
> * ok 10: When the rm in "git-rm -f" fails, it should not remove the
> file from the index
> * failed 1 among 10 test(s)
> kvaneesh@home:~/git-work/git.build/t$
On solaris 10 too, only test 5 also fails.
Peter
^ permalink raw reply
* Re: Test fails on ubuntu breezy
From: linux @ 2006-04-13 11:54 UTC (permalink / raw)
To: git
I've recently encountered the same problem with t/t3600-rm.sh step 9,
but I put it down to compiling as root.
Basically, the chmod of the directory didn't stop the delete from
happening, since I had umask 002 and it was g+w.
Anyway, that test is fragile.
^ permalink raw reply
* Re: [PATCH] Implement limited context matching in git-apply.
From: Eric W. Biederman @ 2006-04-13 12:02 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.64.0604111100510.10745@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> On Mon, 10 Apr 2006, Eric W. Biederman wrote:
>>
>> So at a quick inspection it looks to me like:
>> About .059s to perform to check for missing files.
>> About .019s to write the new tree.
>> About .155s in start up overhead, read_cache, and sanity checks.
>>
>> So at a first glance it looks like librification to
>> allow the redundant work to be skipped, is where
>> the big speed win on my machine would be.
>
> That sounded wrong to me, so I did a stupid patch to datestamp the
> different phases of git-write-tree, and here's what it says for me:
>
> 0.000479 setup_git_directory
> 0.008333 read_cache
> 0.000813 ce_stage check
> 0.001838 tree validity check
> 0.037233 write_tree itself
>
> real 0m0.051s
> user 0m0.044s
> sys 0m0.008s
>
> all times are in seconds.
Ok. This is interesting and probably reveals what is different
about my setup. For you user+sys = real. For me there was
a significant gap. So it looks like for some reason I was not
succeeding in keeping .git/index hot in the page cache.
When you are I/O bound it does make sense for read_cache
to be the dominate time. I just need to track what is up
with my machine that makes me I/O bound. Having too little
ram is an obvious candidate but it is too simple. Currently
out of 512M I only have 21M in the page cache which sounds
really low. Something for me to look at.
> Which would imply pretty major surgery - you'd have to add the tree entry
> information to the index file, and make sure they got invalidated properly
> (all the way to the root) whenever adding/deleting/updating a path in the
> index file.
>
> Quite frankly, I don't think it's really worth it.
For the current size of the kernel tree I agree.
It is a potential scaling limitation and if someone starts
tracking really big tress with git it may be worth revisiting.
> Yes, it would speed up applying of huge patch-sets, but it's not like
> we're really slow at that even now, and I suspect you'd be better off
> trying to either live with it, or trying to see if you could change your
> workflow. There clearly _are_ tools that are better at handling pure
> patches, with quilt being the obvious example.
Probably. For my workflow not having to switch tool chains is
the biggest win. Which is part of what the -C is about.
> I routinely apply 100-200 patches in a go, and that's fast enough to not
> even be an issue. Yes, I have reasonably fast hardware, but we're likely
> talking thousands of patches in a series for it to be _really_ painful
> even on pretty basic developer hardware. Even a slow machine should do a
> few hundred patches in a couple of minutes.
>
> Maybe enough time to get a cup of coffee, but no more than it would take
> to compile the project.
Agreed. I did the analysis so I could understand what was going on.
If the analysis revealed low hanging fruit I would have plucked it.
Eric
^ permalink raw reply
* Re: Common option parsing..
From: Linus Torvalds @ 2006-04-13 14:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vmzeq12zd.fsf@assigned-by-dhcp.cox.net>
On Wed, 12 Apr 2006, Junio C Hamano wrote:
>
> However, I am not sure about the two-revs case. I suspect the
> incoming items are sorted in the revs->commits list
Not by the argument parsing. That happens by "rev_parse_setup()" when we
start to do the revision walking.
So after setup_revisions() it's all good (although I think the list may be
in "reverse order", I didn't check).
Linus
^ permalink raw reply
* Use less memory in "git log"
From: Linus Torvalds @ 2006-04-13 17:01 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
This trivially avoids keeping the commit message data around after we
don't need it any more, avoiding a continually growing "git log" memory
footprint.
It's not a huge deal, but it's somewhat noticeable. For the current kernel
tree, doing a full "git log" I got
- before: /usr/bin/time git log > /dev/null
0.81user 0.02system 0:00.84elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+8851minor)pagefaults 0swaps
- after: /usr/bin/time git log > /dev/null
0.79user 0.03system 0:00.83elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+5039minor)pagefaults 0swaps
ie the touched pages dropped from 8851 to 5039. For the historic kernel
archive, the numbers are 18357->11037 minor page faults.
We could/should in theory free the commits themselves, but that's really a
lot harder, since during revision traversal we may hit the same commit
twice through different children having it as a parent, even after we've
shown it once (when that happens, we'll silently ignore it next time, but
we still need the "struct commit" to know).
And as the commit message data is clearly the biggest part of the commit,
this is the really easy 60% solution.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/git.c b/git.c
index d6f17db..78ed403 100644
--- a/git.c
+++ b/git.c
@@ -391,6 +391,8 @@ static int cmd_log(int argc, const char
if (do_diff)
log_tree_commit(&opt, commit);
shown = 1;
+ free(commit->buffer);
+ commit->buffer = NULL;
}
free(buf);
return 0;
^ permalink raw reply related
* Re: [PATCH] diff-options: add --stat
From: Marco Costalba @ 2006-04-13 17:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, git
In-Reply-To: <7vek02ynif.fsf@assigned-by-dhcp.cox.net>
On 4/13/06, Junio C Hamano <junkio@cox.net> wrote:
> Junio C Hamano <junkio@cox.net> writes:
>
> It is very
> likely that diff-stat followed by diff-patch would be a popular
> format (that is what git-format-patch does),
Yes, it is very likely the new output format (stat+patch) will be the
default in qgit diff window viewer ;-)
Marco
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox