Git development
 help / color / mirror / Atom feed
* [PATCH] git submodule foreach: Provide access to submodule name, as '$name'
From: Johan Herland @ 2009-08-16  1:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Mark Levedahl, Lars Hjemli

The argument to 'git submodule foreach' already has access to the variables
'$path' (the path to the submodule, relative to the superproject) and '$sha1'
(the submodule commit recorded by the superproject).

This patch adds another variable -- '$name' -- which contains the name of the
submodule, as recorded in the superproject's .gitmodules file.

Signed-off-by: Johan Herland <johan@herland.net>
---
 Documentation/git-submodule.txt |    3 ++-
 git-submodule.sh                |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 7dd73ae..97c32fe 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -131,7 +131,8 @@ summary::
 
 foreach::
 	Evaluates an arbitrary shell command in each checked out submodule.
-	The command has access to the variables $path and $sha1:
+	The command has access to the variables $name, $path and $sha1:
+	$name is the name of the relevant submodule section in .gitmodules,
 	$path is the name of the submodule directory relative to the
 	superproject, and $sha1 is the commit as recorded in the superproject.
 	Any submodules defined in the superproject but not checked out are
diff --git a/git-submodule.sh b/git-submodule.sh
index ebed711..d8ecdb9 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -243,6 +243,7 @@ cmd_foreach()
 		if test -e "$path"/.git
 		then
 			say "Entering '$path'"
+			name=$(module_name "$path")
 			(cd "$path" && eval "$@") ||
 			die "Stopping at '$path'; script returned non-zero status."
 		fi
-- 
1.6.4.rc3.138.ga6b98.dirty

^ permalink raw reply related

* How to stop sharing objects between repositories
From: Jon Jensen @ 2009-08-16  0:04 UTC (permalink / raw)
  To: git

Hello.

Situation: I used "git clone -s" to share objects between repositories. 
That creates .git/objects/info/alternates, which points to the other 
repository. Later I need to remove the dependency and make the dependent 
repository self-sufficient, i.e. it should have all the objects internal 
to itself.

I've looked around for a way to do that but haven't found either tools or 
instructions.

I came up with this manual way, copying over the unique remote objects and 
then removing the alternate repository pointer:

(cd /path/to/alternate/repo.git/objects && tar cp .) | (cd .git/objects && tar xvpk)
# some objects will already exist and be skipped, leading to an error on exit, which is fine
rm .git/objects/info/alternates
# or if there's more than one and you're only removing one, edit the alternates file and remove only that pointer

(With GNU tar -C the copy is a little simpler.)

I posted this to the wiki:

http://git.or.cz/gitwiki/GitFaq#Howtostopsharingobjectsbetweenrepositories.3F

If there's a better or built-in way to do this with Git tools, I'd like to 
learn it, and I'd be happy to update the wiki accordingly.

Thanks,
Jon

-- 
Jon Jensen
End Point Corporation
http://www.endpoint.com/

^ permalink raw reply

* Re: Linus' sha1 is much faster!
From: Theodore Tso @ 2009-08-16  0:06 UTC (permalink / raw)
  To: John Tapsell
  Cc: Bryan Donlan, Pádraig Brady, Bug-coreutils, Linus Torvalds,
	Git Mailing List, Brandon Casey, Junio C Hamano, Nicolas Pitre
In-Reply-To: <43d8ce650908151312o6a43416el27965c4b0ab8d83d@mail.gmail.com>

On Sat, Aug 15, 2009 at 09:12:58PM +0100, John Tapsell wrote:
> 2009/8/15 Bryan Donlan <bdonlan@gmail.com>:
> > coreutils is licensed under GPLv3, and git under GPLv2 (only), so
> > you'd need permission from all contributors to the implementation in
> > order to relicense under GPLv3. A quick grep of the history suggests
> > these contributors to be:
> 
> X11 also requires a fast SHA1 implementation.  It uses this to check
> if two pixmaps are the same.  So it would be really nice to relicense
> under a liberal enough license that xorg can use it.

If the checksum isn't being exposed in the protocol (i.e., it's just
internal to the X server), one possibility for X11 is to consider to
use the SHA-3 candidate Skein instead.  After receiving a large amount
of evaluation by cryptographic experts, it was one of the 18
algorithms (our of an original 64 entries) that have made it the 2nd
round of the NIST competition.  It's also *substantially* faster than
SHA:

    One exception to this is Skein, created by several well-known
    cryptographers and noted pundit Bruce Schneier. It was designed
    specifically to exploit all three of the Core 2 execution units
    and to run at a full 64-bits. This gives it roughly four to 10
    times the logic density of competing submissions.

    This is what I meant by the Matrix quote above. They didn't bend
    the spoon; they bent the crypto algorithm. They moved the logic
    operations around in a way that wouldn't weaken the crypto, but
    would strengthen its speed on the Intel Core 2.

    In their paper (PDF), the authors of Skein express surprise that a
    custom silicon ASIC implementation is not any faster than the
    software implementation. They shouldn't be surprised. Every time
    you can redefine a problem to run optimally in software, you will
    reach the same speeds you get with optimized ASIC hardware. The
    reason software has a reputation of being slow is because people
    don't redefine the original problem.

    http://www.darkreading.com/blog/archives/2008/11/bending_skein_c.html

For more information and some optimized implementation, see:

	http://www.skein-hash.info/

							- Ted

^ permalink raw reply

* Re: [RFC PATCH v3 8/8] --sparse for porcelains
From: Jakub Narebski @ 2009-08-15 23:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nguyen Thai Ngoc Duy, git, Johannes Schindelin
In-Reply-To: <7veird4yyi.fsf@alter.siamese.dyndns.org>

On Sat, 15 Aug 2009, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>>>> Hmmm... this looks like either argument for introducing --full option
>>>>  to git-checkout (ignore CE_VALID bit, checkout everything, and clean
>>>>  CE_VALID (?))...
>>>>
>>>>  ...or for going with _separate_ bit for partial checkout, like in the
>>>>  very first version of this series, which otherwise functions like
>>>>  CE_VALID, or is just used to mark that CE_VALID was set using sparse.
> 
> How would a separate bit help?  Just like you need to clear CE_VALID bit
> to revert the index into a normal (or "non sparse") state somehow, you
> would need to have a way to clear that separate bit anyway.
> 
> A separate bit would help only if you want to handle assume-unchanged and
> sparse checkout independently. But my impression was that the recent lstat
> reduction effort addressed the issue assume-unchanged were invented to
> work around in the first place.

Well, if we assume that we don't need (don't want) to handle
assume-unchanged and sparse checkout independently, then of course the
idea of having separate or additional bit for sparse doesn't make sense.
 
-- 
Jakub Narebski
Poland

^ permalink raw reply

* [PATCH 7/9] git stat -s: short status output
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-7-git-send-email-gitster@pobox.com>

Give -s(hort) option to "git stat" that shows the status of paths in a
more concise way.

    XY PATH1 -> PATH2

format to be more machine readable than output from "git status", which is
about previewing of "git commit" with the same arguments.

PATH1 is the path in the HEAD, and " -> PATH2" part is shown only when
PATH1 corresponds to a different path in the index/worktree.

