Code

do not overwrite files marked "assume unchanged"
[git.git] / builtin-reflog.c
index ddfdf5a3cbc79003dfbad14af8d1f047e3594aa6..bd7880dc04830253daae932ba534f02db85f6d2a 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 static const char reflog_expire_usage[] =
-"git reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git reflog expire [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
 static const char reflog_delete_usage[] =
 "git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...";
 
@@ -362,7 +362,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
                } else if (cmd->updateref &&
                        (write_in_full(lock->lock_fd,
                                sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
-                        write_in_full(lock->lock_fd, "\n", 1) != 1 ||
+                        write_str_in_full(lock->lock_fd, "\n") != 1 ||
                         close_ref(lock) < 0)) {
                        status |= error("Couldn't write %s",
                                lock->lk->filename);
@@ -530,16 +530,14 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
        int i, status, do_all;
        int explicit_expiry = 0;
 
+       default_reflog_expire_unreachable = now - 30 * 24 * 3600;
+       default_reflog_expire = now - 90 * 24 * 3600;
        git_config(reflog_expire_config, NULL);
 
        save_commit_buffer = 0;
        do_all = status = 0;
        memset(&cb, 0, sizeof(cb));
 
-       if (!default_reflog_expire_unreachable)
-               default_reflog_expire_unreachable = now - 30 * 24 * 3600;
-       if (!default_reflog_expire)
-               default_reflog_expire = now - 90 * 24 * 3600;
        cb.expire_total = default_reflog_expire;
        cb.expire_unreachable = default_reflog_expire_unreachable;
 
@@ -694,10 +692,13 @@ static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
  */
 
 static const char reflog_usage[] =
-"git reflog (expire | ...)";
+"git reflog [ show | expire | delete ]";
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
+       if (argc > 1 && !strcmp(argv[1], "-h"))
+               usage(reflog_usage);
+
        /* With no command, we default to showing it. */
        if (argc < 2 || *argv[1] == '-')
                return cmd_log_reflog(argc, argv, prefix);