Skip to content

Commit ef203f0

Browse files
spearceJunio C Hamano
authored andcommitted
Catch write_ref_sha1 failure in receive-pack
This failure to catch the failure of write_ref_sha1 was noticed by Bill Lear. The ref will not update if the log file could not be appended to (due to file permissions problems). Such a failure should be flagged as a failure to update the ref, so that the client knows the push did not succeed. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 58db64f commit ef203f0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

receive-pack.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ static int update(struct command *cmd)
158158
cmd->error_string = "failed to lock";
159159
return error("failed to lock %s", name);
160160
}
161-
write_ref_sha1(lock, new_sha1, "push");
161+
if (write_ref_sha1(lock, new_sha1, "push")) {
162+
cmd->error_string = "failed to write";
163+
return -1; /* error() already called */
164+
}
162165
fprintf(stderr, "%s: %s -> %s\n", name, old_hex, new_hex);
163166
}
164167
return 0;

0 commit comments

Comments
 (0)