In some rebases, `exec git -C ...` has wrong working directory

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

 



Here is a repro script:

    #!/bin/sh
    set -eux
    git --version
    tmpdir="$(mktemp -d)"
    cd "${tmpdir}"
    mkdir target repo
    cd repo
    git init
    touch file; git add file
    git commit -m "Initial commit"
    git rebase HEAD --exec "git -C ${tmpdir}/target init"

The end of this script prints something like

    Executing: git -C /tmp/tmp.gd2q51jO93/target init
    Reinitialized existing Git repository in /tmp/tmp.gd2q51jO93/repo/.git/
    Successfully rebased and updated refs/heads/master.

But this is wrong: the repository should be initialized in `target`, not
reinitialized in `repo`.

Notes:

  - This propagates to subprocesses: if you run `exec make test` and
    your test suite ends up calling `git -C`, then the same problem
    occurs.

  - Substituting `rebase --root` for `rebase HEAD` causes the problem to
    go away.

  - The `rebase HEAD` exec context adds the `GIT_DIR` environment
    variable, and this is sufficient to reproduce the problem:
    running `GIT_DIR="$PWD" git -C /tmp/target init` puts the repo in
    the current working directory. The `rebase --root` context adds no
    such environment variable. (You can use `--exec 'env >tempfile'` to
    verify these.)

My `git --version` is 2.16.2.



[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]

  Powered by Linux