For unmerged entries, X shows the status of stage #2 (i.e. ours) and Y
shows the status of stage #3 (i.e. theirs).  For entries that do not have
conflicts, X shows the status of the index, and Y shows the status of the
work tree.  For untracked paths, XY are "??".

    X          Y     Meaning
    -------------------------------------------------
              [MD]   not updated
    M        [ MD]   updated in index
    A        [ MD]   added to index
    D        [ MD]   deleted from index
    R        [ MD]   renamed in index
    C        [ MD]   copied in index
    [MARC]           index and work tree matches
    [ MARC]     M    work tree changed since index
    [ MARC]     D    deleted in work tree

    D           D    unmerged, both deleted
    A           U    unmerged, added by us
    U           D    unmerged, deleted by them
    U           A    unmerged, added by them
    D           U    unmerged, deleted by us
    A           A    unmerged, both added
    U           U    unmerged, both modified

    ?           ?    untracked

When given -z option, the records are terminated by NUL characters for
better machine readability.  Because the traditional long format is
designed for human consumption, NUL termination does not make sense.
For this reason, -z option implies -s (short output).

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

 * Unchanged since the last round; rebased on top of the updated code to
   support the long format output.

 builtin-commit.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 106 insertions(+), 8 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 5e23ef1..1a360cb 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -902,12 +902,87 @@ static int git_status_config(const char *k, const char *v, void *cb)
 	return git_diff_ui_config(k, v, NULL);
 }
 
+#define quote_path quote_path_relative
+
+static void short_unmerged(int null_termination, struct string_list_item *it,
+			   struct wt_status *s)
+{
+	struct wt_status_change_data *d = it->util;
+	const char *how = "??";
+
+	switch (d->stagemask) {
+	case 1: how = "DD"; break; /* both deleted */
+	case 2: how = "AU"; break; /* added by us */
+	case 3: how = "UD"; break; /* deleted by them */
+	case 4: how = "UA"; break; /* added by them */
+	case 5: how = "DU"; break; /* deleted by us */
+	case 6: how = "AA"; break; /* both added */
+	case 7: how = "UU"; break; /* both modified */
+	}
+	printf("%s ", how);
+	if (null_termination) {
+		fprintf(stdout, "%s%c", it->string, 0);
+	} else {
+		struct strbuf onebuf = STRBUF_INIT;
+		const char *one;
+		one = quote_path(it->string, -1, &onebuf, s->prefix);
+		printf("%s\n", one);
+		strbuf_release(&onebuf);
+	}
+}
+
+static void short_status(int null_termination, struct string_list_item *it,
+			 struct wt_status *s)
+{
+	struct wt_status_change_data *d = it->util;
+
+	printf("%c%c ",
+	       !d->index_status ? ' ' : d->index_status,
+	       !d->worktree_status ? ' ' : d->worktree_status);
+	if (null_termination) {
+		fprintf(stdout, "%s%c", it->string, 0);
+		if (d->head_path)
+			fprintf(stdout, "%s%c", d->head_path, 0);
+	} else {
+		struct strbuf onebuf = STRBUF_INIT;
+		const char *one;
+		if (d->head_path) {
+			one = quote_path(d->head_path, -1, &onebuf, s->prefix);
+			printf("%s -> ", one);
+			strbuf_release(&onebuf);
+		}
+		one = quote_path(it->string, -1, &onebuf, s->prefix);
+		printf("%s\n", one);
+		strbuf_release(&onebuf);
+	}
+}
+
+static void short_untracked(int null_termination, struct string_list_item *it,
+			    struct wt_status *s)
+{
+	if (null_termination) {
+		fprintf(stdout, "?? %s%c", it->string, 0);
+	} else {
+		struct strbuf onebuf = STRBUF_INIT;
+		const char *one;
+		one = quote_path(it->string, -1, &onebuf, s->prefix);
+		printf("?? %s\n", one);
+		strbuf_release(&onebuf);
+	}
+}
+
 int cmd_stat(int argc, const char **argv, const char *prefix)
 {
 	struct wt_status s;
+	static int null_termination, shortstatus;
+	int i;
 	unsigned char sha1[20];
 	static struct option builtin_stat_options[] = {
 		OPT__VERBOSE(&verbose),
+		OPT_BOOLEAN('s', "short", &shortstatus,
+			    "show status concicely"),
+		OPT_BOOLEAN('z', "null", &null_termination,
+			    "terminate entries with NUL"),
 		{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
 		  "mode",
 		  "show untracked files, optional modes: all, normal, no. (Default: all)",
@@ -915,6 +990,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 		OPT_END(),
 	};
 
+	if (null_termination)
+		shortstatus = 1;
+
 	wt_status_prepare(&s);
 	git_config(git_status_config, &s);
 	argc = parse_options(argc, argv, prefix,
@@ -930,14 +1008,34 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
 	wt_status_collect(&s);
 
-	s.verbose = verbose;
-	if (s.relative_paths)
-		s.prefix = prefix;
-	if (s.use_color == -1)
-		s.use_color = git_use_color_default;
-	if (diff_use_color_default == -1)
-		diff_use_color_default = git_use_color_default;
-	wt_status_print(&s);
+	if (shortstatus) {
+		for (i = 0; i < s.change.nr; i++) {
+			struct wt_status_change_data *d;
+			struct string_list_item *it;
+
+			it = &(s.change.items[i]);
+			d = it->util;
+			if (d->stagemask)
+				short_unmerged(null_termination, it, &s);
+			else
+				short_status(null_termination, it, &s);
+		}
+		for (i = 0; i < s.untracked.nr; i++) {
+			struct string_list_item *it;
+
+			it = &(s.untracked.items[i]);
+			short_untracked(null_termination, it, &s);
+		}
+	} else {
+		s.verbose = verbose;
+		if (s.relative_paths)
+			s.prefix = prefix;
+		if (s.use_color == -1)
+			s.use_color = git_use_color_default;
+		if (diff_use_color_default == -1)
+			diff_use_color_default = git_use_color_default;
+		wt_status_print(&s);
+	}
 	return 0;
 }
 
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 9/9] git-status: adjust tests
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-9-git-send-email-gitster@pobox.com>

There are some tests that expect "git status" to exit with non-zero status
when there is something staged.  Some tests expect "git status path..." to
show the status for a partial commit.

For these, replace "git status" with "git commit --dry-run".  For the
ones that do not attempt a dry-run of a partial commit that check the
output from the command, check the output from "git status" as well, as
they should be identical.

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

 * Kept separate for easier review; shows the extent of damage from the
   change in semantics rather well.

 t/t6040-tracking-info.sh    |    2 +-
 t/t7060-wtstatus.sh         |    8 +++++---
 t/t7506-status-submodule.sh |    6 +++---
 t/t7508-status.sh           |   12 +++++++-----
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index 00e1de9..664b0f8 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -69,7 +69,7 @@ test_expect_success 'status' '
 		cd test &&
 		git checkout b1 >/dev/null &&
 		# reports nothing to commit
-		test_must_fail git status
+		test_must_fail git commit --dry-run
 	) >actual &&
 	grep "have 1 and 1 different" actual
 '
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index 1044aa6..7b5db80 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -50,9 +50,11 @@ test_expect_success 'M/D conflict does not segfault' '
 		git rm foo &&
 		git commit -m delete &&
 		test_must_fail git merge master &&
-		test_must_fail git status > ../actual
-	) &&
-	test_cmp expect actual
+		test_must_fail git commit --dry-run >../actual &&
+		test_cmp ../expect ../actual &&
+		git status >../actual &&
+		test_cmp ../expect ../actual
+	)
 '
 
 test_done
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
index d9a08aa..3ca17ab 100755
--- a/t/t7506-status-submodule.sh
+++ b/t/t7506-status-submodule.sh
@@ -19,8 +19,8 @@ test_expect_success 'status clean' '
 	git status |
 	grep "nothing to commit"
 '
