git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] diff: add --no-diff-deleted to make -p more pleasant
@ 2006-01-29 14:24 Eric Wong
  2006-01-29 20:12 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2006-01-29 14:24 UTC (permalink / raw)
  To: git list

This is a feature I've stol^Wborrowed from svn that I find very
useful since I usually don't care to see what I've deleted.

Signed-off-by: Eric Wong <normalperson@yhbt.net>

---

 diff.c |    6 ++++++
 diff.h |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

0b426af15a7da4f430d9cca8c1ad057557d93627
diff --git a/diff.c b/diff.c
index f45d18c..6db3e19 100644
--- a/diff.c
+++ b/diff.c
@@ -769,6 +769,7 @@ void diff_setup(struct diff_options *opt
 {
 	memset(options, 0, sizeof(*options));
 	options->output_format = DIFF_FORMAT_RAW;
+	options->diff_deleted = 1;
 	options->line_termination = '\n';
 	options->break_opt = -1;
 	options->rename_limit = -1;
@@ -849,6 +850,8 @@ int diff_opt_parse(struct diff_options *
 	}
 	else if (!strcmp(arg, "--find-copies-harder"))
 		options->find_copies_harder = 1;
+	else if (!strcmp(arg, "--no-diff-deleted"))
+		options->diff_deleted = 0;
 	else if (!strcmp(arg, "--abbrev"))
 		options->abbrev = DEFAULT_ABBREV;
 	else if (!strncmp(arg, "--abbrev=", 9)) {
@@ -1103,6 +1106,9 @@ int diff_unmodified_pair(struct diff_fil
 
 static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
 {
+	if (!o->diff_deleted && (p->status == DIFF_STATUS_DELETED))
+		return;
+
 	if (diff_unmodified_pair(p))
 		return;
 
diff --git a/diff.h b/diff.h
index 9a0169c..4f320ac 100644
--- a/diff.h
+++ b/diff.h
@@ -39,6 +39,7 @@ struct diff_options {
 	int find_copies_harder;
 	int line_termination;
 	int output_format;
+	int diff_deleted;
 	int pickaxe_opts;
 	int rename_score;
 	int reverse_diff;
@@ -120,6 +121,8 @@ extern void diffcore_std_no_resolve(stru
 "  -C            detect copies.\n" \
 "  --find-copies-harder\n" \
 "                try unchanged files as candidate for copy detection.\n" \
+"  --no-diff-deleted\n" \
+"                do not print patch format for deleted files\n" \
 "  -l<n>         limit rename attempts up to <n> paths.\n" \
 "  -O<file>      reorder diffs according to the <file>.\n" \
 "  -S<string>    find filepair whose only one side contains the string.\n" \
-- 
1.1.5.gae18-dirty

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

* Re: [PATCH] diff: add --no-diff-deleted to make -p more pleasant
  2006-01-29 14:24 [PATCH] diff: add --no-diff-deleted to make -p more pleasant Eric Wong
@ 2006-01-29 20:12 ` Junio C Hamano
  2006-01-30  0:38   ` Eric Wong
  2006-01-30 18:08   ` Jon Loeliger
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2006-01-29 20:12 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

Eric Wong <normalperson@yhbt.net> writes:

> This is a feature I've stol^Wborrowed from svn that I find very
> useful since I usually don't care to see what I've deleted.

There is a thing called --diff-filter, and 

	git diff -p --no-diff-deleted

is equivalent to

	git diff -p --diff-filter=AM

when you are not using rename/copy detection (and a byte
shorter).  Or maybe improve its syntax to also take:

	--diff-filter=-D

That is, a minus followed by list of undesired change class
letters.

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

* Re: [PATCH] diff: add --no-diff-deleted to make -p more pleasant
  2006-01-29 20:12 ` Junio C Hamano
@ 2006-01-30  0:38   ` Eric Wong
  2006-01-30 18:08   ` Jon Loeliger
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Wong @ 2006-01-30  0:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > This is a feature I've stol^Wborrowed from svn that I find very
> > useful since I usually don't care to see what I've deleted.
> 
> There is a thing called --diff-filter, and 
> 
> 	git diff -p --no-diff-deleted
> 
> is equivalent to
> 
> 	git diff -p --diff-filter=AM

Cool, didn't notice this feature before.  Thanks.

> when you are not using rename/copy detection (and a byte
> shorter).  Or maybe improve its syntax to also take:
> 
> 	--diff-filter=-D
> 
> That is, a minus followed by list of undesired change class
> letters.

Hmm.. maybe another day.  AM is good enough for now.

-- 
Eric Wong

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

* Re: [PATCH] diff: add --no-diff-deleted to make -p more pleasant
  2006-01-29 20:12 ` Junio C Hamano
  2006-01-30  0:38   ` Eric Wong
@ 2006-01-30 18:08   ` Jon Loeliger
  1 sibling, 0 replies; 4+ messages in thread
From: Jon Loeliger @ 2006-01-30 18:08 UTC (permalink / raw)
  To: Git List

On Sun, 2006-01-29 at 14:12, Junio C Hamano wrote:
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > This is a feature I've stol^Wborrowed from svn that I find very
> > useful since I usually don't care to see what I've deleted.
> 
> There is a thing called --diff-filter, and 
> 
> 	git diff -p --no-diff-deleted
> 
> is equivalent to
> 
> 	git diff -p --diff-filter=AM
> 
> when you are not using rename/copy detection (and a byte
> shorter).

Hmmm.... I think this may be the problem:

    % grep -r diff-filter Documentation/
    Documentation/git-diff.txt:$ git diff --diff-filter=MRC <1>

And that is:

    Limiting the diff output::
    +
    ------------
    $ git diff --diff-filter=MRC <1>
    $ git diff --name-status -r <2>
    $ git diff arch/i386 include/asm-i386 <3>
 
    <1> show only modification, rename and copy, but not addition
    nor deletion.
    <2> show only names and the nature of change, but not actual
    diff output.  --name-status disables usual patch generation
    which in turn also disables recursive behaviour, so without -r
    you would only see the directory name if there is a change in a
    file in a subdirectory.
    <3> limit diff output to named subtrees.

That's pretty thin documentation there.
Unless someone beats me to it, I'll try to find
a spare documentation cycle...

jdl

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

end of thread, other threads:[~2006-01-30 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-29 14:24 [PATCH] diff: add --no-diff-deleted to make -p more pleasant Eric Wong
2006-01-29 20:12 ` Junio C Hamano
2006-01-30  0:38   ` Eric Wong
2006-01-30 18:08   ` Jon Loeliger

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).