@matheusbsbs / matheus-bagliano / commits / efb98b4453
Fork 0

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>

Dmitry V. Levin committed May 28, 2008 at 19:29 UTC efb98b44536300f5daed25da3650033a1ce7fdef
2 files changed +40 -3
builtin-fetch.c
+3 -3
@@ -286,7 +286,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
286 {
287 FILE *fp;
288 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;
290 char note[1024];
291 const char *what, *kind;
292 struct ref *rm;
@@ -353,7 +353,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
353 note);
354
355 if (ref)
356 - update_local_ref(ref, what, verbose, note);
356 + rc |= update_local_ref(ref, what, verbose, note);
357 else
358 sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
359 SUMMARY_WIDTH, *kind ? kind : "branch",
@@ -368,7 +368,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
368 }
369 }
370 fclose(fp);
371 - return 0;
371 + return rc;
372 }
373
374 /*
t/t5518-fetch-exit-status.sh new
+37
@@ -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