git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why is there no git-update-cache --modified (aka I give up)
@ 2005-07-12  5:52 Marc Singer
  2005-07-12  7:26 ` Petr Baudis
  2005-07-12  8:14 ` Junio C Hamano
  0 siblings, 2 replies; 9+ messages in thread
From: Marc Singer @ 2005-07-12  5:52 UTC (permalink / raw)
  To: git

  # git-diff-cache HEAD

is really nice.  But, do I really have to invoke git-update-cache with
every modified file?  I could write a script to cul the filenames from
git-diff-cache, but I'm having a hard time believing that that is how
others are preparing their commits.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why is there no git-update-cache --modified (aka I give up)
  2005-07-12  5:52 Why is there no git-update-cache --modified (aka I give up) Marc Singer
@ 2005-07-12  7:26 ` Petr Baudis
  2005-07-12  8:14 ` Junio C Hamano
  1 sibling, 0 replies; 9+ messages in thread
From: Petr Baudis @ 2005-07-12  7:26 UTC (permalink / raw)
  To: Marc Singer; +Cc: git

Dear diary, on Tue, Jul 12, 2005 at 07:52:18AM CEST, I got a letter
where Marc Singer <elf@buici.com> told me that...
>   # git-diff-cache HEAD
> 
> is really nice.  But, do I really have to invoke git-update-cache with
> every modified file?  I could write a script to cul the filenames from
> git-diff-cache, but I'm having a hard time believing that that is how
> others are preparing their commits.

It is. :-) It's only that they have cool scripts to do it, e.g.
cg-commit. (You have to enumerate the files explicitly for
git-commit-script as well, IIRC.)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why is there no git-update-cache --modified (aka I give up)
  2005-07-12  5:52 Why is there no git-update-cache --modified (aka I give up) Marc Singer
  2005-07-12  7:26 ` Petr Baudis
@ 2005-07-12  8:14 ` Junio C Hamano
  2005-07-12 15:53   ` Marc Singer
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2005-07-12  8:14 UTC (permalink / raw)
  To: git; +Cc: Marc Singer

Marc Singer <elf@buici.com> writes:

>   # git-diff-cache HEAD
>
> is really nice.  But, do I really have to invoke git-update-cache with
> every modified file?  I could write a script to cul the filenames from
> git-diff-cache, but I'm having a hard time believing that that is how
> others are preparing their commits.

Me too.  By the way, I think you mean diff-files not
diff-cache.

I'd like to know how others do it, since this was the
first thing I automated when I started using GIT.  Having clear
distinction between cache (aka index file) and work tree files
and making user concious decision of when to and when not to
register/update index is what is quite different in GIT from
CVS, SVN and friends [*1*], and while I appreciate its
flexibility, it often ends up to be simply more typing (and to
certain degree more thinking which is not a bad thing) to the
user [*2*].

This snippet is essentially what I do to match the cache with
the current work tree [*3*]:

	case "$(git-ls-files --unmerged | sed -e 1q)" in
	?*)
		echo >&2 You have unmerged files and cannot commit.
        	exit 1
		;;
	esac
	git-update-cache --refresh >/dev/null
	git-diff-files |
        sed -e 's/.*	//' |
	xargs -r git-update-cache --add --remove --

[Footnote]

*1* I vaguely recall reading somewhere that GIT is not the first
SCM to have these three (not two) levels.  Usual two-level SCM
needs to only move between your hackery and what's in the repo,
and words like "committing" and "checking in" are used
interchangeably, while the other three level SCM (I do not
remember which one I read about) gives distinct meaning to these
two words.  Can anybody tell me which SCM I am talking about?

*2* The commit flow in GIT is three level thing.  You have HEAD
version (a commit with an associated tree already in the object
database that you have checked out and started with), you have
cache, and you have files in your work tree.  Checking out is to
match cache and work tree to HEAD; update-cache is to match
cache to work tree; and committing is to create a new commit
that matches the cache and make it your HEAD.  Roughly speaking,
diff-* brothers are about comparing these three stages:

 - diff-files compares cache and work tree
 - diff-cache compares commit and cache, or commit and work tree
 - diff-tree compares two commits

*3* I do not officially do Porcelain ;-), but the script I use
is slightly different from the one quoted above.  It uses
"git-diff-files -z" and a helper program to handle filenames
with TAB in them.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why is there no git-update-cache --modified (aka I give up)
  2005-07-12  8:14 ` Junio C Hamano
