[PATCH 1/2] diff-index --cached --raw: show tree entry on the LHS for unmerged entries.

Previous thread: [PATCH] Increase packedGit{Limit,WindowSize} on 64 bit systems. by Shawn O. Pearce on Thursday, January 4, 2007 - 8:28 pm. (2 messages)

Next thread: [PATCH 2/2] git-reset <tree> -- <path> restores absense of <path> in <tree> by Junio C Hamano on Friday, January 5, 2007 - 2:46 am. (4 messages)
From: Junio C Hamano
Date: Friday, January 5, 2007 - 2:42 am

This updates the way diffcore represents an unmerged pair
somewhat.  It used to be that entries with mode=0 on both sides
were used to represent an unmerged pair, but now it has an
explicit flag.  This is to allow diff-index --cached to report
the entry from the tree when the path is unmerged in the index.

This is used in updating &quot;git reset &lt;tree&gt; -- &lt;path&gt;&quot; to restore
absense of the path in the index from the tree.

Signed-off-by: Junio C Hamano &lt;junkio@cox.net&gt;
---

 * This is rather subtle but touches fairly core part of the
   plumbing, which I tried to stay away from doing these days.
   I do not think it would break anything, but please holler if
   it breaks your scripts...

 diff-lib.c |    9 ++++++---
 diff.c     |    6 ++++--
 diff.h     |    4 +++-
 diffcore.h |    4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index fc69fb9..2c9be60 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -97,7 +97,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
 			 * Show the diff for the 'ce' if we found the one
 			 * from the desired stage.
 			 */
-			diff_unmerge(&amp;revs-&gt;diffopt, ce-&gt;name);
+			diff_unmerge(&amp;revs-&gt;diffopt, ce-&gt;name, 0, null_sha1);
 			if (ce_stage(ce) != diff_unmerged_stage)
 				continue;
 		}
@@ -297,9 +297,12 @@ static int diff_cache(struct rev_info *revs,
 			    !show_modified(revs, ce, ac[1], 0,
 					   cached, match_missing))
 				break;
-			/* fallthru */
+			diff_unmerge(&amp;revs-&gt;diffopt, ce-&gt;name,
+				     ntohl(ce-&gt;ce_mode), ce-&gt;sha1);
+			break;
 		case 3:
-			diff_unmerge(&amp;revs-&gt;diffopt, ce-&gt;name);
+			diff_unmerge(&amp;revs-&gt;diffopt, ce-&gt;name,
+				     0, null_sha1);
 			break;
 
 		default:
diff --git a/diff.c b/diff.c
index f14288b..2c2e9dc 100644
--- a/diff.c
+++ b/diff.c
@@ -2875,10 +2875,12 @@ void diff_change(struct diff_options *options,
 }
 
 void diff_unmerge(struct diff_options *options,
-		  const char *path)
+		  const char *path,
+		  unsigned mode, ...
Previous thread: [PATCH] Increase packedGit{Limit,WindowSize} on 64 bit systems. by Shawn O. Pearce on Thursday, January 4, 2007 - 8:28 pm. (2 messages)

Next thread: [PATCH 2/2] git-reset <tree> -- <path> restores absense of <path> in <tree> by Junio C Hamano on Friday, January 5, 2007 - 2:46 am. (4 messages)