-test_expect_success 'status -a clean' '
-	git status -a |
+test_expect_success 'commit --dry-run -a clean' '
+	git commit --dry-run -a |
 	grep "nothing to commit"
 '
 test_expect_success 'rm submodule contents' '
@@ -31,7 +31,7 @@ test_expect_success 'status clean (empty submodule dir)' '
 	grep "nothing to commit"
 '
 test_expect_success 'status -a clean (empty submodule dir)' '
-	git status -a |
+	git commit --dry-run -a |
 	grep "nothing to commit"
 '
 
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 93f875f..1173dbb 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -248,8 +248,8 @@ cat <<EOF >expect
 #	output
 #	untracked
 EOF
-test_expect_success 'status of partial commit excluding new file in index' '
-	git status dir1/modified >output &&
+test_expect_success 'dry-run of partial commit excluding new file in index' '
+	git commit --dry-run dir1/modified >output &&
 	test_cmp expect output
 '
 
@@ -358,7 +358,9 @@ EOF
 test_expect_success 'status submodule summary (clean submodule)' '
 	git commit -m "commit submodule" &&
 	git config status.submodulesummary 10 &&
-	test_must_fail git status >output &&
+	test_must_fail git commit --dry-run >output &&
+	test_cmp expect output &&
+	git status >output &&
 	test_cmp expect output
 '
 
@@ -391,9 +393,9 @@ cat >expect <<EOF
 #	output
 #	untracked
 EOF
-test_expect_success 'status submodule summary (--amend)' '
+test_expect_success 'commit --dry-run submodule summary (--amend)' '
 	git config status.submodulesummary 10 &&
-	git status --amend >output &&
+	git commit --dry-run --amend >output &&
 	test_cmp expect output
 '
 
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 8/9] git status: not "commit --dry-run" anymore
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-8-git-send-email-gitster@pobox.com>

This removes tentative "git stat" and make it take over "git status".

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

 * This alone fails some tests; 9/9 will be squashed in in the final round.

 Documentation/git-status.txt |   79 ++++++++++++++++++++++++++++++++++++-----
 builtin-commit.c             |   29 ++-------------
 builtin.h                    |    1 -
 git.c                        |    1 -
 4 files changed, 73 insertions(+), 37 deletions(-)

diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 84f60f3..b5939d6 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -8,7 +8,7 @@ git-status - Show the working tree status
 
 SYNOPSIS
 --------
-'git status' <options>...
+'git status' [<options>...] [--] [<pathspec>...]
 
 DESCRIPTION
 -----------
@@ -20,25 +20,85 @@ are what you _would_ commit by running `git commit`; the second and
 third are what you _could_ commit by running 'git-add' before running
 `git commit`.
 
-The command takes the same set of options as 'git-commit'; it
-shows what would be committed if the same options are given to
-'git-commit'.
-
-If there is no path that is different between the index file and
-the current HEAD commit (i.e., there is nothing to commit by running
-`git commit`), the command exits with non-zero status.
+OPTIONS
+-------
+
+-s::
+--short::
+	Give the output in the short-format.
+
+-u[<mode>]::
+--untracked-files[=<mode>]::
+	Show untracked files (Default: 'all').
++
+The mode parameter is optional, and is used to specify
+the handling of untracked files. The possible options are:
++
+--
+	- 'no'     - Show no untracked files
+	- 'normal' - Shows untracked files and directories
+	- 'all'    - Also shows individual files in untracked directories.
+--
++
+See linkgit:git-config[1] for configuration variable
+used to change the default for when the option is not
+specified.
+
+-z::
+	Terminate entries with NUL, instead of LF.  This implies `-s`
+	(short status) output format.
 
 
 OUTPUT
 ------
 The output from this command is designed to be used as a commit
 template comment, and all the output lines are prefixed with '#'.
+The default, long format, is designed to be human readable,
+verbose and descriptive.  They are subject to change in any time.
 
 The paths mentioned in the output, unlike many other git commands, are
 made relative to the current directory if you are working in a
 subdirectory (this is on purpose, to help cutting and pasting). See
 the status.relativePaths config option below.
 
+In short-format, the status of each path is shown as
+
+	XY PATH1 -> PATH2
+
+where `PATH1` is the path in the `HEAD`, and ` -> PATH2` part is
+shown only when `PATH1` corresponds to a different path in the
+index/worktree (i.e. renamed).
+
+For unmerged entries, `X` shows the status of stage #2 (i.e. ours) and `Y`
+shows the status of stage #3 (i.e. theirs).
+
+For entries that do not have conflicts, `X` shows the status of the index,
+and `Y` shows the status of the work tree.  For untracked paths, `XY` are
+`??`.
+
+    X          Y     Meaning
+    -------------------------------------------------
+              [MD]   not updated
+    M        [ MD]   updated in index
+    A        [ MD]   added to index
+    D        [ MD]   deleted from index
+    R        [ MD]   renamed in index
+    C        [ MD]   copied in index
+    [MARC]           index and work tree matches
+    [ MARC]     M    work tree changed since index
+    [ MARC]     D    deleted in work tree
+    -------------------------------------------------
+    D           D    unmerged, both deleted
+    A           U    unmerged, added by us
+    U           D    unmerged, deleted by them
+    U           A    unmerged, added by them
+    D           U    unmerged, deleted by us
+    A           A    unmerged, both added
+    U           U    unmerged, both modified
+    -------------------------------------------------
+    ?           ?    untracked
+    -------------------------------------------------
+
 
 CONFIGURATION
 -------------
@@ -63,8 +123,7 @@ linkgit:gitignore[5]
 
 Author
 ------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <gitster@pobox.com>.
+Written by Junio C Hamano <gitster@pobox.com>.
 
 Documentation
 --------------
diff --git a/builtin-commit.c b/builtin-commit.c
index 1a360cb..6cb0e40 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -36,11 +36,6 @@ static const char * const builtin_status_usage[] = {
 	NULL
 };
 
-static const char * const builtin_stat_usage[] = {
-	"git stat [options]",
-	NULL
-};
-
 static unsigned char head_sha1[20], merge_head_sha1[20];
 static char *use_message_buffer;
 static const char commit_editmsg[] = "COMMIT_EDITMSG";
@@ -971,13 +966,13 @@ static void short_untracked(int null_termination, struct string_list_item *it,
 	}
 }
 