@ 2005-07-12 15:53   ` Marc Singer
  2005-07-12 16:16     ` Matthias Urlichs
  0 siblings, 1 reply; 9+ messages in thread
From: Marc Singer @ 2005-07-12 15:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Tue, Jul 12, 2005 at 01:14:24AM -0700, Junio C Hamano wrote:
> Marc Singer <elf@buici.com> writes:
> 
> >   # git-diff-cache HEAD
> >
> > is really nice.  But, do I really have to invoke git-update-cache with
> > every modified file?  I could write a script to cul the filenames from
> > git-diff-cache, but I'm having a hard time believing that that is how
> > others are preparing their commits.
> 
> Me too.  By the way, I think you mean diff-files not
> diff-cache.

No, I mean git-diff-cache.  I find that this works pretty well, though.

  # git-update-cache `git-diff-cache | cut -f2`

It looks like the same thing works for git-diff-files. 

  # git-update-cache `git-diff-files | cut -f2`

This seems to agree with the way you handle things.

Similarly, there is the need to determine which files are new to the
tree.  This isn't much of a burden when creating files in the tree,
but can be bothersome when using patch since git-apply is conservative
about fuzz.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why is there no git-update-cache --modified (aka I give up)
  2005-07-12 15:53   ` Marc Singer
@ 2005-07-12 16:16     ` Matthias Urlichs
  2005-07-12 20:51       ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: Matthias Urlichs @ 2005-07-12 16:16 UTC (permalink / raw)
  To: git

Hi, Marc Singer wrote:

>   # git-update-cache `git-diff-cache | cut -f2`

g-d-c should have an option to print file names only. All that cutting
and argument-backtick-ing gets pretty nasty when there are a lot of files,
or if they contain special characters.

-- 
Matthias Urlichs   |   {M:U} IT Design @ m-u-it.de   |  smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
 - -
God is a perfect example of the kind of aberration that can result from
an untrained intellect combining with an unrestrained imagination.
		-- Simon Ewins

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Why is there no git-update-cache --modified (aka I give up)
  2005-07-12 16:16     ` Matthias Urlichs
@ 2005-07-12 20:51       ` Junio C Hamano
  2005-07-13 19:45         ` [PATCH] diff-stages: support "-u" as a synonym for "-p" Junio C Hamano
                           ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Junio C Hamano @ 2005-07-12 20:51 UTC (permalink / raw)
  To: git

Matthias Urlichs <smurf <at> smurf.noris.de> writes:

> 
> Hi, Marc Singer wrote:
> 
> >   # git-update-cache `git-diff-cache | cut -f2`
> 
> g-d-c should have an option to print file names only. All that cutting
> and argument-backtick-ing gets pretty nasty when there are a lot of files,
> or if they contain special characters.

I concur.  I'll add --name-only flag to diff brothers soonish.

Sorry I am at work and have turned the incoming connection to my home network
before I left for work today -- this is the same junkio@cox.net who is guilty
for all your diff problems ;-).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] diff-stages: support "-u" as a synonym for "-p".
  2005-07-12 20:51       ` Junio C Hamano
