{"thread":{"id":"3","subject":"Re: Re: Re: Remove need to untrack before tracking new branch","startedAt":"2005-04-13T22:19:37Z","lastAt":"2005-04-15T23:49:05Z","messageCount":16,"participants":["Petr Baudis","Martin Schlemmer","Alex Riesen","Paul Jackson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15","messageId":"20050413221936.GI25711@pasky.ji.cz","threadId":"3","inReplyTo":"1113394537.23299.51.camel@nosferatu.lan","subject":"Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-13T22:19:37Z","receivedAt":"2005-04-13T22:19:37Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"I didn't weed out the replies since this was not cc'd to the mailing\nlist and I believe it could contain some useful information for google\nor whatever to pick. :-)\n\nDear diary, on Wed, Apr 13, 2005 at 02:15:37PM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> On Wed, 2005-04-13 at 11:26 +0200, Petr Baudis wrote:\n> > BTW, why aren't we cc'ing the list?\n> > \n> \n> Hmm, no reason really.  If you want to, will do next time.\n> \n> > Dear diary, on Wed, Apr 13, 2005 at 10:41:12AM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > On Wed, 2005-04-13 at 09:54 +0200, Petr Baudis wrote:\n> > > PS: not having looked deeper yet, why does fsck-cache always find\n> > > unreferenced blobs/commits (no matter what tree is tracked, they stay\n> > > the same) ?  And trying to remove them leads to more, which leads to an\n> > > empty .git/opjects/ =)  Also, leading to this, will adding an option to\n> > > remove disconnected commits/blobs from local commits (that was\n> > > disconnected with a pull) be a viable option to add?\n> > \n> > fsck-cache is concerned only by the objects database, so all the HEADs\n> > are unreferenced commits too. This is a right thing, the HEAD tracking\n> > should stay purely in the scripts - if we want to make fsck-cache\n> > smarter about that, we should implement git fsck or something.\n> > \n> > Killing unreferenced blobs should be safe, I think.\n> > \n> > > First, about the 'git diff' thing I asked yesterday .. what I meant, was\n> > > should it actually output this:\n> > > \n> > > ----\n> > > COPYING:  fe2a4177a760fd110e78788734f167bd633be8de 33\n> > > Makefile:  929aa49a3dbe683ad52094099797bc636a7949a6 33\n> > > README:  46c6a9ea48ddd1dda45ca585f49975a6869ffe51 33\n> > > ...\n> > > ----\n> > > \n> > > Shouldn't it just show actual changes?\n> > \n> > This is an actual change. It's just that it's a change to metadata\n> > (somewhat esotherically described by the \"33\"), not the file contents.\n> > \n> > BTW, git diff does actually something completely different from git diff\n> > with any arguments. It diffs to the directory cache, not to any tree! It\n> > just wraps show-diff, which has also a different output format (not\n> > outputting \"git diffs\"). The worst thing is that it requires a different\n> > -p option to apply. Someone should purge this wart, I think.\n> > \n> \n> Check applied patch (also in the new output).\n\nPlease send patches inline and properly signed off.\n\n> > > Also on the same note .. should 'git ci' without listed files to be\n> > > committed, really add a reference to all files as it currently do in the\n> > > commit/blob/whatever info, instead of just the changed/added files (see\n> > > the git-seperate-dir.patch you have not yet commented on for reference)?\n> > \n> > ...\n> > \n> \n> Patch will also resolve this.\n\nI'm sorry - the ellipsis was there so that I'll write up a reply for\nthat later but I forgot.\n\nYour patch is bad - it removes the pure metadata changes, but you\ndefinitively do not want to do that! If you are annoyed by meaningless\ntime changes etc, do update-cache --refresh. Ignoring mode changes is a\npure disaster.\n\n> > > Secondly, how about style/error issues?  Basically on the style front,\n> > > currently some scripts use bash - how about pure bash for all:\n> > > \n> > > ----\n> > > [[ -n ${tracking} ]] && \\\n> > > ----\n> > > \n> > > rather than:\n> > > \n> > > ----\n> > > [ \"$tracking\" ] && \\\n> > > ----\n> > > \n> > > as you do not need the quotes, and for checking files, etc, it just do\n> > > better handling than single quotes.  I am prepared to do patches if you\n> > > like.\n> > \n> > Well. I'm just not used to it and not quite sure about how it behaves\n> > etc. So far I tried to make it as sh-like as possible, using bash\n> > features only when absolutely necessary. I'm not saying this is the best\n> > approach, but I wouldn't change it *now* (especially since it would slow\n> > me down which I really don't want now) if someone doesn't give me some\n> > really compelling arguments.\n> > \n> \n> No problem.\n> \n..snip..\n> > > 2) Did not add the gitapply.sh that was new in your tree\n> > \n> > This very bug should be fixed by introduction of gitapply.sh. ;-)\n> > \n> > Actually I forgot to implement this. Fixed now.\n> > \n> > > I guess I might have done things wrong (wrong way around)?  But the\n> > > actual question is this .. when I tried to switch, it failed on the\n> > > gitapply.sh hunk, but went on anyway ... how about doing a patch\n> > > --dry-run first, and showing the user what would happen if that fails,\n> > > asking for confirmation?\n> > \n> > Just s/merge -b/diff/ on the command line and it will show precisely\n> > what it is going to apply.  When we get the automatic base detection\n> > something to just print the base could be indeed useful.\n> > \n> > If that fails, all what will happen is that the user gets rejects. No\n> > big deal. He can anytime just back out by\n> > \n> > \tgit diff | patch -p0 -R\n> > \n> > So, what did it \"went on\" with? The merge (nor the tracked pull) never\n> > commits anything. That's up to you, after you resolve the conflicts and\n> > make sure everything is right.\n> > \n> \n> Ah, right.\n> \n> > > I know its in its infancy, but I am not sure on what scm you are basing\n> > > it, so not sure how things should behave.\n> > \n> > I'm trying to base it on common sense and principle of least surprise.\n> > :-)\n> > \n> \n> Ok, I'll just bug you then if I am not sure on how you want something ;p\n\nOr do it somehow and I'll bug you back if I don't like it. ;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"45","messageId":"1113461754.23299.68.camel@nosferatu.lan","threadId":"3","inReplyTo":"20050413221936.GI25711@pasky.ji.cz","subject":"Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T06:55:54Z","receivedAt":"2005-04-14T06:55:54Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:\n> Dear diary, on Wed, Apr 13, 2005 at 02:15:37PM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > On Wed, 2005-04-13 at 11:26 +0200, Petr Baudis wrote:\n> >> > Dear diary, on Wed, Apr 13, 2005 at 10:41:12AM CEST, I got a letter\n> > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > On Wed, 2005-04-13 at 09:54 +0200, Petr Baudis wrote:\n> > > > PS: not having looked deeper yet, why does fsck-cache always find\n> > > > unreferenced blobs/commits (no matter what tree is tracked, they stay\n> > > > the same) ?  And trying to remove them leads to more, which leads to an\n> > > > empty .git/opjects/ =)  Also, leading to this, will adding an option to\n> > > > remove disconnected commits/blobs from local commits (that was\n> > > > disconnected with a pull) be a viable option to add?\n> > > \n> > > fsck-cache is concerned only by the objects database, so all the HEADs\n> > > are unreferenced commits too. This is a right thing, the HEAD tracking\n> > > should stay purely in the scripts - if we want to make fsck-cache\n> > > smarter about that, we should implement git fsck or something.\n> > > \n> > > Killing unreferenced blobs should be safe, I think.\n> > > \n> > > > First, about the 'git diff' thing I asked yesterday .. what I meant, was\n> > > > should it actually output this:\n> > > > \n> > > > ----\n> > > > COPYING:  fe2a4177a760fd110e78788734f167bd633be8de 33\n> > > > Makefile:  929aa49a3dbe683ad52094099797bc636a7949a6 33\n> > > > README:  46c6a9ea48ddd1dda45ca585f49975a6869ffe51 33\n> > > > ...\n> > > > ----\n> > > > \n> > > > Shouldn't it just show actual changes?\n> > > \n> > > This is an actual change. It's just that it's a change to metadata\n> > > (somewhat esotherically described by the \"33\"), not the file contents.\n> > > \n> > > BTW, git diff does actually something completely different from git diff\n> > > with any arguments. It diffs to the directory cache, not to any tree! It\n> > > just wraps show-diff, which has also a different output format (not\n> > > outputting \"git diffs\"). The worst thing is that it requires a different\n> > > -p option to apply. Someone should purge this wart, I think.\n> > > \n> > \n> > Check applied patch (also in the new output).\n> \n> Please send patches inline and properly signed off.\n> \n\nThe new evo have a bad habit of screwing the tabs, but sure.\n\n> > > > Also on the same note .. should 'git ci' without listed files to be\n> > > > committed, really add a reference to all files as it currently do in the\n> > > > commit/blob/whatever info, instead of just the changed/added files (see\n> > > > the git-seperate-dir.patch you have not yet commented on for reference)?\n> > > \n> > > ...\n> > > \n> > \n> > Patch will also resolve this.\n> \n> Your patch is bad - it removes the pure metadata changes, but you\n> definitively do not want to do that! If you are annoyed by meaningless\n> time changes etc, do update-cache --refresh. Ignoring mode changes is a\n> pure disaster.\n> \n\nAhh - and there was light.  I do not have a problem with the mode\nchanges - its just _all_ files was shown after tracked branch was\nchanged.  How about below patch?\n\n> > > > I know its in its infancy, but I am not sure on what scm you are basing\n> > > > it, so not sure how things should behave.\n> > > \n> > > I'm trying to base it on common sense and principle of least surprise.\n> > > :-)\n> > > \n> > \n> > Ok, I'll just bug you then if I am not sure on how you want something ;p\n> \n> Or do it somehow and I'll bug you back if I don't like it. ;-)\n> \n\nDitto\n\n\n----\n\nNormalize show-diff output and make sure we only show real changes after\nchanging the tracked branch.\n\nSigned-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n\ngittrack.sh:  a9d7c3d117390787e562a0450deb14c7cbf4b565 33\n--- a9d7c3d117390787e562a0450deb14c7cbf4b565/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -49,6 +49,7 @@\n\n        read-tree $(tree-id \"$name\")\n        gitdiff.sh local \"$name\" | gitapply.sh\n+       update-cache --refresh\n\n else\n        [ \"$tracking\" ] || \\\n@@ -59,6 +60,7 @@\n        if [ -s \".git/HEAD.local\" ]; then\n                gitdiff.sh \"$tracking\" local | gitapply.sh\n                read-tree $(tree-id local)\n+               update-cache --refresh\n\n                head=$(cat .git/HEAD)\n                branchhead=$(cat .git/HEAD.$tracking)\nshow-diff.c:  136ec315b82d10d33ff9b4517f1b8ab91e3dcabc 33\n--- 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n\n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n        void *old_contents, unsigned long long old_size)\n {\n        static char cmd[1000];\n+       static char sha1[41];\n+       int n;\n        FILE *f;\n\n-       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+       for (n = 0; n < 20; n++)\n+               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+               sha1, ce->name, ce->name, ce->name);\n        f = popen(cmd, \"w\");\n        if (old_size)\n                fwrite(old_contents, old_size, 1, f);\n@@ -98,7 +103,7 @@\n\n                fflush(stdout);\n                new = read_sha1_file(ce->sha1, type, &size);\n-               show_differences(ce->name, new, size);\n+               show_differences(ce, new, size);\n                free(new);\n        }\n        return 0;\n\n\n-- \nMartin Schlemmer\n\n\n\ngittrack.sh:  a9d7c3d117390787e562a0450deb14c7cbf4b565 33\n--- a9d7c3d117390787e562a0450deb14c7cbf4b565/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -49,6 +49,7 @@\n \n \tread-tree $(tree-id \"$name\")\n \tgitdiff.sh local \"$name\" | gitapply.sh\n+\tupdate-cache --refresh\n \n else\n \t[ \"$tracking\" ] || \\\n@@ -59,6 +60,7 @@\n \tif [ -s \".git/HEAD.local\" ]; then\n \t\tgitdiff.sh \"$tracking\" local | gitapply.sh\n \t\tread-tree $(tree-id local)\n+\t\tupdate-cache --refresh\n \n \t\thead=$(cat .git/HEAD)\n \t\tbranchhead=$(cat .git/HEAD.$tracking)\nshow-diff.c:  136ec315b82d10d33ff9b4517f1b8ab91e3dcabc 33\n--- 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n \n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n \tvoid *old_contents, unsigned long long old_size)\n {\n \tstatic char cmd[1000];\n+\tstatic char sha1[41];\n+\tint n;\n \tFILE *f;\n \n-\tsnprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+\tfor (n = 0; n < 20; n++)\n+\t\tsnprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+\tsnprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+\t\tsha1, ce->name, ce->name, ce->name);\n \tf = popen(cmd, \"w\");\n \tif (old_size)\n \t\tfwrite(old_contents, old_size, 1, f);\n@@ -98,7 +103,7 @@\n \n \t\tfflush(stdout);\n \t\tnew = read_sha1_file(ce->sha1, type, &size);\n-\t\tshow_differences(ce->name, new, size);\n+\t\tshow_differences(ce, new, size);\n \t\tfree(new);\n \t}\n \treturn 0;\n"},{"id":"53","messageId":"1113467335.23299.77.camel@nosferatu.lan","threadId":"3","inReplyTo":"1113461754.23299.68.camel@nosferatu.lan","subject":"Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T08:28:55Z","receivedAt":"2005-04-14T08:28:55Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Thu, 2005-04-14 at 08:55 +0200, Martin Schlemmer wrote:\n> On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:\n> > Dear diary, on Wed, Apr 13, 2005 at 02:15:37PM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > On Wed, 2005-04-13 at 11:26 +0200, Petr Baudis wrote:\n> > >> > Dear diary, on Wed, Apr 13, 2005 at 10:41:12AM CEST, I got a letter\n> > > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > > On Wed, 2005-04-13 at 09:54 +0200, Petr Baudis wrote:\n> > > > > PS: not having looked deeper yet, why does fsck-cache always find\n> > > > > unreferenced blobs/commits (no matter what tree is tracked, they stay\n> > > > > the same) ?  And trying to remove them leads to more, which leads to an\n> > > > > empty .git/opjects/ =)  Also, leading to this, will adding an option to\n> > > > > remove disconnected commits/blobs from local commits (that was\n> > > > > disconnected with a pull) be a viable option to add?\n> > > > \n> > > > fsck-cache is concerned only by the objects database, so all the HEADs\n> > > > are unreferenced commits too. This is a right thing, the HEAD tracking\n> > > > should stay purely in the scripts - if we want to make fsck-cache\n> > > > smarter about that, we should implement git fsck or something.\n> > > > \n> > > > Killing unreferenced blobs should be safe, I think.\n> > > > \n> > > > > First, about the 'git diff' thing I asked yesterday .. what I meant, was\n> > > > > should it actually output this:\n> > > > > \n> > > > > ----\n> > > > > COPYING:  fe2a4177a760fd110e78788734f167bd633be8de 33\n> > > > > Makefile:  929aa49a3dbe683ad52094099797bc636a7949a6 33\n> > > > > README:  46c6a9ea48ddd1dda45ca585f49975a6869ffe51 33\n> > > > > ...\n> > > > > ----\n> > > > > \n> > > > > Shouldn't it just show actual changes?\n> > > > \n> > > > This is an actual change. It's just that it's a change to metadata\n> > > > (somewhat esotherically described by the \"33\"), not the file contents.\n> > > > \n> > > > BTW, git diff does actually something completely different from git diff\n> > > > with any arguments. It diffs to the directory cache, not to any tree! It\n> > > > just wraps show-diff, which has also a different output format (not\n> > > > outputting \"git diffs\"). The worst thing is that it requires a different\n> > > > -p option to apply. Someone should purge this wart, I think.\n> > > > \n> > > \n> > > Check applied patch (also in the new output).\n> > \n> > Please send patches inline and properly signed off.\n> > \n> \n> The new evo have a bad habit of screwing the tabs, but sure.\n> \n> > > > > Also on the same note .. should 'git ci' without listed files to be\n> > > > > committed, really add a reference to all files as it currently do in the\n> > > > > commit/blob/whatever info, instead of just the changed/added files (see\n> > > > > the git-seperate-dir.patch you have not yet commented on for reference)?\n> > > > \n> > > > ...\n> > > > \n> > > \n> > > Patch will also resolve this.\n> > \n> > Your patch is bad - it removes the pure metadata changes, but you\n> > definitively do not want to do that! If you are annoyed by meaningless\n> > time changes etc, do update-cache --refresh. Ignoring mode changes is a\n> > pure disaster.\n> > \n> \n> Ahh - and there was light.  I do not have a problem with the mode\n> changes - its just _all_ files was shown after tracked branch was\n> changed.  How about below patch?\n> \n> > > > > I know its in its infancy, but I am not sure on what scm you are basing\n> > > > > it, so not sure how things should behave.\n> > > > \n> > > > I'm trying to base it on common sense and principle of least surprise.\n> > > > :-)\n> > > > \n> > > \n> > > Ok, I'll just bug you then if I am not sure on how you want something ;p\n> > \n> > Or do it somehow and I'll bug you back if I don't like it. ;-)\n> > \n> \n> Ditto\n> \n> \n> ----\n> \n> Normalize show-diff output and make sure we only show real changes after\n> changing the tracked branch.\n> \n> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n> \n\nOk, so I forgot to pull, and missed gitcancel.sh being added.\nHow about this one?  (One attached in case evo is brain dead and mangles\nthe tabs)\n\n----\n\nNormalize show-diff output, add --update-modes target to update-cache,\nand make sure we only show real changes after changing the tracked\nbranch, as well as update the file modes according to the cache.\n\nSigned-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- gitcancel.sh\n+++ gitcancel.sh        2005-04-14 10:26:49.000000000 +0200\n@@ -12,7 +12,7 @@\n\n # FIXME: Does not revert mode changes!\n\n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n\n update-cache --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- gittrack.sh\n+++ gittrack.sh 2005-04-14 10:26:49.000000000 +0200\n@@ -51,6 +51,8 @@\n\n        read-tree $(tree-id \"$name\")\n        gitdiff.sh local \"$name\" | gitapply.sh\n+       # --update-modes need to be before --refresh\n+       update-cache --update-modes --refresh\n\n else\n        [ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n        if [ -s \".git/HEAD.local\" ]; then\n                gitdiff.sh \"$tracking\" local | gitapply.sh\n                read-tree $(tree-id local)\n+               # --update-modes need to be before --refresh\n+               update-cache --update-modes --refresh\n\n                head=$(cat .git/HEAD)\n                branchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- show-diff.c\n+++ show-diff.c 2005-04-14 10:26:49.000000000 +0200\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n\n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n        void *old_contents, unsigned long long old_size)\n {\n        static char cmd[1000];\n+       static char sha1[41];\n+       int n;\n        FILE *f;\n\n-       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+       for (n = 0; n < 20; n++)\n+               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+               sha1, ce->name, ce->name, ce->name);\n        f = popen(cmd, \"w\");\n        if (old_size)\n                fwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n                        continue;\n\n                new = read_sha1_file(ce->sha1, type, &size);\n-               show_differences(ce->name, new, size);\n+               show_differences(ce, new, size);\n                free(new);\n        }\n        return 0;\nupdate-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n--- update-cache.c\n+++ update-cache.c      2005-04-14 10:27:07.000000000 +0200\n@@ -210,6 +210,39 @@\n        }\n }\n\n+static struct cache_entry *update_file_mode(struct cache_entry *ce)\n+{\n+       struct stat st;\n+       int changed;\n+\n+       if (stat(ce->name, &st) < 0)\n+               return NULL;\n+\n+       changed = cache_match_stat(ce, &st);\n+       if (!changed)\n+               return ce;\n+\n+       if (changed & MODE_CHANGED)\n+               if (chmod(ce->name, ce->st_mode))\n+                       return NULL;\n+\n+       return ce;\n+}\n+\n+static void update_modes(void)\n+{\n+       int i;\n+\n+       for (i = 0; i < active_nr; i++) {\n+               struct cache_entry *ce = active_cache[i];\n+\n+               if (!update_file_mode(ce)) {\n+                       printf(\"%s: needs update\\n\", ce->name);\n+                       continue;\n+               }\n+       }\n+}\n+\n /*\n  * We fundamentally don't like some paths: we don't want\n  * dot or dot-dot anywhere, and in fact, we don't even want\n@@ -282,6 +315,10 @@\n                                refresh_cache();\n                                continue;\n                        }\n+                       if (!strcmp(path, \"--update-modes\")) {\n+                               update_modes();\n+                               continue;\n+                       }\n                        die(\"unknown option %s\", path);\n                }\n                if (!verify_path(path)) {\n\n\n\n-- \nMartin Schlemmer\n\n\n\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- gitcancel.sh\n+++ gitcancel.sh\t2005-04-14 10:26:49.000000000 +0200\n@@ -12,7 +12,7 @@\n \n # FIXME: Does not revert mode changes!\n \n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n \n update-cache --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- gittrack.sh\n+++ gittrack.sh\t2005-04-14 10:26:49.000000000 +0200\n@@ -51,6 +51,8 @@\n \n \tread-tree $(tree-id \"$name\")\n \tgitdiff.sh local \"$name\" | gitapply.sh\n+\t# --update-modes need to be before --refresh\n+\tupdate-cache --update-modes --refresh\n \n else\n \t[ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n \tif [ -s \".git/HEAD.local\" ]; then\n \t\tgitdiff.sh \"$tracking\" local | gitapply.sh\n \t\tread-tree $(tree-id local)\n+\t\t# --update-modes need to be before --refresh\n+\t\tupdate-cache --update-modes --refresh\n \n \t\thead=$(cat .git/HEAD)\n \t\tbranchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- show-diff.c\n+++ show-diff.c\t2005-04-14 10:26:49.000000000 +0200\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n \n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n \tvoid *old_contents, unsigned long long old_size)\n {\n \tstatic char cmd[1000];\n+\tstatic char sha1[41];\n+\tint n;\n \tFILE *f;\n \n-\tsnprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+\tfor (n = 0; n < 20; n++)\n+\t\tsnprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+\tsnprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+\t\tsha1, ce->name, ce->name, ce->name);\n \tf = popen(cmd, \"w\");\n \tif (old_size)\n \t\tfwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n \t\t\tcontinue;\n \n \t\tnew = read_sha1_file(ce->sha1, type, &size);\n-\t\tshow_differences(ce->name, new, size);\n+\t\tshow_differences(ce, new, size);\n \t\tfree(new);\n \t}\n \treturn 0;\nupdate-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n--- update-cache.c\n+++ update-cache.c\t2005-04-14 10:27:07.000000000 +0200\n@@ -210,6 +210,39 @@\n \t}\n }\n \n+static struct cache_entry *update_file_mode(struct cache_entry *ce)\n+{\n+\tstruct stat st;\n+\tint changed;\n+\n+\tif (stat(ce->name, &st) < 0)\n+\t\treturn NULL;\n+\n+\tchanged = cache_match_stat(ce, &st);\n+\tif (!changed)\n+\t\treturn ce;\n+\n+\tif (changed & MODE_CHANGED)\n+\t\tif (chmod(ce->name, ce->st_mode))\n+\t\t\treturn NULL;\n+\n+\treturn ce;\n+}\n+\n+static void update_modes(void)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < active_nr; i++) {\n+\t\tstruct cache_entry *ce = active_cache[i];\n+\n+\t\tif (!update_file_mode(ce)) {\n+\t\t\tprintf(\"%s: needs update\\n\", ce->name);\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+}\n+\n /*\n  * We fundamentally don't like some paths: we don't want\n  * dot or dot-dot anywhere, and in fact, we don't even want\n@@ -282,6 +315,10 @@\n \t\t\t\trefresh_cache();\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(path, \"--update-modes\")) {\n+\t\t\t\tupdate_modes();\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tdie(\"unknown option %s\", path);\n \t\t}\n \t\tif (!verify_path(path)) {\n"},{"id":"54","messageId":"1113467905.23299.81.camel@nosferatu.lan","threadId":"3","inReplyTo":"1113467335.23299.77.camel@nosferatu.lan","subject":"Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T08:38:25Z","receivedAt":"2005-04-14T08:38:25Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Thu, 2005-04-14 at 10:28 +0200, Martin Schlemmer wrote:\n> On Thu, 2005-04-14 at 08:55 +0200, Martin Schlemmer wrote:\n> > On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:\n> > > Dear diary, on Wed, Apr 13, 2005 at 02:15:37PM CEST, I got a letter\n> > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > On Wed, 2005-04-13 at 11:26 +0200, Petr Baudis wrote:\n> > > >> > Dear diary, on Wed, Apr 13, 2005 at 10:41:12AM CEST, I got a letter\n> > > > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > > > On Wed, 2005-04-13 at 09:54 +0200, Petr Baudis wrote:\n> > > > > > PS: not having looked deeper yet, why does fsck-cache always find\n> > > > > > unreferenced blobs/commits (no matter what tree is tracked, they stay\n> > > > > > the same) ?  And trying to remove them leads to more, which leads to an\n> > > > > > empty .git/opjects/ =)  Also, leading to this, will adding an option to\n> > > > > > remove disconnected commits/blobs from local commits (that was\n> > > > > > disconnected with a pull) be a viable option to add?\n> > > > > \n> > > > > fsck-cache is concerned only by the objects database, so all the HEADs\n> > > > > are unreferenced commits too. This is a right thing, the HEAD tracking\n> > > > > should stay purely in the scripts - if we want to make fsck-cache\n> > > > > smarter about that, we should implement git fsck or something.\n> > > > > \n> > > > > Killing unreferenced blobs should be safe, I think.\n> > > > > \n> > > > > > First, about the 'git diff' thing I asked yesterday .. what I meant, was\n> > > > > > should it actually output this:\n> > > > > > \n> > > > > > ----\n> > > > > > COPYING:  fe2a4177a760fd110e78788734f167bd633be8de 33\n> > > > > > Makefile:  929aa49a3dbe683ad52094099797bc636a7949a6 33\n> > > > > > README:  46c6a9ea48ddd1dda45ca585f49975a6869ffe51 33\n> > > > > > ...\n> > > > > > ----\n> > > > > > \n> > > > > > Shouldn't it just show actual changes?\n> > > > > \n> > > > > This is an actual change. It's just that it's a change to metadata\n> > > > > (somewhat esotherically described by the \"33\"), not the file contents.\n> > > > > \n> > > > > BTW, git diff does actually something completely different from git diff\n> > > > > with any arguments. It diffs to the directory cache, not to any tree! It\n> > > > > just wraps show-diff, which has also a different output format (not\n> > > > > outputting \"git diffs\"). The worst thing is that it requires a different\n> > > > > -p option to apply. Someone should purge this wart, I think.\n> > > > > \n> > > > \n> > > > Check applied patch (also in the new output).\n> > > \n> > > Please send patches inline and properly signed off.\n> > > \n> > \n> > The new evo have a bad habit of screwing the tabs, but sure.\n> > \n> > > > > > Also on the same note .. should 'git ci' without listed files to be\n> > > > > > committed, really add a reference to all files as it currently do in the\n> > > > > > commit/blob/whatever info, instead of just the changed/added files (see\n> > > > > > the git-seperate-dir.patch you have not yet commented on for reference)?\n> > > > > \n> > > > > ...\n> > > > > \n> > > > \n> > > > Patch will also resolve this.\n> > > \n> > > Your patch is bad - it removes the pure metadata changes, but you\n> > > definitively do not want to do that! If you are annoyed by meaningless\n> > > time changes etc, do update-cache --refresh. Ignoring mode changes is a\n> > > pure disaster.\n> > > \n> > \n> > Ahh - and there was light.  I do not have a problem with the mode\n> > changes - its just _all_ files was shown after tracked branch was\n> > changed.  How about below patch?\n> > \n> > > > > > I know its in its infancy, but I am not sure on what scm you are basing\n> > > > > > it, so not sure how things should behave.\n> > > > > \n> > > > > I'm trying to base it on common sense and principle of least surprise.\n> > > > > :-)\n> > > > > \n> > > > \n> > > > Ok, I'll just bug you then if I am not sure on how you want something ;p\n> > > \n> > > Or do it somehow and I'll bug you back if I don't like it. ;-)\n> > > \n> > \n> > Ditto\n> > \n> > \n> > ----\n> > \n> > Normalize show-diff output and make sure we only show real changes after\n> > changing the tracked branch.\n> > \n> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n> > \n> \n> Ok, so I forgot to pull, and missed gitcancel.sh being added.\n> How about this one?  (One attached in case evo is brain dead and mangles\n> the tabs)\n> \n\nUrk, forgot the update-cache in gitcancel.sh, and prefix is wrong.  I am\nnot sure this is needed for gitexport.sh though?\n\n----\n\nNormalize show-diff output, add --update-modes target to update-cache,\nand make sure we only show real changes after changing the tracked\nbranch, as well as update the file modes according to the cache.\n\nSigned-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n+++ uncommitted/gitcancel.sh\n@@ -12,7 +12,8 @@\n\n # FIXME: Does not revert mode changes!\n\n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n\n-update-cache --refresh\n+# --update-modes need to be before --refresh\n+update-cache --update-modes --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -51,6 +51,8 @@\n\n        read-tree $(tree-id \"$name\")\n        gitdiff.sh local \"$name\" | gitapply.sh\n+       # --update-modes need to be before --refresh\n+       update-cache --update-modes --refresh\n\n else\n        [ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n        if [ -s \".git/HEAD.local\" ]; then\n                gitdiff.sh \"$tracking\" local | gitapply.sh\n                read-tree $(tree-id local)\n+               # --update-modes need to be before --refresh\n+               update-cache --update-modes --refresh\n\n                head=$(cat .git/HEAD)\n                branchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n\n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n        void *old_contents, unsigned long long old_size)\n {\n        static char cmd[1000];\n+       static char sha1[41];\n+       int n;\n        FILE *f;\n\n-       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+       for (n = 0; n < 20; n++)\n+               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+               sha1, ce->name, ce->name, ce->name);\n        f = popen(cmd, \"w\");\n        if (old_size)\n                fwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n                        continue;\n\n                new = read_sha1_file(ce->sha1, type, &size);\n-               show_differences(ce->name, new, size);\n+               show_differences(ce, new, size);\n                free(new);\n        }\n        return 0;\nupdate-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n--- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c\n+++ uncommitted/update-cache.c\n@@ -210,6 +210,39 @@\n        }\n }\n\n+static struct cache_entry *update_file_mode(struct cache_entry *ce)\n+{\n+       struct stat st;\n+       int changed;\n+\n+       if (stat(ce->name, &st) < 0)\n+               return NULL;\n+\n+       changed = cache_match_stat(ce, &st);\n+       if (!changed)\n+               return ce;\n+\n+       if (changed & MODE_CHANGED)\n+               if (chmod(ce->name, ce->st_mode))\n+                       return NULL;\n+\n+       return ce;\n+}\n+\n+static void update_modes(void)\n+{\n+       int i;\n+\n+       for (i = 0; i < active_nr; i++) {\n+               struct cache_entry *ce = active_cache[i];\n+\n+               if (!update_file_mode(ce)) {\n+                       printf(\"%s: needs update\\n\", ce->name);\n+                       continue;\n+               }\n+       }\n+}\n+\n /*\n  * We fundamentally don't like some paths: we don't want\n  * dot or dot-dot anywhere, and in fact, we don't even want\n@@ -282,6 +315,10 @@\n                                refresh_cache();\n                                continue;\n                        }\n+                       if (!strcmp(path, \"--update-modes\")) {\n+                               update_modes();\n+                               continue;\n+                       }\n                        die(\"unknown option %s\", path);\n                }\n                if (!verify_path(path)) {\n\n\n-- \nMartin Schlemmer\n\n\n\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n+++ uncommitted/gitcancel.sh\n@@ -12,7 +12,8 @@\n \n # FIXME: Does not revert mode changes!\n \n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n \n-update-cache --refresh\n+# --update-modes need to be before --refresh\n+update-cache --update-modes --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -51,6 +51,8 @@\n \n \tread-tree $(tree-id \"$name\")\n \tgitdiff.sh local \"$name\" | gitapply.sh\n+\t# --update-modes need to be before --refresh\n+\tupdate-cache --update-modes --refresh\n \n else\n \t[ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n \tif [ -s \".git/HEAD.local\" ]; then\n \t\tgitdiff.sh \"$tracking\" local | gitapply.sh\n \t\tread-tree $(tree-id local)\n+\t\t# --update-modes need to be before --refresh\n+\t\tupdate-cache --update-modes --refresh\n \n \t\thead=$(cat .git/HEAD)\n \t\tbranchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n \n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n \tvoid *old_contents, unsigned long long old_size)\n {\n \tstatic char cmd[1000];\n+\tstatic char sha1[41];\n+\tint n;\n \tFILE *f;\n \n-\tsnprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+\tfor (n = 0; n < 20; n++)\n+\t\tsnprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+\tsnprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+\t\tsha1, ce->name, ce->name, ce->name);\n \tf = popen(cmd, \"w\");\n \tif (old_size)\n \t\tfwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n \t\t\tcontinue;\n \n \t\tnew = read_sha1_file(ce->sha1, type, &size);\n-\t\tshow_differences(ce->name, new, size);\n+\t\tshow_differences(ce, new, size);\n \t\tfree(new);\n \t}\n \treturn 0;\nupdate-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n--- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c\n+++ uncommitted/update-cache.c\n@@ -210,6 +210,39 @@\n \t}\n }\n \n+static struct cache_entry *update_file_mode(struct cache_entry *ce)\n+{\n+\tstruct stat st;\n+\tint changed;\n+\n+\tif (stat(ce->name, &st) < 0)\n+\t\treturn NULL;\n+\n+\tchanged = cache_match_stat(ce, &st);\n+\tif (!changed)\n+\t\treturn ce;\n+\n+\tif (changed & MODE_CHANGED)\n+\t\tif (chmod(ce->name, ce->st_mode))\n+\t\t\treturn NULL;\n+\n+\treturn ce;\n+}\n+\n+static void update_modes(void)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i < active_nr; i++) {\n+\t\tstruct cache_entry *ce = active_cache[i];\n+\n+\t\tif (!update_file_mode(ce)) {\n+\t\t\tprintf(\"%s: needs update\\n\", ce->name);\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+}\n+\n /*\n  * We fundamentally don't like some paths: we don't want\n  * dot or dot-dot anywhere, and in fact, we don't even want\n@@ -282,6 +315,10 @@\n \t\t\t\trefresh_cache();\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(path, \"--update-modes\")) {\n+\t\t\t\tupdate_modes();\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tdie(\"unknown option %s\", path);\n \t\t}\n \t\tif (!verify_path(path)) {\n"},{"id":"60","messageId":"20050414091106.GX25711@pasky.ji.cz","threadId":"3","inReplyTo":"1113467905.23299.81.camel@nosferatu.lan","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-14T09:11:07Z","receivedAt":"2005-04-14T09:11:07Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Please trim the replied mails a bit, snipping old and irrelevant parts.\nThis is insane. :-)\n\nDear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n..snip..\n> Normalize show-diff output, add --update-modes target to update-cache,\n> and make sure we only show real changes after changing the tracked\n> branch, as well as update the file modes according to the cache.\n\nI'm lost. Why do you do --update-modes? That makes no sense to me.\nYou introduce them to the cache out-of-order w.r.t. commits, that means\nin the normal git usage they are already unrevertable.\n\nWhat are you trying to do? Mode changes _are_ real changes. You _don't_\nwant to silence them. What you want is to even show them more explicitly\nin show-diff.\n\nThe --refreshes are fine.\n\n> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n> \n> gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n> --- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n> +++ uncommitted/gitcancel.sh\n> @@ -12,7 +12,8 @@\n> \n>  # FIXME: Does not revert mode changes!\n> \n> -show-diff | patch -p0 -R\n> +show-diff | patch -p1 -R\n>  rm -f .git/add-queue .git/rm-queue .git/merged\n> \n> -update-cache --refresh\n> +# --update-modes need to be before --refresh\n> +update-cache --update-modes --refresh\n\nHere, e.g., you should do the very opposite - change the modes back to\nhow are they in the cache.\n\n> show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n> +++ uncommitted/show-diff.c\n> @@ -5,13 +5,18 @@\n>   */\n>  #include \"cache.h\"\n> \n> -static void show_differences(char *name,\n> +static void show_differences(struct cache_entry *ce,\n>         void *old_contents, unsigned long long old_size)\n>  {\n>         static char cmd[1000];\n> +       static char sha1[41];\n> +       int n;\n>         FILE *f;\n> \n> -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> +       for (n = 0; n < 20; n++)\n> +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> +               sha1, ce->name, ce->name, ce->name);\n\nThe \"directory\" sha1 is the sha1 of the tree, not of the particular\nfile - that one is in the \"attributes\" list (parentheses after the\nfilename), together with mode.\n\n>         f = popen(cmd, \"w\");\n>         if (old_size)\n>                 fwrite(old_contents, old_size, 1, f);\n> @@ -99,7 +104,7 @@\n>                         continue;\n> \n>                 new = read_sha1_file(ce->sha1, type, &size);\n> -               show_differences(ce->name, new, size);\n> +               show_differences(ce, new, size);\n>                 free(new);\n>         }\n>         return 0;\n> update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n> --- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c\n> +++ uncommitted/update-cache.c\n> @@ -210,6 +210,39 @@\n>         }\n>  }\n> \n> +static struct cache_entry *update_file_mode(struct cache_entry *ce)\n> +{\n> +       struct stat st;\n> +       int changed;\n> +\n> +       if (stat(ce->name, &st) < 0)\n> +               return NULL;\n> +\n> +       changed = cache_match_stat(ce, &st);\n> +       if (!changed)\n> +               return ce;\n> +\n> +       if (changed & MODE_CHANGED)\n> +               if (chmod(ce->name, ce->st_mode))\n> +                       return NULL;\n> +\n> +       return ce;\n> +}\n> +\n> +static void update_modes(void)\n> +{\n> +       int i;\n> +\n> +       for (i = 0; i < active_nr; i++) {\n> +               struct cache_entry *ce = active_cache[i];\n> +\n> +               if (!update_file_mode(ce)) {\n> +                       printf(\"%s: needs update\\n\", ce->name);\n> +                       continue;\n> +               }\n> +       }\n> +}\n> +\n>  /*\n>   * We fundamentally don't like some paths: we don't want\n>   * dot or dot-dot anywhere, and in fact, we don't even want\n\nOh. So you are actually doing the _opposite_! But that's very wrong too.\nupdate-cache is for the direction tree -> index. For the opposite\ndirection, you should use checkout-cache.\n\n> @@ -282,6 +315,10 @@\n>                                 refresh_cache();\n>                                 continue;\n>                         }\n> +                       if (!strcmp(path, \"--update-modes\")) {\n> +                               update_modes();\n> +                               continue;\n> +                       }\n>                         die(\"unknown option %s\", path);\n>                 }\n>                 if (!verify_path(path)) {\n> \n> \n> -- \n> Martin Schlemmer\n> \n\n\n\n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"62","messageId":"1113471609.23299.95.camel@nosferatu.lan","threadId":"3","inReplyTo":"20050414091106.GX25711@pasky.ji.cz","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T09:40:09Z","receivedAt":"2005-04-14T09:40:09Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"(PS, can you check the fact that your mail client keeps on adding a 'Re:\n' ...)\n\nOn Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:\n> Please trim the replied mails a bit, snipping old and irrelevant parts.\n> This is insane. :-)\n> \n> Dear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> ..snip..\n> > Normalize show-diff output, add --update-modes target to update-cache,\n> > and make sure we only show real changes after changing the tracked\n> > branch, as well as update the file modes according to the cache.\n> \n> I'm lost. Why do you do --update-modes? That makes no sense to me.\n> You introduce them to the cache out-of-order w.r.t. commits, that means\n> in the normal git usage they are already unrevertable.\n> \n\nRight, afterwards I thought I did add it to the wrong place.\n\n\n> What are you trying to do? Mode changes _are_ real changes. You _don't_\n> want to silence them. What you want is to even show them more explicitly\n> in show-diff.\n> \n\nNo, you do not understand.  If you actually change the mode, it will\nshow.  What now happens, is that say I track the 'linus' branch, then\nuntrack, and then track 'pasky' again, the Patches will be applied, but\nnot the mode changes which are stored in the cache ...  Let me show you:\n\n-----\n$ ls -l $(./show-diff -s | cut -d: -f1)\n-rw-r--r--  1 root root  168 Apr 14 11:33 commit-id\n-rw-r--r--  1 root root 2213 Apr 14 11:33 git\n-rw-r--r--  1 root root 1168 Apr 14 11:33 gitXnormid.sh\n-rw-r--r--  1 root root  403 Apr 14 11:33 gitadd.sh\n-rw-r--r--  1 root root  844 Apr 14 11:33 gitaddremote.sh\n-rw-r--r--  1 root root 1899 Apr 14 11:33 gitapply.sh\n-rw-r--r--  1 root root  479 Apr 14 11:33 gitcancel.sh\n-rw-r--r--  1 root root 2512 Apr 14 11:33 gitcommit.sh\n-rw-r--r--  1 root root 2152 Apr 14 11:33 gitdiff-do\n-rw-r--r--  1 root root  819 Apr 14 11:33 gitdiff.sh\n-rw-r--r--  1 root root  717 Apr 14 11:33 gitexport.sh\n-rw-r--r--  1 root root  524 Apr 14 11:33 gitlog.sh\n-rw-r--r--  1 root root  228 Apr 14 11:33 gitls.sh\n-rw-r--r--  1 root root  904 Apr 14 11:33 gitlsobj.sh\n-rw-r--r--  1 root root  665 Apr 14 11:33 gitmerge.sh\n-rw-r--r--  1 root root 2044 Apr 14 11:33 gitpull.sh\n-rw-r--r--  1 root root  433 Apr 14 11:33 gitrm.sh\n-rw-r--r--  1 root root  614 Apr 14 11:33 gittag.sh\n-rw-r--r--  1 root root 2272 Apr 14 11:33 gittrack.sh\n-rw-r--r--  1 root root  284 Apr 14 11:33 parent-id\n-rw-r--r--  1 root root  177 Apr 14 11:33 tree-id\n-----\n\n(Note no 'x' bit ...)\n\nAnd that is _after_ doing:\n\n $ git track linus; git track\n\nSo basically the modes that are stored in the cache are not applied ...\nAlthough, yes, I prob should add the relevant code to checkout-cache.\n\n> The --refreshes are fine.\n> \n> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n> > \n> > gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n> > --- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n> > +++ uncommitted/gitcancel.sh\n> > @@ -12,7 +12,8 @@\n> > \n> >  # FIXME: Does not revert mode changes!\n> > \n> > -show-diff | patch -p0 -R\n> > +show-diff | patch -p1 -R\n> >  rm -f .git/add-queue .git/rm-queue .git/merged\n> > \n> > -update-cache --refresh\n> > +# --update-modes need to be before --refresh\n> > +update-cache --update-modes --refresh\n> \n> Here, e.g., you should do the very opposite - change the modes back to\n> how are they in the cache.\n> \n\nUhm, that is what it did ...  Like I said above, the wrong place though\nto add the code to update-cache.\n\n> > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n> > +++ uncommitted/show-diff.c\n> > @@ -5,13 +5,18 @@\n> >   */\n> >  #include \"cache.h\"\n> > \n> > -static void show_differences(char *name,\n> > +static void show_differences(struct cache_entry *ce,\n> >         void *old_contents, unsigned long long old_size)\n> >  {\n> >         static char cmd[1000];\n> > +       static char sha1[41];\n> > +       int n;\n> >         FILE *f;\n> > \n> > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > +       for (n = 0; n < 20; n++)\n> > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > +               sha1, ce->name, ce->name, ce->name);\n> \n> The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> file - that one is in the \"attributes\" list (parentheses after the\n> filename), together with mode.\n> \n\nDoes it really matter?  It is more just to get the patch prefix right,\nand I did it as it went nicely with the printed:\n\n----\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n----\n\nfor example ...\n\n> >         f = popen(cmd, \"w\");\n> >         if (old_size)\n> >                 fwrite(old_contents, old_size, 1, f);\n> > @@ -99,7 +104,7 @@\n> >                         continue;\n> > \n> >                 new = read_sha1_file(ce->sha1, type, &size);\n> > -               show_differences(ce->name, new, size);\n> > +               show_differences(ce, new, size);\n> >                 free(new);\n> >         }\n> >         return 0;\n> > update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312\n> > --- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c\n> > +++ uncommitted/update-cache.c\n> > @@ -210,6 +210,39 @@\n> >         }\n> >  }\n> > \n> > +static struct cache_entry *update_file_mode(struct cache_entry *ce)\n> > +{\n> > +       struct stat st;\n> > +       int changed;\n> > +\n> > +       if (stat(ce->name, &st) < 0)\n> > +               return NULL;\n> > +\n> > +       changed = cache_match_stat(ce, &st);\n> > +       if (!changed)\n> > +               return ce;\n> > +\n> > +       if (changed & MODE_CHANGED)\n> > +               if (chmod(ce->name, ce->st_mode))\n> > +                       return NULL;\n> > +\n> > +       return ce;\n> > +}\n> > +\n> > +static void update_modes(void)\n> > +{\n> > +       int i;\n> > +\n> > +       for (i = 0; i < active_nr; i++) {\n> > +               struct cache_entry *ce = active_cache[i];\n> > +\n> > +               if (!update_file_mode(ce)) {\n> > +                       printf(\"%s: needs update\\n\", ce->name);\n> > +                       continue;\n> > +               }\n> > +       }\n> > +}\n> > +\n> >  /*\n> >   * We fundamentally don't like some paths: we don't want\n> >   * dot or dot-dot anywhere, and in fact, we don't even want\n> \n> Oh. So you are actually doing the _opposite_! But that's very wrong too.\n> update-cache is for the direction tree -> index. For the opposite\n> direction, you should use checkout-cache.\n> \n\nRight, will do.\n\n> > @@ -282,6 +315,10 @@\n> >                                 refresh_cache();\n> >                                 continue;\n> >                         }\n> > +                       if (!strcmp(path, \"--update-modes\")) {\n> > +                               update_modes();\n> > +                               continue;\n> > +                       }\n> >                         die(\"unknown option %s\", path);\n> >                 }\n> >                 if (!verify_path(path)) {\n> > \n> > \n> > -- \n> > Martin Schlemmer\n> > \n> \n\n\n-- \nMartin Schlemmer\n\n"},{"id":"63","messageId":"1113472557.23299.99.camel@nosferatu.lan","threadId":"3","inReplyTo":"1113471609.23299.95.camel@nosferatu.lan","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T09:55:57Z","receivedAt":"2005-04-14T09:55:57Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Thu, 2005-04-14 at 11:40 +0200, Martin Schlemmer wrote:\n> On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:\n> > Please trim the replied mails a bit, snipping old and irrelevant parts.\n> > This is insane. :-)\n> > \n> > Dear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > ..snip..\n> > > Normalize show-diff output, add --update-modes target to update-cache,\n> > > and make sure we only show real changes after changing the tracked\n> > > branch, as well as update the file modes according to the cache.\n> > \n> > I'm lost. Why do you do --update-modes? That makes no sense to me.\n> > You introduce them to the cache out-of-order w.r.t. commits, that means\n> > in the normal git usage they are already unrevertable.\n> > \n> \n> Right, afterwards I thought I did add it to the wrong place.\n> \n> \n> > What are you trying to do? Mode changes _are_ real changes. You _don't_\n> > want to silence them. What you want is to even show them more explicitly\n> > in show-diff.\n> > \n> \n> No, you do not understand.  If you actually change the mode, it will\n> show.  What now happens, is that say I track the 'linus' branch, then\n> untrack, and then track 'pasky' again, the Patches will be applied, but\n> not the mode changes which are stored in the cache ...\n>\n> So basically the modes that are stored in the cache are not applied ...\n> Although, yes, I prob should add the relevant code to checkout-cache.\n> \n\nOk, this should be a better one I think.\n\n----\n\nNormalize show-diff output, add --update-modes target to update-cache,\nand make sure we only show real changes after changing the tracked\nbranch, as well as update the file modes according to the cache.\n\nSigned-off-by: Martin Schlemmer <azarah@nosferatu.za.org>\n\ncheckout-cache.c:  f06871cdbc1b18ea93bdf4e17126aeb4cca1373e\n--- f06871cdbc1b18ea93bdf4e17126aeb4cca1373e/checkout-cache.c\n+++ uncommitted/checkout-cache.c\n@@ -34,7 +34,7 @@\n  */\n #include \"cache.h\"\n\n-static int force = 0, quiet = 0;\n+static int force = 0, quiet = 0, update_mode = 0;\n\n static void create_directories(const char *path)\n {\n@@ -99,6 +99,8 @@\n                unsigned changed = cache_match_stat(ce, &st);\n                if (!changed)\n                        return 0;\n+               if (update_mode && changed & MODE_CHANGED)\n+                       chmod(ce->name, ce->st_mode);\n                if (!force) {\n                        if (!quiet)\n                                fprintf(stderr, \"checkout-cache: %s already exists\\n\", ce->name);\n@@ -158,6 +160,10 @@\n                                quiet = 1;\n                                continue;\n                        }\n+                       if (!strcmp(arg, \"-m\")) {\n+                               update_mode = 1;\n+                               continue;\n+                       }\n                }\n                checkout_file(arg);\n        }\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n+++ uncommitted/gitcancel.sh\n@@ -12,7 +12,8 @@\n\n # FIXME: Does not revert mode changes!\n\n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n\n+checkout-cache -q -m -a\n update-cache --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -51,6 +51,8 @@\n\n        read-tree $(tree-id \"$name\")\n        gitdiff.sh local \"$name\" | gitapply.sh\n+       checkout-cache -q -m -a\n+       update-cache --refresh\n\n else\n        [ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n        if [ -s \".git/HEAD.local\" ]; then\n                gitdiff.sh \"$tracking\" local | gitapply.sh\n                read-tree $(tree-id local)\n+               checkout-cache -q -m -a\n+               update-cache --refresh\n\n                head=$(cat .git/HEAD)\n                branchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n\n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n        void *old_contents, unsigned long long old_size)\n {\n        static char cmd[1000];\n+       static char sha1[41];\n+       int n;\n        FILE *f;\n\n-       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+       for (n = 0; n < 20; n++)\n+               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+               sha1, ce->name, ce->name, ce->name);\n        f = popen(cmd, \"w\");\n        if (old_size)\n                fwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n                        continue;\n\n                new = read_sha1_file(ce->sha1, type, &size);\n-               show_differences(ce->name, new, size);\n+               show_differences(ce, new, size);\n                free(new);\n        }\n        return 0;\n\n\n-- \nMartin Schlemmer\n\n\n\ncheckout-cache.c:  f06871cdbc1b18ea93bdf4e17126aeb4cca1373e\n--- f06871cdbc1b18ea93bdf4e17126aeb4cca1373e/checkout-cache.c\n+++ uncommitted/checkout-cache.c\n@@ -34,7 +34,7 @@\n  */\n #include \"cache.h\"\n \n-static int force = 0, quiet = 0;\n+static int force = 0, quiet = 0, update_mode = 0;\n \n static void create_directories(const char *path)\n {\n@@ -99,6 +99,8 @@\n \t\tunsigned changed = cache_match_stat(ce, &st);\n \t\tif (!changed)\n \t\t\treturn 0;\n+\t\tif (update_mode && changed & MODE_CHANGED)\n+\t\t\tchmod(ce->name, ce->st_mode);\n \t\tif (!force) {\n \t\t\tif (!quiet)\n \t\t\t\tfprintf(stderr, \"checkout-cache: %s already exists\\n\", ce->name);\n@@ -158,6 +160,10 @@\n \t\t\t\tquiet = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"-m\")) {\n+\t\t\t\tupdate_mode = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t}\n \t\tcheckout_file(arg);\n \t}\ngitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0\n--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh\n+++ uncommitted/gitcancel.sh\n@@ -12,7 +12,8 @@\n \n # FIXME: Does not revert mode changes!\n \n-show-diff | patch -p0 -R\n+show-diff | patch -p1 -R\n rm -f .git/add-queue .git/rm-queue .git/merged\n \n+checkout-cache -q -m -a\n update-cache --refresh\ngittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808\n--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh\n+++ uncommitted/gittrack.sh\n@@ -51,6 +51,8 @@\n \n \tread-tree $(tree-id \"$name\")\n \tgitdiff.sh local \"$name\" | gitapply.sh\n+\tcheckout-cache -q -m -a\n+\tupdate-cache --refresh\n \n else\n \t[ \"$tracking\" ] || \\\n@@ -61,6 +63,8 @@\n \tif [ -s \".git/HEAD.local\" ]; then\n \t\tgitdiff.sh \"$tracking\" local | gitapply.sh\n \t\tread-tree $(tree-id local)\n+\t\tcheckout-cache -q -m -a\n+\t\tupdate-cache --refresh\n \n \t\thead=$(cat .git/HEAD)\n \t\tbranchhead=$(cat .git/heads/$tracking)\nshow-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n+++ uncommitted/show-diff.c\n@@ -5,13 +5,18 @@\n  */\n #include \"cache.h\"\n \n-static void show_differences(char *name,\n+static void show_differences(struct cache_entry *ce,\n \tvoid *old_contents, unsigned long long old_size)\n {\n \tstatic char cmd[1000];\n+\tstatic char sha1[41];\n+\tint n;\n \tFILE *f;\n \n-\tsnprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n+\tfor (n = 0; n < 20; n++)\n+\t\tsnprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n+\tsnprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n+\t\tsha1, ce->name, ce->name, ce->name);\n \tf = popen(cmd, \"w\");\n \tif (old_size)\n \t\tfwrite(old_contents, old_size, 1, f);\n@@ -99,7 +104,7 @@\n \t\t\tcontinue;\n \n \t\tnew = read_sha1_file(ce->sha1, type, &size);\n-\t\tshow_differences(ce->name, new, size);\n+\t\tshow_differences(ce, new, size);\n \t\tfree(new);\n \t}\n \treturn 0;\n"},{"id":"140","messageId":"81b0412b0504141535793cc235@mail.gmail.com","threadId":"3","inReplyTo":"1113472557.23299.99.camel@nosferatu.lan","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2005-04-14T22:35:03Z","receivedAt":"2005-04-14T22:35:03Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 4/14/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:\n> +               if (update_mode && changed & MODE_CHANGED)\n> +                       chmod(ce->name, ce->st_mode);\n\nit's \"if ((update_mode && changed) & MODE_CHANGED)\"\nDid you really mean that?\n\n-alex\n"},{"id":"142","messageId":"20050414224257.GM22699@pasky.ji.cz","threadId":"3","inReplyTo":"1113471609.23299.95.camel@nosferatu.lan","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-14T22:42:57Z","receivedAt":"2005-04-14T22:42:57Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> (PS, can you check the fact that your mail client keeps on adding a 'Re:\n> ' ...)\n\nHmm. I guess my ancient reply_regexp\n\"^((\\\\[|\\\\()([^B]|B([^u]|u([^g]|g([^ ]|AnTiMaTcH))))[^]]+(\\\\]|\\\\)))?[\n \\t]*((re([\\\\[0-9\\\\]+])*|aw):[ \\t]*)?\" is broken... ;-)\n\n> On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:\n> > I'm lost. Why do you do --update-modes? That makes no sense to me.\n> > You introduce them to the cache out-of-order w.r.t. commits, that means\n> > in the normal git usage they are already unrevertable.\n> > \n> \n> Right, afterwards I thought I did add it to the wrong place.\n\nSo, could you please do something with it? :-)\n\n> > What are you trying to do? Mode changes _are_ real changes. You _don't_\n> > want to silence them. What you want is to even show them more explicitly\n> > in show-diff.\n> > \n> \n> No, you do not understand.  If you actually change the mode, it will\n> show.  What now happens, is that say I track the 'linus' branch, then\n> untrack, and then track 'pasky' again, the Patches will be applied, but\n> not the mode changes which are stored in the cache ...  Let me show you:\n> \n> -----\n> $ ls -l $(./show-diff -s | cut -d: -f1)\n..directroy listing with no 'x' bit..\n> -----\n> \n> (Note no 'x' bit ...)\n> \n> And that is _after_ doing:\n> \n>  $ git track linus; git track\n> \n> So basically the modes that are stored in the cache are not applied ...\n> Although, yes, I prob should add the relevant code to checkout-cache.\n\nThis should be fixed now, BTW. git apply didn't correctly apply the\nmode changes, but now it should. Several bugs prevented it to, in fact.\n;-)\n\n> > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n> > > +++ uncommitted/show-diff.c\n> > > @@ -5,13 +5,18 @@\n> > >   */\n> > >  #include \"cache.h\"\n> > > \n> > > -static void show_differences(char *name,\n> > > +static void show_differences(struct cache_entry *ce,\n> > >         void *old_contents, unsigned long long old_size)\n> > >  {\n> > >         static char cmd[1000];\n> > > +       static char sha1[41];\n> > > +       int n;\n> > >         FILE *f;\n> > > \n> > > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > > +       for (n = 0; n < 20; n++)\n> > > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > > +               sha1, ce->name, ce->name, ce->name);\n> > \n> > The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> > file - that one is in the \"attributes\" list (parentheses after the\n> > filename), together with mode.\n> > \n> \n> Does it really matter?  It is more just to get the patch prefix right,\n> and I did it as it went nicely with the printed:\n> \n> ----\n> show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> ----\n> \n> for example ...\n\nYes, it matters, and I don't care how nicely it wents with what you\nprint before.\n\nEither print there some nonsense which is clear not to be a tree ID, or\n(much more preferably) print the real tree ID there. If some tool ever\nuses it (e.g. to help resolve conflicts, perhaps even actually doing a\nreal merge based on the patch), you just confused it.\n\nAlso, do you think you could separate this patch from the other\n(--update-modes) patch? (If we actually still need the --update-modes\npatch after git apply was fixed.)\n\nThanks,\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"152","messageId":"20050414230047.GS22699@pasky.ji.cz","threadId":"3","inReplyTo":"1113519687.23299.126.camel@nosferatu.lan","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-14T23:00:47Z","receivedAt":"2005-04-14T23:00:47Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:\n> > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > So basically the modes that are stored in the cache are not applied ...\n> > > Although, yes, I prob should add the relevant code to checkout-cache.\n> > \n> > This should be fixed now, BTW. git apply didn't correctly apply the\n> > mode changes, but now it should. Several bugs prevented it to, in fact.\n> > ;-)\n> \n> Yep, I saw - thought you scrapped this, so mailed a new patch (or was\n> busy doing the touch ups to the email when this came in.\n\nHmm, I must've missed the new patch. The latest I have still puts the\nstuff to update-cache and combines it with the show-diff change.\n\n> > > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n> > > > > +++ uncommitted/show-diff.c\n> > > > > @@ -5,13 +5,18 @@\n..snip..\n> > > > > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > > > > +       for (n = 0; n < 20; n++)\n> > > > > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > > > > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > > > > +               sha1, ce->name, ce->name, ce->name);\n> > > > \n> > > > The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> > > > file - that one is in the \"attributes\" list (parentheses after the\n> > > > filename), together with mode.\n> > > > \n> > > \n> > > Does it really matter?  It is more just to get the patch prefix right,\n> > > and I did it as it went nicely with the printed:\n> > > \n> > > ----\n> > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > ----\n> > > \n> > > for example ...\n> > \n> > Yes, it matters, and I don't care how nicely it wents with what you\n> > print before.\n> > \n> \n> hah ;p\n> \n> > Either print there some nonsense which is clear not to be a tree ID, or\n> > (much more preferably) print the real tree ID there. If some tool ever\n> > uses it (e.g. to help resolve conflicts, perhaps even actually doing a\n> > real merge based on the patch), you just confused it.\n> > \n> \n> Ok, understood.  Do you think it will be scripted?  If not I guess we\n> can just do labels like:\n> \n> --- committed/\n> +++ uncommitted/\n> \n> ?\n\nHeh. Well, of course this could do. But is there any technical reason\nwhy not just carry the sha1 id of the tree around and stuff it there?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"150","messageId":"1113519687.23299.126.camel@nosferatu.lan","threadId":"3","inReplyTo":"20050414224257.GM22699@pasky.ji.cz","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T23:01:27Z","receivedAt":"2005-04-14T23:01:27Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:\n> Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > (PS, can you check the fact that your mail client keeps on adding a 'Re:\n> > ' ...)\n> \n> Hmm. I guess my ancient reply_regexp\n> \"^((\\\\[|\\\\()([^B]|B([^u]|u([^g]|g([^ ]|AnTiMaTcH))))[^]]+(\\\\]|\\\\)))?[\n>  \\t]*((re([\\\\[0-9\\\\]+])*|aw):[ \\t]*)?\" is broken... ;-)\n> \n> > On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:\n> > > I'm lost. Why do you do --update-modes? That makes no sense to me.\n> > > You introduce them to the cache out-of-order w.r.t. commits, that means\n> > > in the normal git usage they are already unrevertable.\n> > > \n> > \n> > Right, afterwards I thought I did add it to the wrong place.\n> \n> So, could you please do something with it? :-)\n> \n> > > What are you trying to do? Mode changes _are_ real changes. You _don't_\n> > > want to silence them. What you want is to even show them more explicitly\n> > > in show-diff.\n> > > \n> > \n> > No, you do not understand.  If you actually change the mode, it will\n> > show.  What now happens, is that say I track the 'linus' branch, then\n> > untrack, and then track 'pasky' again, the Patches will be applied, but\n> > not the mode changes which are stored in the cache ...  Let me show you:\n> > \n> > -----\n> > $ ls -l $(./show-diff -s | cut -d: -f1)\n> ..directroy listing with no 'x' bit..\n> > -----\n> > \n> > (Note no 'x' bit ...)\n> > \n> > And that is _after_ doing:\n> > \n> >  $ git track linus; git track\n> > \n> > So basically the modes that are stored in the cache are not applied ...\n> > Although, yes, I prob should add the relevant code to checkout-cache.\n> \n> This should be fixed now, BTW. git apply didn't correctly apply the\n> mode changes, but now it should. Several bugs prevented it to, in fact.\n> ;-)\n> \n\nYep, I saw - thought you scrapped this, so mailed a new patch (or was\nbusy doing the touch ups to the email when this came in.\n\n> > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c\n> > > > +++ uncommitted/show-diff.c\n> > > > @@ -5,13 +5,18 @@\n> > > >   */\n> > > >  #include \"cache.h\"\n> > > > \n> > > > -static void show_differences(char *name,\n> > > > +static void show_differences(struct cache_entry *ce,\n> > > >         void *old_contents, unsigned long long old_size)\n> > > >  {\n> > > >         static char cmd[1000];\n> > > > +       static char sha1[41];\n> > > > +       int n;\n> > > >         FILE *f;\n> > > > \n> > > > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > > > +       for (n = 0; n < 20; n++)\n> > > > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > > > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > > > +               sha1, ce->name, ce->name, ce->name);\n> > > \n> > > The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> > > file - that one is in the \"attributes\" list (parentheses after the\n> > > filename), together with mode.\n> > > \n> > \n> > Does it really matter?  It is more just to get the patch prefix right,\n> > and I did it as it went nicely with the printed:\n> > \n> > ----\n> > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > ----\n> > \n> > for example ...\n> \n> Yes, it matters, and I don't care how nicely it wents with what you\n> print before.\n> \n\nhah ;p\n\n> Either print there some nonsense which is clear not to be a tree ID, or\n> (much more preferably) print the real tree ID there. If some tool ever\n> uses it (e.g. to help resolve conflicts, perhaps even actually doing a\n> real merge based on the patch), you just confused it.\n> \n\nOk, understood.  Do you think it will be scripted?  If not I guess we\ncan just do labels like:\n\n--- committed/\n+++ uncommitted/\n\n?\n\n> Also, do you think you could separate this patch from the other\n> (--update-modes) patch? (If we actually still need the --update-modes\n> patch after git apply was fixed.)\n> \n\nYeah, already split it out locally, just waiting on above response ...\n\n\nThanks,\n\n-- \nMartin Schlemmer\n\n"},{"id":"155","messageId":"1113520175.23299.134.camel@nosferatu.lan","threadId":"3","inReplyTo":"20050414230047.GS22699@pasky.ji.cz","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T23:09:35Z","receivedAt":"2005-04-14T23:09:35Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-15 at 01:00 +0200, Petr Baudis wrote:\n> Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:\n> > > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter\n> > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > > > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > > > > > +       for (n = 0; n < 20; n++)\n> > > > > > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > > > > > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > > > > > +               sha1, ce->name, ce->name, ce->name);\n> > > > > \n> > > > > The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> > > > > file - that one is in the \"attributes\" list (parentheses after the\n> > > > > filename), together with mode.\n> > > > > \n> > > > \n> > > > Does it really matter?  It is more just to get the patch prefix right,\n> > > > and I did it as it went nicely with the printed:\n> > > > \n> > > > ----\n> > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > > ----\n> > > > \n> > > > for example ...\n> > > \n> > > Yes, it matters, and I don't care how nicely it wents with what you\n> > > print before.\n> > > \n> > \n> > hah ;p\n> > \n> > > Either print there some nonsense which is clear not to be a tree ID, or\n> > > (much more preferably) print the real tree ID there. If some tool ever\n> > > uses it (e.g. to help resolve conflicts, perhaps even actually doing a\n> > > real merge based on the patch), you just confused it.\n> > > \n> > \n> > Ok, understood.  Do you think it will be scripted?  If not I guess we\n> > can just do labels like:\n> > \n> > --- committed/\n> > +++ uncommitted/\n> > \n> > ?\n> \n> Heh. Well, of course this could do. But is there any technical reason\n> why not just carry the sha1 id of the tree around and stuff it there?\n> \n\nNot at all. Just wanted to know if anybody saw the possible use before\nadding possible cruft that could be done shorter - will do a patch\nshortly.\n\n\nThanks,\n\n-- \nMartin Schlemmer\n\n"},{"id":"161","messageId":"1113521156.23299.140.camel@nosferatu.lan","threadId":"3","inReplyTo":"1113520175.23299.134.camel@nosferatu.lan","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-14T23:25:56Z","receivedAt":"2005-04-14T23:25:56Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-15 at 01:09 +0200, Martin Schlemmer wrote:\n> On Fri, 2005-04-15 at 01:00 +0200, Petr Baudis wrote:\n> > Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter\n> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:\n> > > > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter\n> > > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > > > > > > -       snprintf(cmd, sizeof(cmd), \"diff -L %s -u -N  - %s\", name, name);\n> > > > > > > +       for (n = 0; n < 20; n++)\n> > > > > > > +               snprintf(&(sha1[n*2]), 3, \"%02x\", ce->sha1[n]);\n> > > > > > > +       snprintf(cmd, sizeof(cmd), \"diff -L %s/%s -L uncommitted/%s -u -N  - %s\",\n> > > > > > > +               sha1, ce->name, ce->name, ce->name);\n> > > > > > \n> > > > > > The \"directory\" sha1 is the sha1 of the tree, not of the particular\n> > > > > > file - that one is in the \"attributes\" list (parentheses after the\n> > > > > > filename), together with mode.\n> > > > > > \n> > > > > \n> > > > > Does it really matter?  It is more just to get the patch prefix right,\n> > > > > and I did it as it went nicely with the printed:\n> > > > > \n> > > > > ----\n> > > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96\n> > > > > ----\n> > > > > \n> > > > > for example ...\n> > > > \n> > > > Yes, it matters, and I don't care how nicely it wents with what you\n> > > > print before.\n> > > > \n> > > \n> > > hah ;p\n> > > \n> > > > Either print there some nonsense which is clear not to be a tree ID, or\n> > > > (much more preferably) print the real tree ID there. If some tool ever\n> > > > uses it (e.g. to help resolve conflicts, perhaps even actually doing a\n> > > > real merge based on the patch), you just confused it.\n> > > > \n> > > \n> > > Ok, understood.  Do you think it will be scripted?  If not I guess we\n> > > can just do labels like:\n> > > \n> > > --- committed/\n> > > +++ uncommitted/\n> > > \n> > > ?\n> > \n> > Heh. Well, of course this could do. But is there any technical reason\n> > why not just carry the sha1 id of the tree around and stuff it there?\n> > \n> \n> Not at all. Just wanted to know if anybody saw the possible use before\n> adding possible cruft that could be done shorter - will do a patch\n> shortly.\n> \n\nHo hum - none of the lowlevel tools know or work with the tree-id, and I\nam not too sure if Linus will like adding something to get it ... any\nideas?\n\n\n-- \nMartin Schlemmer\n\n"},{"id":"187","messageId":"1113543914.23299.151.camel@nosferatu.lan","threadId":"3","inReplyTo":"81b0412b0504141535793cc235@mail.gmail.com","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-15T05:45:14Z","receivedAt":"2005-04-15T05:45:14Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-15 at 00:35 +0200, Alex Riesen wrote:\n> On 4/14/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:\n> > +               if (update_mode && changed & MODE_CHANGED)\n> > +                       chmod(ce->name, ce->st_mode);\n> \n> it's \"if ((update_mode && changed) & MODE_CHANGED)\"\n> Did you really mean that?\n> \n\nNo, '&' have a higher priority (weight?) than '&&'.  Although, yes, it\nmight be better style to add brackets.\n\nBut just to make you happy, let me prove it:\n\n-----\n$ cat foo1.c\nint main() {\n        int foo, bar;\n\n        if (foo && bar & 1)\n                return 1;\n\n        return 0;\n}\n$ cat foo2.c\nint main() {\n        int foo, bar;\n\n        if (foo && (bar & 1))\n                return 1;\n\n        return 0;\n}\n$ cat foo3.c\nint main() {\n        int foo, bar;\n\n        if ((foo && bar) & 1)\n                return 1;\n\n        return 0;\n}\n$ gcc -c -S foo1.c -o foo1.S\n$ gcc -c -S foo2.c -o foo2.S\n$ gcc -c -S foo3.c -o foo3.S\n$ diff -u foo1.S foo2.S\n--- foo1.S      2005-04-15 07:42:27.000000000 +0200\n+++ foo2.S      2005-04-15 07:42:32.000000000 +0200\n@@ -1,4 +1,4 @@\n-       .file   \"foo1.c\"\n+       .file   \"foo2.c\"\n        .text\n .globl main\n        .type   main, @function\n$ diff -u foo1.S foo3.S\n--- foo1.S      2005-04-15 07:42:27.000000000 +0200\n+++ foo3.S      2005-04-15 07:42:35.000000000 +0200\n@@ -1,4 +1,4 @@\n-       .file   \"foo1.c\"\n+       .file   \"foo3.c\"\n        .text\n .globl main\n        .type   main, @function\n@@ -9,9 +9,14 @@\n        andl    $-16, %esp\n        movl    $0, %eax\n        subl    %eax, %esp\n+       movl    $0, -16(%ebp)\n        cmpl    $0, -4(%ebp)\n-       je      .L2\n-       movl    -8(%ebp), %eax\n+       je      .L3\n+       cmpl    $0, -8(%ebp)\n+       je      .L3\n+       movl    $1, -16(%ebp)\n+.L3:\n+       movl    -16(%ebp), %eax\n        andl    $1, %eax\n        testl   %eax, %eax\n        je      .L2\n-----\n\n\n-- \nMartin Schlemmer\n\n"},{"id":"193","messageId":"20050414234231.663fd7b3.pj@engr.sgi.com","threadId":"3","inReplyTo":"1113543914.23299.151.camel@nosferatu.lan","subject":"Re: Remove need to untrack before tracking new branch","fromName":"Paul Jackson","fromEmail":"pj@engr.sgi.com","sentAt":"2005-04-15T06:42:31Z","receivedAt":"2005-04-15T06:42:31Z","isPatch":false,"sender":{"key":"pj@engr.sgi.com","avatar":null},"body":"> No, '&' have a higher priority (weight?) than '&&'.\n\n& has a higher precedence than &&\n\n  C Operator Precedence and Associativity\n  http://www.difranco.net/cop2220/op-prec.htm\n\nand many others -- google for 'c operator precedence'\n\nWhere the bitops &, | and ^ bite you is that they are\nlower precedence than many other ops, including '=='.\n\n-- \n                  I won't rest till it's the best ...\n                  Programmer, Linux Scalability\n                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401\n"},{"id":"258","messageId":"81b0412b050415164958cadbe8@mail.gmail.com","threadId":"3","inReplyTo":"1113543914.23299.151.camel@nosferatu.lan","subject":"Re: Re: Re: Re: Remove need to untrack before tracking new branch","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2005-04-15T23:49:05Z","receivedAt":"2005-04-15T23:49:05Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 4/15/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:\n> > > +               if (update_mode && changed & MODE_CHANGED)\n> > > +                       chmod(ce->name, ce->st_mode);\n> >\n> > it's \"if ((update_mode && changed) & MODE_CHANGED)\"\n> > Did you really mean that?\n> \n> No, '&' have a higher priority (weight?) than '&&'.  Although, yes, it\n> might be better style to add brackets.\n\nI wasn't concerned about style\n\n> But just to make you happy, let me prove it:\n\nIt's not to make me happy, it's just to prove you're right.\nYou did it, I stand corrected.\n"}]}