{"thread":{"id":"3477","subject":"Quick question: how to generate a patch?","startedAt":"2006-02-27T14:57:05Z","lastAt":"2006-02-28T02:48:11Z","messageCount":13,"participants":["Aubrey","Andreas Ericsson","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"16819","messageId":"6d6a94c50602270657m453cc581p6ec290c20879de25@mail.gmail.com","threadId":"3477","inReplyTo":null,"subject":"Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-27T14:57:05Z","receivedAt":"2006-02-27T14:57:05Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"Hi all,\n\nI'm a newbie of git. I have a question about how to generate a patch by git.\nI want to make a patch againt git repository HEAD. So in my local\ntree, I do the command:\n\ngit diff -p > my.patch\n\nThe file my.patch is generated. But the unchanged files information is\nalso included in the patch file. It should be quiet.\nWas I wrong to use git by this way?\n\nThanks for your hints.\n\nRegards,\n-Aubrey\n"},{"id":"16822","messageId":"44031A84.1080704@op5.se","threadId":"3477","inReplyTo":"6d6a94c50602270657m453cc581p6ec290c20879de25@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-02-27T15:28:04Z","receivedAt":"2006-02-27T15:28:04Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Aubrey wrote:\n> Hi all,\n> \n> I'm a newbie of git. I have a question about how to generate a patch by git.\n> I want to make a patch againt git repository HEAD. So in my local\n> tree, I do the command:\n> \n> git diff -p > my.patch\n> \n> The file my.patch is generated. But the unchanged files information is\n> also included in the patch file. It should be quiet.\n> Was I wrong to use git by this way?\n> \n> Thanks for your hints.\n> \n\nThe current best practice involves these steps:\n1. Create a topic branch (git checkout -b feature-name)\n2. Apply your changes and commit them, preferrably in small and isolated \nsteps, making sure it compiles after each change.\n3. Run \"git format-patch origin\".\n\nThis will result in one or more commit-patches, which contains your \nauthor info, the commit-messages you wrote, the commit-time and all \nother such info and ofcourse the diff in unified git format. You can \nsend those patches on using \"git send-email\" or apply them using \"git am \n-k 00*.txt\".\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"16824","messageId":"Pine.LNX.4.64.0602270801280.22647@g5.osdl.org","threadId":"3477","inReplyTo":"6d6a94c50602270657m453cc581p6ec290c20879de25@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-27T16:04:36Z","receivedAt":"2006-02-27T16:04:36Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 27 Feb 2006, Aubrey wrote:\n> \n> I'm a newbie of git. I have a question about how to generate a patch by git.\n> I want to make a patch againt git repository HEAD. So in my local\n> tree, I do the command:\n> \n> git diff -p > my.patch\n\nYou don't need the \"-p\" - it's the default for \"git diff\".\n\n> The file my.patch is generated. But the unchanged files information is\n> also included in the patch file. It should be quiet.\n\nIt sounds like your index is not synchronized with your file contents. \nHave you done \"touch\" on files? Or edited them, and then edited them back?\n\nIf so, \"git-update-index --refresh\" will re-synchronize your index with \nwhatever file contents you have.\n\n\t\t\tLinus\n"},{"id":"16826","messageId":"6d6a94c50602270818k5f82bb8ft68a19899db3db636@mail.gmail.com","threadId":"3477","inReplyTo":"Pine.LNX.4.64.0602270801280.22647@g5.osdl.org","subject":"Re: Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-27T16:18:57Z","receivedAt":"2006-02-27T16:18:57Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"> > The file my.patch is generated. But the unchanged files information is\n> > also included in the patch file. It should be quiet.\n>\n> It sounds like your index is not synchronized with your file contents.\n> Have you done \"touch\" on files? Or edited them, and then edited them back?\n>\n> If so, \"git-update-index --refresh\" will re-synchronize your index with\n> whatever file contents you have.\n>\nNo, what I did was just \"git clone\" one repository to my local directory.\nAnd entered the local directory to modify one file I wanted.\nThen I run \"git diff > my.patch\". The \"my.patch\" was supposed to\ncontain one file diff information. But it contained the all the files,\nincluding which were not changed.\n\nThanks to reply. I''ll try to Andreas's suggestion.\n\nRegards,\n-Aubrey\n"},{"id":"16828","messageId":"Pine.LNX.4.64.0602270830330.22647@g5.osdl.org","threadId":"3477","inReplyTo":"6d6a94c50602270818k5f82bb8ft68a19899db3db636@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-27T16:32:36Z","receivedAt":"2006-02-27T16:32:36Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 28 Feb 2006, Aubrey wrote:\n>\n> No, what I did was just \"git clone\" one repository to my local directory.\n> And entered the local directory to modify one file I wanted.\n> Then I run \"git diff > my.patch\". The \"my.patch\" was supposed to\n> contain one file diff information. But it contained the all the files,\n> including which were not changed.\n\nIt really should \"just have worked\". Can you show what the diff actually \nlooked like, and your exact command history?\n\nIf it was something like\n\n\tgit clone remote-repo localdir\n\tcd localdir\n\tvi somefile\n\tgit diff\n\nthen you did everything right, and if it gives any diff other than your \nchanges to \"somefile\", something is buggy. Need more info.\n\nDoes \"git diff\" and \"git diff HEAD\" give different results, btw?\n\n\t\tLinus\n"},{"id":"16832","messageId":"6d6a94c50602270902k2c06aaffw7e70268b0753ef64@mail.gmail.com","threadId":"3477","inReplyTo":"Pine.LNX.4.64.0602270830330.22647@g5.osdl.org","subject":"Re: Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-27T17:02:57Z","receivedAt":"2006-02-27T17:02:57Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"> It really should \"just have worked\". Can you show what the diff actually\n> looked like, and your exact command history?\n\n=================================================================\naubrey@linux:/checkout/uboot/patch/work/drivers> git diff\n----snip----\ndiff --git a/drivers/sk98lin/skxmac2.c b/drivers/sk98lin/skxmac2.c\ndiff --git a/drivers/sk98lin/u-boot_compat.h b/drivers/sk98lin/u-boot_compat.h\ndiff --git a/drivers/sk98lin/uboot_drv.c b/drivers/sk98lin/uboot_drv.c\ndiff --git a/drivers/sk98lin/uboot_skb.c b/drivers/sk98lin/uboot_skb.c\ndiff --git a/drivers/sl811.h b/drivers/sl811.h\ndiff --git a/drivers/sl811_usb.c b/drivers/sl811_usb.c\ndiff --git a/drivers/sm501.c b/drivers/sm501.c\ndiff --git a/drivers/smc91111.c b/drivers/smc91111.c\ndiff --git a/drivers/smc91111.h b/drivers/smc91111.h\nindex cf08582..e5742ba 100644\n--- a/drivers/smc91111.h\n+++ b/drivers/smc91111.h\n@@ -185,6 +185,8 @@ typedef unsigned long int           dword;\n\n #ifdef CONFIG_ADNPESC1\n #define        SMC_inw(r)      (*((volatile word\n*)(SMC_BASE_ADDRESS+((r)<<1))))\n+#elif CONFIG_BLACKFIN\n+#define SMC_inw(r)      ({ word __v = (*((volatile word\n*)(SMC_BASE_ADDRESS+(r)))); __builtin_bfin_ssync(); __v;})\n #else\n #define        SMC_inw(r)      (*((volatile word *)(SMC_BASE_ADDRESS+(r))))\n #endif\n@@ -192,6 +194,8 @@ typedef unsigned long int           dword;\n\n #ifdef CONFIG_ADNPESC1\n #define        SMC_outw(d,r)   (*((volatile word\n*)(SMC_BASE_ADDRESS+((r)<<1))) = d)\n+#elif CONFIG_BLACKFIN\n+#define SMC_outw(d,r)   {(*((volatile word *)(SMC_BASE_ADDRESS+(r)))\n= d);__builtin_bfin_ssync();}\n #else\n #define        SMC_outw(d,r)   (*((volatile word *)(SMC_BASE_ADDRESS+(r))) = d)\n #endif\n@@ -232,6 +236,8 @@ typedef unsigned long int           dword;\n\n #ifdef CONFIG_XSENGINE\n #define        SMC_inl(r)      (*((volatile dword *)(SMC_BASE_ADDRESS+(r<<1))))\n+#elif CONFIG_BLACKFIN\n+#define SMC_inl(r)      ({ dword __v = (*((volatile dword\n*)(SMC_BASE_ADDRESS+(r))));__builtin_bfin_ssync(); __v;})\n #else\n #define        SMC_inl(r)      (*((volatile dword *)(SMC_BASE_ADDRESS+(r))))\n #endif\n@@ -247,6 +253,8 @@ typedef unsigned long int           dword;\n\n #ifdef CONFIG_XSENGINE\n #define        SMC_outl(d,r)   (*((volatile dword\n*)(SMC_BASE_ADDRESS+(r<<1))) = d)\n+#elif CONFIG_BLACKFIN\n+#define SMC_outl(d,r)   {(*((volatile dword *)(SMC_BASE_ADDRESS+(r)))\n= d);__builtin_bfin_ssync();}\n #else\n #define        SMC_outl(d,r)   (*((volatile dword\n*)(SMC_BASE_ADDRESS+(r))) = d)\n #endif\ndiff --git a/drivers/smiLynxEM.c b/drivers/smiLynxEM.c\ndiff --git a/drivers/status_led.c b/drivers/status_led.c\ndiff --git a/drivers/sym53c8xx.c b/drivers/sym53c8xx.c\ndiff --git a/drivers/ti_pci1410a.c b/drivers/ti_pci1410a.c\ndiff --git a/drivers/tigon3.c b/drivers/tigon3.c\ndiff --git a/drivers/tigon3.h b/drivers/tigon3.h\ndiff --git a/drivers/tsec.c b/drivers/tsec.c\ndiff --git a/drivers/tsec.h b/drivers/tsec.h\n----snip----\n=================================================================\n>\n> If it was something like\n>\n>         git clone remote-repo localdir\n>         cd localdir\n>         vi somefile\n>         git diff\n>\nYes, exactly right.\n\n> then you did everything right, and if it gives any diff other than your\n> changes to \"somefile\", something is buggy. Need more info.\n>\n> Does \"git diff\" and \"git diff HEAD\" give different results, btw?\n\nYes. the two commands give the same results.\n\nI'm using git-1.2.3\n\nRegards,\n-Aubrey\n"},{"id":"16833","messageId":"44033241.6070001@op5.se","threadId":"3477","inReplyTo":"6d6a94c50602270902k2c06aaffw7e70268b0753ef64@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-02-27T17:09:21Z","receivedAt":"2006-02-27T17:09:21Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Aubrey wrote:\n>>It really should \"just have worked\". Can you show what the diff actually\n>>looked like, and your exact command history?\n> \n> \n> \n>>If it was something like\n>>\n>>        git clone remote-repo localdir\n>>        cd localdir\n>>        vi somefile\n>>        git diff\n>>\n> \n> Yes, exactly right.\n> \n\nDid you by any chance do chmod -R, chown -R or start an ntp daemon \nsomewhere in between there (don't know if clock skews will be detected \nby git, but...)?\n\n> \n>>then you did everything right, and if it gives any diff other than your\n>>changes to \"somefile\", something is buggy. Need more info.\n>>\n>>Does \"git diff\" and \"git diff HEAD\" give different results, btw?\n> \n> \n> Yes. the two commands give the same results.\n> \n\nDecidedly odd. What happens when you do \"git update-index --refresh\" and \nthen re-run the \"git diff > my.patch\" thing?\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"16835","messageId":"6d6a94c50602270918l323fe54al764469232de66503@mail.gmail.com","threadId":"3477","inReplyTo":"44033241.6070001@op5.se","subject":"Re: Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-27T17:18:03Z","receivedAt":"2006-02-27T17:18:03Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"> Did you by any chance do chmod -R, chown -R or start an ntp daemon\n> somewhere in between there (don't know if clock skews will be detected\n> by git, but...)?\n\nNo, I did nothing between \"git clone\" and \"git diff\" except changing one file.\n>\n>\n> Decidedly odd. What happens when you do \"git update-index --refresh\" and\n> then re-run the \"git diff > my.patch\" thing?\n>\nYes, \"git update-index --refresh\" works. After this command, I got what I want.\nIt's the diff in unified git format.\n\nRegards,\n-Aubrey\n"},{"id":"16836","messageId":"Pine.LNX.4.64.0602270909500.22647@g5.osdl.org","threadId":"3477","inReplyTo":"6d6a94c50602270902k2c06aaffw7e70268b0753ef64@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-27T17:19:35Z","receivedAt":"2006-02-27T17:19:35Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 28 Feb 2006, Aubrey wrote:\n> \n> =================================================================\n> aubrey@linux:/checkout/uboot/patch/work/drivers> git diff\n> ----snip----\n> diff --git a/drivers/sk98lin/skxmac2.c b/drivers/sk98lin/skxmac2.c\n> diff --git a/drivers/sk98lin/u-boot_compat.h b/drivers/sk98lin/u-boot_compat.h\n\nOk, this is _definitely_ your index being out of touch with your file \ncontents.\n\nRun \"git-update-index --refresh\" and it should be ok.\n\nNow the question is why the index got out-of-kilter with the file contents \nin the first place. I used to have all these debug aids to show why git \nthought a file had changed, but we've not had any bugs here for a long \nlong time, so..\n\nThe final checkout of the \"git clone\" should have made sure that the index \nis up-to-date.\n\n> >         git clone remote-repo localdir\n> >         cd localdir\n> >         vi somefile\n> >         git diff\n>\n> Yes, exactly right.\n> \n> > then you did everything right, and if it gives any diff other than your\n> > changes to \"somefile\", something is buggy. Need more info.\n> >\n> > Does \"git diff\" and \"git diff HEAD\" give different results, btw?\n> \n> Yes. the two commands give the same results.\n> \n> I'm using git-1.2.3\n\nWhat OS/filesystem? \n\nThe way the index keeps track of files that haven't changed is by checking \nthe size, the mtime and the ctime of the inode. It also checks the \nuser/gid and inode number. If you use a filesystem where those might \nchange (networked?), that might cause this..\n\n\t\tLinus\n"},{"id":"16837","messageId":"Pine.LNX.4.64.0602270923120.22647@g5.osdl.org","threadId":"3477","inReplyTo":"44033241.6070001@op5.se","subject":"Re: Quick question: how to generate a patch?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-27T17:28:37Z","receivedAt":"2006-02-27T17:28:37Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 27 Feb 2006, Andreas Ericsson wrote:\n> \n> Did you by any chance do chmod -R, chown -R or start an ntp daemon somewhere\n> in between there (don't know if clock skews will be detected by git, but...)?\n\noff on this tangent: git shouldn't care about clock skew, because git \nnever cares about the current time. The only thing that matters is that \n\"stat()\" returns the same time when called sequentially.\n\nNow, if you have a distributed filesystem, and the _filesystem_ has some \nstrange clock-skew problem, that would definitely screw up git.\n\nThat sounds insane, but a trivial case of it might be a networked \nfilesystem where the mtime/ctime for a file create is filled in by the \nclient first, but then the server will do the \"final version\" when it \nactually writes the file.\n\nWe used to have some bugs in our NFS client that did things like that: the \n\"mtime\" of a file had this confusing duality between \"client time\" and \n\"server time\", and it depended on whether the client had done a \"getattr\" \nto the server which one you saw.\n\nI could well imagine that we still have some bug like that (ctime in \nparticular is much less used than mtime, and thus more likely to have not \nbeen noticed). And it could be much worse on some less-commonly-used and \nless-unixy networked filesystem like smb, which is why I was wondering \nwhat OS version and filesystem Aubrey might be using.\n\n\t\tLinus\n"},{"id":"16875","messageId":"6d6a94c50602271755v41e0d31ch25892192547003a9@mail.gmail.com","threadId":"3477","inReplyTo":"Pine.LNX.4.64.0602270923120.22647@g5.osdl.org","subject":"Re: Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-28T01:55:40Z","receivedAt":"2006-02-28T01:55:40Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"On 2/28/06, Linus Torvalds <torvalds@osdl.org> wrote:\n> I could well imagine that we still have some bug like that (ctime in\n> particular is much less used than mtime, and thus more likely to have not\n> been noticed). And it could be much worse on some less-commonly-used and\n> less-unixy networked filesystem like smb, which is why I was wondering\n> what OS version and filesystem Aubrey might be using.\n\nI'm using suse9.3. The filesystem is EXT3.\nI think I forgot one thing last night. When I changed the file, I\ncompiled the package to verify my modification. It should be the\nreason. But should it really affect the result of \"git diff\"?\n\nThanks,\n-Aubrey\n"},{"id":"16876","messageId":"Pine.LNX.4.64.0602271802110.22647@g5.osdl.org","threadId":"3477","inReplyTo":"6d6a94c50602271755v41e0d31ch25892192547003a9@mail.gmail.com","subject":"Re: Quick question: how to generate a patch?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-28T02:09:18Z","receivedAt":"2006-02-28T02:09:18Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 28 Feb 2006, Aubrey wrote:\n> \n> I'm using suse9.3. The filesystem is EXT3.\n\nOk, something else is going on. There's no way ext3 can get confused about \ntimes that I can see.\n\n> I think I forgot one thing last night. When I changed the file, I\n> compiled the package to verify my modification. It should be the\n> reason. But should it really affect the result of \"git diff\"?\n\nNope. Something else is happening.\n\nIf you can re-create this at will, it would be interesting to see _what_ \nmakes git think you've modified a file. A small mod to \"read-cache.c\" like \nthe appended patch should give you (very very verbose) output that could \nhelp us figure this out.\n\n\t\tLinus\n\n----\ndiff --git a/read-cache.c b/read-cache.c\nindex f97f92d..4946163 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -183,6 +183,8 @@ int ce_match_stat(struct cache_entry *ce\n \t    index_file_timestamp <= ntohl(ce->ce_mtime.sec))\n \t\tchanged |= ce_modified_check_fs(ce, st);\n \n+if (changed) error(\"changed: 0x%x %s\", changed, ce->name);\n+\n \treturn changed;\n }\n \n"},{"id":"16877","messageId":"6d6a94c50602271848g4bf18669na6167a78a74bf834@mail.gmail.com","threadId":"3477","inReplyTo":"Pine.LNX.4.64.0602271802110.22647@g5.osdl.org","subject":"Re: Quick question: how to generate a patch?","fromName":"Aubrey","fromEmail":"aubreylee@gmail.com","sentAt":"2006-02-28T02:48:11Z","receivedAt":"2006-02-28T02:48:11Z","isPatch":false,"sender":{"key":"aubreylee@gmail.com","avatar":null},"body":"> If you can re-create this at will, it would be interesting to see _what_\n> makes git think you've modified a file. A small mod to \"read-cache.c\" like\n> the appended patch should give you (very very verbose) output that could\n> help us figure this out.\nOops, It's my fault. My mistake is that copy the clone git directory\nto another directory for backup. And work on another directory. Sorry\nfor my incaution.\n\n-Aubrey\n"}]}