diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py
index 631f84744..9c18b216e 100644
--- a/dvc/scm/git/__init__.py
+++ b/dvc/scm/git/__init__.py
@@ -212,11 +212,7 @@ class Git(Base):
         return [t.name for t in self.repo.tags]
 
     def _install_hook(self, name, cmd):
-        command = (
-            '[ "$3" == "0" ]'
-            ' || [ -z "$(git ls-files .dvc)" ]'
-            " || exec dvc {}".format(cmd)
-        )
+        command = '[ -z "$(git ls-files .dvc)" ] || exec dvc {}'.format(cmd)
 
         hook = os.path.join(self.root_dir, self.GIT_DIR, "hooks", name)
 

local variable 'old_handler' referenced before assignment
**Please provide information about your setup**
DVC version(i.e. `dvc --version`), Platform and method of installation (pip, homebrew, pkg Mac, exe (Windows), DEB(Linux), RPM(Linux))

dvc version: 0.55.0 on macos via homebrew cask

![Screen Shot 2019-08-19 at 3 31 14 AM](https://user-images.githubusercontent.com/2790092/63246986-e3a5f100-c231-11e9-8f96-0fcd9c77ba9e.png)

diff --git a/tests/func/test_install.py b/tests/func/test_install.py
index 1ff4ca23a..140e0b5d5 100644
--- a/tests/func/test_install.py
+++ b/tests/func/test_install.py
@@ -39,9 +39,7 @@ class TestInstall(object):
         expected_script = (
             "#!/bin/sh\n"
             "echo hello\n"
-            '[ "$3" == "0" ]'
-            ' || [ -z "$(git ls-files .dvc)" ]'
-            " || exec dvc checkout\n"
+            '[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
         )
 
         with open(self._hook("post-checkout"), "r") as fobj:
@@ -53,9 +51,7 @@ class TestInstall(object):
 
         expected_script = (
             "#!/bin/sh\n"
-            '[ "$3" == "0" ]'
-            ' || [ -z "$(git ls-files .dvc)" ]'
-            " || exec dvc checkout\n"
+            '[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
         )
 
         with open(self._hook("post-checkout"), "r") as fobj:
diff --git a/tests/func/test_run.py b/tests/func/test_run.py
index 8ff535915..383a4204a 100644
--- a/tests/func/test_run.py
+++ b/tests/func/test_run.py
@@ -5,9 +5,6 @@ import logging
 import mock
 import shutil
 import filecmp
-import subprocess
-import signal
-import threading
 import pytest
 
 from dvc.main import main
@@ -272,66 +269,6 @@ class TestRunBadName(TestDvc):
             )
 
 
-@pytest.mark.skipif(
-    not isinstance(threading.current_thread(), threading._MainThread),
-    reason="Not running in the main thread.",
-)
-@mock.patch.object(subprocess.Popen, "wait", new=KeyboardInterrupt)
-def test_keyboard_interrupt(repo_dir, dvc_repo):
-    assert (
-        main(
-            [
-                "run",
-                "-d",
-                repo_dir.FOO,
-                "-d",
-                repo_dir.CODE,
-                "-o",
-                "out",
-                "-f",
-                "out.dvc",
-                "python",
-                repo_dir.CODE,
-                repo_dir.FOO,
-                "out",
-            ]
-        )
-        == 1
-    )
-
-
-@pytest.mark.skipif(
-    not isinstance(threading.current_thread(), threading._MainThread),
-    reason="Not running in the main thread.",
-)
-def test_keyboard_interrupt_after_second_signal_call(
-    mocker, repo_dir, dvc_repo
-):
-    mocker.patch.object(
-        signal, "signal", side_effect=[None, KeyboardInterrupt]
-    )
-    assert (
-        main(
-            [
-                "run",
-                "-d",
-                repo_dir.FOO,
-                "-d",
-                repo_dir.CODE,
-                "-o",
-                "out",
-                "-f",
-                "out.dvc",
-                "python",
-                repo_dir.CODE,
-                repo_dir.FOO,
-                "out",
-            ]
-        )
-        == 252
-    )
-
-
 class TestRunRemoveOuts(TestDvc):
     def test(self):
         with open(self.CODE, "w+") as fobj:
diff --git a/tests/unit/test_stage.py b/tests/unit/test_stage.py
index a477059a8..41460f9e6 100644
--- a/tests/unit/test_stage.py
+++ b/tests/unit/test_stage.py
@@ -2,6 +2,10 @@ from dvc.path_info import PathInfo
 from dvc.stage import Stage, StageUpdateError
 from dvc.dependency.repo import DependencyREPO
 
+import signal
+import threading
+import subprocess
+
 import mock
 import pytest
 from unittest import TestCase
@@ -82,3 +86,24 @@ def test_stage_update(mocker):
     is_repo_import.return_value = False
     with pytest.raises(StageUpdateError):
         stage.update()
+
+
+@pytest.mark.skipif(
+    not isinstance(threading.current_thread(), threading._MainThread),
+    reason="Not running in the main thread.",
+)
+def test_stage_run_ignore_sigint(mocker):
+    stage = Stage(None, "path")
+
+    proc = mocker.Mock()
+    communicate = mocker.Mock()
+    proc.configure_mock(returncode=0, communicate=communicate)
+    popen = mocker.patch.object(subprocess, "Popen", return_value=proc)
+    signal_mock = mocker.patch("signal.signal")
+
+    stage._run()
+
+    assert popen.called_once()
+    assert communicate.called_once_with()
+    signal_mock.assert_any_call(signal.SIGINT, signal.SIG_IGN)
+    assert signal.getsignal(signal.SIGINT) == signal.default_int_handler

pip install -e .[all]
parse_log_pytest
pytest
pytest pytest-timeout pytest-cov pytest-xdist pytest-mock flaky mock xmltodict awscli google-compute-engine Pygments collective.checkdocs flake8 psutil flake8-docstrings pydocstyle jaraco.windows mock-ssh-server moto rangehttpserver
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aliyun-python-sdk-core==2.16.0
aliyun-python-sdk-core-v3==2.13.33
aliyun-python-sdk-kms==2.16.5
appdirs==1.4.4
asciimatics==1.14.0
attrs @ file:///croot/attrs_1668696182826/work
autocommand==2.2.2
awscli==1.31.13
azure-common==1.1.28
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
bcrypt==4.2.1
boto==2.49.0
boto3==1.9.115
botocore==1.12.253
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
collective.checkdocs==0.2
colorama==0.4.4
configobj==5.0.9
configparser==5.3.0
coverage==7.2.7
crcmod==1.7
cryptography==44.0.2
distro==1.9.0
docutils==0.15.2
-e git+https://github.com/iterative/dvc.git@239739d6e1235c22215ce822f0d5300049339e44#egg=dvc
execnet==2.0.2
flake8==5.0.4
flake8-docstrings==1.7.0
flaky==3.8.1
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
funcy==2.0
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==1.34.1
google-auth==2.38.0
google-cloud-core==0.28.1
google-cloud-storage==1.13.0
google-compute-engine==2.8.13
google-crc32c==1.5.0
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
humanize==4.6.0
idna==3.10
importlib-metadata==4.2.0
importlib-resources==5.12.0
inflect==6.0.5
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
jaraco.classes==3.2.3
jaraco.collections==4.2.0
jaraco.context==4.3.0
jaraco.functools==3.7.0
jaraco.structures==2.1.0
jaraco.text==3.11.1
jaraco.ui==2.3.0
jaraco.windows==5.7.0
Jinja2==3.1.6
jmespath==0.10.0
jsonpath-ng==1.7.0
MarkupSafe==2.1.5
mccabe==0.7.0
mock==5.2.0
mock-ssh-server==0.9.1
more-itertools==9.1.0
moto==4.2.14
nanotime==0.5.2
networkx==2.6.3
numpy==1.21.6
oss2==2.6.1
packaging @ file:///croot/packaging_1671697413597/work
paramiko==3.5.1
path==16.6.0
pathspec==0.11.2
Pillow==9.5.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
ply==3.11
protobuf==3.20.3
psutil==7.0.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyarrow==0.14.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pycparser==2.21
pycryptodome==3.22.0
pydantic==1.10.21
pydocstyle==6.3.0
pyfiglet==0.8.post1
pyflakes==2.5.0
Pygments==2.17.2
PyNaCl==1.5.0
pyparsing==3.1.4
pytest==7.1.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-timeout==2.3.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
PyYAML==6.0.1
rangehttpserver==1.4.0
requests==2.31.0
responses==0.23.3
rsa==4.7.2
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.8
s3transfer==0.2.1
schema==0.7.7
shortuuid==1.0.13
six==1.17.0
smmap==5.0.2
snowballstemmer==2.2.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
treelib==1.7.1
types-PyYAML==6.0.12.12
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
urllib3==1.25.11
wcwidth==0.2.13
Werkzeug==2.2.3
xmltodict==0.14.2
zc.lockfile==3.0.post1
zipp @ file:///croot/zipp_1672387121353/work

