{"thread":{"id":"5103","subject":"Creating diffs","startedAt":"2006-08-03T12:29:37Z","lastAt":"2006-08-03T18:45:00Z","messageCount":6,"participants":["Rocco Rutte","Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"24632","messageId":"20060803122937.GI5016@robert.daprodeges.fqdn.th-h.de","threadId":"5103","inReplyTo":null,"subject":"Creating diffs","fromName":"Rocco Rutte","fromEmail":"pdmef@gmx.net","sentAt":"2006-08-03T12:29:37Z","receivedAt":"2006-08-03T12:29:37Z","isPatch":false,"sender":{"key":"pdmef@gmx.net","avatar":null},"body":"Hi,\n\nwhen creating a diff between two branches, one particular file needs a \nmanually created/modified diff (the file contains just 1 line). As I \ncannot exclude files from the diff and create the missing one manually, \nI tried using the opposite approach: include all wanted.\n\nHowever, when I do:\n\n   $ git diff source:file dest:file\n\nI get:\n\n   --- a/source:file\n   +++ b/source:file\n\nBut I'd like to drop the branchname. Can I do that without filtering \neverything through sed(1)?\n\nAlso, I think the diffs are reversed:\n\n   $ git diff master:builtin-rm.c appname:builtin-rm.c\n   diff --git a/master:builtin-rm.c b/master:builtin-rm.c\n   index 735f3db..92d205a 100644\n   --- a/master:builtin-rm.c\n   +++ b/master:builtin-rm.c\n   @@ -50,7 +50,6 @@ int cmd_rm(int argc, const char **argv, \n           const char **pathspec;\n           char *seen;\n   \n   -       git_set_appname(\"git-rm\");\n           git_config(git_default_config);\n   \n           newfd = hold_lock_file_for_update(&lock_file, get_index_file());\n\nsince the appname branch contains the change while master doesn't.\n\nGit version is 1.4.2.rc2 but both \"bugs\" happen with unpatched 1.3, too.\n\n   bye, Rocco\n-- \n:wq!\n"},{"id":"24635","messageId":"easqpi$o51$1@sea.gmane.org","threadId":"5103","inReplyTo":"20060803122937.GI5016@robert.daprodeges.fqdn.th-h.de","subject":"Re: Creating diffs","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-03T12:39:47Z","receivedAt":"2006-08-03T12:39:47Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Rocco Rutte wrote:\n\n> However, when I do:\n> \n>    $ git diff source:file dest:file\n> \n> I get:\n> \n>    --- a/source:file\n>    +++ b/source:file\n> \n> But I'd like to drop the branchname. Can I do that without filtering \n> everything through sed(1)?\n\nIf I remember correctly there were two patches which solved it differently:\none gave\n\n   --- a/source:file\n   +++ b/dest:file\n\nsecond (and I guess it is better solution)\n\n   --- a/file\n   +++ b/file\n\nUnfortunately they seem unapplied...\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24638","messageId":"eat29j$lil$1@sea.gmane.org","threadId":"5103","inReplyTo":"easqpi$o51$1@sea.gmane.org","subject":"Re: Creating diffs","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-03T14:47:49Z","receivedAt":"2006-08-03T14:47:49Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> Rocco Rutte wrote:\n> \n>> However, when I do:\n>> \n>>    $ git diff source:file dest:file\n>> \n>> I get:\n>> \n>>    --- a/source:file\n>>    +++ b/source:file\n>> \n>> But I'd like to drop the branchname. Can I do that without filtering \n>> everything through sed(1)?\n> \n> If I remember correctly there were two patches which solved it \n> differently: \n>\n> one gave \n> \n>    --- a/source:file\n>    +++ b/dest:file\n> \n> second (and I guess it is better solution)\n> \n>    --- a/file\n>    +++ b/file\n> \n> Unfortunately they seem unapplied...\n\nThe patches are:\n  http://www.gelato.unsw.edu.au/archives/git/0607/24325.html\n  http://www.gelato.unsw.edu.au/archives/git/0607/24326.html\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24639","messageId":"20060803145850.GK5016@robert.daprodeges.fqdn.th-h.de","threadId":"5103","inReplyTo":"eat29j$lil$1@sea.gmane.org","subject":"Re: Creating diffs","fromName":"Rocco Rutte","fromEmail":"pdmef@gmx.net","sentAt":"2006-08-03T14:58:50Z","receivedAt":"2006-08-03T14:58:50Z","isPatch":false,"sender":{"key":"pdmef@gmx.net","avatar":null},"body":"Hi,\n\n* Jakub Narebski [06-08-03 16:47:49 +0200] wrote:\n\n>The patches are:\n>  http://www.gelato.unsw.edu.au/archives/git/0607/24325.html\n>  http://www.gelato.unsw.edu.au/archives/git/0607/24326.html\n\nHmm, ok, thanks for the pointer. What made me wonder in the first place \nis that the format differs from the diff-two-branches case because I \nassumed the algorithm basically is what I want to do (except it just \ndoes not exclude files) (i.e. diff-two-trees := get changed files and \nfor each file, dump diff).\n\nAnd what about the reverted diff contents? I don't know git too well so \nit take me quite long to provide a patch...\n\n   bye, Rocco\n-- \n:wq!\n"},{"id":"24655","messageId":"7vbqr1r85g.fsf@assigned-by-dhcp.cox.net","threadId":"5103","inReplyTo":"20060803122937.GI5016@robert.daprodeges.fqdn.th-h.de","subject":"Re: Creating diffs","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-03T18:22:51Z","receivedAt":"2006-08-03T18:22:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rocco Rutte <pdmef@gmx.net> writes:\n\n> Also, I think the diffs are reversed:\n\nYeah, I noticed that too.\n"},{"id":"24659","messageId":"7v4pwtr74j.fsf@assigned-by-dhcp.cox.net","threadId":"5103","inReplyTo":"easqpi$o51$1@sea.gmane.org","subject":"Re: Creating diffs","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-03T18:45:00Z","receivedAt":"2006-08-03T18:45:00Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> If I remember correctly there were two patches which solved it differently:\n> one gave\n>\n>    --- a/source:file\n>    +++ b/dest:file\n>\n> second (and I guess it is better solution)\n>\n>    --- a/file\n>    +++ b/file\n>\n> Unfortunately they seem unapplied...\n\nI think I explained why it was not enough in a neighboring\nthread.  You would need to defeat the rename classification done\nin diff.c::diff_resolve_rename_copy().\n\nThe diff reversal is independent.  I think it was introduced by\nmistake when we switched revision.c::add_pending_object() to use\nobject_array from object_list.\n\nHere is a patch to fix the reversal (swapping of indices for\nblob[].sha1 in builtin-diff.c), show both names (swapping of\nindices for blob[].name in builtin-diff.c), and not mistake this\nas an rename (all the rest).  The change touches rather delicate\nparts of the system, so I am reluctant to do the latter two at\nthis late in the game for 1.4.2, but please do test it and give\nfeedback.\n\n---\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 48d2fd0..cb4216e 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -125,9 +125,6 @@ static int builtin_diff_blobs(struct rev\n \t\t\t      int argc, const char **argv,\n \t\t\t      struct blobinfo *blob)\n {\n-\t/* Blobs: the arguments are reversed when setup_revisions()\n-\t * picked them up.\n-\t */\n \tunsigned mode = canon_mode(S_IFREG | 0644);\n \n \tif (argc > 1)\n@@ -135,8 +132,8 @@ static int builtin_diff_blobs(struct rev\n \n \tstuff_change(&revs->diffopt,\n \t\t     mode, mode,\n-\t\t     blob[1].sha1, blob[0].sha1,\n-\t\t     blob[0].name, blob[0].name);\n+\t\t     blob[0].sha1, blob[1].sha1,\n+\t\t     blob[0].name, blob[1].name);\n \tdiffcore_std(&revs->diffopt);\n \tdiff_flush(&revs->diffopt);\n \treturn 0;\ndiff --git a/diff.c b/diff.c\nindex 607c357..895c137 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1786,13 +1786,9 @@ struct diff_filepair *diff_queue(struct \n \t\t\t\t struct diff_filespec *one,\n \t\t\t\t struct diff_filespec *two)\n {\n-\tstruct diff_filepair *dp = xmalloc(sizeof(*dp));\n+\tstruct diff_filepair *dp = xcalloc(1, sizeof(*dp));\n \tdp->one = one;\n \tdp->two = two;\n-\tdp->score = 0;\n-\tdp->status = 0;\n-\tdp->source_stays = 0;\n-\tdp->broken_pair = 0;\n \tif (queue)\n \t\tdiff_q(queue, dp);\n \treturn dp;\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 1de8d32..0ec488a 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -205,6 +205,7 @@ static void record_rename_pair(int dst_i\n \tfill_filespec(two, dst->sha1, dst->mode);\n \n \tdp = diff_queue(NULL, one, two);\n+\tdp->renamed_pair = 1;\n \tif (!strcmp(src->path, dst->path))\n \t\tdp->score = rename_src[src_index].score;\n \telse\ndiff --git a/diffcore.h b/diffcore.h\nindex 73c7842..2249bc2 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -53,11 +53,12 @@ struct diff_filepair {\n \tchar status; /* M C R N D U (see Documentation/diff-format.txt) */\n \tunsigned source_stays : 1; /* all of R/C are copies */\n \tunsigned broken_pair : 1;\n+\tunsigned renamed_pair : 1;\n };\n #define DIFF_PAIR_UNMERGED(p) \\\n \t(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))\n \n-#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))\n+#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)\n \n #define DIFF_PAIR_BROKEN(p) \\\n \t( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \\\n"}]}