-int cmd_stat(int argc, const char **argv, const char *prefix)
+int cmd_status(int argc, const char **argv, const char *prefix)
 {
 	struct wt_status s;
 	static int null_termination, shortstatus;
 	int i;
 	unsigned char sha1[20];
-	static struct option builtin_stat_options[] = {
+	static struct option builtin_status_options[] = {
 		OPT__VERBOSE(&verbose),
 		OPT_BOOLEAN('s', "short", &shortstatus,
 			    "show status concicely"),
@@ -996,8 +991,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	wt_status_prepare(&s);
 	git_config(git_status_config, &s);
 	argc = parse_options(argc, argv, prefix,
-			     builtin_stat_options,
-			     builtin_stat_usage, 0);
+			     builtin_status_options,
+			     builtin_status_usage, 0);
 	handle_untracked_files_arg(&s);
 
 	if (*argv)
@@ -1039,22 +1034,6 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	return 0;
 }
 
-int cmd_status(int argc, const char **argv, const char *prefix)
-{
-	struct wt_status s;
-
-	wt_status_prepare(&s);
-	git_config(git_status_config, &s);
-	if (s.use_color == -1)
-		s.use_color = git_use_color_default;
-	if (diff_use_color_default == -1)
-		diff_use_color_default = git_use_color_default;
-
-	argc = parse_and_validate_options(argc, argv, builtin_status_usage,
-					  prefix, &s);
-	return dry_run_commit(argc, argv, prefix, &s);
-}
-
 static void print_summary(const char *prefix, const unsigned char *sha1)
 {
 	struct rev_info rev;
diff --git a/builtin.h b/builtin.h
index eeaf0b6..20427d2 100644
--- a/builtin.h
+++ b/builtin.h
@@ -95,7 +95,6 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
 extern int cmd_show(int argc, const char **argv, const char *prefix);
 extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
-extern int cmd_stat(int argc, const char **argv, const char *prefix);
 extern int cmd_status(int argc, const char **argv, const char *prefix);
 extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
 extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index de7fcf6..807d875 100644
--- a/git.c
+++ b/git.c
@@ -350,7 +350,6 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "shortlog", cmd_shortlog, USE_PAGER },
 		{ "show-branch", cmd_show_branch, RUN_SETUP },
 		{ "show", cmd_show, RUN_SETUP | USE_PAGER },
-		{ "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE },
 		{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
 		{ "stripspace", cmd_stripspace },
 		{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 5/9] git stat: show traditional status headers and trailers as well
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-5-git-send-email-gitster@pobox.com>

Also honor -v to show the "diff --cached" output.

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

 * Fix-up to 3/9; will be squashed in the final round to remove the trace
   of ill conceived wt_status_print_body() refactoring.

 builtin-commit.c |    8 +++++++-
 wt-status.c      |   27 +++++++++------------------
 wt-status.h      |    1 -
 3 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 7120876..8db0365 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -352,6 +352,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
 static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,
 		      struct wt_status *s)
 {
+	unsigned char sha1[20];
+
 	if (s->relative_paths)
 		s->prefix = prefix;
 
@@ -363,7 +365,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
 	s->index_file = index_file;
 	s->fp = fp;
 	s->nowarn = nowarn;
+	s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
 
+	wt_status_collect(s);
 	wt_status_print(s);
 
 	return s->commitable;
@@ -903,6 +907,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	struct wt_status s;
 	unsigned char sha1[20];
 	static struct option builtin_stat_options[] = {
+		OPT__VERBOSE(&verbose),
 		{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
 		  "mode",
 		  "show untracked files, optional modes: all, normal, no. (Default: all)",
@@ -922,13 +927,14 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
 	wt_status_collect(&s);
 
+	s.verbose = verbose;
 	if (s.relative_paths)
 		s.prefix = prefix;
 	if (s.use_color == -1)
 		s.use_color = git_use_color_default;
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
-	wt_status_print_body(&s);
+	wt_status_print(&s);
 	return 0;
 }
 
diff --git a/wt-status.c b/wt-status.c
index c887a90..c55be53 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -531,25 +531,10 @@ static void wt_status_print_tracking(struct wt_status *s)
 	color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 }
 
-void wt_status_print_body(struct wt_status *s)
-{
-	wt_status_print_unmerged(s);
-	wt_status_print_updated(s);
-	wt_status_print_changed(s);
-	if (s->submodule_summary)
-		wt_status_print_submodule_summary(s);
-	if (s->show_untracked_files)
-		wt_status_print_untracked(s);
-	else if (s->commitable)
-		 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
-}
-
 void wt_status_print(struct wt_status *s)
 {
-	unsigned char sha1[20];
 	const char *branch_color = color(WT_STATUS_HEADER, s);
 
-	s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
 	if (s->branch) {
 		const char *on_what = "On branch ";
 		const char *branch_name = s->branch;
@@ -566,15 +551,21 @@ void wt_status_print(struct wt_status *s)
 			wt_status_print_tracking(s);
 	}
 
-	wt_status_collect(s);
-
 	if (s->is_initial) {
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit");
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 	}
 
-	wt_status_print_body(s);
+	wt_status_print_unmerged(s);
+	wt_status_print_updated(s);
+	wt_status_print_changed(s);
+	if (s->submodule_summary)
+		wt_status_print_submodule_summary(s);
+	if (s->show_untracked_files)
+		wt_status_print_untracked(s);
+	else if (s->commitable)
+		 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
 
 	if (s->verbose)
 		wt_status_print_verbose(s);
diff --git a/wt-status.h b/wt-status.h
index ab52ce1..a0e7517 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -54,6 +54,5 @@ struct wt_status {
 void wt_status_prepare(struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
-void wt_status_print_body(struct wt_status *s);
 
 #endif /* STATUS_H */
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 6/9] git stat: pathspec limits, unlike traditional "git status"
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-6-git-send-email-gitster@pobox.com>

The "git stat" command is not "preview of commit with the same arguments";
the path parameters are not paths to be added to the pristine index (aka
"--only" option), but are taken as pathspecs to limit the output.

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

 * Fix-up to 3/9; will be squashed in the final round.

 builtin-commit.c |    3 +++
 wt-status.c      |    6 ++++++
 wt-status.h      |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 8db0365..5e23ef1 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -922,6 +922,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 			     builtin_stat_usage, 0);
 	handle_untracked_files_arg(&s);
 
+	if (*argv)
+		s.pathspec = get_pathspec(prefix, argv);
+
 	read_cache();
 	refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
 	s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
diff --git a/wt-status.c b/wt-status.c
index c55be53..249227c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_collect_changed_cb;
 	rev.diffopt.format_callback_data = s;
+	rev.prune_data = s->pathspec;
 	run_diff_files(&rev, 0);
 }
 
@@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 	rev.diffopt.detect_rename = 1;
 	rev.diffopt.rename_limit = 200;
 	rev.diffopt.break_opt = 0;
+	rev.prune_data = s->pathspec;
 	run_diff_index(&rev, 1);
 }
 
@@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
 		struct wt_status_change_data *d;
 		struct cache_entry *ce = active_cache[i];
 
+		if (!ce_path_match(ce, s->pathspec))
+			continue;
 		it = string_list_insert(ce->name, &s->change);
 		d = it->util;
 		if (!d) {
@@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s)
 		struct dir_entry *ent = dir.entries[i];
 		if (!cache_name_is_other(ent->name, ent->len))
 			continue;
+		if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
+			continue;
 		s->workdir_untracked = 1;
 		string_list_insert(ent->name, &s->untracked);
 	}
diff --git a/wt-status.h b/wt-status.h
index a0e7517..09fd9f1 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -31,6 +31,7 @@ struct wt_status {
 	int is_initial;
 	char *branch;
 	const char *reference;
+	const char **pathspec;
 	int verbose;
 	int amend;
 	int nowarn;
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 4/9] git stat: honor relative paths setting
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-4-git-send-email-gitster@pobox.com>

When run from a subdirectory, by default (and when status.relativepaths is
set), we should pass it to wt_status_print_body()

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

 * Fix-up to 3/9; will be squashed in the final round.

 builtin-commit.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 0ef7c8f..7120876 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -922,6 +922,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
 	wt_status_collect(&s);
 
+	if (s.relative_paths)
+		s.prefix = prefix;
 	if (s.use_color == -1)
 		s.use_color = git_use_color_default;
 	if (diff_use_color_default == -1)
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 3/9] git stat: the beginning
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-3-git-send-email-gitster@pobox.com>

Tentatively add "git stat" as a new command.  This does not munge the
index with paths parameters before showing the status like "git status"
does.  In later rounds, we will take path parameters as pathspec to limit
the output.

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

 * Unchanged since the last round.

 Makefile         |    1 +
 builtin-commit.c |   64 +++++++++++++++++++++++++++++++++++++++++++++--------
 builtin.h        |    1 +
 git.c            |    1 +
 wt-status.c      |   23 +++++++++++-------
 wt-status.h      |    1 +
 6 files changed, 72 insertions(+), 19 deletions(-)