name: dvc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aliyun-python-sdk-core==2.16.0
      - aliyun-python-sdk-core-v3==2.13.33
      - aliyun-python-sdk-kms==2.16.5
      - appdirs==1.4.4
      - asciimatics==1.14.0
      - autocommand==2.2.2
      - awscli==1.31.13
      - azure-common==1.1.28
      - azure-storage-blob==2.1.0
      - azure-storage-common==2.1.0
      - bcrypt==4.2.1
      - boto==2.49.0
      - boto3==1.9.115
      - botocore==1.12.253
      - cachetools==5.5.2
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - collective-checkdocs==0.2
      - colorama==0.4.4
      - configobj==5.0.9
      - configparser==5.3.0
      - coverage==7.2.7
      - crcmod==1.7
      - cryptography==44.0.2
      - distro==1.9.0
      - docutils==0.15.2
      - dvc==0.55.0
      - execnet==2.0.2
      - flake8==5.0.4
      - flake8-docstrings==1.7.0
      - flaky==3.8.1
      - funcy==2.0
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-api-core==1.34.1
      - google-auth==2.38.0
      - google-cloud-core==0.28.1
      - google-cloud-storage==1.13.0
      - google-compute-engine==2.8.13
      - google-crc32c==1.5.0
      - google-resumable-media==2.7.2
      - googleapis-common-protos==1.69.2
      - grandalf==0.6
      - humanize==4.6.0
      - idna==3.10
      - importlib-metadata==4.2.0
      - importlib-resources==5.12.0
      - inflect==6.0.5
      - jaraco-classes==3.2.3
      - jaraco-collections==4.2.0
      - jaraco-context==4.3.0
      - jaraco-functools==3.7.0
      - jaraco-structures==2.1.0
      - jaraco-text==3.11.1
      - jaraco-ui==2.3.0
      - jaraco-windows==5.7.0
      - jinja2==3.1.6
      - jmespath==0.10.0
      - jsonpath-ng==1.7.0
      - markupsafe==2.1.5
      - mccabe==0.7.0
      - mock==5.2.0
      - mock-ssh-server==0.9.1
      - more-itertools==9.1.0
      - moto==4.2.14
      - nanotime==0.5.2
      - networkx==2.6.3
      - numpy==1.21.6
      - oss2==2.6.1
      - paramiko==3.5.1
      - path==16.6.0
      - pathspec==0.11.2
      - pillow==9.5.0
      - ply==3.11
      - protobuf==3.20.3
      - psutil==7.0.0
      - pyarrow==0.14.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pycryptodome==3.22.0
      - pydantic==1.10.21
      - pydocstyle==6.3.0
      - pyfiglet==0.8.post1
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pynacl==1.5.0
      - pyparsing==3.1.4
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-timeout==2.3.1
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.1
      - rangehttpserver==1.4.0
      - requests==2.31.0
      - responses==0.23.3
      - rsa==4.7.2
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.8
      - s3transfer==0.2.1
      - schema==0.7.7
      - shortuuid==1.0.13
      - six==1.17.0
      - smmap==5.0.2
      - snowballstemmer==2.2.0
      - treelib==1.7.1
      - types-pyyaml==6.0.12.12
      - urllib3==1.25.11
      - wcwidth==0.2.13
      - werkzeug==2.2.3
      - xmltodict==0.14.2
      - zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc

