path: root/builtin/reset.c
diff options
authorMartin von Zweigbergk <>2013-01-15 05:47:34 (GMT)
committerJunio C Hamano <>2013-01-15 17:38:07 (GMT)
commitd94c5e2fa24dce13a3dc1ba178f381cb09bb0853 (patch)
tree97c3a045e9e613d8fd74fce6c52fb6524d9b0459 /builtin/reset.c
parent10746a361689aaa1aa98b8d4e7fb3b8463391864 (diff)
reset $pathspec: exit with code 0 if successful
"git reset $pathspec" currently exits with a non-zero exit code if the worktree is dirty after resetting, which is inconsistent with reset without pathspec, and it makes it harder to know whether the command really failed. Change it to exit with code 0 regardless of whether the worktree is dirty so that non-zero indicates an error. This makes the 4 "disambiguation" test cases in t7102 clearer since they all used to "fail", 3 of which "failed" due to changes in the work tree. Now only the ambiguous one fails. Signed-off-by: Martin von Zweigbergk <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/reset.c')
1 files changed, 3 insertions, 5 deletions
diff --git a/builtin/reset.c b/builtin/reset.c
index 8cc7c72..65413d0 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -119,19 +119,17 @@ static void print_new_head_line(struct commit *commit)
static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
- int result;
if (!index_lock) {
index_lock = xcalloc(1, sizeof(struct lock_file));
fd = hold_locked_index(index_lock, 1);
- result = refresh_index(&the_index, (flags), NULL, NULL,
- _("Unstaged changes after reset:")) ? 1 : 0;
+ refresh_index(&the_index, (flags), NULL, NULL,
+ _("Unstaged changes after reset:"));
if (write_cache(fd, active_cache, active_nr) ||
return error ("Could not refresh index");
- return result;
+ return 0;
static void update_index_from_diff(struct diff_queue_struct *q,