From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] Fix type-change handling when assigning the status code to filepairs.
Date: Wed, 25 May 2005 15:07:08 -0700 [thread overview]
Message-ID: <7vvf57hsdv.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vzmujjdq4.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Wed, 25 May 2005 12:40:51 -0700")
The interim single-liner '?' fix resulted delete entries that
should not have emitted coming out in the output as an
unintended side effect; I caught this with the "rename" test in
the test suite. This patch instead fixes the code that assigns
the status code to each filepair.
I verified this does not break the testcase in udev.git tree Kay
Sievers gave us, by running git-diff-tree on that tree which
showed 21 file to symlink changes.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
*** Linus, it just struck me that there is nothing inherently
*** wrong to detect whole subtree renames (diffcore-rename
*** currently does not attempt to match tree creation against
*** tree delete to produce tree rename/copy). This is something
*** I am _not_ going to do, but it still would be interesting to
*** keep in mind...
diff.c | 36 ++++++++++++++++++++++--------------
diffcore.h | 3 +++
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -691,27 +691,34 @@ static void diff_resolve_rename_copy(voi
for (i = 0; i < q->nr; i++) {
p = q->queue[i];
- p->status = 0;
+ p->status = 0; /* undecided */
if (DIFF_PAIR_UNMERGED(p))
p->status = 'U';
else if (!DIFF_FILE_VALID((p)->one))
p->status = 'N';
else if (!DIFF_FILE_VALID((p)->two)) {
/* Deletion record should be omitted if there
- * is another entry that is a rename or a copy
- * and it uses this one as the source. Then we
- * can say the other one is a rename.
+ * are rename/copy entries using this one as
+ * the source. Then we can say one of them
+ * is a rename and the rest are copies.
*/
+ p->status = 'D';
for (j = 0; j < q->nr; j++) {
pp = q->queue[j];
if (!strcmp(pp->one->path, p->one->path) &&
- strcmp(pp->one->path, pp->two->path))
+ strcmp(pp->one->path, pp->two->path)) {
+ p->status = 'X';
break;
+ }
}
- if (j < q->nr)
- continue; /* has rename/copy */
- p->status = 'D';
}
+ else if (DIFF_PAIR_TYPE_CHANGED(p))
+ p->status = 'T';
+
+ /* from this point on, we are dealing with a pair
+ * whose both sides are valid and of the same type, i.e.
+ * either in-place edit or rename/copy edit.
+ */
else if (strcmp(p->one->path, p->two->path)) {
/* See if there is somebody else anywhere that
* will keep the path (either modified or
@@ -719,7 +726,7 @@ static void diff_resolve_rename_copy(voi
* not a rename. In addition, if there is
* some other rename or copy that comes later
* than us that uses the same source, we
- * cannot be a rename either.
+ * have to be a copy, not a rename.
*/
for (j = 0; j < q->nr; j++) {
pp = q->queue[j];
@@ -745,10 +752,9 @@ static void diff_resolve_rename_copy(voi
}
else if (memcmp(p->one->sha1, p->two->sha1, 20))
p->status = 'M';
- else {
- /* we do not need this one */
- p->status = 0;
- }
+ else
+ /* this is a "no-change" entry */
+ p->status = 'X';
}
diff_debug_queue("resolve-rename-copy done", q);
}
@@ -767,8 +773,10 @@ void diff_flush(int diff_output_style, i
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
+ if (p->status == 'X')
+ continue;
if (p->status == 0)
- p->status = '?';
+ die("internal error in diff-resolve-rename-copy");
switch (diff_output_style) {
case DIFF_FORMAT_PATCH:
diff_flush_patch(p);
diff --git a/diffcore.h b/diffcore.h
--- a/diffcore.h
+++ b/diffcore.h
@@ -45,6 +45,9 @@ struct diff_filepair {
#define DIFF_PAIR_UNMERGED(p) \
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
+#define DIFF_PAIR_TYPE_CHANGED(p) \
+ ((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
+
extern int diff_unmodified_pair(struct diff_filepair *);
struct diff_queue_struct {
------------------------------------------------
next prev parent reply other threads:[~2005-05-25 22:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-25 11:17 change of git-diff-tree and symlinks Kay Sievers
2005-05-25 18:08 ` Linus Torvalds
2005-05-25 18:35 ` Kay Sievers
2005-05-25 19:40 ` Junio C Hamano
2005-05-25 22:06 ` [PATCH] Adjust show-files test for dotfiles Junio C Hamano
2005-05-25 22:07 ` Junio C Hamano [this message]
2005-05-25 22:26 ` change of git-diff-tree and symlinks Kay Sievers
2005-05-25 22:43 ` Junio C Hamano
2005-05-25 22:47 ` Linus Torvalds
2005-05-25 23:00 ` [PATCH] Mode only changes from diff Junio C Hamano
2005-05-26 2:11 ` [PATCH] Test case portability fix Junio C Hamano
2005-05-26 2:36 ` Linus Torvalds
2005-05-26 2:55 ` Junio C Hamano
2005-05-29 14:16 ` change of git-diff-tree and symlinks Jochen Roemling
2005-05-29 15:06 ` Kay Sievers
2005-05-29 16:06 ` Jochen Roemling
2005-05-29 16:14 ` Sebastian Kuzminsky
2005-05-30 3:17 ` Sebastian Kuzminsky
2005-05-29 18:55 ` Junio C Hamano
2005-05-29 21:32 ` Petr Baudis
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=7vvf57hsdv.fsf_-_@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=kay.sievers@vrfy.org \
--cc=torvalds@osdl.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.