Re: git-grep to operate across who repository and not just CWD?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Jay Soffian <jaysoffian@xxxxxxxxx> writes:
>
>> I had the crazy thought that if git had a --cdup option, then this
>> would work with any command you wanted to run from the top:
>>
>>   git --cdup grep ...
>>
>> Maybe that's the best way to expose "from the top please" generically?
>
> We tend to give --full-tree option to individual subcommands where it
> makes sense to get the same effect.
>
> One problem with a global "git --cdup" is ...

Having said all that, here is a tip of the day.  I have this in my .bashrc
for interactive shells.

        cdup () {
                local eh
                eh=$(git rev-parse --is-inside-work-tree) || return
                case "$eh" in
                true)
                        eh=$(git rev-parse --show-toplevel)
                        test -z "$eh" || cd "$eh"
                        ;;
                false)
                        eh=$(git rev-parse --git-dir) || return
                        cd "$eh" || return
                        eh=$(git rev-parse --is-bare-repository) || return
                        test "z$eh" = ztrue || cd ..
                        ;;
                esac
        }

and I can say

	$ cd Documentation/howto
        $ editor *.txt
        $ cdup

to come back to the toplevel after having worked somewhere deep in the
mine.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]