@ 2005-07-13 19:45         ` Junio C Hamano
  2005-07-13 19:45         ` [PATCH] git-diff-*: --name-only and --name-only-z Junio C Hamano
  2005-07-13 19:52         ` [PATCH] Clean up diff option descriptions Junio C Hamano
  2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2005-07-13 19:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Just to be consistent, support "-u" as a synonym for "-p" like
everybody else does.

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

 diff-stages.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

ef519b28e8edb19d4a0233152c9497ee807a4f5b
diff --git a/diff-stages.c b/diff-stages.c
--- a/diff-stages.c
+++ b/diff-stages.c
@@ -67,7 +67,7 @@ int main(int ac, const char **av)
 		const char *arg = av[1];
 		if (!strcmp(arg, "-r"))
 			; /* as usual */
-		else if (!strcmp(arg, "-p"))
+		else if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
 			diff_output_format = DIFF_FORMAT_PATCH;
 		else if (!strncmp(arg, "-B", 2)) {
 			if ((diff_break_opt = diff_scoreopt_parse(arg)) == -1)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] git-diff-*: --name-only and --name-only-z.
  2005-07-12 20:51       ` Junio C Hamano
  2005-07-13 19:45         ` [PATCH] diff-stages: support "-u" as a synonym for "-p" Junio C Hamano
@ 2005-07-13 19:45         ` Junio C Hamano
  2005-07-13 19:52         ` [PATCH] Clean up diff option descriptions Junio C Hamano
  2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2005-07-13 19:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Porcelain layers often want to find only names of changed files,
and even with diff-raw output format they end up having to pick
out only the filename.  Support --name-only (and --name-only-z
for xargs -0 and cpio -0 users that want to treat filenames with
embedded newlines sanely) flag to help them.

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

 diff-cache.c  |    8 ++++++++
 diff-files.c  |    4 ++++
 diff-stages.c |    4 ++++
 diff-tree.c   |    8 ++++++++
 diff.c        |   13 ++++++++++++-
 diff.h        |    2 ++
 6 files changed, 38 insertions(+), 1 deletions(-)

ea3228b62de0838cd854ecf503f6f534b0b7e25c
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -223,6 +223,14 @@ int main(int argc, const char **argv)
 			diff_output_format = DIFF_FORMAT_MACHINE;
 			continue;
 		}
+		if (!strcmp(arg, "--name-only")) {
+			diff_output_format = DIFF_FORMAT_NAME;
+			continue;
+		}
+		if (!strcmp(arg, "--name-only-z")) {
+			diff_output_format = DIFF_FORMAT_NAME_Z;
+			continue;
+		}
 		if (!strcmp(arg, "-R")) {
 			diff_setup_opt |= DIFF_SETUP_REVERSE;
 			continue;
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -55,6 +55,10 @@ int main(int argc, const char **argv)
 			; /* no-op */
 		else if (!strcmp(argv[1], "-z"))
 			diff_output_format = DIFF_FORMAT_MACHINE;
+		else if (!strcmp(argv[1], "--name-only"))
+			diff_output_format = DIFF_FORMAT_NAME;
+		else if (!strcmp(argv[1], "--name-only-z"))
+			diff_output_format = DIFF_FORMAT_NAME_Z;
 		else if (!strcmp(argv[1], "-R"))
 			diff_setup_opt |= DIFF_SETUP_REVERSE;
 		else if (!strncmp(argv[1], "-S", 2))
diff --git a/diff-stages.c b/diff-stages.c
--- a/diff-stages.c
+++ b/diff-stages.c
@@ -87,6 +87,10 @@ int main(int ac, const char **av)
 			find_copies_harder = 1;
 		else if (!strcmp(arg, "-z"))
 			diff_output_format = DIFF_FORMAT_MACHINE;
+		else if (!strcmp(arg, "--name-only"))
+			diff_output_format = DIFF_FORMAT_NAME;
+		else if (!strcmp(arg, "--name-only-z"))
+			diff_output_format = DIFF_FORMAT_NAME_Z;
 		else if (!strcmp(arg, "-R"))
 			diff_setup_opt |= DIFF_SETUP_REVERSE;
 		else if (!strncmp(arg, "-S", 2))
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -480,6 +480,14 @@ int main(int argc, const char **argv)
 			find_copies_harder = 1;
 			continue;
 		}
+		if (!strcmp(arg, "--name-only")) {
+			diff_output_format = DIFF_FORMAT_NAME;
+			continue;
+		}
+		if (!strcmp(arg, "--name-only-z")) {
+			diff_output_format = DIFF_FORMAT_NAME_Z;
+			continue;
+		}
 		if (!strcmp(arg, "-z")) {
 			diff_output_format = DIFF_FORMAT_MACHINE;
 			continue;
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -818,6 +818,12 @@ static void diff_flush_raw(struct diff_f
 	putchar(line_termination);
 }
 
+static void diff_flush_name(struct diff_filepair *p,
+			    int line_termination)
+{
+	printf("%s%c", p->two->path, line_termination);
+}
+
 int diff_unmodified_pair(struct diff_filepair *p)
 {
 	/* This function is written stricter than necessary to support
@@ -978,7 +984,8 @@ void diff_flush(int diff_output_style)
 	int line_termination = '\n';
 	int inter_name_termination = '\t';
 
-	if (diff_output_style == DIFF_FORMAT_MACHINE)
+	if (diff_output_style == DIFF_FORMAT_MACHINE ||
+	    diff_output_style == DIFF_FORMAT_NAME_Z)
 		line_termination = inter_name_termination = 0;
 
 	for (i = 0; i < q->nr; i++) {
@@ -997,6 +1004,10 @@ void diff_flush(int diff_output_style)
 			diff_flush_raw(p, line_termination,
 				       inter_name_termination);
 			break;
+		case DIFF_FORMAT_NAME:
+		case DIFF_FORMAT_NAME_Z:
+			diff_flush_name(p, line_termination);
+			break;
 		}
 	}
 	for (i = 0; i < q->nr; i++)
diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -59,6 +59,8 @@ extern int diff_queue_is_empty(void);
 #define DIFF_FORMAT_MACHINE	1
 #define DIFF_FORMAT_PATCH	2
 #define DIFF_FORMAT_NO_OUTPUT	3
+#define DIFF_FORMAT_NAME	4
+#define DIFF_FORMAT_NAME_Z	5
 
 extern void diff_flush(int output_style);
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] Clean up diff option descriptions.
  2005-07-12 20:51       ` Junio C Hamano
  2005-07-13 19:45         ` [PATCH] diff-stages: support "-u" as a synonym for "-p" Junio C Hamano
  2005-07-13 19:45         ` [PATCH] git-diff-*: --name-only and --name-only-z Junio C Hamano
