{"thread":{"id":"46830","subject":"git ls-tree -d doesn't work if the specified path is the repository root?","startedAt":"2017-09-25T19:14:34Z","lastAt":"2017-09-25T22:26:20Z","messageCount":3,"participants":["Roy Wellington","Santiago Torres","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"328867","messageId":"CAF5E6=pqGZt_BUDRDeN2uAQK7qBTeO+zcR8NsvSPg-rLjbsqdQ@mail.gmail.com","threadId":"46830","inReplyTo":null,"subject":"git ls-tree -d doesn't work if the specified path is the repository root?","fromName":"Roy Wellington","fromEmail":"deathanatos@gmail.com","sentAt":"2017-09-25T19:14:28Z","receivedAt":"2017-09-25T19:14:34Z","isPatch":false,"sender":{"key":"deathanatos@gmail.com","avatar":null},"body":"Hi,\n\nWhen I run `git ls-tree -d HEAD -- subdir` from the root of my\nrepository, where `subdir` is a subdirectory in that root, I get the\ntreehash of that subdirectory. This is what I expect.\n\nHowever, if I merely replace `subdir` with `.` (the root of the\nrepository), (i.e., `git ls-tree -d HEAD -- .`) git ls-tree returns\nthe treehashes of the /children/ of the root, instead of the root\nitself, contrary to the documented behavior of -d.\n\nIs there some reason for this? This behavior seems like a bug to me:\nit means that prior to calling ls-tree I need to check if the\nreferenced path happens to be the root, and if so, find some other\nmeans (rev-parse?) of converting it to a treehash.\n\nThanks,\n—Roy\n"},{"id":"328869","messageId":"20170925192204.hmhgejhzsj6phqlg@LykOS.localdomain","threadId":"46830","inReplyTo":"CAF5E6=pqGZt_BUDRDeN2uAQK7qBTeO+zcR8NsvSPg-rLjbsqdQ@mail.gmail.com","subject":"Re: git ls-tree -d doesn't work if the specified path is the repository root?","fromName":"Santiago Torres","fromEmail":"santiago@nyu.edu","sentAt":"2017-09-25T19:22:08Z","receivedAt":"2017-09-25T19:22:05Z","isPatch":false,"sender":{"key":"santiago@nyu.edu","avatar":"https://avatars.githubusercontent.com/u/3579933?v=4"},"body":" \n> Is there some reason for this? This behavior seems like a bug to me:\n> it means that prior to calling ls-tree I need to check if the\n> referenced path happens to be the root, and if so, find some other\n> means (rev-parse?) of converting it to a treehash.\n\nHmm, interesting.\n\nI see these four behaviors:\n\n[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- src\n    040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3    src\n\n[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- src/\n    040000 tree 767beaaf0927f89e630c52830b6fbac138ec039a    src/bg_daemon\n\n[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- .\n    040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3    src\n    040000 tree de12675d1023b1e743f7e11c2276fc417b3650a6    tests\n\n[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- ./\n    040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3    src\n    040000 tree de12675d1023b1e743f7e11c2276fc417b3650a6    tests\n\nIMHO, I think it'd be more consistent if . returned the root treehash and ./\nreturned the treehash of the directories in root.\n\nI don't personally know if there is a reason for this...\n\nThanks,\n-Santiago.\n\n> \n> Thanks,\n> —Roy\n"},{"id":"328891","messageId":"20170925222556.GH27425@aiede.mtv.corp.google.com","threadId":"46830","inReplyTo":"CAF5E6=pqGZt_BUDRDeN2uAQK7qBTeO+zcR8NsvSPg-rLjbsqdQ@mail.gmail.com","subject":"Re: git ls-tree -d doesn't work if the specified path is the repository root?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-09-25T22:25:56Z","receivedAt":"2017-09-25T22:26:20Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nRoy Wellington wrote:\n\n> When I run `git ls-tree -d HEAD -- subdir` from the root of my\n> repository, where `subdir` is a subdirectory in that root, I get the\n> treehash of that subdirectory. This is what I expect.\n>\n> However, if I merely replace `subdir` with `.` (the root of the\n> repository), (i.e., `git ls-tree -d HEAD -- .`) git ls-tree returns\n> the treehashes of the /children/ of the root, instead of the root\n> itself, contrary to the documented behavior of -d.\n\nCan you be more specific?  What documentation led you to this\nexpectation?\n\nI don't have a strong opinion about this behavior, but in any case if\nthe documentation and command disagree about the correct behavior then\none of them needs to be fixed. :)\n\n> Is there some reason for this? This behavior seems like a bug to me:\n> it means that prior to calling ls-tree I need to check if the\n> referenced path happens to be the root, and if so, find some other\n> means (rev-parse?) of converting it to a treehash.\n\nDoes\n\n\tgit rev-parse HEAD:subdir\n\nwork better for what you're trying to accomplish?  To get the root of\nthe repository, you can use\n\n\tgit rev-parse HEAD:\n\nThanks and hope that helps,\nJonathan\n"}]}