Skip to content

Commit efb98b4

Browse files
ldv-altgitster
authored andcommitted
builtin-fetch.c (store_updated_refs): Honor update_local_ref() return value
Sync with builtin-fetch--tool.c where append_fetch_head() honors update_local_ref() return value. This fixes non fast forward fetch exit status, http://bugzilla.altlinux.org/show_bug.cgi?id=15037 Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6eec46b commit efb98b4

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

builtin-fetch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
286286
{
287287
FILE *fp;
288288
struct commit *commit;
289-
int url_len, i, note_len, shown_url = 0;
289+
int url_len, i, note_len, shown_url = 0, rc = 0;
290290
char note[1024];
291291
const char *what, *kind;
292292
struct ref *rm;
@@ -353,7 +353,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
353353
note);
354354

355355
if (ref)
356-
update_local_ref(ref, what, verbose, note);
356+
rc |= update_local_ref(ref, what, verbose, note);
357357
else
358358
sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
359359
SUMMARY_WIDTH, *kind ? kind : "branch",
@@ -368,7 +368,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
368368
}
369369
}
370370
fclose(fp);
371-
return 0;
371+
return rc;
372372
}
373373

374374
/*

t/t5518-fetch-exit-status.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2008 Dmitry V. Levin
4+
#
5+
6+
test_description='fetch exit status test'
7+
8+
. ./test-lib.sh
9+
10+
test_expect_success setup '
11+
12+
>file &&
13+
git add file &&
14+
git commit -m initial &&
15+
16+
git checkout -b side &&
17+
echo side >file &&
18+
git commit -a -m side &&
19+
20+
git checkout master &&
21+
echo next >file &&
22+
git commit -a -m next
23+
'
24+
25+
test_expect_success 'non fast forward fetch' '
26+
27+
test_must_fail git fetch . master:side
28+
29+
'
30+
31+
test_expect_success 'forced update' '
32+
33+
git fetch . +master:side
34+
35+
'
36+
37+
test_done

0 commit comments

Comments
 (0)