tests/func/test_install.py::TestInstall::test_should_append_hooks_if_file_already_exists tests/func/test_install.py::TestInstall::test_should_be_idempotent
tests/func/test_run.py::TestRunUnprotectOutsCopy::test tests/func/test_run.py::TestRunUnprotectOutsSymlink::test tests/func/test_run.py::TestRunUnprotectOutsHardlink::test tests/unit/test_stage.py::TestPathConversion::test
tests/func/test_install.py::TestInstall::test_should_create_hooks tests/func/test_install.py::TestInstall::test_should_post_checkout_hook_checkout tests/func/test_install.py::TestInstall::test_should_pre_push_hook_push tests/func/test_run.py::TestRun::test tests/func/test_run.py::TestRunEmpty::test tests/func/test_run.py::TestRunMissingDep::test tests/func/test_run.py::TestRunBadStageFilename::test tests/func/test_run.py::TestRunNoExec::test tests/func/test_run.py::TestRunCircularDependency::test tests/func/test_run.py::TestRunCircularDependency::test_graph tests/func/test_run.py::TestRunCircularDependency::test_non_normalized_paths tests/func/test_run.py::TestRunCircularDependency::test_outs_no_cache tests/func/test_run.py::TestRunDuplicatedArguments::test tests/func/test_run.py::TestRunDuplicatedArguments::test_non_normalized_paths tests/func/test_run.py::TestRunDuplicatedArguments::test_outs_no_cache tests/func/test_run.py::TestRunStageInsideOutput::test_cwd tests/func/test_run.py::TestRunStageInsideOutput::test_file_name tests/func/test_run.py::TestRunBadCwd::test tests/func/test_run.py::TestRunBadCwd::test_same_prefix tests/func/test_run.py::TestRunBadWdir::test tests/func/test_run.py::TestRunBadWdir::test_not_dir tests/func/test_run.py::TestRunBadWdir::test_not_found tests/func/test_run.py::TestRunBadWdir::test_same_prefix tests/func/test_run.py::TestRunBadName::test tests/func/test_run.py::TestRunBadName::test_not_found tests/func/test_run.py::TestRunBadName::test_same_prefix tests/func/test_run.py::TestRunRemoveOuts::test tests/func/test_run.py::TestCmdRunOverwrite::test tests/func/test_run.py::TestCmdRunCliMetrics::test_cached tests/func/test_run.py::TestCmdRunCliMetrics::test_not_cached tests/func/test_run.py::TestCmdRunWorkingDirectory::test_cwd_is_ignored tests/func/test_run.py::TestCmdRunWorkingDirectory::test_default_wdir_is_written tests/func/test_run.py::TestCmdRunWorkingDirectory::test_fname_changes_path_and_wdir tests/func/test_run.py::test_run_deterministic tests/func/test_run.py::test_run_deterministic_overwrite tests/func/test_run.py::test_run_deterministic_callback tests/func/test_run.py::test_run_deterministic_changed_dep tests/func/test_run.py::test_run_deterministic_changed_deps_list tests/func/test_run.py::test_run_deterministic_new_dep tests/func/test_run.py::test_run_deterministic_remove_dep tests/func/test_run.py::test_run_deterministic_changed_out tests/func/test_run.py::test_run_deterministic_changed_cmd tests/func/test_run.py::TestRunCommit::test tests/func/test_run.py::TestRunPersistOuts::test tests/func/test_run.py::TestRunPersistOutsNoCache::test tests/func/test_run.py::TestShouldRaiseOnOverlappingOutputPaths::test tests/func/test_run.py::TestNewRunShouldRemoveOutsOnNoPersist::test tests/func/test_run.py::TestNewRunShouldNotRemoveOutsOnPersist::test tests/func/test_run.py::TestShouldNotCheckoutUponCorruptedLocalHardlinkCache::test tests/func/test_run.py::TestPersistentOutput::test_ignore_build_cache tests/func/test_run.py::test_bad_stage_fname tests/unit/test_stage.py::test_stage_checksum tests/unit/test_stage.py::test_wdir_default_ignored tests/unit/test_stage.py::test_wdir_non_default_is_not_ignored tests/unit/test_stage.py::test_meta_ignored tests/unit/test_stage.py::test_stage_fname[True] tests/unit/test_stage.py::test_stage_fname[False] tests/unit/test_stage.py::test_stage_update tests/unit/test_stage.py::test_stage_run_ignore_sigint
dvc/scm/git/__init__.py
dvc/scm/git/__init__.py