summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/checkout.c5
-rwxr-xr-xt/t1410-reflog.sh8
2 files changed, 9 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index d3fc3a8532..c4db4ca931 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -651,10 +651,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
}
}
if (old->path && old->name) {
- char ref_file[PATH_MAX];
-
- git_snpath(ref_file, sizeof(ref_file), "%s", old->path);
- if (!file_exists(ref_file) && reflog_exists(old->path))
+ if (!ref_exists(old->path) && reflog_exists(old->path))
delete_reflog(old->path);
}
}
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 236b13a3ab..8cab06f90a 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -245,4 +245,12 @@ test_expect_success 'gc.reflogexpire=false' '
'
+test_expect_success 'checkout should not delete log for packed ref' '
+ test $(git reflog master | wc -l) = 4 &&
+ git branch foo &&
+ git pack-refs --all &&
+ git checkout foo &&
+ test $(git reflog master | wc -l) = 4
+'
+
test_done