Allow the test suite to pass in a directory whose name contains spaces
[gitweb.git] / builtin / am.c
index 7d39156ff3f8230c2898439dfa38aeca46b6e4d0..593c1b5dda953d146c66a479b3bc5028efad5bf8 100644 (file)
@@ -1351,19 +1351,16 @@ static int get_mail_commit_oid(struct object_id *commit_id, const char *mail)
        struct strbuf sb = STRBUF_INIT;
        FILE *fp = xfopen(mail, "r");
        const char *x;
+       int ret = 0;
 
-       if (strbuf_getline_lf(&sb, fp))
-               return -1;
-
-       if (!skip_prefix(sb.buf, "From ", &x))
-               return -1;
-
-       if (get_oid_hex(x, commit_id) < 0)
-               return -1;
+       if (strbuf_getline_lf(&sb, fp) ||
+           !skip_prefix(sb.buf, "From ", &x) ||
+           get_oid_hex(x, commit_id) < 0)
+               ret = -1;
 
        strbuf_release(&sb);
        fclose(fp);
-       return 0;
+       return ret;
 }
 
 /**
@@ -2151,7 +2148,7 @@ static void am_abort(struct am_state *state)
        am_rerere_clear();
 
        curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
-       has_curr_head = !is_null_oid(&curr_head);
+       has_curr_head = curr_branch && !is_null_oid(&curr_head);
        if (!has_curr_head)
                hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
 
@@ -2314,6 +2311,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                OPT_END()
        };
 
+       if (argc == 2 && !strcmp(argv[1], "-h"))
+               usage_with_options(usage, options);
+
        git_config(git_am_config, NULL);
 
        am_state_init(&state);