diff --git a/Makefile b/Makefile
index daf4296..39dd334 100644
--- a/Makefile
+++ b/Makefile
@@ -378,6 +378,7 @@ BUILT_INS += git-init$X
 BUILT_INS += git-merge-subtree$X
 BUILT_INS += git-peek-remote$X
 BUILT_INS += git-repo-config$X
+BUILT_INS += git-stat$X
 BUILT_INS += git-show$X
 BUILT_INS += git-stage$X
 BUILT_INS += git-status$X
diff --git a/builtin-commit.c b/builtin-commit.c
index 200ffda..0ef7c8f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -24,6 +24,7 @@
 #include "string-list.h"
 #include "rerere.h"
 #include "unpack-trees.h"
+#include "quote.h"
 
 static const char * const builtin_commit_usage[] = {
 	"git commit [options] [--] <filepattern>...",
@@ -35,6 +36,11 @@ static const char * const builtin_status_usage[] = {
 	NULL
 };
 
+static const char * const builtin_stat_usage[] = {
+	"git stat [options]",
+	NULL
+};
+
 static unsigned char head_sha1[20], merge_head_sha1[20];
 static char *use_message_buffer;
 static const char commit_editmsg[] = "COMMIT_EDITMSG";
@@ -691,6 +697,21 @@ static const char *find_author_by_nickname(const char *name)
 	die("No existing author found with '%s'", name);
 }
 
+
+static void handle_untracked_files_arg(struct wt_status *s)
+{
+	if (!untracked_files_arg)
+		; /* default already initialized */
+	else if (!strcmp(untracked_files_arg, "no"))
+		s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+	else if (!strcmp(untracked_files_arg, "normal"))
+		s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+	else if (!strcmp(untracked_files_arg, "all"))
+		s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+	else
+		die("Invalid untracked files mode '%s'", untracked_files_arg);
+}
+
 static int parse_and_validate_options(int argc, const char *argv[],
 				      const char * const usage[],
 				      const char *prefix,
@@ -794,16 +815,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
 	else
 		die("Invalid cleanup mode %s", cleanup_arg);
 
-	if (!untracked_files_arg)
-		; /* default already initialized */
-	else if (!strcmp(untracked_files_arg, "no"))
-		s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
-	else if (!strcmp(untracked_files_arg, "normal"))
-		s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
-	else if (!strcmp(untracked_files_arg, "all"))
-		s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
-	else
-		die("Invalid untracked files mode '%s'", untracked_files_arg);
+	handle_untracked_files_arg(s);
 
 	if (all && argc > 0)
 		die("Paths with -a does not make sense.");
@@ -886,6 +898,38 @@ static int git_status_config(const char *k, const char *v, void *cb)
 	return git_diff_ui_config(k, v, NULL);
 }
 
