@matheusbsbs / matheus-bagliano / commits / 2cb60093e6
Fork 0

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>

Nguyễn Thái Ngọc Duy committed Aug 5, 2010 at 22:12 UTC 2cb60093e6c6b53cfc8ffe75f697386a1adab778
3 files changed +36 -5
builtin/bundle.c
+2 -4
@@ -18,7 +18,6 @@ static const char builtin_bundle_usage[] =
18 int cmd_bundle(int argc, const char **argv, const char *prefix)
19 {
20 struct bundle_header header;
21 - int nongit;
21 const char *cmd, *bundle_file;
22 int bundle_fd = -1;
23 char buffer[PATH_MAX];
@@ -31,7 +30,6 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
30 argc -= 2;
31 argv += 2;
32
34 - prefix = setup_git_directory_gently(&nongit);
33 if (prefix && bundle_file[0] != '/') {
34 snprintf(buffer, sizeof(buffer), "%s/%s", prefix, bundle_file);
35 bundle_file = buffer;
@@ -54,11 +52,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
52 return !!list_bundle_refs(&header, argc, argv);
53 }
54 if (!strcmp(cmd, "create")) {
57 - if (nongit)
55 + if (!startup_info->have_repository)
56 die("Need a repository to create a bundle.");
57 return !!create_bundle(&header, bundle_file, argc, argv);
58 } else if (!strcmp(cmd, "unbundle")) {
61 - if (nongit)
59 + if (!startup_info->have_repository)
60 die("Need a repository to unbundle.");
61 return !!unbundle(&header, bundle_fd) ||
62 list_bundle_refs(&header, argc, argv);
git.c
+1 -1
@@ -306,7 +306,7 @@ static void handle_internal_command(int argc, const char **argv)
306 { "bisect--helper", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },
307 { "blame", cmd_blame, RUN_SETUP },
308 { "branch", cmd_branch, RUN_SETUP },
309 - { "bundle", cmd_bundle },
309 + { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
310 { "cat-file", cmd_cat_file, RUN_SETUP },
311 { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
312 { "checkout-index", cmd_checkout_index,
t/t7006-pager.sh
+33
@@ -58,6 +58,21 @@ test_expect_success TTY 'some commands use a pager' '
58 test -e paginated.out
59 '
60
61 +test_expect_failure TTY 'pager runs from subdir' '
62 + echo subdir/paginated.out >expected &&
63 + mkdir -p subdir &&
64 + rm -f paginated.out subdir/paginated.out &&
65 + (
66 + cd subdir &&
67 + test_terminal git log
68 + ) &&
69 + {
70 + ls paginated.out subdir/paginated.out ||
71 + :
72 + } >actual &&
73 + test_cmp expected actual
74 +'
75 +
76 test_expect_success TTY 'some commands do not use a pager' '
77 rm -f paginated.out ||
78 cleanup_fail &&
@@ -119,6 +134,24 @@ test_expect_success TTY 'configuration can disable pager' '
134 ! test -e paginated.out
135 '
136
137 +test_expect_success 'configuration can enable pager (from subdir)' '
138 + rm -f paginated.out &&
139 + mkdir -p subdir &&
140 + git config pager.bundle true &&
141 + test_when_finished "git config --unset pager.bundle" &&
142 +
143 + git bundle create test.bundle --all &&
144 + rm -f paginated.out subdir/paginated.out &&
145 + (
146 + cd subdir &&
147 + test_terminal git bundle unbundle ../test.bundle
148 + ) &&
149 + {
150 + test -e paginated.out ||
151 + test -e subdir/paginated.out
152 + }
153 +'
154 +
155 # A colored commit log will begin with an appropriate ANSI escape
156 # for the first color; the text "commit" comes later.
157 colorful() {