Skip to content

Commit faf7526

Browse files
committed
Merge branch 'maint'
* maint: t9350: fix careless use of "cd" difftool: Fix '--gui' when diff.guitool is unconfigured fast-export: don't segfault when marks file cannot be opened
2 parents 10439d8 + 4c367c6 commit faf7526

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static void export_marks(char *file)
503503

504504
f = fopen(file, "w");
505505
if (!f)
506-
error("Unable to open marks file %s for writing.", file);
506+
die_errno("Unable to open marks file %s for writing.", file);
507507

508508
for (i = 0; i < idnums.size; i++) {
509509
if (deco->base && deco->base->type == 1) {

git-difftool.perl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ sub generate_command
7878
next;
7979
}
8080
if ($arg eq '-g' || $arg eq '--gui') {
81-
my $tool = Git::command_oneline('config',
82-
'diff.guitool');
83-
if (length($tool)) {
84-
$ENV{GIT_DIFF_TOOL} = $tool;
85-
}
81+
eval {
82+
my $tool = Git::command_oneline('config',
83+
'diff.guitool');
84+
if (length($tool)) {
85+
$ENV{GIT_DIFF_TOOL} = $tool;
86+
}
87+
};
8688
next;
8789
}
8890
if ($arg eq '-y' || $arg eq '--no-prompt') {

t/t7800-difftool.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
9292
restore_test_defaults
9393
'
9494

95+
test_expect_success 'difftool --gui works without configured diff.guitool' '
96+
git config diff.tool test-tool &&
97+
98+
diff=$(git difftool --no-prompt --gui branch) &&
99+
test "$diff" = "branch" &&
100+
101+
restore_test_defaults
102+
'
103+
95104
# Specify the diff tool using $GIT_DIFF_TOOL
96105
test_expect_success 'GIT_DIFF_TOOL variable' '
97106
git config --unset diff.tool

t/t9350-fast-export.sh

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -150,20 +150,22 @@ test_expect_success 'setup submodule' '
150150
151151
git checkout -f master &&
152152
mkdir sub &&
153-
cd sub &&
154-
git init &&
155-
echo test file > file &&
156-
git add file &&
157-
git commit -m sub_initial &&
158-
cd .. &&
153+
(
154+
cd sub &&
155+
git init &&
156+
echo test file > file &&
157+
git add file &&
158+
git commit -m sub_initial
159+
) &&
159160
git submodule add "`pwd`/sub" sub &&
160161
git commit -m initial &&
161162
test_tick &&
162-
cd sub &&
163-
echo more data >> file &&
164-
git add file &&
165-
git commit -m sub_second &&
166-
cd .. &&
163+
(
164+
cd sub &&
165+
echo more data >> file &&
166+
git add file &&
167+
git commit -m sub_second
168+
) &&
167169
git add sub &&
168170
git commit -m second
169171
@@ -264,19 +266,20 @@ test_expect_success 'cope with tagger-less tags' '
264266

265267
test_expect_success 'setup for limiting exports by PATH' '
266268
mkdir limit-by-paths &&
267-
cd limit-by-paths &&
268-
git init &&
269-
echo hi > there &&
270-
git add there &&
271-
git commit -m "First file" &&
272-
echo foo > bar &&
273-
git add bar &&
274-
git commit -m "Second file" &&
275-
git tag -a -m msg mytag &&
276-
echo morefoo >> bar &&
277-
git add bar &&
278-
git commit -m "Change to second file" &&
279-
cd ..
269+
(
270+
cd limit-by-paths &&
271+
git init &&
272+
echo hi > there &&
273+
git add there &&
274+
git commit -m "First file" &&
275+
echo foo > bar &&
276+
git add bar &&
277+
git commit -m "Second file" &&
278+
git tag -a -m msg mytag &&
279+
echo morefoo >> bar &&
280+
git add bar &&
281+
git commit -m "Change to second file"
282+
)
280283
'
281284

282285
cat > limit-by-paths/expected << EOF
@@ -297,10 +300,11 @@ M 100644 :1 there
297300
EOF
298301

299302
test_expect_success 'dropping tag of filtered out object' '
303+
(
300304
cd limit-by-paths &&
301305
git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
302-
test_cmp output expected &&
303-
cd ..
306+
test_cmp output expected
307+
)
304308
'
305309

306310
cat >> limit-by-paths/expected << EOF
@@ -313,10 +317,11 @@ msg
313317
EOF
314318

315319
test_expect_success 'rewriting tag of filtered out object' '
320+
(
316321
cd limit-by-paths &&
317322
git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
318-
test_cmp output expected &&
319-
cd ..
323+
test_cmp output expected
324+
)
320325
'
321326

322327
cat > limit-by-paths/expected << EOF
@@ -343,13 +348,13 @@ M 100644 :2 there
343348
EOF
344349

345350
test_expect_failure 'no exact-ref revisions included' '
346-
cd limit-by-paths &&
347-
git fast-export master~2..master~1 > output &&
348-
test_cmp output expected &&
349-
cd ..
351+
(
352+
cd limit-by-paths &&
353+
git fast-export master~2..master~1 > output &&
354+
test_cmp output expected
355+
)
350356
'
351357

352-
353358
test_expect_success 'set-up a few more tags for tag export tests' '
354359
git checkout -f master &&
355360
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&

0 commit comments

Comments
 (0)