bundle: run setup_git_directory_gently() sooner
Without this change, “git -p bundle” does not always respect the repository-local “[core] pager” setting. It is hard to notice because subcommands other than “git bundle unbundle” do not produce much output. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
d1ea896290
commit
2cb60093e6
|
@ -18,7 +18,6 @@ static const char builtin_bundle_usage[] =
|
||||||
int cmd_bundle(int argc, const char **argv, const char *prefix)
|
int cmd_bundle(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
struct bundle_header header;
|
struct bundle_header header;
|
||||||
int nongit;
|
|
||||||
const char *cmd, *bundle_file;
|
const char *cmd, *bundle_file;
|
||||||
int bundle_fd = -1;
|
int bundle_fd = -1;
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
|
@ -31,7 +30,6 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
argv += 2;
|
argv += 2;
|
||||||
|
|
||||||
prefix = setup_git_directory_gently(&nongit);
|
|
||||||
if (prefix && bundle_file[0] != '/') {
|
if (prefix && bundle_file[0] != '/') {
|
||||||
snprintf(buffer, sizeof(buffer), "%s/%s", prefix, bundle_file);
|
snprintf(buffer, sizeof(buffer), "%s/%s", prefix, bundle_file);
|
||||||
bundle_file = buffer;
|
bundle_file = buffer;
|
||||||
|
@ -54,11 +52,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
|
||||||
return !!list_bundle_refs(&header, argc, argv);
|
return !!list_bundle_refs(&header, argc, argv);
|
||||||
}
|
}
|
||||||
if (!strcmp(cmd, "create")) {
|
if (!strcmp(cmd, "create")) {
|
||||||
if (nongit)
|
if (!startup_info->have_repository)
|
||||||
die("Need a repository to create a bundle.");
|
die("Need a repository to create a bundle.");
|
||||||
return !!create_bundle(&header, bundle_file, argc, argv);
|
return !!create_bundle(&header, bundle_file, argc, argv);
|
||||||
} else if (!strcmp(cmd, "unbundle")) {
|
} else if (!strcmp(cmd, "unbundle")) {
|
||||||
if (nongit)
|
if (!startup_info->have_repository)
|
||||||
die("Need a repository to unbundle.");
|
die("Need a repository to unbundle.");
|
||||||
return !!unbundle(&header, bundle_fd) ||
|
return !!unbundle(&header, bundle_fd) ||
|
||||||
list_bundle_refs(&header, argc, argv);
|
list_bundle_refs(&header, argc, argv);
|
||||||
|
|
2
git.c
2
git.c
|
@ -306,7 +306,7 @@ static void handle_internal_command(int argc, const char **argv)
|
||||||
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
|
{ "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
|
||||||
{ "blame", cmd_blame, RUN_SETUP },
|
{ "blame", cmd_blame, RUN_SETUP },
|
||||||
{ "branch", cmd_branch, RUN_SETUP },
|
{ "branch", cmd_branch, RUN_SETUP },
|
||||||
{ "bundle", cmd_bundle },
|
{ "bundle", cmd_bundle, RUN_SETUP_GENTLY },
|
||||||
{ "cat-file", cmd_cat_file, RUN_SETUP },
|
{ "cat-file", cmd_cat_file, RUN_SETUP },
|
||||||
{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
|
{ "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
|
||||||
{ "checkout-index", cmd_checkout_index,
|
{ "checkout-index", cmd_checkout_index,
|
||||||
|
|
|
@ -58,6 +58,21 @@ test_expect_success TTY 'some commands use a pager' '
|
||||||
test -e paginated.out
|
test -e paginated.out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_failure TTY 'pager runs from subdir' '
|
||||||
|
echo subdir/paginated.out >expected &&
|
||||||
|
mkdir -p subdir &&
|
||||||
|
rm -f paginated.out subdir/paginated.out &&
|
||||||
|
(
|
||||||
|
cd subdir &&
|
||||||
|
test_terminal git log
|
||||||
|
) &&
|
||||||
|
{
|
||||||
|
ls paginated.out subdir/paginated.out ||
|
||||||
|
:
|
||||||
|
} >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success TTY 'some commands do not use a pager' '
|
test_expect_success TTY 'some commands do not use a pager' '
|
||||||
rm -f paginated.out ||
|
rm -f paginated.out ||
|
||||||
cleanup_fail &&
|
cleanup_fail &&
|
||||||
|
@ -119,6 +134,24 @@ test_expect_success TTY 'configuration can disable pager' '
|
||||||
! test -e paginated.out
|
! test -e paginated.out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'configuration can enable pager (from subdir)' '
|
||||||
|
rm -f paginated.out &&
|
||||||
|
mkdir -p subdir &&
|
||||||
|
git config pager.bundle true &&
|
||||||
|
test_when_finished "git config --unset pager.bundle" &&
|
||||||
|
|
||||||
|
git bundle create test.bundle --all &&
|
||||||
|
rm -f paginated.out subdir/paginated.out &&
|
||||||
|
(
|
||||||
|
cd subdir &&
|
||||||
|
test_terminal git bundle unbundle ../test.bundle
|
||||||
|
) &&
|
||||||
|
{
|
||||||
|
test -e paginated.out ||
|
||||||
|
test -e subdir/paginated.out
|
||||||
|
}
|
||||||
|
'
|
||||||
|
|
||||||
# A colored commit log will begin with an appropriate ANSI escape
|
# A colored commit log will begin with an appropriate ANSI escape
|
||||||
# for the first color; the text "commit" comes later.
|
# for the first color; the text "commit" comes later.
|
||||||
colorful() {
|
colorful() {
|
||||||
|
|
Loading…
Reference in New Issue