From ec722203ee43beed8e4feac84af4307eb68f1ba3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 13 Dec 2006 00:58:28 -0800 Subject: [PATCH 01/13] spurious .sp in manpages This cherry-picks 7ef04350 that has been applied to the 'master' to fix ".sp" in generated manpages. Signed-off-by: Junio C Hamano --- Documentation/callouts.xsl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/callouts.xsl b/Documentation/callouts.xsl index ad03755d8f..6a361a2136 100644 --- a/Documentation/callouts.xsl +++ b/Documentation/callouts.xsl @@ -13,4 +13,18 @@ .br + + + + + + + + + + + + From c902c9a608c1b727160d6fbb04fa363d9418cd00 Mon Sep 17 00:00:00 2001 From: Terje Sten Bjerkseth Date: Wed, 20 Dec 2006 17:32:21 -0800 Subject: [PATCH 02/13] Fix system header problems on Mac OS X For Mac OS X 10.4, _XOPEN_SOURCE defines _POSIX_C_SOURCE which hides many symbols from the program. Breakage noticed and initial analysis provided by Randal L. Schwartz. Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index bc296b3a45..41fa7f67bc 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -11,8 +11,10 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#ifndef __APPLE_CC__ #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ +#endif #define _GNU_SOURCE #define _BSD_SOURCE From 7dda22e3174dd6e4b8b2f60fb0ad1e8f1be912ad Mon Sep 17 00:00:00 2001 From: Quy Tonthat Date: Thu, 21 Dec 2006 15:18:07 +1100 Subject: [PATCH 03/13] Documentation/git-branch: new -r to delete remote-tracking branches. Signed-off-by: Quy Tonthat Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 71417feba8..c464bd2fda 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -11,7 +11,7 @@ SYNOPSIS 'git-branch' [-r | -a] [-v [--abbrev=]] 'git-branch' [-l] [-f] [] 'git-branch' (-m | -M) [] -'git-branch' (-d | -D) ... +'git-branch' (-d | -D) [-r] ... DESCRIPTION ----------- @@ -33,7 +33,8 @@ to happen. With a `-d` or `-D` option, `` will be deleted. You may specify more than one branch for deletion. If the branch currently -has a ref log then the ref log will also be deleted. +has a ref log then the ref log will also be deleted. Use -r together with -d +to delete remote-tracking branches. OPTIONS @@ -60,7 +61,7 @@ OPTIONS Move/rename a branch even if the new branchname already exists. -r:: - List the remote-tracking branches. + List or delete (if used with -d) the remote-tracking branches. -a:: List both remote-tracking branches and local branches. @@ -111,10 +112,12 @@ Delete unneeded branch:: ------------ $ git clone git://git.kernel.org/.../git.git my.git $ cd my.git -$ git branch -D todo <1> +$ git branch -d -r todo html man <1> +$ git branch -D test <2> ------------ + -<1> delete todo branch even if the "master" branch does not have all +<1> delete remote-tracking branches "todo", "html", "man" +<2> delete "test" branch even if the "master" branch does not have all commits from todo branch. From e6d40d65df07059fc655fabe62fa5b575ead7815 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 22 Dec 2006 03:20:11 +0100 Subject: [PATCH 04/13] diff --check: fix off by one error When parsing the diff line starting with '@@', the line number of the '+' file is parsed. For the subsequent line parses, the line number should therefore be incremented after the parse, not before it. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/diff.c b/diff.c index 33153787b8..b003c00016 100644 --- a/diff.c +++ b/diff.c @@ -825,8 +825,6 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) if (line[0] == '+') { int i, spaces = 0; - data->lineno++; - /* check space before tab */ for (i = 1; i < len && (line[i] == ' ' || line[i] == '\t'); i++) if (line[i] == ' ') @@ -841,6 +839,8 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len) if (isspace(line[len - 1])) printf("%s:%d: white space at end: %.*s\n", data->filename, data->lineno, (int)len, line); + + data->lineno++; } else if (line[0] == ' ') data->lineno++; else if (line[0] == '@') { From caba139d432c420f853c352987cf29cefafc2b84 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 22 Dec 2006 03:20:55 +0100 Subject: [PATCH 05/13] Use git-merge-file in git-merge-one-file, too Would you believe? I edited git-merge-one-file (note the missing ".sh"!) when I submitted the patch which became commit e2b7008752... Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-merge-one-file.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh index c49e4c65af..7d62d7902c 100755 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@ -104,7 +104,7 @@ case "${1:-.}${2:-.}${3:-.}" in # Be careful for funny filename such as "-L" in "$4", which # would confuse "merge" greatly. src1=`git-unpack-file $2` - merge "$src1" "$orig" "$src2" + git-merge-file "$src1" "$orig" "$src2" ret=$? # Create the working tree file, using "our tree" version from the From 64646d11773774193093df96020d3fcb0df4a270 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 21 Dec 2006 21:30:17 -0500 Subject: [PATCH 06/13] Suggest 'add' in am/revert/cherry-pick. Now that we have decided to make 'add' behave like 'update-index' (and therefore fully classify update-index as strictly plumbing) the am/revert/cherry-pick family of commands should not steer the user towards update-index. Instead send them to the command they probably already know, 'add'. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-am.sh | 4 ++-- git-revert.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/git-am.sh b/git-am.sh index 5df6787a3f..0126a77b92 100755 --- a/git-am.sh +++ b/git-am.sh @@ -401,14 +401,14 @@ do changed="$(git-diff-index --cached --name-only HEAD)" if test '' = "$changed" then - echo "No changes - did you forget update-index?" + echo "No changes - did you forget to use 'git add'?" stop_here_user_resolve $this fi unmerged=$(git-ls-files -u) if test -n "$unmerged" then echo "You still have unmerged paths in your index" - echo "did you forget update-index?" + echo "did you forget to use 'git add'?" stop_here_user_resolve $this fi apply_status=0 diff --git a/git-revert.sh b/git-revert.sh index 6eab3c72df..50cc47b063 100755 --- a/git-revert.sh +++ b/git-revert.sh @@ -155,7 +155,7 @@ Conflicts: uniq } >>"$GIT_DIR/MERGE_MSG" echo >&2 "Automatic $me failed. After resolving the conflicts," - echo >&2 "mark the corrected paths with 'git-update-index '" + echo >&2 "mark the corrected paths with 'git-add '" echo >&2 "and commit the result." case "$me" in cherry-pick) From 9e11554917d391c18e043bc0b38ee0377e69568e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Dec 2006 22:10:56 -0800 Subject: [PATCH 07/13] Revert "git-pull: refuse default merge without branch.*.merge" This reverts commit a71fb0a1412c82405f078fb536797d3f5de68d53. The logic to decide when to refuse to use the default "first set of refs fetched" for merge was utterly bogus. In a repository that happily worked correctly without any of the per-branch configuration crap did not have (and did not have to have) any branch..merge. With that broken commit, pulling from origin no longer would work. --- git-parse-remote.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index ea7511e8a0..871c08f097 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -141,8 +141,7 @@ canon_refs_list_for_fetch () { curr_branch=$(git-symbolic-ref HEAD | \ sed -e 's|^refs/heads/||') merge_branches=$(git-repo-config \ - --get-all "branch.${curr_branch}.merge") || - merge_branches=.this.would.never.match.any.ref. + --get-all "branch.${curr_branch}.merge") fi set x $(expand_refs_wildcard "$@") shift From f79c73ce9ce5d8bd1b4abaf3fc384aa8daa169ef Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 21 Dec 2006 15:13:02 +0100 Subject: [PATCH 08/13] git-tag: support -F option This imitates the behaviour of git-commit. Noticed by Han-Wen Nienhuys. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/git-tag.txt | 6 +++++- git-tag.sh | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index 45476c2e41..48b82b86f8 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -9,7 +9,8 @@ git-tag - Create a tag object signed with GPG SYNOPSIS -------- [verse] -'git-tag' [-a | -s | -u ] [-f | -d] [-m ] [] +'git-tag' [-a | -s | -u ] [-f | -d] [-m | -F ] + [] 'git-tag' -l [] DESCRIPTION @@ -60,6 +61,9 @@ OPTIONS -m :: Use the given tag message (instead of prompting) +-F :: + Take the tag message from the given file. Use '-' to + read the message from the standard input. Author ------ diff --git a/git-tag.sh b/git-tag.sh index d53f94cd9c..36cd6aa256 100755 --- a/git-tag.sh +++ b/git-tag.sh @@ -45,6 +45,17 @@ do message_given=1 fi ;; + -F) + annotate=1 + shift + if test "$#" = "0"; then + die "error: option -F needs an argument" + exit 2 + else + message="$(cat "$1")" + message_given=1 + fi + ;; -u) annotate=1 signed=1 From 95f2fb7d9f84779bf036bb748e245c91bc572840 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 21 Dec 2006 15:26:35 +0100 Subject: [PATCH 09/13] git-reset --hard: tell the user what the HEAD was reset to Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-reset.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-reset.sh b/git-reset.sh index 8d95e3748d..2379db082f 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -86,7 +86,12 @@ update_ref_status=$? case "$reset_type" in --hard ) - ;; # Nothing else to do + test $update_ref_status = 0 && { + echo -n "HEAD is now at " + GIT_PAGER= git log --max-count=1 --pretty=oneline \ + --abbrev-commit HEAD + } + ;; --soft ) ;; # Nothing else to do --mixed ) From d41cb273d313a21979b05dba57d0c6b565b28ba6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Dec 2006 22:39:09 -0800 Subject: [PATCH 10/13] parse-remote: mark all refs not for merge only when fetching more than one An earlier commit a71fb0a1 implemented much requested safety valve to refuse "git pull" or "git pull origin" without explicit refspecs from using the first set of remote refs obtained by reading .git/remotes/origin file or branch.*.fetch configuration variables to create a merge. The argument was that while on a branch different from the default branch, it is often wrong to merge the default remote ref suitable for merging into the master. That is fine as a theory. But many repositories already in use by people in the real world do not have any of the per branch configuration crap. They did not need it, and they do not need it now. Merging with the first remote ref listed was just fine, because they had only one ref (e.g. 'master' from linux-2.6.git) anyway. So this changes the safety valve to be a lot looser. When "git fetch" gets only one remote branch, the irritating warning would not trigger anymore. I think we could also make the warning trigger when branch.*.merge is not specified for the current branch, but is for some other branch. That is for another commit. Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 871c08f097..f163821d03 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -136,6 +136,8 @@ canon_refs_list_for_fetch () { if test "$1" = "-d" then shift ; remote="$1" ; shift + set x $(expand_refs_wildcard "$@") + shift if test "$remote" = "$(get_default_remote)" then curr_branch=$(git-symbolic-ref HEAD | \ @@ -143,8 +145,13 @@ canon_refs_list_for_fetch () { merge_branches=$(git-repo-config \ --get-all "branch.${curr_branch}.merge") fi - set x $(expand_refs_wildcard "$@") - shift + # If we are fetching only one branch, then first branch + # is the only thing that makes sense to merge anyway, + # so there is no point refusing that traditional rule. + if test $# != 1 && test "z$merge_branches" = z + then + merge_branches=..this..would..never..match.. + fi fi for ref do From a01c9c28a576fbf3cd7caa4423dae4858a5ae6f5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 21 Dec 2006 22:51:42 -0800 Subject: [PATCH 11/13] _XOPEN_SOURCE problem also exists on FreeBSD Suggested by Rocco Rutte, Marco Roeland and others. Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index 41fa7f67bc..c66e0a4247 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -11,7 +11,7 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#ifndef __APPLE_CC__ +#if !defined(__APPLE__) && !defined(__FreeBSD) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif From 51dcaa9686d9ff591e9d051e6090d8529bc263a5 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 21 Dec 2006 19:48:12 -0500 Subject: [PATCH 12/13] Rename imap-send's internal info/warn functions. Because I am about to introduce a global warn() function (much like the global error function) this global declaration would conflict with the one supplied by imap-send. Further since imap-send's warn function output depends on its Quiet setting we cannot simply remove its internal definition and use the forthcoming global one. So refactor warn() -> imap_warn() and info() -> imap_info() (the latter was done just to be consistent in naming). Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- imap-send.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/imap-send.c b/imap-send.c index 894cbbdf53..ad91858bc4 100644 --- a/imap-send.c +++ b/imap-send.c @@ -96,8 +96,8 @@ typedef struct { static int Verbose, Quiet; -static void info( const char *, ... ); -static void warn( const char *, ... ); +static void imap_info( const char *, ... ); +static void imap_warn( const char *, ... ); static char *next_arg( char ** ); @@ -297,7 +297,7 @@ buffer_gets( buffer_t * b, char **s ) } static void -info( const char *msg, ... ) +imap_info( const char *msg, ... ) { va_list va; @@ -310,7 +310,7 @@ info( const char *msg, ... ) } static void -warn( const char *msg, ... ) +imap_warn( const char *msg, ... ) { va_list va; @@ -903,7 +903,7 @@ imap_open_store( imap_server_conf_t *srvc ) /* open connection to IMAP server */ if (srvc->tunnel) { - info( "Starting tunnel '%s'... ", srvc->tunnel ); + imap_info( "Starting tunnel '%s'... ", srvc->tunnel ); if (socketpair( PF_UNIX, SOCK_STREAM, 0, a )) { perror( "socketpair" ); @@ -926,31 +926,31 @@ imap_open_store( imap_server_conf_t *srvc ) imap->buf.sock.fd = a[1]; - info( "ok\n" ); + imap_info( "ok\n" ); } else { memset( &addr, 0, sizeof(addr) ); addr.sin_port = htons( srvc->port ); addr.sin_family = AF_INET; - info( "Resolving %s... ", srvc->host ); + imap_info( "Resolving %s... ", srvc->host ); he = gethostbyname( srvc->host ); if (!he) { perror( "gethostbyname" ); goto bail; } - info( "ok\n" ); + imap_info( "ok\n" ); addr.sin_addr.s_addr = *((int *) he->h_addr_list[0]); s = socket( PF_INET, SOCK_STREAM, 0 ); - info( "Connecting to %s:%hu... ", inet_ntoa( addr.sin_addr ), ntohs( addr.sin_port ) ); + imap_info( "Connecting to %s:%hu... ", inet_ntoa( addr.sin_addr ), ntohs( addr.sin_port ) ); if (connect( s, (struct sockaddr *)&addr, sizeof(addr) )) { close( s ); perror( "connect" ); goto bail; } - info( "ok\n" ); + imap_info( "ok\n" ); imap->buf.sock.fd = s; @@ -979,7 +979,7 @@ imap_open_store( imap_server_conf_t *srvc ) if (!preauth) { - info ("Logging in...\n"); + imap_info ("Logging in...\n"); if (!srvc->user) { fprintf( stderr, "Skipping server %s, no user\n", srvc->host ); goto bail; @@ -1006,7 +1006,7 @@ imap_open_store( imap_server_conf_t *srvc ) fprintf( stderr, "Skipping account %s@%s, server forbids LOGIN\n", srvc->user, srvc->host ); goto bail; } - warn( "*** IMAP Warning *** Password is being sent in the clear\n" ); + imap_warn( "*** IMAP Warning *** Password is being sent in the clear\n" ); if (imap_exec( ctx, NULL, "LOGIN \"%s\" \"%s\"", srvc->user, srvc->pass ) != RESP_OK) { fprintf( stderr, "IMAP error: LOGIN failed\n" ); goto bail; From fa39b6b5b11f9b580c515a7b4a8e4eb8eaa79b75 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 21 Dec 2006 19:48:32 -0500 Subject: [PATCH 13/13] Introduce a global level warn() function. Like the existing error() function the new warn() function can be used to describe a situation that probably should not be occuring, but which the user (and Git) can continue to work around without running into too many problems. An example situation is a bad commit SHA1 found in a reflog. Attempting to read this record out of the reflog isn't really an error as we have skipped over it in the past. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 ++ usage.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/git-compat-util.h b/git-compat-util.h index c66e0a4247..a55b923894 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -71,10 +71,12 @@ 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 warn(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)); +extern void set_warn_routine(void (*routine)(const char *warn, va_list params)); #ifdef NO_MMAP diff --git a/usage.c b/usage.c index 52c2e96056..4dc5c77633 100644 --- a/usage.c +++ b/usage.c @@ -29,12 +29,17 @@ static void error_builtin(const char *err, va_list params) report("error: ", err, params); } +static void warn_builtin(const char *warn, va_list params) +{ + report("warning: ", warn, 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; +static void (*warn_routine)(const char *err, va_list params) = warn_builtin; void set_usage_routine(void (*routine)(const char *err) NORETURN) { @@ -51,6 +56,11 @@ void set_error_routine(void (*routine)(const char *err, va_list params)) error_routine = routine; } +void set_warn_routine(void (*routine)(const char *warn, va_list params)) +{ + warn_routine = routine; +} + void usage(const char *err) { @@ -75,3 +85,12 @@ int error(const char *err, ...) va_end(params); return -1; } + +void warn(const char *warn, ...) +{ + va_list params; + + va_start(params, warn); + warn_routine(warn, params); + va_end(params); +}