From 8d3cbd27d46bdf42d632de0a2e7f048855941128 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 23 Jun 2006 17:36:21 +0200 Subject: [PATCH 1/5] patch-id: take "commit" prefix as well as "diff-tree" prefix Some time ago we changed git-log in a massive way, and one consequence is that the keyword changed. Adjust patch-id for that. [jc: as Linus suggests, allowing both old and new prefix.] Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- patch-id.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patch-id.c b/patch-id.c index edbc4aa3e..3b4c80f76 100644 --- a/patch-id.c +++ b/patch-id.c @@ -42,6 +42,8 @@ static void generate_id_list(void) if (!memcmp(line, "diff-tree ", 10)) p += 10; + else if (!memcmp(line, "commit ", 7)) + p += 7; if (!get_sha1_hex(p, n)) { flush_current_id(patchlen, sha1, &ctx); From cda8ab59bbdb24b4ef87083781dac1f4f1b973a1 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 23 Jun 2006 09:43:38 -0400 Subject: [PATCH 2/5] git-commit: allow -e option anywhere on command line Previously, the command 'git-commit -e -m foo' would ignore the '-e' option because the '-m' option overwrites the no_edit flag during sequential option parsing. Now we cause -e to reset the no_edit flag after all options are parsed. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-commit.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/git-commit.sh b/git-commit.sh index 6dd04fd36..e74fe640b 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -199,6 +199,7 @@ only= logfile= use_commit= amend= +edit_flag= no_edit= log_given= log_message= @@ -246,7 +247,7 @@ do shift ;; -e|--e|--ed|--edi|--edit) - no_edit= + edit_flag=t shift ;; -i|--i|--in|--inc|--incl|--inclu|--includ|--include) @@ -384,6 +385,7 @@ $1" ;; esac done +case "$edit_flag" in t) no_edit= ;; esac ################################################################ # Sanity check options From 5e7c91d6f744dbf9a18152d2d49057aa3dd06160 Mon Sep 17 00:00:00 2001 From: Timo Hirvonen Date: Sat, 24 Jun 2006 00:45:40 +0300 Subject: [PATCH 3/5] git-merge: Don't use -p when outputting summary -p is not needed and we only want diffstat and summary. Signed-off-by: Timo Hirvonen Signed-off-by: Junio C Hamano --- git-merge.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge.sh b/git-merge.sh index af1f25b3c..da5657eb4 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -55,7 +55,7 @@ finish () { case "$no_summary" in '') - git-diff-tree -p --stat --summary -M "$head" "$1" + git-diff-tree --stat --summary -M "$head" "$1" ;; esac } From 39a3f5ea7c0352a530338d30d4e618f6b4db84e4 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sat, 24 Jun 2006 04:34:38 +0200 Subject: [PATCH 4/5] Customizable error handlers This patch makes the usage(), die() and error() handlers customizable. Nothing in the git code itself uses that but many other libgit users (like Git.pm) will. This is implemented using the mutator functions primarily because you cannot directly modifying global variables of libgit from a program that dlopen()ed it, apparently. But having functions for that is a better API anyway. Signed-off-by: Petr Baudis Signed-off-by: Junio C Hamano --- git-compat-util.h | 4 ++++ usage.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/git-compat-util.h b/git-compat-util.h index 5d543d29f..b3d4cf532 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -40,6 +40,10 @@ extern void usage(const char *err) NORETURN; extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2))); extern int error(const char *err, ...) __attribute__((format (printf, 1, 2))); +extern void set_usage_routine(void (*routine)(const char *err) NORETURN); +extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN); +extern void set_error_routine(void (*routine)(const char *err, va_list params)); + #ifdef NO_MMAP #ifndef PROT_READ diff --git a/usage.c b/usage.c index 1fa924c3d..b781b0061 100644 --- a/usage.c +++ b/usage.c @@ -12,20 +12,58 @@ static void report(const char *prefix, const char *err, va_list params) fputs("\n", stderr); } -void usage(const char *err) +void usage_builtin(const char *err) { fprintf(stderr, "usage: %s\n", err); exit(129); } +void die_builtin(const char *err, va_list params) +{ + report("fatal: ", err, params); + exit(128); +} + +void error_builtin(const char *err, va_list params) +{ + report("error: ", err, params); +} + + +/* If we are in a dlopen()ed .so write to a global variable would segfault + * (ugh), so keep things static. */ +static void (*usage_routine)(const char *err) NORETURN = usage_builtin; +static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin; +static void (*error_routine)(const char *err, va_list params) = error_builtin; + +void set_usage_routine(void (*routine)(const char *err) NORETURN) +{ + usage_routine = routine; +} + +void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN) +{ + die_routine = routine; +} + +void set_error_routine(void (*routine)(const char *err, va_list params)) +{ + error_routine = routine; +} + + +void usage(const char *err) +{ + usage_routine(err); +} + void die(const char *err, ...) { va_list params; va_start(params, err); - report("fatal: ", err, params); + die_routine(err, params); va_end(params); - exit(128); } int error(const char *err, ...) @@ -33,7 +71,7 @@ int error(const char *err, ...) va_list params; va_start(params, err); - report("error: ", err, params); + error_routine(err, params); va_end(params); return -1; } From ce88ac5b129dd562a1062522039366ebbf1157e1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 23 Jun 2006 22:44:33 -0700 Subject: [PATCH 5/5] usage: minimum type fix. Signed-off-by: Junio C Hamano --- usage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usage.c b/usage.c index b781b0061..52c2e9605 100644 --- a/usage.c +++ b/usage.c @@ -12,19 +12,19 @@ static void report(const char *prefix, const char *err, va_list params) fputs("\n", stderr); } -void usage_builtin(const char *err) +static NORETURN void usage_builtin(const char *err) { fprintf(stderr, "usage: %s\n", err); exit(129); } -void die_builtin(const char *err, va_list params) +static NORETURN void die_builtin(const char *err, va_list params) { report("fatal: ", err, params); exit(128); } -void error_builtin(const char *err, va_list params) +static void error_builtin(const char *err, va_list params) { report("error: ", err, params); }