Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Local git patches, not suitable for upstream
From 689d73b1f07425ce778362377f8f1bc0371033b1 Tue Jul 31 06:35:55 2012
Message-Id: <689d73b1f07425ce778362377f8f1bc0371033b1.1343719228.git.chris@arachsys.com>
From: Chris Webb <chris@arachsys.com>
Date: Thu, 15 Apr 2010 15:31:15 +0100
Subject: [PATCH 1/2] format-patch: use commit date in mbox 'From COMMIT DATE'
header line
Put the commit date in the 'From COMMIT DATE' header line instead of using
the fixed date 'Mon Sep 17 00:00:00 2001'. A DATE_UTC mode for show_date() is
introduced so we can easily generate this line in the correct format, and
t4013 is fixed not to expect a constant From line.
Signed-off-by: Chris Webb <chris@arachsys.com>
---
builtin/blame.c | 1 +
cache.h | 3 ++-
date.c | 4 +++-
log-tree.c | 2 +-
t/t4013-diff-various.sh | 3 ++-
5 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 0d50273..cc58b8e 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2404,6 +2404,7 @@ parse_done:
/* "normal" is used as the fallback for "relative" */
case DATE_LOCAL:
case DATE_NORMAL:
+ case DATE_UTC:
blame_date_width = sizeof("Thu Oct 19 16:00:04 2006 -0700");
break;
}
diff --git a/cache.h b/cache.h
index 67f28b4..96d77d1 100644
--- a/cache.h
+++ b/cache.h
@@ -881,7 +881,8 @@ enum date_mode {
DATE_LOCAL,
DATE_ISO8601,
DATE_RFC2822,
- DATE_RAW
+ DATE_RAW,
+ DATE_UTC
};
const char *show_date(unsigned long time, int timezone, enum date_mode mode);
diff --git a/date.c b/date.c
index 57331ed..b54224d 100644
--- a/date.c
+++ b/date.c
@@ -182,6 +182,8 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
if (mode == DATE_LOCAL)
tz = local_tzoffset(time);
+ else if (mode == DATE_UTC)
+ tz = 0;
tm = time_to_tm(time, tz);
if (!tm)
@@ -210,7 +212,7 @@ const char *show_date(unsigned long time, int tz, enum date_mode mode)
tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
tm->tm_year + 1900,
- (mode == DATE_LOCAL) ? 0 : ' ',
+ (mode != DATE_NORMAL) ? 0 : ' ',
tz);
return timebuf.buf;
}
diff --git a/log-tree.c b/log-tree.c
index c894930..d9cc1bf 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -350,7 +350,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
subject = "Subject: ";
}
- printf("From %s Mon Sep 17 00:00:00 2001\n", name);
+ printf("From %s %s\n", name, show_date(commit->date, 0, DATE_UTC));
graph_show_oneline(opt->graph);
if (opt->message_id) {
printf("Message-Id: <%s>\n", opt->message_id);
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index e77c09c..afcfb04 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -123,7 +123,8 @@ do
echo "\$ git $cmd"
git $cmd |
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
- -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
+ -e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/" \
+ -e "s/^\\(From [0-9a-f][0-9a-f]*\\) .*/\\1 Mon Sep 17 00:00:00 2001/"
echo "\$"
} >"$actual" &&
if test -f "$expect"
From 597157529393488b85d319bd6f0e6813815798b6 Tue Jul 31 06:35:55 2012
Message-Id: <597157529393488b85d319bd6f0e6813815798b6.1343719228.git.chris@arachsys.com>
In-Reply-To: <689d73b1f07425ce778362377f8f1bc0371033b1.1343719228.git.chris@arachsys.com>
References: <689d73b1f07425ce778362377f8f1bc0371033b1.1343719228.git.chris@arachsys.com>
From: Chris Webb <chris@arachsys.com>
Date: Sun, 15 Jul 2012 20:14:00 +0100
Subject: [PATCH 2/2] Add a help format 'usage' to provide brief command usage
Configuring the new help.format = usage makes git foo --help exactly
equivalent to git foo -h, displaying brief command-line usage info
instead of full documentation in the form of a man/html page.
This is useful on stripped-down servers where man pages and viewer
aren't present, or if your fingers are trained to type COMMAND --help
instead of COMMAND -h to get usage info and the man page behaviour is
disturbing.
Signed-off-by: Chris Webb <chris@arachsys.com>
---
builtin/help.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/builtin/help.c b/builtin/help.c
index efea4f5..adc832a 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -31,7 +31,8 @@ enum help_format {
HELP_FORMAT_NONE,
HELP_FORMAT_MAN,
HELP_FORMAT_INFO,
- HELP_FORMAT_WEB
+ HELP_FORMAT_WEB,
+ HELP_FORMAT_USAGE
};
static const char *html_path;
@@ -46,11 +47,13 @@ static struct option builtin_help_options[] = {
HELP_FORMAT_WEB),
OPT_SET_INT('i', "info", &help_format, "show info page",
HELP_FORMAT_INFO),
+ OPT_SET_INT('u', "usage", &help_format, "show usage",
+ HELP_FORMAT_USAGE),
OPT_END(),
};
static const char * const builtin_help_usage[] = {
- "git help [--all] [--man|--web|--info] [command]",
+ "git help [--all] [--man|--web|--info|--usage] [command]",
NULL
};
@@ -62,6 +65,8 @@ static enum help_format parse_help_format(const char *format)
return HELP_FORMAT_INFO;
if (!strcmp(format, "web") || !strcmp(format, "html"))
return HELP_FORMAT_WEB;
+ if (!strcmp(format, "usage"))
+ return HELP_FORMAT_USAGE;
die(_("unrecognized help format '%s'"), format);
}
@@ -431,6 +436,11 @@ static void show_html_page(const char *git_cmd)
open_html(page_path.buf);
}
+static void show_usage(const char *git_cmd)
+{
+ execl_git_cmd(git_cmd, "-h", NULL);
+}
+
int cmd_help(int argc, const char **argv, const char *prefix)
{
int nongit;
@@ -482,6 +492,9 @@ int cmd_help(int argc, const char **argv, const char *prefix)
case HELP_FORMAT_WEB:
show_html_page(argv[0]);
break;
+ case HELP_FORMAT_USAGE:
+ show_usage(argv[0]);
+ break;
}
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment