All of lore.kernel.org
 help / color / mirror / Atom feed
* Creating diffs
@ 2006-08-03 12:29 Rocco Rutte
  2006-08-03 12:39 ` Jakub Narebski
  2006-08-03 18:22 ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Rocco Rutte @ 2006-08-03 12:29 UTC (permalink / raw)
  To: git

Hi,

when creating a diff between two branches, one particular file needs a 
manually created/modified diff (the file contains just 1 line). As I 
cannot exclude files from the diff and create the missing one manually, 
I tried using the opposite approach: include all wanted.

However, when I do:

   $ git diff source:file dest:file

I get:

   --- a/source:file
   +++ b/source:file

But I'd like to drop the branchname. Can I do that without filtering 
everything through sed(1)?

Also, I think the diffs are reversed:

   $ git diff master:builtin-rm.c appname:builtin-rm.c
   diff --git a/master:builtin-rm.c b/master:builtin-rm.c
   index 735f3db..92d205a 100644
   --- a/master:builtin-rm.c
   +++ b/master:builtin-rm.c
   @@ -50,7 +50,6 @@ int cmd_rm(int argc, const char **argv, 
           const char **pathspec;
           char *seen;
   
   -       git_set_appname("git-rm");
           git_config(git_default_config);
   
           newfd = hold_lock_file_for_update(&lock_file, get_index_file());

since the appname branch contains the change while master doesn't.

Git version is 1.4.2.rc2 but both "bugs" happen with unpatched 1.3, too.

   bye, Rocco
-- 
:wq!

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

* Re: Creating diffs
  2006-08-03 12:29 Creating diffs Rocco Rutte
@ 2006-08-03 12:39 ` Jakub Narebski
  2006-08-03 14:47   ` Jakub Narebski
  2006-08-03 18:45   ` Junio C Hamano
  2006-08-03 18:22 ` Junio C Hamano
  1 sibling, 2 replies; 6+ messages in thread
From: Jakub Narebski @ 2006-08-03 12:39 UTC (permalink / raw)
  To: git

Rocco Rutte wrote:

> However, when I do:
> 
>    $ git diff source:file dest:file
> 
> I get:
> 
>    --- a/source:file
>    +++ b/source:file
> 
> But I'd like to drop the branchname. Can I do that without filtering 
> everything through sed(1)?

If I remember correctly there were two patches which solved it differently:
one gave

   --- a/source:file
   +++ b/dest:file

second (and I guess it is better solution)

   --- a/file
   +++ b/file

Unfortunately they seem unapplied...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* Re: Creating diffs
  2006-08-03 12:39 ` Jakub Narebski
@ 2006-08-03 14:47   ` Jakub Narebski
  2006-08-03 14:58     ` Rocco Rutte
  2006-08-03 18:45   ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2006-08-03 14:47 UTC (permalink / raw)
  To: git

Jakub Narebski wrote:

> Rocco Rutte wrote:
> 
>> However, when I do:
>> 
>>    $ git diff source:file dest:file
>> 
>> I get:
>> 
>>    --- a/source:file
>>    +++ b/source:file
>> 
>> But I'd like to drop the branchname. Can I do that without filtering 
>> everything through sed(1)?
> 
> If I remember correctly there were two patches which solved it 
> differently: 
>
> one gave 
> 
>    --- a/source:file
>    +++ b/dest:file
> 
> second (and I guess it is better solution)
> 
>    --- a/file
>    +++ b/file
> 
> Unfortunately they seem unapplied...

The patches are:
  http://www.gelato.unsw.edu.au/archives/git/0607/24325.html
  http://www.gelato.unsw.edu.au/archives/git/0607/24326.html

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

* Re: Creating diffs
  2006-08-03 14:47   ` Jakub Narebski
@ 2006-08-03 14:58     ` Rocco Rutte
  0 siblings, 0 replies; 6+ messages in thread
From: Rocco Rutte @ 2006-08-03 14:58 UTC (permalink / raw)
  To: git

Hi,

* Jakub Narebski [06-08-03 16:47:49 +0200] wrote:

>The patches are:
>  http://www.gelato.unsw.edu.au/archives/git/0607/24325.html
>  http://www.gelato.unsw.edu.au/archives/git/0607/24326.html

Hmm, ok, thanks for the pointer. What made me wonder in the first place 
is that the format differs from the diff-two-branches case because I 
assumed the algorithm basically is what I want to do (except it just 
does not exclude files) (i.e. diff-two-trees := get changed files and 
for each file, dump diff).

And what about the reverted diff contents? I don't know git too well so 
it take me quite long to provide a patch...

   bye, Rocco
-- 
:wq!

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

* Re: Creating diffs
  2006-08-03 12:29 Creating diffs Rocco Rutte
  2006-08-03 12:39 ` Jakub Narebski
@ 2006-08-03 18:22 ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-08-03 18:22 UTC (permalink / raw)
  To: Rocco Rutte; +Cc: git

Rocco Rutte <pdmef@gmx.net> writes:

> Also, I think the diffs are reversed:

Yeah, I noticed that too.

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

* Re: Creating diffs
  2006-08-03 12:39 ` Jakub Narebski
  2006-08-03 14:47   ` Jakub Narebski
@ 2006-08-03 18:45   ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-08-03 18:45 UTC (permalink / raw)
  To: git; +Cc: jnareb

Jakub Narebski <jnareb@gmail.com> writes:

> If I remember correctly there were two patches which solved it differently:
> one gave
>
>    --- a/source:file
>    +++ b/dest:file
>
> second (and I guess it is better solution)
>
>    --- a/file
>    +++ b/file
>
> Unfortunately they seem unapplied...

I think I explained why it was not enough in a neighboring
thread.  You would need to defeat the rename classification done
in diff.c::diff_resolve_rename_copy().

The diff reversal is independent.  I think it was introduced by
mistake when we switched revision.c::add_pending_object() to use
object_array from object_list.

Here is a patch to fix the reversal (swapping of indices for
blob[].sha1 in builtin-diff.c), show both names (swapping of
indices for blob[].name in builtin-diff.c), and not mistake this
as an rename (all the rest).  The change touches rather delicate
parts of the system, so I am reluctant to do the latter two at
this late in the game for 1.4.2, but please do test it and give
feedback.

---
diff --git a/builtin-diff.c b/builtin-diff.c
index 48d2fd0..cb4216e 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -125,9 +125,6 @@ static int builtin_diff_blobs(struct rev
 			      int argc, const char **argv,
 			      struct blobinfo *blob)
 {
-	/* Blobs: the arguments are reversed when setup_revisions()
-	 * picked them up.
-	 */
 	unsigned mode = canon_mode(S_IFREG | 0644);
 
 	if (argc > 1)
@@ -135,8 +132,8 @@ static int builtin_diff_blobs(struct rev
 
 	stuff_change(&revs->diffopt,
 		     mode, mode,
-		     blob[1].sha1, blob[0].sha1,
-		     blob[0].name, blob[0].name);
+		     blob[0].sha1, blob[1].sha1,
+		     blob[0].name, blob[1].name);
 	diffcore_std(&revs->diffopt);
 	diff_flush(&revs->diffopt);
 	return 0;
diff --git a/diff.c b/diff.c
index 607c357..895c137 100644
--- a/diff.c
+++ b/diff.c
@@ -1786,13 +1786,9 @@ struct diff_filepair *diff_queue(struct 
 				 struct diff_filespec *one,
 				 struct diff_filespec *two)
 {
-	struct diff_filepair *dp = xmalloc(sizeof(*dp));
+	struct diff_filepair *dp = xcalloc(1, sizeof(*dp));
 	dp->one = one;
 	dp->two = two;
-	dp->score = 0;
-	dp->status = 0;
-	dp->source_stays = 0;
-	dp->broken_pair = 0;
 	if (queue)
 		diff_q(queue, dp);
 	return dp;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 1de8d32..0ec488a 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -205,6 +205,7 @@ static void record_rename_pair(int dst_i
 	fill_filespec(two, dst->sha1, dst->mode);
 
 	dp = diff_queue(NULL, one, two);
+	dp->renamed_pair = 1;
 	if (!strcmp(src->path, dst->path))
 		dp->score = rename_src[src_index].score;
 	else
diff --git a/diffcore.h b/diffcore.h
index 73c7842..2249bc2 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -53,11 +53,12 @@ struct diff_filepair {
 	char status; /* M C R N D U (see Documentation/diff-format.txt) */
 	unsigned source_stays : 1; /* all of R/C are copies */
 	unsigned broken_pair : 1;
+	unsigned renamed_pair : 1;
 };
 #define DIFF_PAIR_UNMERGED(p) \
 	(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
 
-#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
+#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
 
 #define DIFF_PAIR_BROKEN(p) \
 	( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \

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

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-03 12:29 Creating diffs Rocco Rutte
2006-08-03 12:39 ` Jakub Narebski
2006-08-03 14:47   ` Jakub Narebski
2006-08-03 14:58     ` Rocco Rutte
2006-08-03 18:45   ` Junio C Hamano
2006-08-03 18:22 ` Junio C Hamano

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.