* git ls-tree -d doesn't work if the specified path is the repository root?
@ 2017-09-25 19:14 Roy Wellington
2017-09-25 19:22 ` Santiago Torres
2017-09-25 22:25 ` Jonathan Nieder
0 siblings, 2 replies; 3+ messages in thread
From: Roy Wellington @ 2017-09-25 19:14 UTC (permalink / raw)
To: git
Hi,
When I run `git ls-tree -d HEAD -- subdir` from the root of my
repository, where `subdir` is a subdirectory in that root, I get the
treehash of that subdirectory. This is what I expect.
However, if I merely replace `subdir` with `.` (the root of the
repository), (i.e., `git ls-tree -d HEAD -- .`) git ls-tree returns
the treehashes of the /children/ of the root, instead of the root
itself, contrary to the documented behavior of -d.
Is there some reason for this? This behavior seems like a bug to me:
it means that prior to calling ls-tree I need to check if the
referenced path happens to be the root, and if so, find some other
means (rev-parse?) of converting it to a treehash.
Thanks,
—Roy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git ls-tree -d doesn't work if the specified path is the repository root?
2017-09-25 19:14 git ls-tree -d doesn't work if the specified path is the repository root? Roy Wellington
@ 2017-09-25 19:22 ` Santiago Torres
2017-09-25 22:25 ` Jonathan Nieder
1 sibling, 0 replies; 3+ messages in thread
From: Santiago Torres @ 2017-09-25 19:22 UTC (permalink / raw)
To: Roy Wellington; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1191 bytes --]
> Is there some reason for this? This behavior seems like a bug to me:
> it means that prior to calling ls-tree I need to check if the
> referenced path happens to be the root, and if so, find some other
> means (rev-parse?) of converting it to a treehash.
Hmm, interesting.
I see these four behaviors:
[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- src
040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3 src
[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- src/
040000 tree 767beaaf0927f89e630c52830b6fbac138ec039a src/bg_daemon
[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- .
040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3 src
040000 tree de12675d1023b1e743f7e11c2276fc417b3650a6 tests
[santiago@LykOS bg_daemon]$ git ls-tree -d HEAD -- ./
040000 tree 238a62ca62527423fd3190d00917ddfef0d254a3 src
040000 tree de12675d1023b1e743f7e11c2276fc417b3650a6 tests
IMHO, I think it'd be more consistent if . returned the root treehash and ./
returned the treehash of the directories in root.
I don't personally know if there is a reason for this...
Thanks,
-Santiago.
>
> Thanks,
> —Roy
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git ls-tree -d doesn't work if the specified path is the repository root?
2017-09-25 19:14 git ls-tree -d doesn't work if the specified path is the repository root? Roy Wellington
2017-09-25 19:22 ` Santiago Torres
@ 2017-09-25 22:25 ` Jonathan Nieder
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2017-09-25 22:25 UTC (permalink / raw)
To: Roy Wellington; +Cc: git
Hi,
Roy Wellington wrote:
> When I run `git ls-tree -d HEAD -- subdir` from the root of my
> repository, where `subdir` is a subdirectory in that root, I get the
> treehash of that subdirectory. This is what I expect.
>
> However, if I merely replace `subdir` with `.` (the root of the
> repository), (i.e., `git ls-tree -d HEAD -- .`) git ls-tree returns
> the treehashes of the /children/ of the root, instead of the root
> itself, contrary to the documented behavior of -d.
Can you be more specific? What documentation led you to this
expectation?
I don't have a strong opinion about this behavior, but in any case if
the documentation and command disagree about the correct behavior then
one of them needs to be fixed. :)
> Is there some reason for this? This behavior seems like a bug to me:
> it means that prior to calling ls-tree I need to check if the
> referenced path happens to be the root, and if so, find some other
> means (rev-parse?) of converting it to a treehash.
Does
git rev-parse HEAD:subdir
work better for what you're trying to accomplish? To get the root of
the repository, you can use
git rev-parse HEAD:
Thanks and hope that helps,
Jonathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-25 22:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 19:14 git ls-tree -d doesn't work if the specified path is the repository root? Roy Wellington
2017-09-25 19:22 ` Santiago Torres
2017-09-25 22:25 ` Jonathan Nieder
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.