+int cmd_stat(int argc, const char **argv, const char *prefix)
+{
+	struct wt_status s;
+	unsigned char sha1[20];
+	static struct option builtin_stat_options[] = {
+		{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
+		  "mode",
+		  "show untracked files, optional modes: all, normal, no. (Default: all)",
+		  PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+		OPT_END(),
+	};
+
+	wt_status_prepare(&s);
+	git_config(git_status_config, &s);
+	argc = parse_options(argc, argv, prefix,
+			     builtin_stat_options,
+			     builtin_stat_usage, 0);
+	handle_untracked_files_arg(&s);
+
+	read_cache();
+	refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
+	s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
+	wt_status_collect(&s);
+
+	if (s.use_color == -1)
+		s.use_color = git_use_color_default;
+	if (diff_use_color_default == -1)
+		diff_use_color_default = git_use_color_default;
+	wt_status_print_body(&s);
+	return 0;
+}
+
 int cmd_status(int argc, const char **argv, const char *prefix)
 {
 	struct wt_status s;
diff --git a/builtin.h b/builtin.h
index 20427d2..eeaf0b6 100644
--- a/builtin.h
+++ b/builtin.h
@@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
 extern int cmd_show(int argc, const char **argv, const char *prefix);
 extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
+extern int cmd_stat(int argc, const char **argv, const char *prefix);
 extern int cmd_status(int argc, const char **argv, const char *prefix);
 extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
 extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 807d875..de7fcf6 100644
--- a/git.c
+++ b/git.c
@@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "shortlog", cmd_shortlog, USE_PAGER },
 		{ "show-branch", cmd_show_branch, RUN_SETUP },
 		{ "show", cmd_show, RUN_SETUP | USE_PAGER },
+		{ "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE },
 		{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
 		{ "stripspace", cmd_stripspace },
 		{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
diff --git a/wt-status.c b/wt-status.c
index 63598ce..c887a90 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -531,6 +531,19 @@ static void wt_status_print_tracking(struct wt_status *s)
 	color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 }
 
+void wt_status_print_body(struct wt_status *s)
+{
+	wt_status_print_unmerged(s);
+	wt_status_print_updated(s);
+	wt_status_print_changed(s);
+	if (s->submodule_summary)
+		wt_status_print_submodule_summary(s);
+	if (s->show_untracked_files)
+		wt_status_print_untracked(s);
+	else if (s->commitable)
+		 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
+}
+
 void wt_status_print(struct wt_status *s)
 {
 	unsigned char sha1[20];
@@ -561,15 +574,7 @@ void wt_status_print(struct wt_status *s)
 		color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
 	}
 
-	wt_status_print_unmerged(s);
-	wt_status_print_updated(s);
-	wt_status_print_changed(s);
-	if (s->submodule_summary)
-		wt_status_print_submodule_summary(s);
-	if (s->show_untracked_files)
-		wt_status_print_untracked(s);
-	else if (s->commitable)
-		 fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
+	wt_status_print_body(s);
 
 	if (s->verbose)
 		wt_status_print_verbose(s);
diff --git a/wt-status.h b/wt-status.h
index a0e7517..ab52ce1 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -54,5 +54,6 @@ struct wt_status {
 void wt_status_prepare(struct wt_status *s);
 void wt_status_print(struct wt_status *s);
 void wt_status_collect(struct wt_status *s);
+void wt_status_print_body(struct wt_status *s);
 
 #endif /* STATUS_H */
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 2/9] git commit --dry-run -v: show diff in color when asked
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-2-git-send-email-gitster@pobox.com>

The earlier implementation of --dry-run didn't duplicate the use of color
"git status -v" set up for diff output.

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

 * Unchanged since the last round.

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

diff --git a/builtin-commit.c b/builtin-commit.c
index 1c200eb..200ffda 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -979,9 +979,11 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
 	argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
 					  prefix, &s);
-	if (dry_run)
+	if (dry_run) {
+		if (diff_use_color_default == -1)
+			diff_use_color_default = git_use_color_default;
 		return dry_run_commit(argc, argv, prefix, &s);
-
+	}
 	index_file = prepare_index(argc, argv, prefix, 0);
 
 	/* Set up everything for writing the commit object.  This includes
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 1/9] Documentation/git-commit.txt: describe --dry-run
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git
In-Reply-To: <1250375997-10657-1-git-send-email-gitster@pobox.com>

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

 * Unchanged since the last round.

 Documentation/git-commit.txt |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index d01ff5a..64f94cf 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -9,7 +9,7 @@ SYNOPSIS
 --------
 [verse]
 'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
-	   [(-c | -C) <commit>] [-F <file> | -m <msg>]
+	   [(-c | -C) <commit>] [-F <file> | -m <msg>] [--dry-run]
 	   [--allow-empty] [--no-verify] [-e] [--author=<author>]
 	   [--cleanup=<mode>] [--] [[-i | -o ]<file>...]
 
@@ -42,10 +42,9 @@ The content to be added can be specified in several ways:
    by one which files should be part of the commit, before finalizing the
    operation.  Currently, this is done by invoking 'git-add --interactive'.
 
-The 'git-status' command can be used to obtain a
+The `--dry-run` option can be used to obtain a
 summary of what is included by any of the above for the next
-commit by giving the same set of parameters you would give to
-this command.
+commit by giving the same set of parameters (options and paths).
 
 If you make a commit and then find a mistake immediately after
 that, you can recover from it with 'git-reset'.
@@ -70,6 +69,12 @@ OPTIONS
 	Like '-C', but with '-c' the editor is invoked, so that
 	the user can further edit the commit message.
 
+--dry-run::
+	Do not actually make a commit, but show the list of paths
+	with updates in the index, paths with changes in the work tree,
+	and paths that are untracked, similar to the one that is given
+	in the commit log editor.
+
 -F <file>::
 --file=<file>::
 	Take the commit message from the given file.  Use '-' to
-- 
1.6.4.224.g3be84

^ permalink raw reply related

* [PATCH 0/9] "git status" that is not "git commit --dry-run"
From: Junio C Hamano @ 2009-08-15 22:39 UTC (permalink / raw)
  To: git

Here is an update relative to 7637868 (wt-status: collect untracked files
in a separate "collect" phase, 2009-08-10) that has been queued in 'next'.

[PATCH 1/9] and [PATCH 2/9] are the same from last night's fixes.

[PATCH 3/9] through [PATCH 6/9] introduce a new "git status" with
different semantics for 1.7.0 under a tentative name "git stat".  They
will be squashed into one commit in the final round, as 4, 5, and 6 are
fix-ups, but are keft separate for easier review.

    The new "git status" handles paths differently from the traditional
    one.  It used to be the preview of "git commit paths...", IOW,
    "show what would happen if we try to make a partial commit of only
    these paths".  The new "git status" only limits the paths the output
    talks about and is not a preview of anything at all anymore.

    Another semantic change is that its exit status no longer says if
    there is something to be committed in the index.  We used to exit with
    non-zero status if there is nothing to commit.

[PATCH 7/9] introduces a short format output.

The last two patches make the new "git status" official.  They will be
squashed together into one commit in the final round, but are kept
separate for reviewability.

Junio C Hamano (9):
  Documentation/git-commit.txt: describe --dry-run
  git commit --dry-run -v: show diff in color when asked
  git stat: the beginning
  git stat: honor relative paths setting
  git stat: show traditional status headers and trailers as well
  git stat: pathspec limits, unlike traditional "git status"
  git stat -s: short status output
  git status: not "commit --dry-run" anymore
  git-status: adjust tests

 Documentation/git-commit.txt |   13 ++-
 Documentation/git-status.txt |   79 +++++++++++++++++---
 Makefile                     |    1 +
 builtin-commit.c             |  172 +++++++++++++++++++++++++++++++++++++-----
 t/t6040-tracking-info.sh     |    2 +-
 t/t7060-wtstatus.sh          |    8 +-
 t/t7506-status-submodule.sh  |    6 +-
 t/t7508-status.sh            |   12 ++-
 wt-status.c                  |   10 ++-
 wt-status.h                  |    1 +
 10 files changed, 255 insertions(+), 49 deletions(-)

^ permalink raw reply

* Re: git-svn bug report: %20 in http:// should translate to a space ' ' automatically
From: Tony Finch @ 2009-08-15 22:37 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: Mike Smullin, Eric Wong, git
In-Reply-To: <20090815181637.GC19833@atjola.homenet>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 374 bytes --]

On Sat, 15 Aug 2009, Björn Steinbrink wrote:
>
> 3) git svn clone -Tgoo "http://host/repo/path with spaces/foo/bar"
>
> Works.

Spaces are not permitted in URLs so this should be treated as a syntax
error.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.

^ permalink raw reply

* Re: Simplify '--prett=xyz' options
From: Linus Torvalds @ 2009-08-15 21:39 UTC (permalink / raw)
  To: Thomas Rast; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151236250.3162@localhost.localdomain>



On Sat, 15 Aug 2009, Linus Torvalds wrote:
> 
> I would like to also make "--pretty=oneline" have the same abbrev-commit 
> semantics as "--oneline" has, but I didn't actually do that change.

Here's a patch if anybody cares.

It basically replaces the tests that do

	cut -b42-

or

	sed -e "s/^.\{41\}//"

(to get just the subject) with

	sed -e "s/^[0-9a-f]* //"

instead (which is an already pre-existing pattern that some other tests 
used).

The patch itself was trivial. The only question is whether the semantic 
change is ok (it certainly makes _sense_, it's just silly how "--oneline" 
is different from "--pretty=oneline"). 

This patch obviously depends on the previous one, since it just removes 
the special-casing of "--oneline" (it now falls out automatically from the 
"if you can't recognize the flag, see if it's a format flag" logic, and is 
no longer a special case).

The 'format/tformat' misdesigns I've not touched.

		Linus

---
 pretty.c                      |    4 +++-
 revision.c                    |    4 ----
 t/t3413-rebase-hook.sh        |    2 +-
 t/t5510-fetch.sh              |    2 +-
 t/t6009-rev-list-parent.sh    |    2 +-
 t/t9108-git-svn-glob.sh       |    4 ++--
 t/t9109-git-svn-multi-glob.sh |    6 +++---
 7 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/pretty.c b/pretty.c
index 1a76320..6d0fa60 100644
--- a/pretty.c
+++ b/pretty.c
@@ -52,8 +52,10 @@ int try_get_commit_format(const char *arg, struct rev_info *rev)
 	for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
 		if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
 		    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
-			if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
+			if (cmt_fmts[i].v == CMIT_FMT_ONELINE) {
 				rev->use_terminator = 1;
+				rev->abbrev_commit = 1;
+			}
 			rev->commit_format = cmt_fmts[i].v;
 			return 1;
 		}
diff --git a/revision.c b/revision.c
index bdace8b..b7f047a 100644
--- a/revision.c
+++ b/revision.c
@@ -1126,10 +1126,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
 	} else if (!prefixcmp(arg, "--pretty=")) {
 		revs->verbose_header = 1;
 		get_commit_format(arg+9, revs);
-	} else if (!strcmp(arg, "--oneline")) {
-		revs->verbose_header = 1;
-		get_commit_format("oneline", revs);
-		revs->abbrev_commit = 1;
 	} else if (!strcmp(arg, "--graph")) {
 		revs->topo_order = 1;
 		revs->rewrite_parents = 1;
diff --git a/t/t3413-rebase-hook.sh b/t/t3413-rebase-hook.sh
index 098b755..2f14c5c 100755
--- a/t/t3413-rebase-hook.sh
+++ b/t/t3413-rebase-hook.sh
@@ -19,7 +19,7 @@ test_expect_success setup '
 	test_tick &&
 	git commit -m side &&
 	git checkout master &&
-	git log --pretty=oneline --abbrev-commit --graph --all &&
+	git log --oneline --graph --all &&
 	git branch test side
 '
 
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index d13c806..62a45c0 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -168,7 +168,7 @@ test_expect_success 'bundle 1 has only 3 files ' '
 test_expect_success 'unbundle 2' '
 	cd "$D/bundle" &&
 	git fetch ../bundle2 master:master &&
-	test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
+	test "tip" = "$(git log -1 --pretty=oneline master | sed 's/^[0-9a-f]* //')"
 '
 
 test_expect_success 'bundle does not prerequisite objects' '
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index c8a96a9..9a90ce8 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -24,7 +24,7 @@ test_expect_success setup '
 	commit three &&
 	commit four &&
 
-	git log --pretty=oneline --abbrev-commit
+	git log --oneline
 '
 
 test_expect_success 'one is ancestor of others and should not be shown' '
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index d732d31..4d386f2 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '
 	                 "tags/*/src/a:refs/remotes/tags/*" &&
 	git svn multi-fetch &&
 	git log --pretty=oneline refs/remotes/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.end &&
+	    sed -e "s/^[0-9a-f]* //" > output.end &&
 	test_cmp expect.end output.end &&
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/start`" &&
@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '
 	test `git rev-parse refs/remotes/two/tags/end~3` = \
 	     `git rev-parse refs/remotes/two/branches/start` &&
 	git log --pretty=oneline refs/remotes/two/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.two &&
+	    sed -e "s/^[0-9a-f]* //" > output.two &&
 	test_cmp expect.two output.two
 	'
 
diff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh
index c318f9f..da93cf1 100755
--- a/t/t9109-git-svn-multi-glob.sh
+++ b/t/t9109-git-svn-multi-glob.sh
@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '
 	                 "tags/*/src/a:refs/remotes/tags/*" &&
 	git svn multi-fetch &&
 	git log --pretty=oneline refs/remotes/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.end &&
+	    sed -e "s/^[0-9a-f]* //" > output.end &&
 	test_cmp expect.end output.end &&
 	test "`git rev-parse refs/remotes/tags/end~1`" = \
 		"`git rev-parse refs/remotes/branches/v1/start`" &&
@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '
 	test `git rev-parse refs/remotes/two/tags/end~3` = \
 	     `git rev-parse refs/remotes/two/branches/v1/start` &&
 	git log --pretty=oneline refs/remotes/two/tags/end | \
-	    sed -e "s/^.\{41\}//" > output.two &&
+	    sed -e "s/^[0-9a-f]* //" > output.two &&
 	test_cmp expect.two output.two
 	'
 cat > expect.four <<EOF
@@ -131,7 +131,7 @@ test_expect_success 'test another branch' '
 	test `git rev-parse refs/remotes/four/tags/next~2` = \
 	     `git rev-parse refs/remotes/four/branches/v2/start` &&
 	git log --pretty=oneline refs/remotes/four/tags/next | \
-	    sed -e "s/^.\{41\}//" > output.four &&
+	    sed -e "s/^[0-9a-f]* //" > output.four &&
 	test_cmp expect.four output.four
 	'
 

^ permalink raw reply related

* Re: Simplify '--prett=xyz' options
From: Linus Torvalds @ 2009-08-15 21:29 UTC (permalink / raw)
  To: Avery Pennarun; +Cc: Junio C Hamano, Thomas Rast, Git Mailing List
In-Reply-To: <32541b130908151405j661cde8fh9783e91cebf1e398@mail.gmail.com>



On Sat, 15 Aug 2009, Avery Pennarun wrote:
> 
> I'm guessing that "after header" was just an implementation error.  It
> was presumably intended to be "after commit", so that the only
> difference between format and tformat is the presence or absence of
> the very last terminator.
> 
> Maybe the correct fix is just to make tformat not broken?

I do agree. 'tformat' is broken. But my point was more that 'tformat' was 
introduced for all the wrong reasons (ie that 'format' was broken, and 
then instead of fixing 'format', people introduced 'tformat' with a 
_different_ brokenness).

		Linus

^ permalink raw reply

* Re: jc/shortstatus
From: Junio C Hamano @ 2009-08-15 21:23 UTC (permalink / raw)
  To: Jeff King; +Cc: git
In-Reply-To: <7v8whltrqj.fsf@alter.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> A few points I haven't managed to think about, decide, nor test, are:
>
>  - What should its exit code be?  Should it be consistent with the
>    traditional "git status" at least when no paths are given, signallying
>    failure when nothing is staged for committing, so that ancient out of
>    tree scripts people may have written would not break too badly when we
>    make the switch?
>
>  - What should its default mode of output be?  Do people prefer "svn st"
>    style short-format output, or should we stay verbose and explanatory?
>
>  - Is it handling corner cases correctly?  e.g. Does it operate correctly
>    when run from a subdirectory?  How should it handle submodules?  Before
>    the initial commit?  Use of colors?

Just a quick status update, lest others waste too much time staring at the
series I posted last night.

 - Leading and trailing comments (e.g. "On branch foo", "Initial commit",
   "# No changes", ...) were missing.
 - Did not honor -v to show "diff --cached".
 - Subdirectory behaviour (status.relativepath configuration) was broken.

I have a version that fixes the above, and exits 0 when there is no error
(i.e. does not exit non-zero on clean index).  There are existing tests
that expect "git status" erroring out on clean index and there are some
that depends on "git status paths..." to show preview of a partial commit,
which needed to be replaced with "git commit --dry-run", but as far as I
can tell, I've took care of them all.

I am still feeling uneasy about the exit status change (the test scripts
are sources of how people who script around git take their inspirations
after all), but I'll send the result out for a review later without
changing that back to "exit failure when there is nothing to commit".

^ permalink raw reply

* Re: Simplify '--prett=xyz' options
From: Avery Pennarun @ 2009-08-15 21:05 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Thomas Rast, Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151324380.3162@localhost.localdomain>

On Sat, Aug 15, 2009 at 4:36 PM, Linus
Torvalds<torvalds@linux-foundation.org> wrote:
> On Sat, 15 Aug 2009, Junio C Hamano wrote:
>> If you try that without --stat, i.e.
>>
>>     $ git log -4 --pretty=format:%s | cat -e
>>     $ git log -4 --pretty=tformat:%s | cat -e
>>
>> I suspect you may then find that --pretty=format (not --pretty=tformat) is
>> broken.
>
> I disagree. The real brokenness is that we don't have any way to say "I
> want no newline at all after the format", and then having this mixup with
> the whole "terminator" thing - sometimes it's "between commits" (which is
> _correct_ any time you have stat info or something), and sometimes it's
> "after header" (which is almost always incorrect).

I'm guessing that "after header" was just an implementation error.  It
was presumably intended to be "after commit", so that the only
difference between format and tformat is the presence or absence of
the very last terminator.

Maybe the correct fix is just to make tformat not broken?

Avery

^ permalink raw reply

* Re: Linus' sha1 is much faster!
From: Linus Torvalds @ 2009-08-15 20:54 UTC (permalink / raw)
  To: John Tapsell
  Cc: Paul Kocher, Bryan Donlan, Bug-coreutils, Brandon Casey,
	Junio C Hamano, Nicolas Pitre, Pádraig Brady,
	Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151315400.3162@localhost.localdomain>



On Sat, 15 Aug 2009, Linus Torvalds wrote:
> 
> That said, I don't know if the MPL is ok for X11. I've not looked at 
> compatibility issues with MPL. For git, we could just ignore the MPL, 
> since the GPLv2 was acceptable regardless of it.

If MPL isn't ok for X11, then we'd need to make sure that even the 
silliest Mozilla crud has been rewritten. There really isn't much, but 
hey, the _history_ is based on the mozilla code, and who knows - the 
'blk_SHA_CTX' struct has things like the fields in the same order as the 
Mozilla equivalent, for all those historical reasons.

(Heh. Looking at that, I probably should move the 'size' field first, 
since that would have different alignment rules, and the struct would be 
more tightly packed that way, and initialize better).

Afaik, none of the actual code remains (the mozilla SHA1 thing did the 
wrong thing for performance even for just the final bytes, and did those a 
byte at a time etc, so I rewrote even the trivial SHA1_Final parts).

Of course, maybe the Mozilla people would be interested in taking my 
faster version, and say that the new-BSD license is ok, and make everybody 
happy. The only listed author for the Mozilla SHA1 is Paul Kocher. I added 
him to the Cc.

Paul, for your information, we're talking about a faster rewritten "mostly 
portable" SHA1 routines that you can find at

	http://git.kernel.org/?p=git/git.git;a=tree;f=block-sha1;hb=pu

(follow the "blob" pointers to see sha1.c and sha1.h). I don't know if 
you're active with Mozilla/Firefox or whether you even care, but you seem 
to be the logical choice of person to ask.

			Linus

^ permalink raw reply

* Re: Simplify '--prett=xyz' options
From: Linus Torvalds @ 2009-08-15 20:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Thomas Rast, Git Mailing List
In-Reply-To: <7viqgoestz.fsf@alter.siamese.dyndns.org>



On Sat, 15 Aug 2009, Junio C Hamano wrote:
> 
> If you try that without --stat, i.e.
> 
>     $ git log -4 --pretty=format:%s | cat -e
>     $ git log -4 --pretty=tformat:%s | cat -e
> 
> I suspect you may then find that --pretty=format (not --pretty=tformat) is
> broken.

I disagree. The real brokenness is that we don't have any way to say "I 
want no newline at all after the format", and then having this mixup with 
the whole "terminator" thing - sometimes it's "between commits" (which is 
_correct_ any time you have stat info or something), and sometimes it's 
"after header" (which is almost always incorrect).

For an example of this, try to do a one-line format that shows the 
diffstat on the same line. IOW, what you really want is something like

	git log -4 --shortstat --format=%s%NOTERM

but you can't do it at all right now - and defaulting to the "tformat" 
thing is actually _worse_.

So I do agree that "format" is broken and confused. I just think that 
"tformat" is EVEN MORE broken and confused, it just happens to fix that 
one form of brokenness that "format" has.

Notice how "CMIT_FMT_ONELINE" use the "use_terminator" (like tformat), but 
then does things right (unlike tformat). In particular, it's this one:

        pp_header(fmt, abbrev, dmode, encoding, commit, &msg, sb);
        if (fmt != CMIT_FMT_ONELINE && !subject) {
                strbuf_addch(sb, '\n');
        }       
	..
        /* Make sure there is an EOLN for the non-oneline case */
        if (fmt != CMIT_FMT_ONELINE)
                strbuf_addch(sb, '\n');

and notice how we have no way to edit those from the "format" descriptors.

			Linus

^ permalink raw reply

* Re: Linus' sha1 is much faster!
From: Linus Torvalds @ 2009-08-15 20:23 UTC (permalink / raw)
  To: John Tapsell
  Cc: Bryan Donlan, Pádraig Brady, Bug-coreutils, Git Mailing List,
	Brandon Casey, Junio C Hamano, Nicolas Pitre
In-Reply-To: <43d8ce650908151312o6a43416el27965c4b0ab8d83d@mail.gmail.com>



On Sat, 15 Aug 2009, John Tapsell wrote:

> 2009/8/15 Bryan Donlan <bdonlan@gmail.com>:
> > coreutils is licensed under GPLv3, and git under GPLv2 (only), so
> > you'd need permission from all contributors to the implementation in
> > order to relicense under GPLv3. A quick grep of the history suggests
> > these contributors to be:
> 
> X11 also requires a fast SHA1 implementation.  It uses this to check
> if two pixmaps are the same.  So it would be really nice to relicense
> under a liberal enough license that xorg can use it.

I'm personally ok with retaining the mozilla-sha1 license.

There's not really anything _remaining_ of the mozilla code, but hey, I 
started from it. In retrospect I probably should have started from the PPC 
asm code that already did the blocking sanely - but that's a "20/20 
hindsight" kind of thing.

Plus hey, the mozilla code being a horrid pile of crud was why I was so 
convinced that I could improve on things. So that's a kind of source for 
it, even if it's more about the motivational side than any actual 
remaining code ;)

That said, I don't know if the MPL is ok for X11. I've not looked at 
compatibility issues with MPL. For git, we could just ignore the MPL, 
since the GPLv2 was acceptable regardless of it.

			Linus

^ permalink raw reply

* Re: Simplify '--prett=xyz' options
From: Johannes Schindelin @ 2009-08-15 20:22 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151156510.3162@localhost.localdomain>

Hi,

On Sat, 15 Aug 2009, Linus Torvalds wrote:

> 
> I keep on thinking that I can write
> 
> 	git log --format:'%aN: %s'

You mean as opposed to "--format=%aN:\ %s" (which works)?

> Now I just need a patch to make me athletic and handsome.

I thought that already happened?  /me remembers seeing a youtube video 
with you in speedos.


> diff --git a/revision.c b/revision.c
> index 9f5dac5..181593f 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1192,6 +1192,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
>  	} else if (!strcmp(arg, "--children")) {
>  		revs->children.name = "children";
>  		revs->limited = 1;
> +	} else if (!strncmp(arg, "--", 2) && try_get_commit_format(arg+2, revs)) {

prefixcmp?

Ciao,
Dscho

^ permalink raw reply

* Re: Simplify '--prett=xyz' options
From: Junio C Hamano @ 2009-08-15 20:16 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Thomas Rast, Git Mailing List
In-Reply-To: <alpine.LFD.2.01.0908151236250.3162@localhost.localdomain>

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Sat, 15 Aug 2009, Thomas Rast wrote:
>
>> Granted, it makes it equivalent to --pretty=tformat:foo, but isn't
>> tformat the better choice in many cases?
>
> Not really. Look at what happens with
>
> 	git log --stat --pretty=format:%s
>
> and then try tformat instead. 'tformat' is broken, as is our current 
> --format=%s.
>
> In other words, all of that crud is totally illogical, and our "short 
> versions" (--oneline and --format=) were done entirely incorrectly (well, 
> --oneline probably has the _right_ semantics, and --pretty=oneline is just 
> wrong, but whatever).

If you try that without --stat, i.e.

    $ git log -4 --pretty=format:%s | cat -e
    $ git log -4 --pretty=tformat:%s | cat -e

I suspect you may then find that --pretty=format (not --pretty=tformat) is
broken.

^ permalink raw reply

* Re: Linus' sha1 is much faster!
From: John Tapsell @ 2009-08-15 20:12 UTC (permalink / raw)
  To: Bryan Donlan
  Cc: Pádraig Brady, Bug-coreutils, Linus Torvalds,
	Git Mailing List, Brandon Casey, Junio C Hamano, Nicolas Pitre
In-Reply-To: <3e8340490908151302y33a97d50t38ad0a8a788f1cee@mail.gmail.com>

2009/8/15 Bryan Donlan <bdonlan@gmail.com>:
> coreutils is licensed under GPLv3, and git under GPLv2 (only), so
> you'd need permission from all contributors to the implementation in
> order to relicense under GPLv3. A quick grep of the history suggests
> these contributors to be:


X11 also requires a fast SHA1 implementation.  It uses this to check
if two pixmaps are the same.  So it would be really nice to relicense
under a liberal enough license that xorg can use it.

John

^ 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