@ 2005-07-13 19:52         ` Junio C Hamano
  2 siblings, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2005-07-13 19:52 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

I got tired of maintaining almost duplicated descriptions in
diff-* brothers, both in usage string and documentation.

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

*** This comes after the "diff-stages -u" and "--name-only" patches.
*** I am in the process of a full sweep over Documentation/ and
*** program usage strings right now so you will see more patches
*** to Documentation/ area from me.

 Documentation/Makefile            |    2 +
 Documentation/diff-options.txt    |   53 +++++++++++++++++++++++++++++++++++++
 Documentation/git-diff-cache.txt  |   48 ++--------------------------------
 Documentation/git-diff-files.txt  |   44 +------------------------------
 Documentation/git-diff-stages.txt |   48 ++--------------------------------
 Documentation/git-diff-tree.txt   |   46 ++------------------------------
 diff-cache.c                      |    4 ++-
 diff-files.c                      |    4 ++-
 diff-stages.c                     |    3 +-
 diff-tree.c                       |    4 ++-
 diff.h                            |   20 ++++++++++++++
 11 files changed, 96 insertions(+), 180 deletions(-)
 create mode 100644 Documentation/diff-options.txt

6a3a580f9f9da9d5e821c2ffbe9d0dd1fe54cb63
diff --git a/Documentation/Makefile b/Documentation/Makefile
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -25,7 +25,7 @@ man1: $(DOC_MAN1)
 man7: $(DOC_MAN7)
 
 # 'include' dependencies
-git-diff-%.txt: diff-format.txt
+git-diff-%.txt: diff-format.txt diff-options.txt
 	touch $@
 
 clean:
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/diff-options.txt
@@ -0,0 +1,53 @@
+-p::
+	Generate patch (see section on generating patches)
+
+-u::
+	Synonym for "-p".
+
+-r::
+	Look recursivelly in subdirectories; this flag does not
+	mean anything to commands other than "git-diff-tree";
+	other commands always looks at all the subdirectories.
+
+-z::
+	\0 line termination on output
+
+--name-only::
+	Show only names of changed files.
+
+--name-only-z::
+	Same as --name-only, but terminate lines with NUL.
+
+-B::
+	Break complete rewrite changes into pairs of delete and create.
+
+-M::
+	Detect renames.
+
+-C::
+	Detect copies as well as renames.
+
+--find-copies-harder::
+	By default, -C option finds copies only if the original
+	file of the copy was modified in the same changeset for
+	performance reasons.  This flag makes the command
+	inspect unmodified files as candidates for the source of
+	copy.  This is a very expensive operation for large
+	projects, so use it with caution.
+
+-S<string>::
+	Look for differences that contains the change in <string>.
+
+--pickaxe-all::
+	When -S finds a change, show all the changes in that
+	changeset, not just the files that contains the change
+	in <string>.
+
+-O<orderfile>::
+	Output the patch in the order specified in the
+	<orderfile>, which has one shell glob pattern per line.
+
+-R::
+	Swap two inputs; that is, show differences from cache or
+	on-disk file to tree contents.
+
diff --git a/Documentation/git-diff-cache.txt b/Documentation/git-diff-cache.txt
--- a/Documentation/git-diff-cache.txt
+++ b/Documentation/git-diff-cache.txt
@@ -9,7 +9,7 @@ git-diff-cache - Compares content and mo
 
 SYNOPSIS
 --------
-'git-diff-cache' [-p] [-r] [-z] [-m] [--cached] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> [<path>...]
+'git-diff-cache' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
 
 DESCRIPTION
 -----------
@@ -21,53 +21,11 @@ entries in the cache are compared.
 
 OPTIONS
 -------
+include::diff-options.txt[]
+
 <tree-ish>::
 	The id of a tree object to diff against.
 
--p::
-	Generate patch (see section on generating patches)
-
--r::
-	This flag does not mean anything.  It is there only to match
-	"git-diff-tree".  Unlike "git-diff-tree", "git-diff-cache"
-	always looks at all the subdirectories.
-
--z::
-	\0 line termination on output
-
--B::
-	Break complete rewrite changes into pairs of delete and create.
-
--M::
-	Detect renames.
-
--C::
-	Detect copies as well as renames.
-
---find-copies-harder::
-	By default, -C option finds copies only if the original
-	file of the copy was modified in the same changeset for
-	performance reasons.  This flag makes the command
-	inspect unmodified files as candidates for the source of
-	copy.  This is a very expensive operation for large
-	projects, so use it with caution.
-
--S<string>::
-	Look for differences that contains the change in <string>.
-
---pickaxe-all::
-	When -S finds a change, show all the changes in that
-	changeset, not just the files that contains the change
-	in <string>.
-
--O<orderfile>::
-	Output the patch in the order specified in the
-	<orderfile>, which has one shell glob pattern per line.
-
--R::
-	Swap two inputs; that is, show differences from cache or
-	on-disk file to tree contents.
-
 --cached::
 	do not consider the on-disk file at all
 
diff --git a/Documentation/git-diff-files.txt b/Documentation/git-diff-files.txt
--- a/Documentation/git-diff-files.txt
+++ b/Documentation/git-diff-files.txt
@@ -9,7 +9,7 @@ git-diff-files - Compares files in the w
 
 SYNOPSIS
 --------
-'git-diff-files' [-p] [-q] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]
+'git-diff-files' [-q] [<common diff options>] [<path>...]
 
 DESCRIPTION
 -----------
@@ -20,51 +20,11 @@ same as "git-diff-cache" and "git-diff-t
 
 OPTIONS
 -------
--p::
-	generate patch (see section on generating patches).
+include::diff-options.txt[]
 
 -q::
 	Remain silent even on nonexisting files
 
--R::
-	Swap two inputs; that is, show differences from on-disk files
-	to cache contents.
-
--B::
-	Break complete rewrite changes into pairs of delete and create.
-
--M::
-	Detect renames.
-
--C::
-	Detect copies as well as renames.
-
---find-copies-harder::
-	By default, -C option finds copies only if the original
-	file of the copy was modified in the same changeset for
-	performance reasons.  This flag makes the command
-	inspect unmodified files as candidates for the source of
-	copy.  This is a very expensive operation for large
-	projects, so use it with caution.
-
--S<string>::
-	Look for differences that contains the change in <string>.
-
---pickaxe-all::
-	When -S finds a change, show all the changes in that
-	changeset, not just the files that contains the change
-	in <string>.
-
--O<orderfile>::
-	Output the patch in the order specified in the
-	<orderfile>, which has one shell glob pattern per line.
-
--r::
-	This flag does not mean anything.  It is there only to match
-	git-diff-tree.  Unlike git-diff-tree, git-diff-files always looks
-	at all the subdirectories.
-
-
 Output format
 -------------
 include::diff-format.txt[]
diff --git a/Documentation/git-diff-stages.txt b/Documentation/git-diff-stages.txt
--- a/Documentation/git-diff-stages.txt
+++ b/Documentation/git-diff-stages.txt
@@ -9,7 +9,7 @@ git-diff-stages - Compares content and m
 
 SYNOPSIS
 --------
-'git-diff-stages' [-p] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <stage1> <stage2> [<path>...]
+'git-diff-stages' [<common diff options>] <stage1> <stage2> [<path>...]
 
 DESCRIPTION
 -----------
@@ -18,53 +18,11 @@ unmerged index file.
 
 OPTIONS
 -------
+include::diff-options.txt[]
+
 <stage1>,<stage2>::
 	The stage number to be compared.
 
--p::
-	Generate patch (see section on generating patches)
-
--r::
-	This flag does not mean anything.  It is there only to match
-	"git-diff-tree".  Unlike "git-diff-tree", "git-diff-stages"
-	always looks at all the subdirectories.
-
--z::
-	\0 line termination on output
-
--B::
-	Break complete rewrite changes into pairs of delete and create.
-
--M::
-	Detect renames.
-
--C::
-	Detect copies as well as renames.
-
---find-copies-harder::
-	By default, -C option finds copies only if the original
-	file of the copy was modified in the same changeset for
-	performance reasons.  This flag makes the command
-	inspect unmodified files as candidates for the source of
-	copy.  This is a very expensive operation for large
-	projects, so use it with caution.
-
--S<string>::
-	Look for differences that contains the change in <string>.
-
---pickaxe-all::
-	When -S finds a change, show all the changes in that
-	changeset, not just the files that contains the change
-	in <string>.
-
--O<orderfile>::
-	Output the patch in the order specified in the
-	<orderfile>, which has one shell glob pattern per line.
-
--R::
-	Swap two inputs; that is, show differences from <stage2> to
-	<stage1>.
-
 Output format
 -------------
 include::diff-format.txt[]
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -9,7 +9,7 @@ git-diff-tree - Compares the content and
 
 SYNOPSIS
 --------
-'git-diff-tree' [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [-t] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish> [<path>...]
+'git-diff-tree' [--stdin] [-m] [-s] [-v] [--pretty] [-t] [<common diff options>] <tree-ish> <tree-ish> [<path>...]
 
 DESCRIPTION
 -----------
@@ -19,6 +19,8 @@ Note that "git-diff-tree" can use the tr
 
 OPTIONS
 -------
+include::diff-options.txt[]
+
 <tree-ish>::
 	The id of a tree object.
 
@@ -29,51 +31,9 @@ OPTIONS
 	Note that this parameter does not provide any wildcard or regexp
 	features.
 
--p::
-	generate patch (see section on generating patches).  For
-	git-diff-tree, this flag implies '-r' as well.
-
--B::
-	Break complete rewrite changes into pairs of delete and create.
-
--M::
-	Detect renames.
-
--C::
-	Detect copies as well as renames.
-
---find-copies-harder::
-	By default, -C option finds copies only if the original
-	file of the copy was modified in the same changeset for
-	performance reasons.  This flag makes the command
-	inspect unmodified files as candidates for the source of
-	copy.  This is a very expensive operation for large
-	projects, so use it with caution.
-
--R::
-	Swap two input trees.
-
--S<string>::
-	Look for differences that contains the change in <string>.
-
---pickaxe-all::
-	When -S finds a change, show all the changes in that
-	changeset, not just the files that contains the change
-	in <string>.
-
--O<orderfile>::
-	Output the patch in the order specified in the
-	<orderfile>, which has one shell glob pattern per line.
-
--r::
-	recurse
-
 -t::
 	show tree entry itself as well as subtrees.  Implies -r.
 
--z::
-	\0 line termination on output
-
 --root::
 	When '--root' is specified the initial commit will be showed as a big
 	creation event. This is equivalent to a diff against the NULL tree.
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -159,7 +159,9 @@ static void mark_merge_entries(void)
 }
 
 static char *diff_cache_usage =
-"git-diff-cache [-p] [-r] [-z] [-m] [--cached] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> [<path>...]";
+"git-diff-cache [-m] [--cached] "
+"[<common diff options>] <tree-ish> [<path>...]"
+COMMON_DIFF_OPTIONS_HELP;
 
 int main(int argc, const char **argv)
 {
diff --git a/diff-files.c b/diff-files.c
--- a/diff-files.c
+++ b/diff-files.c
@@ -7,7 +7,9 @@
 #include "diff.h"
 
 static const char *diff_files_usage =
-"git-diff-files [-p] [-q] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]";
+"git-diff-files [-q] "
+"[<common diff options>] [<path>...]"
+COMMON_DIFF_OPTIONS_HELP;
 
 static int diff_output_format = DIFF_FORMAT_HUMAN;
 static int detect_rename = 0;
diff --git a/diff-stages.c b/diff-stages.c
--- a/diff-stages.c
+++ b/diff-stages.c
@@ -17,7 +17,8 @@ static const char *orderfile = NULL;
 static const char *diff_filter = NULL;
 
 static char *diff_stages_usage =
-"git-diff-stages [-p] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <stage1> <stage2> [<path>...]";
+"git-diff-stages [<common diff options>] <stage1> <stage2> [<path>...]"
+COMMON_DIFF_OPTIONS_HELP;
 
 static void diff_stages(int stage1, int stage2)
 {
diff --git a/diff-tree.c b/diff-tree.c
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -395,7 +395,9 @@ static int diff_tree_stdin(char *line)
 }
 
 static char *diff_tree_usage =
-"git-diff-tree [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [--pretty] [-t] [-R] [-B] [-M] [-C] [--find-copies-header] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish>";
+"git-diff-tree [--stdin] [-m] [-s] [-v] [--pretty] [-t] "
+"[<common diff options>] <tree-ish> <tree-ish>"
+COMMON_DIFF_OPTIONS_HELP;
 
 int main(int argc, const char **argv)
 {
diff --git a/diff.h b/diff.h
--- a/diff.h
+++ b/diff.h
@@ -53,6 +53,26 @@ extern void diffcore_std_no_resolve(cons
 				    const char *pickaxe, int pickaxe_opts,
 				    const char *orderfile, const char *filter);
 
+#define COMMON_DIFF_OPTIONS_HELP \
+"\ncommon diff options:\n" \
+"  -r		diff recursively (only meaningful in diff-tree)\n" \
+"  -z		output diff-raw with lines terminated with NUL.\n" \
+"  -p		output patch format.\n" \
+"  -u		synonym for -p.\n" \
+"  --name-only	show only names of changed files.\n" \
+"  --name-only-z\n" \
+"		same as --name-only but terminate lines with NUL.\n" \
+"  -R		swap input file pairs.\n" \
+"  -B		detect complete rewrites.\n" \
+"  -M		detect renames.\n" \
+"  -C		detect copies.\n" \
+"  --find-copies-harder\n" \
+"		try unchanged files as candidate for copy detection.\n" \
+"  -O<file>	reorder diffs according to the <file>.\n" \
+"  -S<string>	find filepair whose only one side contains the string.\n" \
+"  --pickaxe-all\n" \
+"		show all files diff when -S is used and hit is found.\n"
+
 extern int diff_queue_is_empty(void);
 
 #define DIFF_FORMAT_HUMAN	0

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-07-13 20:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-12  5:52 Why is there no git-update-cache --modified (aka I give up) Marc Singer
2005-07-12  7:26 ` Petr Baudis
2005-07-12  8:14 ` Junio C Hamano
2005-07-12 15:53   ` Marc Singer
2005-07-12 16:16     ` Matthias Urlichs
2005-07-12 20:51       ` Junio C Hamano
2005-07-13 19:45         ` [PATCH] diff-stages: support "-u" as a synonym for "-p" Junio C Hamano
2005-07-13 19:45         ` [PATCH] git-diff-*: --name-only and --name-only-z Junio C Hamano
2005-07-13 19:52         ` [PATCH] Clean up diff option descriptions Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).