{"thread":{"id":"2718","subject":"What's new in git.git master branch","startedAt":"2005-11-30T22:57:06Z","lastAt":"2005-12-07T10:01:41Z","messageCount":15,"participants":["Junio C Hamano","Fredrik Kuivinen","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13017","messageId":"7vlkz5n3r1.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":null,"subject":"What's new in git.git master branch","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-30T22:57:06Z","receivedAt":"2005-11-30T22:57:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As promised (or warned), most of the things are now graduating\nfrom proposed updates to the master branch.  The plan is to\nmerge this into \"maint\" by the weekend after field testing\n(sorry, you guys are guinea pigs, but I did human experiments on\nmyself first ;-)), and label that 1.0rc4.  After that, hopefully\nno disrupting feature changes until 1.0 final.\n\nAmong the miscellaneous fixes, notable recent changes are:\n\n - bisect can cut down trials if given pathspec (Linus).\n\n - merge-one-file leaves unmerged entries in index (Linus,\n   linux@horizon.com, me).  The recursive merge strategy has\n   been also updated to match this but only in no-renaming\n   case.\n\n - diff-files updated to show diff between a higher stage and\n   working tree (Linus).  I reverted most of the butchering I\n   suggested last night on the list except one obvious bugfix\n   Linus agreed.\n\n - ls-tree rewrite (Linus).\n\n - making more things work from subdirectories (me).\n\n - repository format version futureproofing (Martin Atukunda and\n   me).  A fix by Tommi Virtanen for the bug reported by David\n   Woodhouse is included here.\n\n - improved gitk (Paulus, Yann Dirson, Pavel Roskin)\n\nI am still holding back \"Disable USE_SYMLINK_HEAD\" by Pavel\nRoskin in the proposed updates branch.  This makes symref\neverywhere, not only on symbolic-challenged platforms, to\nrepresent HEAD link.  As far as I know, Cogito and StGIT are\nready for this change, but this will break gitweb, which\ndirectly reads from $project/HEAD to find out the object name of\nthe HEAD commit (it needs to do `GIT_DIR=$project git-rev-parse\nHEAD` now).  I think we earlier agreed that this patch will go\nin sometime after 1.0; correct me if I am wrong.\n\nOne interesting change is ls-tree rewrite by Linus.  The command\ndoes _not_ show tree nodes when running with -r flag anymore.\nRunning \"git diff v0.99.9i t/t3100-ls-tree-restrict.sh\"\nafter updating to the master tells you the summary of changes in\nthe behaviour.\n\nI've looked at gitweb, Cogito and StGIT to see if this breaks\nthings, and while I think it is safe for these three, authors of\nPorcelains including these three are asked to double check.\n\nParticularly interesting one is cg-log, which only uses\n\"git-ls-tree -r\" to show the list of things being committed for\nthe initial commit, and this change actually fixes a small bug\nthere (I think with the ls-tree before this change it would end\nup listing tree entries).  cg-restore guards itself with a sed\nscript from ls-tree spitting out entries other than blob, so it\nis not affected, but it could lose that guard now.\n\nAnother improvement is around git-merge-one-file and\ngit-diff-files to change how the conflicting path information is\nleft in the index after a failed automerge.  This change was\nprompted by a question from linux@horizon.com (do you have a\nreal name?).  We leave the failed merge result in the working\ntree with conflict markers as before, but unlike the previous\nround which registered the HEAD commit version at stage0 in the\nindex file, we now leave the index entries unmerged.  \"git diff\"\ncommand can be used to see what the changes from our HEAD commit\nis as before, but you can also say \"git diff --base\" to see the\ndifferences from the merge base, and \"git diff --theirs\" to see\nthe differences from the other branch that was merged.\n"},{"id":"13031","messageId":"20051201085433.GA7866@c165.ib.student.liu.se","threadId":"2718","inReplyTo":"7vlkz5n3r1.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's new in git.git master branch","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2005-12-01T08:54:33Z","receivedAt":"2005-12-01T08:54:33Z","isPatch":false,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Wed, Nov 30, 2005 at 02:57:06PM -0800, Junio C Hamano wrote:\n\n[...]\n\n>  - ls-tree rewrite (Linus).\n\n[...]\n\n> One interesting change is ls-tree rewrite by Linus.  The command\n> does _not_ show tree nodes when running with -r flag anymore.\n> Running \"git diff v0.99.9i t/t3100-ls-tree-restrict.sh\"\n> after updating to the master tells you the summary of changes in\n> the behaviour.\n\nIt turns out that this change breaks the directory/file conflict\nhandling in git-merge-recursive. Right now merge-recursive uses\n\n   git-ls-tree -r -z <tree SHA1>\n\nto get a listing of every blob object (which corresponds to files) and\nevery tree object (which corresponds to directories) in the tree\ndesignated by the SHA1. With the new ls-tree behaviour we don't get\nany tree objects and hence merge-recursive can't do the d/f conflict\ndetection as it doesn't know about the directories. As we don't track\nempty directories it could be fixed within git-merge-recursive, a list\nof the directory names can be obtained from the list of file names by\nstripping everything after the last slash in the file names.\n\nShould we do it that way or should ls-tree be changed?\n\n- Fredrik\n"},{"id":"13033","messageId":"7vmzjljgwo.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"20051201085433.GA7866@c165.ib.student.liu.se","subject":"Re: What's new in git.git master branch","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-01T09:38:47Z","receivedAt":"2005-12-01T09:38:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fredrik Kuivinen <freku045@student.liu.se> writes:\n\n> It turns out that this change breaks the directory/file conflict\n> handling in git-merge-recursive.\n>\n>    git-ls-tree -r -z <tree SHA1>\n>\n> Should we do it that way or should ls-tree be changed?\n\nOuch.  Sorry, I should have been more careful.  For this\nparticular one, I think updating merge-recursive is less work,\nso for now I'd vote for that approach.  However, as you might\nalready be aware, I am not convinced that the new behaviour is\nbetter than the previous round (there is no question about the\nimplementation quality and the clean-up value the rewrite\nbrings), so we might want to also add the \"show tree entry in\nrecursive cases too\" option to ls-tree as well.  What I am\nsaying is essentially, \"why not do both?\" ;-).\n\nI was looking at the merge-recursive, and there is another topic\nI wanted to discuss with you about.  Conflicts in renaming\nmerges and index collapsing.  The latest merge-one-file leaves\nindex entries uncollapsed when the file content changes cannot\nbe automerged, and I think we would want to match that in\nmerge-recursive.  When there is no rename involved it can do the\nsame thing as merge-one-file does -- just leave the index\nunmerged.  Renaming case is different.\n\nCurrently, rename result is recorded by using \"git-update-index\n--cacheinfo\" to populate the index.  This method unfortunately\ncan only create a stage0 entry.  We can go two ways.  One way is\nto support \"register this mode/sha1 tuple at stageN for path\" to\nupdate-index.  Another would be for merge-recursive to first\nconstruct three trees with the final directory structure\n(i.e. prepare three temporary trees with renames applied) and\nrun read-tree 3-way merge on these temporary trees.  I suspect\nthe former is probably of lesser impact.  Thoughts?\n\nAlso I think I broke the case where base trees need to be merged\nin 58cce8a8 commit (I changed processEntry not to collapse the\nindex entry when file content changes cannot be automerged, but\nthat change has to be done only for the final merge, and merges\nbetween base trees must collapse to be able to write the index\nfile out as a tree).\n"},{"id":"13054","messageId":"Pine.LNX.4.64.0512011022520.3099@g5.osdl.org","threadId":"2718","inReplyTo":"20051201085433.GA7866@c165.ib.student.liu.se","subject":"git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-12-01T18:35:51Z","receivedAt":"2005-12-01T18:35:51Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThe old (new) behaviour was that it only shows trees if the object is \nspecified exactly, and recursive is not set. That makes sense, because \nthere is obviously nothing else it can show for that case.\n\nHowever, with the new \"-t\" option, it will show the tree even with \"-r\", \nas it traverses down into it.\n\nNOTE! This also means that it will show all trees leading up to that tree. \n\nFor example, if you do a\n\n\tgit-ls-tree -t HEAD -- drivers/char/this/file/does/not/exist\n\nit will show the trees that lead up to the files that do not exist:\n\n\t[torvalds@g5 linux]$ git-ls-tree -t HEAD -- drivers/char/this/file/does/not/exist\n\t040000 tree 9cb687b77dcd64bf82e9a73214db467c964c1266    drivers\n\t040000 tree 298e2fadf0ff3867d1ef49936fd2c7bf6ce1eb66    drivers/char\n\t[torvalds@g5 linux]$\n\nand note how this is true even though I didn't specify \"-r\": the fact that \nI supplied a pathspec automatically implies \"enough recursion\" for that \nparticular pathspec.\n\nI think the code is cleaner and easier to understand too: the patch looks \nbigger, but it's really just splitting up the \"should we recurse into this \ntree\" into a function of its own.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n----\n\nThis obviously means that to fix merge-recursive, we should add that \"-t\" \nflag to it, but then hopefully everything should be ok? Do you have a \ntest-case, and perhaps something we could add to \"make test\".\n\nTalking about \"make test\", this doesn't break any (since it doesn't change \nbehaviour without the \"-t\" flag), but maybe it should add some. But I'm \nlazy.\n\nOn Thu, 1 Dec 2005, Fredrik Kuivinen wrote:\n> \n> It turns out that this change breaks the directory/file conflict\n> handling in git-merge-recursive. Right now merge-recursive uses\n> \n>    git-ls-tree -r -z <tree SHA1>\n> \n> to get a listing of every blob object (which corresponds to files) and\n> every tree object (which corresponds to directories) in the tree\n> designated by the SHA1.\n\ndiff --git a/ls-tree.c b/ls-tree.c\nindex d4b6219..a2a5eb0 100644\n--- a/ls-tree.c\n+++ b/ls-tree.c\n@@ -11,39 +11,53 @@\n static int line_termination = '\\n';\n #define LS_RECURSIVE 1\n #define LS_TREE_ONLY 2\n+#define LS_SHOW_TREES 4\n static int ls_options = 0;\n const char **pathspec;\n \n static const char ls_tree_usage[] =\n-\t\"git-ls-tree [-d] [-r] [-z] <tree-ish> [path...]\";\n+\t\"git-ls-tree [-d] [-r] [-t] [-z] <tree-ish> [path...]\";\n+\n+static int show_recursive(const char *base, int baselen, const char *pathname)\n+{\n+\tconst char **s;\n+\n+\tif (ls_options & LS_RECURSIVE)\n+\t\treturn 1;\n+\n+\ts = pathspec;\n+\tif (!s)\n+\t\treturn 0;\n+\n+\tfor (;;) {\n+\t\tconst char *spec = *s++;\n+\t\tint len, speclen;\n+\n+\t\tif (!spec)\n+\t\t\treturn 0;\n+\t\tif (strncmp(base, spec, baselen))\n+\t\t\tcontinue;\n+\t\tlen = strlen(pathname);\n+\t\tspec += baselen;\n+\t\tspeclen = strlen(spec);\n+\t\tif (speclen <= len)\n+\t\t\tcontinue;\n+\t\tif (memcmp(pathname, spec, len))\n+\t\t\tcontinue;\n+\t\treturn 1;\n+\t}\n+}\n \n static int show_tree(unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)\n {\n+\tint retval = 0;\n \tconst char *type = \"blob\";\n \n \tif (S_ISDIR(mode)) {\n-\t\tconst char **s;\n-\t\tif (ls_options & LS_RECURSIVE)\n-\t\t\treturn READ_TREE_RECURSIVE;\n-\t\ts = pathspec;\n-\t\tif (s) {\n-\t\t\tfor (;;) {\n-\t\t\t\tconst char *spec = *s++;\n-\t\t\t\tint len, speclen;\n-\n-\t\t\t\tif (!spec)\n-\t\t\t\t\tbreak;\n-\t\t\t\tif (strncmp(base, spec, baselen))\n-\t\t\t\t\tcontinue;\n-\t\t\t\tlen = strlen(pathname);\n-\t\t\t\tspec += baselen;\n-\t\t\t\tspeclen = strlen(spec);\n-\t\t\t\tif (speclen <= len)\n-\t\t\t\t\tcontinue;\n-\t\t\t\tif (memcmp(pathname, spec, len))\n-\t\t\t\t\tcontinue;\n-\t\t\t\treturn READ_TREE_RECURSIVE;\n-\t\t\t}\n+\t\tif (show_recursive(base, baselen, pathname)) {\n+\t\t\tretval = READ_TREE_RECURSIVE;\n+\t\t\tif (!(ls_options & LS_SHOW_TREES))\n+\t\t\t\treturn retval;\n \t\t}\n \t\ttype = \"tree\";\n \t}\n@@ -51,7 +65,7 @@ static int show_tree(unsigned char *sha1\n \tprintf(\"%06o %s %s\\t\", mode, type, sha1_to_hex(sha1));\n \twrite_name_quoted(base, baselen, pathname, line_termination, stdout);\n \tputchar(line_termination);\n-\treturn 0;\n+\treturn retval;\n }\n \n int main(int argc, const char **argv)\n@@ -73,6 +87,9 @@ int main(int argc, const char **argv)\n \t\tcase 'd':\n \t\t\tls_options |= LS_TREE_ONLY;\n \t\t\tbreak;\n+\t\tcase 't':\n+\t\t\tls_options |= LS_SHOW_TREES;\n+\t\t\tbreak;\n \t\tdefault:\n \t\t\tusage(ls_tree_usage);\n \t\t}\n"},{"id":"13063","messageId":"7vlkz4friv.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"Pine.LNX.4.64.0512011022520.3099@g5.osdl.org","subject":"Re: git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-01T21:15:20Z","receivedAt":"2005-12-01T21:15:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> NOTE! This also means that it will show all trees leading up to that tree. \n\n... which is logical but slightly unexpected.  Also I noticed we\nlost '-d' but still accept it as an option, so...\n\n-- >8 --\n[PATCH]: ls-tree: resurrect '-d' to mean 'show trees only'\n\nWith this:\n\n\tgit-ls-tree -d HEAD -- drivers/net/\n\nshows only immediate subtrees of drivers/net.\n\n\tgit-ls-tree -d -t HEAD -- drivers/net/\n\nshows drivers, drivers/net and immediate subtrees of\ndrivers/net.\n\n\tgit-ls-tree -d -r HEAD -- drivers/net/\n\nshows drivers, drivers/net and all subtrees of drivers/net (but\nnot blobs).\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * The practical value of this patch is dubious, and we might\n   want to simply remove '-d' from the options.  But the output\n   from this looks kind-of nice.  Thoughts?\n\ndiff --git a/ls-tree.c b/ls-tree.c\nindex a2a5eb0..07db863 100644\n--- a/ls-tree.c\n+++ b/ls-tree.c\n@@ -61,6 +61,8 @@ static int show_tree(unsigned char *sha1\n \t\t}\n \t\ttype = \"tree\";\n \t}\n+\telse if (ls_options & LS_TREE_ONLY)\n+\t\treturn 0;\n \n \tprintf(\"%06o %s %s\\t\", mode, type, sha1_to_hex(sha1));\n \twrite_name_quoted(base, baselen, pathname, line_termination, stdout);\n@@ -95,6 +97,10 @@ int main(int argc, const char **argv)\n \t\t}\n \t\targc--; argv++;\n \t}\n+\t/* -d -r should imply -t, but -d by itself should not have to. */\n+\tif ( (LS_TREE_ONLY|LS_RECURSIVE) ==\n+\t    ((LS_TREE_ONLY|LS_RECURSIVE) & ls_options))\n+\t\tls_options |= LS_SHOW_TREES;\n \n \tif (argc < 2)\n \t\tusage(ls_tree_usage);\n"},{"id":"13069","messageId":"Pine.LNX.4.64.0512011354500.3099@g5.osdl.org","threadId":"2718","inReplyTo":"7vlkz4friv.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-12-01T21:57:29Z","receivedAt":"2005-12-01T21:57:29Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 1 Dec 2005, Junio C Hamano wrote:\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n> > NOTE! This also means that it will show all trees leading up to that tree. \n> \n> ... which is logical but slightly unexpected.  Also I noticed we\n> lost '-d' but still accept it as an option, so...\n\nYes. I like the notion of doing\n\n\tgit-ls-tree -r -d HEAD\n\nto get a full list of directories for the project.\n\nThat brings up another issue. I typed\n\n\tgit-ls-tree -r --name-only ..\n\nand it obviously didn't work. That's kind of sad. I use that quite a lot \nfor \"git diff\", for example, because quite often I want to see the files, \nbut I don't care about anything else.\n\nMaybe nobody else uses that \"--name-only\" thing.\n\n\t\tLinus\n"},{"id":"13070","messageId":"7vfypceao8.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"Pine.LNX.4.64.0512011354500.3099@g5.osdl.org","subject":"Re: git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-01T22:04:39Z","receivedAt":"2005-12-01T22:04:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Maybe nobody else uses that \"--name-only\" thing.\n\nI often use --name-status for diff, so that makes me nobody.\n"},{"id":"13075","messageId":"7v8xv4ctp2.fsf_-_@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"Pine.LNX.4.64.0512011354500.3099@g5.osdl.org","subject":"[PATCH] ls-tree: --name-only","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-01T22:56:41Z","receivedAt":"2005-12-01T22:56:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Fingers of some \"git diff\" users are trained to do --name-only\nwhich git-ls-tree unfortunately does not take.  With this,\n\n\tcd sub/directory && git-ls-tree -r --name-only HEAD -- ..\n\nwould show only the paths but not object names nor modes.  I\nthrew in another synonym --name-status only for usability, but\nobviously ls-tree does not do any comparison so what it does is\nthe same as --name-only.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n  Linus Torvalds <torvalds@osdl.org> writes:\n\n  > That brings up another issue. I typed\n  >\n  > \tgit-ls-tree -r --name-only ..\n  >\n  > and it obviously didn't work. That's kind of sad. I use that quite a lot \n  > for \"git diff\", for example, because quite often I want to see the files, \n  > but I don't care about anything else.\n\n ls-tree.c |   13 +++++++++++--\n 1 files changed, 11 insertions(+), 2 deletions(-)\n\nc639a5548a5d8414b55202592885449f66ee2f33\ndiff --git a/ls-tree.c b/ls-tree.c\nindex 07db863..dae377d 100644\n--- a/ls-tree.c\n+++ b/ls-tree.c\n@@ -12,11 +12,12 @@ static int line_termination = '\\n';\n #define LS_RECURSIVE 1\n #define LS_TREE_ONLY 2\n #define LS_SHOW_TREES 4\n+#define LS_NAME_ONLY 8\n static int ls_options = 0;\n const char **pathspec;\n \n static const char ls_tree_usage[] =\n-\t\"git-ls-tree [-d] [-r] [-t] [-z] <tree-ish> [path...]\";\n+\t\"git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] <tree-ish> [path...]\";\n \n static int show_recursive(const char *base, int baselen, const char *pathname)\n {\n@@ -64,7 +65,8 @@ static int show_tree(unsigned char *sha1\n \telse if (ls_options & LS_TREE_ONLY)\n \t\treturn 0;\n \n-\tprintf(\"%06o %s %s\\t\", mode, type, sha1_to_hex(sha1));\n+\tif (!(ls_options & LS_NAME_ONLY))\n+\t\tprintf(\"%06o %s %s\\t\", mode, type, sha1_to_hex(sha1));\n \twrite_name_quoted(base, baselen, pathname, line_termination, stdout);\n \tputchar(line_termination);\n \treturn retval;\n@@ -92,6 +94,13 @@ int main(int argc, const char **argv)\n \t\tcase 't':\n \t\t\tls_options |= LS_SHOW_TREES;\n \t\t\tbreak;\n+\t\tcase '-':\n+\t\t\tif (!strcmp(argv[1]+2, \"name-only\") ||\n+\t\t\t    !strcmp(argv[1]+2, \"name-status\")) {\n+\t\t\t\tls_options |= LS_NAME_ONLY;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\t/* otherwise fallthru */\n \t\tdefault:\n \t\t\tusage(ls_tree_usage);\n \t\t}\n-- \n0.99.9.GIT\n"},{"id":"13090","messageId":"7vacfk9hn6.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"7vmzjljgwo.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's new in git.git master branch","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-02T05:45:17Z","receivedAt":"2005-12-02T05:45:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Fredrik Kuivinen <freku045@student.liu.se> writes:\n>\n>> It turns out that this change breaks the directory/file conflict\n>> handling in git-merge-recursive.\n>>\n>>    git-ls-tree -r -z <tree SHA1>\n>>\n>> Should we do it that way or should ls-tree be changed?\n>\n> Ouch.  Sorry, I should have been more careful.\n\nSo we updated ls-tree to take -t flag which shows tree entries\nunder -r flag.  I'd appreciate if you test the attached patch.\n\n> Also I think I broke the case where base trees need to be merged\n> in 58cce8a8 commit (I changed processEntry not to collapse the\n> index entry when file content changes cannot be automerged, but\n> that change has to be done only for the final merge, and merges\n> between base trees must collapse to be able to write the index\n> file out as a tree).\n\nI think that the above worry was unfounded, because the\nupdateFileExt call I removed to prevent it from collapsing the\nunmerged entries was in effect only in !cacheOnly case\n(i.e. callDepth == 0).\n"},{"id":"13091","messageId":"7v7jao9hln.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"7vmzjljgwo.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's new in git.git master branch","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-02T05:46:12Z","receivedAt":"2005-12-02T05:46:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Fredrik Kuivinen <freku045@student.liu.se> writes:\n>\n>> It turns out that this change breaks the directory/file conflict\n>> handling in git-merge-recursive.\n>>\n>>    git-ls-tree -r -z <tree SHA1>\n>>\n>> Should we do it that way or should ls-tree be changed?\n>\n> Ouch.  Sorry, I should have been more careful.\n\nSo we updated ls-tree to take -t flag which shows tree entries\nunder -r flag.  I'd appreciate if you test the attached patch.\n\n> Also I think I broke the case where base trees need to be merged\n> in 58cce8a8 commit (I changed processEntry not to collapse the\n> index entry when file content changes cannot be automerged, but\n> that change has to be done only for the final merge, and merges\n> between base trees must collapse to be able to write the index\n> file out as a tree).\n\nI think that the above worry was unfounded, because the\nupdateFileExt call I removed to prevent it from collapsing the\nunmerged entries was in effect only in !cacheOnly case\n(i.e. callDepth == 0).\n\n-- >8 --\n[PATCH] merge-recursive: adjust git-ls-tree use for the latest.\n\nYou need to pass -t flag if you want to see tree objects in\n\"git-ls-tree -r\" output these days.  This change broke the tree\nstructure reading code in git-merge-recursive used to detect D/F\nconflicts.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n git-merge-recursive.py |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\na6b51f11ab7f7f838a9b17f81059eebfc36e4c84\ndiff --git a/git-merge-recursive.py b/git-merge-recursive.py\nindex e599b11..b7fb096 100755\n--- a/git-merge-recursive.py\n+++ b/git-merge-recursive.py\n@@ -98,7 +98,7 @@ getFilesRE = re.compile(r'^([0-7]+) (\\S+\n def getFilesAndDirs(tree):\n     files = Set()\n     dirs = Set()\n-    out = runProgram(['git-ls-tree', '-r', '-z', tree])\n+    out = runProgram(['git-ls-tree', '-r', '-z', '-t', tree])\n     for l in out.split('\\0'):\n         m = getFilesRE.match(l)\n         if m:\n-- \n0.99.9.GIT\n"},{"id":"13094","messageId":"20051202083652.GA4824@c165.ib.student.liu.se","threadId":"2718","inReplyTo":"7vmzjljgwo.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's new in git.git master branch","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2005-12-02T08:36:52Z","receivedAt":"2005-12-02T08:36:52Z","isPatch":false,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Thu, Dec 01, 2005 at 01:38:47AM -0800, Junio C Hamano wrote:\n\n> Currently, rename result is recorded by using \"git-update-index\n> --cacheinfo\" to populate the index.  This method unfortunately\n> can only create a stage0 entry.  We can go two ways.  One way is\n> to support \"register this mode/sha1 tuple at stageN for path\" to\n> update-index.  Another would be for merge-recursive to first\n> construct three trees with the final directory structure\n> (i.e. prepare three temporary trees with renames applied) and\n> run read-tree 3-way merge on these temporary trees.  I suspect\n> the former is probably of lesser impact.  Thoughts?\n\nIf we really want to do this then the former is certainly easier from\nthe perspective of git-merge-recursive.\n\n- Fredrik\n"},{"id":"13095","messageId":"20051202084654.GB4824@c165.ib.student.liu.se","threadId":"2718","inReplyTo":"7v7jao9hln.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's new in git.git master branch","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2005-12-02T08:46:54Z","receivedAt":"2005-12-02T08:46:54Z","isPatch":false,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Thu, Dec 01, 2005 at 09:46:12PM -0800, Junio C Hamano wrote:\n> Junio C Hamano <junkio@cox.net> writes:\n> \n> > Fredrik Kuivinen <freku045@student.liu.se> writes:\n> >\n> >> It turns out that this change breaks the directory/file conflict\n> >> handling in git-merge-recursive.\n> >>\n> >>    git-ls-tree -r -z <tree SHA1>\n> >>\n> >> Should we do it that way or should ls-tree be changed?\n> >\n> > Ouch.  Sorry, I should have been more careful.\n> \n> So we updated ls-tree to take -t flag which shows tree entries\n> under -r flag.  I'd appreciate if you test the attached patch.\n\nWith the patch tt works properly again. Thanks :)\n\n> > Also I think I broke the case where base trees need to be merged\n> > in 58cce8a8 commit (I changed processEntry not to collapse the\n> > index entry when file content changes cannot be automerged, but\n> > that change has to be done only for the final merge, and merges\n> > between base trees must collapse to be able to write the index\n> > file out as a tree).\n> \n> I think that the above worry was unfounded, because the\n> updateFileExt call I removed to prevent it from collapsing the\n> unmerged entries was in effect only in !cacheOnly case\n> (i.e. callDepth == 0).\n\nYes, the code is correct. You can apply the following patch to make it\na bit simpler.\n\n- Fredrik\n\n--\nmerge-recursive: Clean up index updates\n\nSigned-off-by: Fredrik Kuivinen <freku045@student.liu.se>\n\n\n---\n\n git-merge-recursive.py |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\n66b1a0157f25629b35ecf300450618a230741218\ndiff --git a/git-merge-recursive.py b/git-merge-recursive.py\nindex b7fb096..4f061da 100755\n--- a/git-merge-recursive.py\n+++ b/git-merge-recursive.py\n@@ -825,10 +825,7 @@ def processEntry(entry, branch1Name, bra\n             cleanMerge = False\n             output('CONFLICT (content): Merge conflict in', path)\n \n-            if cacheOnly:\n-                updateFile(False, sha, mode, path)\n-            else:\n-                updateFileExt(sha, mode, path, updateCache=False, updateWd=True)\n+            updateFile(False, sha, mode, path)\n     else:\n         die(\"ERROR: Fatal merge failure, shouldn't happen.\")\n \n-- \n0.99.9.GIT\n"},{"id":"13120","messageId":"loom.20051202T231110-711@post.gmane.org","threadId":"2718","inReplyTo":"Pine.LNX.4.64.0512011354500.3099@g5.osdl.org","subject":"Re: git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Junio C Hamano","fromEmail":"junkio@twinsun.com","sentAt":"2005-12-02T22:12:09Z","receivedAt":"2005-12-02T22:12:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds <at> osdl.org> writes:\n\n> That brings up another issue. I typed\n> \n> \tgit-ls-tree -r --name-only ..\n> \n> and it obviously didn't work.\n\nThis brings up another issue.  When git-ls-tree works from subdirectory,\ndo we want to see repository-relative paths, or cwd relative paths?\nCurrently we do the latter.\n"},{"id":"13124","messageId":"Pine.LNX.4.64.0512021459380.3099@g5.osdl.org","threadId":"2718","inReplyTo":"loom.20051202T231110-711@post.gmane.org","subject":"Re: git-ls-tree: add \"-t\" option to always show the tree entries","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-12-02T23:11:38Z","receivedAt":"2005-12-02T23:11:38Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 2 Dec 2005, Junio C Hamano wrote:\n> \n> This brings up another issue.  When git-ls-tree works from subdirectory,\n> do we want to see repository-relative paths, or cwd relative paths?\n> Currently we do the latter.\n\nUmm, I'd not say that we do the latter, but yeah, that's broken. We \nactually do _filter_ based on the cwd, but then we show the whole path, \nwhich makes no sense.\n\nSomething like this?\n\n\t\tLinus\n\n---\ndiff --git a/ls-tree.c b/ls-tree.c\nindex dae377d..09dc34d 100644\n--- a/ls-tree.c\n+++ b/ls-tree.c\n@@ -14,6 +14,7 @@ static int line_termination = '\\n';\n #define LS_SHOW_TREES 4\n #define LS_NAME_ONLY 8\n static int ls_options = 0;\n+static int skip_chars = 0;\n const char **pathspec;\n \n static const char ls_tree_usage[] =\n@@ -65,6 +66,12 @@ static int show_tree(unsigned char *sha1\n \telse if (ls_options & LS_TREE_ONLY)\n \t\treturn 0;\n \n+\t/* Normalize to cwd */\n+\tif (baselen < skip_chars)\n+\t\treturn retval;\n+\tbase += skip_chars;\n+\tbaselen -= skip_chars;\n+\n \tif (!(ls_options & LS_NAME_ONLY))\n \t\tprintf(\"%06o %s %s\\t\", mode, type, sha1_to_hex(sha1));\n \twrite_name_quoted(base, baselen, pathname, line_termination, stdout);\n@@ -116,6 +123,9 @@ int main(int argc, const char **argv)\n \tif (get_sha1(argv[1], sha1) < 0)\n \t\tusage(ls_tree_usage);\n \n+\n+\tif (prefix)\n+\t\tskip_chars = strlen(prefix);\n \tpathspec = get_pathspec(prefix, argv + 2);\n \tbuf = read_object_with_reference(sha1, \"tree\", &size, NULL);\n \tif (!buf)\n"},{"id":"13311","messageId":"7vr78pted6.fsf@assigned-by-dhcp.cox.net","threadId":"2718","inReplyTo":"20051202083652.GA4824@c165.ib.student.liu.se","subject":"[PATCH 3/3] update-index: allow --index-info to add higher stages.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-07T10:01:41Z","receivedAt":"2005-12-07T10:01:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The new merge world order tells the merge strategies to leave\nthe cache unmerged and store the automerge result in the working\ntree if automerge is not clean.  This was done for the resolve\nstrategy and recursive strategy when no rename is involved, but\nrecording a conflicting merge in the rename case could not\neasily be done by the recursive strategy.\n\nThis commit adds a new input format, in addition to the exsting\ntwo, to \"update-index --index-info\".\n\n    (1) mode         SP sha1          TAB path\n    The first format is what \"git-apply --index-info\"\n    reports, and used to reconstruct a partial tree\n    that is used for phony merge base tree when falling\n    back on 3-way merge.\n\n    (2) mode SP type SP sha1          TAB path\n    The second format is to stuff git-ls-tree output\n    into the index file.\n\n    (3) mode         SP sha1 SP stage TAB path\n    This format is to put higher order stages into the\n    index file and matches git-ls-files --stage output.\n\nTo place a higher stage entry to the index, the path should\nfirst be removed by feeding a mode=0 entry for the path, and\nthen feeding necessary input lines in the (3) format.\n\nFor example, starting with this index:\n\n$ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz\n\n$ git update-index --index-info ;# interactive session -- input follows...\n\n0 0000000000000000000000000000000000000000\tfrotz\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz\n\nThe first line of the input feeds 0 as the mode to remove the\npath; the SHA1 does not matter as long as it is well formatted.\nThen the second and third line feeds stage 1 and stage 2 entries\nfor that path.  After the above, we would end up with this:\n\n$ git ls-files -s\n100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz\n\nThis completes the groundwork for the new merge world order.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n Documentation/git-update-index.txt |   57 +++++++++++++++++++++++++++++++++\n update-index.c                     |   63 ++++++++++++++++++++++++++----------\n 2 files changed, 103 insertions(+), 17 deletions(-)\n\nd23748a6af3e3db2b239090553f92c3a779b3578\ndiff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt\nindex e4678cd..c74311d 100644\n--- a/Documentation/git-update-index.txt\n+++ b/Documentation/git-update-index.txt\n@@ -136,6 +136,63 @@ in the database but the file isn't avail\n useful when the file is available, but you do not wish to update the\n object database.\n \n+\n+Using --index-info\n+------------------\n+\n+`--index-info` is a more powerful mechanism that lets you feed\n+multiple entry definitions from the standard input, and designed\n+specifically for scripts.  It can take inputs of three formats:\n+\n+    . mode         SP sha1          TAB path\n++\n+The first format is what \"git-apply --index-info\"\n+reports, and used to reconstruct a partial tree\n+that is used for phony merge base tree when falling\n+back on 3-way merge.\n+\n+    . mode SP type SP sha1          TAB path\n++\n+The second format is to stuff git-ls-tree output\n+into the index file.\n+\n+    . mode         SP sha1 SP stage TAB path\n++\n+This format is to put higher order stages into the\n+index file and matches git-ls-files --stage output.\n+\n+To place a higher stage entry to the index, the path should\n+first be removed by feeding a mode=0 entry for the path, and\n+then feeding necessary input lines in the third format.\n+\n+For example, starting with this index:\n+\n+------------\n+$ git ls-files -s\n+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 0       frotz\n+------------\n+\n+you can feed the following input to `--index-info`:\n+\n+------------\n+$ git update-index --index-info\n+0 0000000000000000000000000000000000000000\tfrotz\n+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n+100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz\n+------------\n+\n+The first line of the input feeds 0 as the mode to remove the\n+path; the SHA1 does not matter as long as it is well formatted.\n+Then the second and third line feeds stage 1 and stage 2 entries\n+for that path.  After the above, we would end up with this:\n+\n+------------\n+$ git ls-files -s\n+100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1\tfrotz\n+100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2\tfrotz\n+------------\n+\n+\n Examples\n --------\n To update and refresh only the files already checked out:\ndiff --git a/update-index.c b/update-index.c\nindex 11b7f6a..be87b99 100644\n--- a/update-index.c\n+++ b/update-index.c\n@@ -256,35 +256,30 @@ inside:\n \t}\n }\n \n-static int add_cacheinfo(const char *arg1, const char *arg2, const char *arg3)\n+static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,\n+\t\t\t const char *path, int stage)\n {\n \tint size, len, option;\n-\tunsigned int mode;\n-\tunsigned char sha1[20];\n \tstruct cache_entry *ce;\n \n-\tif (sscanf(arg1, \"%o\", &mode) != 1)\n-\t\treturn -1;\n-\tif (get_sha1_hex(arg2, sha1))\n-\t\treturn -1;\n-\tif (!verify_path(arg3))\n+\tif (!verify_path(path))\n \t\treturn -1;\n \n-\tlen = strlen(arg3);\n+\tlen = strlen(path);\n \tsize = cache_entry_size(len);\n \tce = xmalloc(size);\n \tmemset(ce, 0, size);\n \n \tmemcpy(ce->sha1, sha1, 20);\n-\tmemcpy(ce->name, arg3, len);\n-\tce->ce_flags = htons(len);\n+\tmemcpy(ce->name, path, len);\n+\tce->ce_flags = create_ce_flags(len, stage);\n \tce->ce_mode = create_ce_mode(mode);\n \toption = allow_add ? ADD_CACHE_OK_TO_ADD : 0;\n \toption |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0;\n \tif (add_cache_entry(ce, option))\n \t\treturn error(\"%s: cannot add to the index - missing --add option?\",\n-\t\t\t     arg3);\n-\treport(\"add '%s'\", arg3);\n+\t\t\t     path);\n+\treport(\"add '%s'\", path);\n \treturn 0;\n }\n \n@@ -342,7 +337,24 @@ static void read_index_info(int line_ter\n \t\tchar *path_name;\n \t\tunsigned char sha1[20];\n \t\tunsigned int mode;\n+\t\tint stage;\n \n+\t\t/* This reads lines formatted in one of three formats:\n+\t\t *\n+\t\t * (1) mode         SP sha1          TAB path\n+\t\t * The first format is what \"git-apply --index-info\"\n+\t\t * reports, and used to reconstruct a partial tree\n+\t\t * that is used for phony merge base tree when falling\n+\t\t * back on 3-way merge.\n+\t\t *\n+\t\t * (2) mode SP type SP sha1          TAB path\n+\t\t * The second format is to stuff git-ls-tree output\n+\t\t * into the index file.\n+\t\t * \n+\t\t * (3) mode         SP sha1 SP stage TAB path\n+\t\t * This format is to put higher order stages into the\n+\t\t * index file and matches git-ls-files --stage output.\n+\t\t */\n \t\tread_line(&buf, stdin, line_termination);\n \t\tif (buf.eof)\n \t\t\tbreak;\n@@ -354,9 +366,19 @@ static void read_index_info(int line_ter\n \t\ttab = strchr(ptr, '\\t');\n \t\tif (!tab || tab - ptr < 41)\n \t\t\tgoto bad_line;\n+\n+\t\tif (tab[-2] == ' ' && '1' <= tab[-1] && tab[-1] <= '3') {\n+\t\t\tstage = tab[-1] - '0';\n+\t\t\tptr = tab + 1; /* point at the head of path */\n+\t\t\ttab = tab - 2; /* point at tail of sha1 */\n+\t\t}\n+\t\telse {\n+\t\t\tstage = 0;\n+\t\t\tptr = tab + 1; /* point at the head of path */\n+\t\t}\n+\n \t\tif (get_sha1_hex(tab - 40, sha1) || tab[-41] != ' ')\n \t\t\tgoto bad_line;\n-\t\tptr = tab + 1;\n \n \t\tif (line_termination && ptr[0] == '\"')\n \t\t\tpath_name = unquote_c_style(ptr, NULL);\n@@ -382,7 +404,7 @@ static void read_index_info(int line_ter\n \t\t\t * ptr[-41] is at the beginning of sha1\n \t\t\t */\n \t\t\tptr[-42] = ptr[-1] = 0;\n-\t\t\tif (add_cacheinfo(buf.buf, ptr-41, path_name))\n+\t\t\tif (add_cacheinfo(mode, sha1, path_name, stage))\n \t\t\t\tdie(\"git-update-index: unable to update %s\",\n \t\t\t\t    path_name);\n \t\t}\n@@ -449,10 +471,17 @@ int main(int argc, const char **argv)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(path, \"--cacheinfo\")) {\n+\t\t\t\tunsigned char sha1[20];\n+\t\t\t\tunsigned int mode;\n+\n \t\t\t\tif (i+3 >= argc)\n \t\t\t\t\tdie(\"git-update-index: --cacheinfo <mode> <sha1> <path>\");\n-\t\t\t\tif (add_cacheinfo(argv[i+1], argv[i+2], argv[i+3]))\n-\t\t\t\t\tdie(\"git-update-index: --cacheinfo cannot add %s\", argv[i+3]);\n+\n+\t\t\t\tif ((sscanf(argv[i+1], \"%o\", &mode) != 1) ||\n+\t\t\t\t    get_sha1_hex(argv[i+2], sha1) ||\n+\t\t\t\t    add_cacheinfo(mode, sha1, argv[i+3], 0))\n+\t\t\t\t\tdie(\"git-update-index: --cacheinfo\"\n+\t\t\t\t\t    \" cannot add %s\", argv[i+3]);\n \t\t\t\ti += 3;\n \t\t\t\tcontinue;\n \t\t\t}\n-- \n0.99.9.GIT\n"}]}