git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Michael J Gruber" <git@drmicha.warpmail.net>,
	"Mart Sõmermaa" <mrts.pydev@gmail.com>,
	git@vger.kernel.org
Subject: Re: git diff: add option for omitting the contents of deletes
Date: Mon, 28 Feb 2011 16:11:55 -0800	[thread overview]
Message-ID: <7vy64zg0ms.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vfwr7hh7f.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Mon\, 28 Feb 2011 15\:28\:36 -0800")

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

> Jeff King <peff@peff.net> writes:
>
>> I'm not quite sure what lossage you mean. On the recipient's end? They
>> can just "git revert", no?

This is beating on a dead horse, but in my previous life, in a project I
wasn't deeply involved in, a deployment procedure used was to:

 - give git-archive tarball of a major release to the target machine that
   does not have git repository, and extract the tarball;

 - maintain 'maint' branch, and show the tip of 'maint' on a test server,
   but give the client vetoing power on individual changes;

 - hence ending up preparing a format-patch output for selected changes,
   and running git-apply on the target machine to update it.

The -M/-C options would have worked well in this scenario, including the
recovery from "oops--that didn't work, please revert asap" (I don't know
if they actually used -M/-C when preparing the incremental updates,
though).  The -D option does not have the same reversibility.

I am (have been) only reacting to the earlier statement by Michael that -D
is the same as -M/-C and reversibility does not matter.  It does in such a
situation.

Now that the project with that deployment procedure is totally behind me,
I probably shouldn't care too much about such a workflow, but I suspect
there still are people using that sort of workflow, and this would matter
to them.

In any case, a minimum patch to give what Mart wanted to see would
probably look like this.  I'll leave bugfixes, documentation and tests to
the readers ;-).

 diff.c |   12 +++++++++---
 diff.h |    1 +
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/diff.c b/diff.c
index 5422c43..5c66a53 100644
--- a/diff.c
+++ b/diff.c
@@ -1943,7 +1943,11 @@ static void builtin_diff(const char *name_a,
 		}
 	}
 
-	if (!DIFF_OPT_TST(o, TEXT) &&
+	if (o->irreversible_delete && lbl[1][0] == '/') {
+		fprintf(o->file, "%s", header.buf);
+		strbuf_reset(&header);
+		goto free_ab_and_return;
+	} else if (!DIFF_OPT_TST(o, TEXT) &&
 	    ( (!textconv_one && diff_filespec_is_binary(one)) ||
 	      (!textconv_two && diff_filespec_is_binary(two)) )) {
 		if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
@@ -1963,8 +1967,7 @@ static void builtin_diff(const char *name_a,
 			fprintf(o->file, "%sBinary files %s and %s differ\n",
 				line_prefix, lbl[0], lbl[1]);
 		o->found_changes = 1;
-	}
-	else {
+	} else {
 		/* Crazy xdl interfaces.. */
 		const char *diffopts = getenv("GIT_DIFF_OPTS");
 		xpparam_t xpp;
@@ -3160,6 +3163,9 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 			return error("invalid argument to -M: %s", arg+2);
 		options->detect_rename = DIFF_DETECT_RENAME;
 	}
+	else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) {
+		options->irreversible_delete = 1;
+	}
 	else if (!prefixcmp(arg, "-C") || !prefixcmp(arg, "--find-copies=") ||
 		 !strcmp(arg, "--find-copies")) {
 		if (options->detect_rename == DIFF_DETECT_COPY)
diff --git a/diff.h b/diff.h
index 310bd6b..11d13cf 100644
--- a/diff.h
+++ b/diff.h
@@ -104,6 +104,7 @@ struct diff_options {
 	int interhunkcontext;
 	int break_opt;
 	int detect_rename;
+	int irreversible_delete;
 	int skip_stat_unmatch;
 	int line_termination;
 	int output_format;

  reply	other threads:[~2011-03-01  0:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-26 13:16 git diff: add option for omitting the contents of deletes Mart Sõmermaa
2011-02-26 20:11 ` Junio C Hamano
2011-02-27 14:41   ` Michael J Gruber
2011-02-27 22:33     ` Mart Sõmermaa
2011-02-28  9:58       ` Michael J Gruber
2011-02-28 10:51         ` Mart Sõmermaa
2011-02-27 22:54     ` Junio C Hamano
2011-02-27 23:07       ` Junio C Hamano
2011-02-28  7:31         ` Michael J Gruber
2011-02-28 12:17           ` Jeff King
2011-02-28 12:23             ` Jeff King
2011-02-28 12:32               ` Michael J Gruber
2011-02-28 12:59                 ` Jeff King
2011-02-28 13:05                   ` Michael J Gruber
2011-02-28 21:54                     ` Jeff King
2011-02-28 18:11               ` Junio C Hamano
2011-02-28 22:23                 ` Jeff King
2011-02-28 23:28                   ` Junio C Hamano
2011-03-01  0:11                     ` Junio C Hamano [this message]
2011-03-07 20:38                       ` Mart Sõmermaa
2011-03-08  7:14                         ` Michael J Gruber
2011-03-08 19:49                         ` Junio C Hamano
2011-03-08 21:25                           ` Mart Sõmermaa
2011-03-08 21:31                             ` Jeff King
2011-02-28 12:42             ` symling diff driver (Was: Re: git diff: add option for omitting the contents of deletes) Michael J Gruber
2011-02-28 13:08               ` Jeff King
2011-02-28 15:26                 ` [PATCH/WIP] attr: make attributes depend on file type Michael J Gruber
2011-02-28 17:30                   ` Jeff King
2011-02-28 17:48                     ` Junio C Hamano
2011-03-01  7:46                       ` Michael J Gruber
2011-02-28 10:45         ` git diff: add option for omitting the contents of deletes Mart Sõmermaa
2011-02-28 16:10           ` Michael J Gruber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vy64zg0ms.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=mrts.pydev@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).