diff options
60 files changed, 991 insertions, 481 deletions
diff --git a/Documentation/RelNotes-1.5.4.4.txt b/Documentation/RelNotes-1.5.4.4.txt index 5635977c93..89fa6d03bc 100644 --- a/Documentation/RelNotes-1.5.4.4.txt +++ b/Documentation/RelNotes-1.5.4.4.txt @@ -37,10 +37,30 @@ Fixes since v1.5.4.3 * "git revert" did not properly fail when attempting to run with a dirty index. -Also included are a handful documentation updates. + * "git merge --no-commit --no-ff <other>" incorrectly made commits. + + * "git merge --squash --no-ff <other>", which is a nonsense combination + of options, was not rejected. + + * "git ls-remote" and "git remote show" against an empty repository + failed, instead of just giving an empty result (regression). + + * "git fast-import" did not handle a renamed path whose name needs to be + quoted, due to a bug in unquote_c_style() function. + + * "git cvsexportcommit" was confused when multiple files with the same + basename needed to be pushed out in the same commit. + + * "git daemon" did not send early errors to syslog. ---- -exec >/var/tmp/1 -echo O=$(git describe maint) -O=v1.5.4.3-32-g0f2d447 -git shortlog --no-merges $O..maint + * "git log --merge" did not work well with --left-right option. + + * "git svn" promprted for client cert password every time it accessed the + server. + + * The reset command in "git fast-import" data stream was documented to + end with an optional LF, but it actually required one. + + * "git svn dcommit/rebase" did not honor --rewrite-root option. + +Also included are a handful documentation updates. diff --git a/Documentation/RelNotes-1.5.5.txt b/Documentation/RelNotes-1.5.5.txt index b57fa1eb1a..874dad9a4f 100644 --- a/Documentation/RelNotes-1.5.5.txt +++ b/Documentation/RelNotes-1.5.5.txt @@ -160,13 +160,9 @@ Fixes since v1.5.4 All of the fixes in v1.5.4 maintenance series are included in this release, unless otherwise noted. - * "git-daemon" did not send early errors to syslog. - * "git-http-push" did not allow deletion of remote ref with the usual "push <remote> :<branch>" syntax. - * "git-log --merge" did not well work with --left-right option. - * "git-rebase --abort" did not go back to the right location if "git-reset" was run during the "git-rebase" session. diff --git a/Documentation/config.txt b/Documentation/config.txt index 2091caa111..c5e094a9c4 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -556,6 +556,11 @@ format.suffix:: `.patch`. Use this variable to change that suffix (make sure to include the dot if you want it). +format.pretty:: + The default pretty format for log/show/whatchanged command, + See linkgit:git-log[1], linkgit:git-show[1], + linkgit:git-whatchanged[1]. + gc.aggressiveWindow:: The window size parameter used in the delta compression algorithm used by 'git gc --aggressive'. This defaults @@ -749,8 +754,10 @@ merge.summary:: merge.tool:: Controls which merge resolution program is used by - linkgit:git-mergetool[1]. Valid values are: "kdiff3", "tkdiff", - "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff". + linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3", + "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and + "opendiff". Any other value is treated is custom merge tool + and there must be a corresponing mergetool.<tool>.cmd option. merge.verbosity:: Controls the amount of output shown by the recursive merge @@ -777,6 +784,31 @@ mergetool.<tool>.path:: Override the path for the given tool. This is useful in case your tool is not in the PATH. +mergetool.<tool>.cmd:: + Specify the command to invoke the specified merge tool. The + specified command is evaluated in shell with the following + variables available: 'BASE' is the name of a temporary file + containing the common base of the files to be merged, if available; + 'LOCAL' is the name of a temporary file containing the contents of + the file on the current branch; 'REMOTE' is the name of a temporary + file containing the contents of the file from the branch being + merged; 'MERGED' contains the name of the file to which the merge + tool should write the results of a successful merge. + +mergetool.<tool>.trustExitCode:: + For a custom merge command, specify whether the exit code of + the merge command can be used to determine whether the merge was + successful. If this is not set to true then the merge target file + timestamp is checked and the merge assumed to have been successful + if the file has been updated, otherwise the user is prompted to + indicate the success of the merge. + +mergetool.keepBackup:: + After performing a merge, the original file with conflict markers + can be saved as a file with a `.orig` extension. If this variable + is set to `false` then this file is not preserved. Defaults to + `true` (i.e. keep the backup files). + pack.window:: The size of the window used by linkgit:git-pack-objects[1] when no window size is given on the command line. Defaults to 10. @@ -864,15 +896,15 @@ remote.<name>.skipDefaultUpdate:: remote.<name>.receivepack:: The default program to execute on the remote side when pushing. See - option \--exec of linkgit:git-push[1]. + option \--receive-pack of linkgit:git-push[1]. remote.<name>.uploadpack:: The default program to execute on the remote side when fetching. See - option \--exec of linkgit:git-fetch-pack[1]. + option \--upload-pack of linkgit:git-fetch-pack[1]. remote.<name>.tagopt:: - Setting this value to --no-tags disables automatic tag following when fetching - from remote <name> + Setting this value to \--no-tags disables automatic tag following when + fetching from remote <name> remotes.<group>:: The list of remotes which are fetched by "git remote update @@ -939,12 +971,6 @@ imap:: The configuration variables in the 'imap' section are described in linkgit:git-imap-send[1]. -receive.fsckObjects:: - If it is set to true, git-receive-pack will check all received - objects. It will abort in the case of a malformed object or a - broken link. The result of an abort are only dangling objects. - The default value is true. - receive.unpackLimit:: If the number of objects received in a push is below this limit then the objects will be unpacked into loose object diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index e640fc75cd..2387a8d6c2 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox SYNOPSIS -------- [verse] -'git-am' [--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8] +'git-am' [--signoff] [--keep] [--utf8 | --no-utf8] [--3way] [--interactive] [--binary] [--whitespace=<option>] [-C<n>] [-p<n>] <mbox>|<Maildir>... @@ -32,10 +32,6 @@ OPTIONS Add `Signed-off-by:` line to the commit message, using the committer identity of yourself. --d=<dir>, --dotest=<dir>:: - Instead of `.dotest` directory, use <dir> as a working - area to store extracted patches. - -k, --keep:: Pass `-k` flag to `git-mailinfo` (see linkgit:git-mailinfo[1]). diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt index 0c9ad7f2bb..c136b10692 100644 --- a/Documentation/git-merge.txt +++ b/Documentation/git-merge.txt @@ -68,7 +68,8 @@ HOW MERGE WORKS --------------- A merge is always between the current `HEAD` and one or more -remote branch heads, and the index file must exactly match the +commits (usually, branch head or tag), and the index file must +exactly match the tree of `HEAD` commit (i.e. the contents of the last commit) when it happens. In other words, `git-diff --cached HEAD` must report no changes. diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt index 50f106ec5b..8ed44947ef 100644 --- a/Documentation/git-mergetool.txt +++ b/Documentation/git-mergetool.txt @@ -12,12 +12,12 @@ SYNOPSIS DESCRIPTION ----------- -Use 'git mergetool' to run one of several merge utilities to resolve +Use `git mergetool` to run one of several merge utilities to resolve merge conflicts. It is typically run after linkgit:git-merge[1]. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file. If no <file> names are -specified, 'git mergetool' will run the merge tool program on every file +specified, `git mergetool` will run the merge tool program on every file with merge conflicts. OPTIONS @@ -27,16 +27,38 @@ OPTIONS Valid merge tools are: kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff + -If a merge resolution program is not specified, 'git mergetool' -will use the configuration variable merge.tool. If the -configuration variable merge.tool is not set, 'git mergetool' +If a merge resolution program is not specified, `git mergetool` +will use the configuration variable `merge.tool`. If the +configuration variable `merge.tool` is not set, `git mergetool` will pick a suitable default. + You can explicitly provide a full path to the tool by setting the -configuration variable mergetool.<tool>.path. For example, you +configuration variable `mergetool.<tool>.path`. For example, you can configure the absolute path to kdiff3 by setting -mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool -is available in PATH. +`mergetool.kdiff3.path`. Otherwise, `git mergetool` assumes the +tool is available in PATH. ++ +Instead of running one of the known merge tool programs +`git mergetool` can be customized to run an alternative program +by specifying the command line to invoke in a configration +variable `mergetool.<tool>.cmd`. ++ +When `git mergetool` is invoked with this tool (either through the +`-t` or `--tool` option or the `merge.tool` configuration +variable) the configured command line will be invoked with `$BASE` +set to the name of a temporary file containing the common base for +the merge, if available; `$LOCAL` set to the name of a temporary +file containing the contents of the file on the current branch; +`$REMOTE` set to the name of a temporary file containing the +contents of the file to be merged, and `$MERGED` set to the name +of the file to which the merge tool should write the result of the +merge resolution. ++ +If the custom merge tool correctly indicates the success of a +merge resolution with its exit code then the configuration +variable `mergetool.<tool>.trustExitCode` can be set to `true`. +Otherwise, `git mergetool` will prompt the user to indicate the +success of the resolution after the custom tool has exited. Author ------ diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt index f9bba36c23..047e3ce14d 100644 --- a/Documentation/git-reflog.txt +++ b/Documentation/git-reflog.txt @@ -19,6 +19,8 @@ depending on the subcommand: git reflog expire [--dry-run] [--stale-fix] [--verbose] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>... +git reflog delete ref@\{specifier\}... + git reflog [show] [log-options] [<ref>] Reflog is a mechanism to record when the tip of branches are @@ -43,6 +45,9 @@ two moves ago", `master@\{one.week.ago\}` means "where master used to point to one week ago", and so on. See linkgit:git-rev-parse[1] for more details. +To delete single entries from the reflog, use the subcommand "delete" +and specify the _exact_ entry (e.g. ``git reflog delete master@\{2\}''). + OPTIONS ------- @@ -75,6 +80,15 @@ them. --all:: Instead of listing <refs> explicitly, prune all refs. +--updateref:: + Update the ref with the sha1 of the top reflog entry (i.e. + <ref>@\{0\}) after expiring or deleting. + +--rewrite:: + While expiring or deleting, adjust each reflog entry to ensure + that the `old` sha1 field points to the `new` sha1 field of the + previous entry. + --verbose:: Print extra information on screen. diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt index 48e6f5a3f7..8dc35d493e 100644 --- a/Documentation/git-stash.txt +++ b/Documentation/git-stash.txt @@ -8,7 +8,7 @@ git-stash - Stash the changes in a dirty working directory away SYNOPSIS -------- [verse] -'git-stash' (list | show [<stash>] | apply [<stash>] | clear) +'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>] | pop [<stash>]) 'git-stash' [save [<message>]] DESCRIPTION @@ -85,6 +85,17 @@ clear:: Remove all the stashed states. Note that those states will then be subject to pruning, and may be difficult or impossible to recover. +drop [<stash>]:: + + Remove a single stashed state from the stash list. When no `<stash>` + is given, it removes the latest one. i.e. `stash@\{0}` + +pop [<stash>]:: + + Remove a single stashed state from the stash list and apply on top + of the current working tree state. When no `<stash>` is given, + `stash@\{0}` is assumed. See also `apply`. + DISCUSSION ---------- diff --git a/Documentation/git-unpack-objects.txt b/Documentation/git-unpack-objects.txt index 3697896a06..b79be3fd4c 100644 --- a/Documentation/git-unpack-objects.txt +++ b/Documentation/git-unpack-objects.txt @@ -40,9 +40,6 @@ OPTIONS and make the best effort to recover as many objects as possible. ---strict:: - Don't write objects with broken content or links. - Author ------ diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt index 54947b6769..a6e7bd4c8b 100644 --- a/Documentation/git-whatchanged.txt +++ b/Documentation/git-whatchanged.txt @@ -38,11 +38,6 @@ OPTIONS Show git internal diff output, but for the whole tree, not just the top level. ---pretty=<format>:: - Controls the output format for the commit logs. - <format> can be one of 'raw', 'medium', 'short', 'full', - and 'oneline'. - -m:: By default, differences for merge commits are not shown. With this flag, show differences to that commit from all @@ -51,6 +46,10 @@ OPTIONS However, it is not very useful in general, although it *is* useful on a file-by-file basis. +include::pretty-options.txt[] + +include::pretty-formats.txt[] + Examples -------- git-whatchanged -p v2.6.12.. include/scsi drivers/scsi:: diff --git a/Documentation/git.txt b/Documentation/git.txt index 741ae0e4c8..3ed24d449a 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v1.5.4.3/git.html[documentation for release 1.5.4.3] +* link:v1.5.4.4/git.html[documentation for release 1.5.4.4] * release notes for + link:RelNotes-1.5.4.4.txt[1.5.4.4], link:RelNotes-1.5.4.3.txt[1.5.4.3], link:RelNotes-1.5.4.2.txt[1.5.4.2], link:RelNotes-1.5.4.1.txt[1.5.4.1], diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt index 973d8dd733..6d66c74cc1 100644 --- a/Documentation/pretty-options.txt +++ b/Documentation/pretty-options.txt @@ -4,6 +4,9 @@ where '<format>' can be one of 'oneline', 'short', 'medium', 'full', 'fuller', 'email', 'raw' and 'format:<string>'. When omitted, the format defaults to 'medium'. ++ +Note: you can specify the default pretty format in the repository +configuration (see linkgit:git-config[1]). --abbrev-commit:: Instead of showing the full 40-byte hexadecimal commit object diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt index fde3b45321..c364a22c8f 100644 --- a/Documentation/technical/api-run-command.txt +++ b/Documentation/technical/api-run-command.txt @@ -111,9 +111,10 @@ stderr as follows: .no_stdin, .no_stdout, .no_stderr: The respective channel is redirected to /dev/null. - .stdout_to_stderr: stdout of the child is redirected to the - parent's stderr (i.e. *not* to what .err or - .no_stderr specify). + .stdout_to_stderr: stdout of the child is redirected to its + stderr. This happens after stderr is itself redirected. + So stdout will follow stderr to wherever it is + redirected. To modify the environment of the sub-process, specify an array of string pointers (NULL terminated) in .env: @@ -478,6 +478,7 @@ ifeq ($(uname_S),FreeBSD) NO_MEMMEM = YesPlease BASIC_CFLAGS += -I/usr/local/include BASIC_LDFLAGS += -L/usr/local/lib + DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease endif ifeq ($(uname_S),OpenBSD) NO_STRCASESTR = YesPlease @@ -747,6 +748,9 @@ ifdef THREADED_DELTA_SEARCH EXTLIBS += -lpthread LIB_OBJS += thread-utils.o endif +ifdef DIR_HAS_BSD_GROUP_SEMANTICS + COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS +endif ifeq ($(TCLTK_PATH),) NO_TCLTK=NoThanks diff --git a/builtin-describe.c b/builtin-describe.c index 2f1e7ba150..df554b30af 100644 --- a/builtin-describe.c +++ b/builtin-describe.c @@ -21,6 +21,7 @@ static int longformat; static int abbrev = DEFAULT_ABBREV; static int max_candidates = 10; const char *pattern = NULL; +static int always; struct commit_name { struct tag *tag; @@ -156,7 +157,7 @@ static void display_name(struct commit_name *n) { if (n->prio == 2 && !n->tag) { n->tag = lookup_tag(n->sha1); - if (!n->tag || !n->tag->tag) + if (!n->tag || parse_tag(n->tag) || !n->tag->tag) die("annotated tag %s not available", n->path); if (strcmp(n->tag->tag, n->path)) warning("tag '%s' is really '%s' here", n->tag->tag, n->path); @@ -166,9 +167,11 @@ static void display_name(struct commit_name *n) printf("%s", n->tag->tag); else printf("%s", n->path); - if (longformat) - printf("-0-g%s", - find_unique_abbrev(n->tag->tagged->sha1, abbrev)); +} + +static void show_suffix(int depth, const unsigned char *sha1) +{ + printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev)); } static void describe(const char *arg, int last_one) @@ -195,7 +198,12 @@ static void describe(const char *arg, int last_one) n = cmit->util; if (n) { + /* + * Exact match to an existing ref. + */ display_name(n); + if (longformat) + show_suffix(0, n->tag->tagged->sha1); printf("\n"); return; } @@ -250,8 +258,14 @@ static void describe(const char *arg, int last_one) } } - if (!match_cnt) - die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1)); + if (!match_cnt) { + const unsigned char *sha1 = cmit->object.sha1; + if (always) { + printf("%s\n", find_unique_abbrev(sha1, abbrev)); + return; + } + die("cannot describe '%s'", sha1_to_hex(sha1)); + } qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt); @@ -281,8 +295,7 @@ static void describe(const char *arg, int last_one) display_name(all_matches[0].name); if (abbrev) - printf("-%d-g%s", all_matches[0].depth, - find_unique_abbrev(cmit->object.sha1, abbrev)); + show_suffix(all_matches[0].depth, cmit->object.sha1); printf("\n"); if (!last_one) @@ -305,6 +318,8 @@ int cmd_describe(int argc, const char **argv, const char *prefix) "consider <n> most recent tags (default: 10)"), OPT_STRING(0, "match", &pattern, "pattern", "only consider tags matching <pattern>"), + OPT_BOOLEAN(0, "always", &always, + "show abbreviated commit object as fallback"), OPT_END(), }; @@ -320,11 +335,13 @@ int cmd_describe(int argc, const char **argv, const char *prefix) die("--long is incompatible with --abbrev=0"); if (contains) { - const char **args = xmalloc((6 + argc) * sizeof(char*)); + const char **args = xmalloc((7 + argc) * sizeof(char*)); int i = 0; args[i++] = "name-rev"; args[i++] = "--name-only"; args[i++] = "--no-undefined"; + if (always) + args[i++] = "--always"; if (!all) { args[i++] = "--tags"; if (pattern) { diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c index 34fb6d5c61..7b28024224 100644 --- a/builtin-fetch-pack.c +++ b/builtin-fetch-pack.c @@ -41,7 +41,8 @@ static void rev_list_push(struct commit *commit, int mark) commit->object.flags |= mark; if (!(commit->object.parsed)) - parse_commit(commit); + if (parse_commit(commit)) + return; insert_by_date(commit, &rev_list); @@ -83,7 +84,8 @@ static void mark_common(struct commit *commit, if (!ancestors_only && !(o->flags & POPPED)) non_common_revs--; if (!o->parsed && !dont_parse) - parse_commit(commit); + if (parse_commit(commit)) + return; for (parents = commit->parents; parents; @@ -103,20 +105,20 @@ static const unsigned char* get_rev(void) while (commit == NULL) { unsigned int mark; - struct commit_list* parents; + struct commit_list *parents = NULL; if (rev_list == NULL || non_common_revs == 0) return NULL; commit = rev_list->item; if (!(commit->object.parsed)) - parse_commit(commit); + if (!parse_commit(commit)) + parents = commit->parents; + commit->object.flags |= POPPED; if (!(commit->object.flags & COMMON)) non_common_revs--; - parents = commit->parents; - if (commit->object.flags & COMMON) { /* do not send "have", and ignore ancestors */ commit = NULL; @@ -213,7 +215,8 @@ static int find_common(int fd[2], unsigned char *result_sha1, if (!lookup_object(sha1)) die("object not found: %s", line); /* make sure that it is parsed as shallow */ - parse_object(sha1); + if (!parse_object(sha1)) + die("error in object: %s", line); if (unregister_shallow(sha1)) die("no shallow found: %s", line); continue; diff --git a/builtin-log.c b/builtin-log.c index fe8fc6f22a..d983cbc7bc 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -20,6 +20,7 @@ static int default_show_root = 1; static const char *fmt_patch_subject_prefix = "PATCH"; +static const char *fmt_pretty; static void add_name_decoration(const char *prefix, const char *name, struct object *obj) { @@ -54,6 +55,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, rev->abbrev = DEFAULT_ABBREV; rev->commit_format = CMIT_FMT_DEFAULT; + if (fmt_pretty) + rev->commit_format = get_commit_format(fmt_pretty); rev->verbose_header = 1; DIFF_OPT_SET(&rev->diffopt, RECURSIVE); rev->show_root_diff = default_show_root; @@ -221,6 +224,8 @@ static int cmd_log_walk(struct rev_info *rev) static int git_log_config(const char *var, const char *value) { + if (!strcmp(var, "format.pretty")) + return git_config_string(&fmt_pretty, var, value); if (!strcmp(var, "format.subjectprefix")) { if (!value) config_error_nonbool(var); diff --git a/builtin-ls-remote.c b/builtin-ls-remote.c index 023754986e..8907a89d6c 100644 --- a/builtin-ls-remote.c +++ b/builtin-ls-remote.c @@ -94,11 +94,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix) transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack); ref = transport_get_remote_refs(transport); - transport_disconnect(transport); - - if (!ref) + if (transport_disconnect(transport)) return 1; - for ( ; ref; ref = ref->next) { if (!check_ref_type(ref, flags)) continue; diff --git a/builtin-name-rev.c b/builtin-name-rev.c index f22c8b5f5d..384da4db13 100644 --- a/builtin-name-rev.c +++ b/builtin-name-rev.c @@ -125,7 +125,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void } /* returns a static buffer */ -static const char *get_rev_name(struct object *o) +static const char *get_rev_name(const struct object *o) { static char buffer[1024]; struct rev_name *n; @@ -151,6 +151,26 @@ static const char *get_rev_name(struct object *o) } } +static void show_name(const struct object *obj, + const char *caller_name, + int always, int allow_undefined, int name_only) +{ + const char *name; + const unsigned char *sha1 = obj->sha1; + + if (!name_only) + printf("%s ", caller_name ? caller_name : sha1_to_hex(sha1)); + name = get_rev_name(obj); + if (name) + printf("%s\n", name); + else if (allow_undefined) + printf("undefined\n"); + else if (always) + printf("%s\n", find_unique_abbrev(sha1, DEFAULT_ABBREV)); + else + die("cannot describe '%s'", sha1_to_hex(sha1)); +} + static char const * const name_rev_usage[] = { "git-name-rev [options] ( --all | --stdin | <commit>... )", NULL @@ -159,7 +179,7 @@ static char const * const name_rev_usage[] = { int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = { 0, 0, NULL }; - int all = 0, transform_stdin = 0, allow_undefined = 1; + int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0; struct name_ref_data data = { 0, 0, NULL }; struct option opts[] = { OPT_BOOLEAN(0, "name-only", &data.name_only, "print only names (no SHA-1)"), @@ -170,6 +190,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_BOOLEAN(0, "all", &all, "list all commits reachable from all refs"), OPT_BOOLEAN(0, "stdin", &transform_stdin, "read from stdin"), OPT_BOOLEAN(0, "undefined", &allow_undefined, "allow to print `undefined` names"), + OPT_BOOLEAN(0, "always", &always, + "show abbreviated commit object as fallback"), OPT_END(), }; @@ -258,35 +280,14 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) int i, max; max = get_max_object_index(); - for (i = 0; i < max; i++) { - struct object * obj = get_indexed_object(i); - const char *name; - if (!obj) - continue; - if (!data.name_only) - printf("%s ", sha1_to_hex(obj->sha1)); - name = get_rev_name(obj); - if (name) - printf("%s\n", name); - else if (allow_undefined) - printf("undefined\n"); - else - die("cannot describe '%s'", sha1_to_hex(obj->sha1)); - } + for (i = 0; i < max; i++) + show_name(get_indexed_object(i), NULL, + always, allow_undefined, data.name_only); } else { int i; - for (i = 0; i < revs.nr; i++) { - const char *name; - if (!data.name_only) - printf("%s ", revs.objects[i].name); - name = get_rev_name(revs.objects[i].item); - if (name) - printf("%s\n", name); - else if (allow_undefined) - printf("undefined\n"); - else - die("cannot describe '%s'", sha1_to_hex(revs.objects[i].item->sha1)); - } + for (i = 0; i < revs.nr; i++) + show_name(revs.objects[i].item, revs.objects[i].name, + always, allow_undefined, data.name_only); } return 0; diff --git a/builtin-reflog.c b/builtin-reflog.c index ab53c8cb7c..280e24e151 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -14,6 +14,8 @@ static const char reflog_expire_usage[] = "git-reflog (show|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>..."; static unsigned long default_reflog_expire; static unsigned long default_reflog_expire_unreachable; @@ -22,9 +24,12 @@ struct cmd_reflog_expire_cb { struct rev_info revs; int dry_run; int stalefix; + int rewrite; + int updateref; int verbose; unsigned long expire_total; unsigned long expire_unreachable; + int recno; }; struct expire_reflog_cb { @@ -32,6 +37,7 @@ struct expire_reflog_cb { const char *ref; struct commit *ref_commit; struct cmd_reflog_expire_cb *cmd; + unsigned char last_kept_sha1[20]; }; struct collected_reflog { @@ -213,6 +219,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, if (timestamp < cb->cmd->expire_total) goto prune; + if (cb->cmd->rewrite) + osha1 = cb->last_kept_sha1; + old = new = NULL; if (cb->cmd->stalefix && (!keep_entry(&old, osha1) || !keep_entry(&new, nsha1))) @@ -230,6 +239,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, goto prune; } + if (cb->cmd->recno && --(cb->cmd->recno) == 0) + goto prune; + if (cb->newlog) { char sign = (tz < 0) ? '-' : '+'; int zone = (tz < 0) ? (-tz) : tz; @@ -237,6 +249,7 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, sha1_to_hex(osha1), sha1_to_hex(nsha1), email, timestamp, sign, zone, message); + hashcpy(cb->last_kept_sha1, nsha1); } if (cb->cmd->verbose) printf("keep %s", message); @@ -280,10 +293,20 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, status |= error("%s: %s", strerror(errno), newlog_path); unlink(newlog_path); + } 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 || + close_ref(lock) < 0)) { + status |= error("Couldn't write %s", + lock->lk->filename); + unlink(newlog_path); } else if (rename(newlog_path, log_file)) { status |= error("cannot rename %s to %s", newlog_path, log_file); unlink(newlog_path); + } else if (cmd->updateref && commit_ref(lock)) { + status |= error("Couldn't set %s", lock->ref_name); } } free(newlog_path); @@ -358,6 +381,10 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) cb.expire_unreachable = approxidate(arg + 21); else if (!strcmp(arg, "--stale-fix")) cb.stalefix = 1; + else if (!strcmp(arg, "--rewrite")) + cb.rewrite = 1; + else if (!strcmp(arg, "--updateref")) + cb.updateref = 1; else if (!strcmp(arg, "--all")) do_all = 1; else if (!strcmp(arg, "--verbose")) @@ -406,6 +433,78 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) return status; } +static int count_reflog_ent(unsigned char *osha1, unsigned char *nsha1, + const char *email, unsigned long timestamp, int tz, + const char *message, void *cb_data) +{ + struct cmd_reflog_expire_cb *cb = cb_data; + if (!cb->expire_total || timestamp < cb->expire_total) + cb->recno++; + return 0; +} + +static int cmd_reflog_delete(int argc, const char **argv, const char *prefix) +{ + struct cmd_reflog_expire_cb cb; + int i, status = 0; + + memset(&cb, 0, sizeof(cb)); + + for (i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n")) + cb.dry_run = 1; + else if (!strcmp(arg, "--rewrite")) + cb.rewrite = 1; + else if (!strcmp(arg, "--updateref")) + cb.updateref = 1; + else if (!strcmp(arg, "--verbose")) + cb.verbose = 1; + else if (!strcmp(arg, "--")) { + i++; + break; + } + else if (arg[0] == '-') + usage(reflog_delete_usage); + else + break; + } + + if (argc - i < 1) + return error("Nothing to delete?"); + + for ( ; i < argc; i++) { + const char *spec = strstr(argv[i], "@{"); + unsigned char sha1[20]; + char *ep, *ref; + int recno; + + if (!spec) { + status |= error("Not a reflog: %s", argv[i]); + continue; + } + + if (!dwim_ref(argv[i], spec - argv[i], sha1, &ref)) { + status |= error("%s points nowhere!", argv[i]); + continue; + } + + recno = strtoul(spec + 2, &ep, 10); + if (*ep == '}') { + cb.recno = -recno; + for_each_reflog_ent(ref, count_reflog_ent, &cb); + } else { + cb.expire_total = approxidate(spec + 2); + for_each_reflog_ent(ref, count_reflog_ent, &cb); + cb.expire_total = 0; + } + + status |= expire_reflog(ref, sha1, 0, &cb); + free(ref); + } + return status; +} + /* * main "reflog" */ @@ -425,6 +524,9 @@ int cmd_reflog(int argc, const char **argv, const char *prefix) if (!strcmp(argv[1], "expire")) return cmd_reflog_expire(argc - 1, argv + 1, prefix); + if (!strcmp(argv[1], "delete")) + return cmd_reflog_delete(argc - 1, argv + 1, prefix); + /* Not a recognized reflog command..*/ usage(reflog_usage); } diff --git a/builtin-reset.c b/builtin-reset.c index bb3e19240a..79424bb26e 100644 --- a/builtin-reset.c +++ b/builtin-reset.c @@ -17,9 +17,13 @@ #include "diffcore.h" #include "tree.h" #include "branch.h" +#include "parse-options.h" -static const char builtin_reset_usage[] = -"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]"; +static const char * const git_reset_usage[] = { + "git-reset [--mixed | --soft | --hard] [-q] [<commit>]", + "git-reset [--mixed] <commit> [--] <paths>...", + NULL +}; static char *args_to_str(const char **argv) { @@ -165,40 +169,31 @@ static const char *reset_type_names[] = { "mixed", "soft", "hard", NULL }; int cmd_reset(int argc, const char **argv, const char *prefix) { - int i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0; + int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0; const char *rev = "HEAD"; unsigned char sha1[20], *orig = NULL, sha1_orig[20], *old_orig = NULL, sha1_old_orig[20]; struct commit *commit; char *reflog_action, msg[1024]; + const struct option options[] = { + OPT_SET_INT(0, "mixed", &reset_type, + "reset HEAD and index", MIXED), + OPT_SET_INT(0, "soft", &reset_type, "reset only HEAD", SOFT), + OPT_SET_INT(0, "hard", &reset_type, + "reset HEAD, index and working tree", HARD), + OPT_BOOLEAN('q', NULL, &quiet, + "disable showing new HEAD in hard reset"), + OPT_END() + }; git_config(git_default_config); + argc = parse_options(argc, argv, options, git_reset_usage, + PARSE_OPT_KEEP_DASHDASH); reflog_action = args_to_str(argv); setenv("GIT_REFLOG_ACTION", reflog_action, 0); - while (i < argc) { - if (!strcmp(argv[i], "--mixed")) { - reset_type = MIXED; - i++; - } - else if (!strcmp(argv[i], "--soft")) { - reset_type = SOFT; - i++; - } - else if (!strcmp(argv[i], "--hard")) { - reset_type = HARD; - i++; - } - else if (!strcmp(argv[i], "-q")) { - quiet = 1; - i++; - } - else - break; - } - - if (i < argc && argv[i][0] != '-') + if (i < argc && strcmp(argv[i], "--")) rev = argv[i++]; if (get_sha1(rev, sha1)) @@ -211,8 +206,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix) if (i < argc && !strcmp(argv[i], "--")) i++; - else if (i < argc && argv[i][0] == '-') - usage(builtin_reset_usage); /* git reset tree [--] paths... can be used to * load chosen paths from the tree into the index without diff --git a/builtin-shortlog.c b/builtin-shortlog.c index af31abaaf8..b22b0edd65 100644 --- a/builtin-shortlog.c +++ b/builtin-shortlog.c @@ -70,11 +70,12 @@ static void insert_one_record(struct shortlog *log, else free(buffer); + /* Skip any leading whitespace, including any blank lines. */ + while (*oneline && isspace(*oneline)) + oneline++; eol = strchr(oneline, '\n'); if (!eol) eol = oneline + strlen(oneline); - while (*oneline && isspace(*oneline) && *oneline != '\n') - oneline++; if (!prefixcmp(oneline, "[PATCH")) { char *eob = strchr(oneline, ']'); if (eob && (!eol || eob < eol)) diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c index 9d2a854950..50e07faa12 100644 --- a/builtin-unpack-objects.c +++ b/builtin-unpack-objects.c @@ -7,13 +7,11 @@ #include "commit.h" #include "tag.h" #include "tree.h" -#include "tree-walk.h" #include "progress.h" #include "decorate.h" -#include "fsck.h" -static int dry_run, quiet, recover, has_errors, strict; -static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] [--strict] < pack-file"; +static int dry_run, quiet, recover, has_errors; +static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file"; /* We always read in 4kB chunks. */ static unsigned char buffer[4096]; @@ -33,16 +31,6 @@ static struct obj_buffer *lookup_object_buffer(struct object *base) return lookup_decoration(&obj_decorate, base); } -static void add_object_buffer(struct object *object, char *buffer, unsigned long size) -{ - struct obj_buffer *obj; - obj = xcalloc(1, sizeof(struct obj_buffer)); - obj->buffer = buffer; - obj->size = size; - if (add_decoration(&obj_decorate, object, obj)) - die("object %s tried to add buffer twice!", sha1_to_hex(object->sha1)); -} - /* * Make sure at least "min" bytes are available in the buffer, and * return the pointer to the buffer. @@ -146,58 +134,9 @@ static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1, struct obj_info { off_t offset; unsigned char sha1[20]; - struct object *obj; }; -#define FLAG_OPEN (1u<<20) -#define FLAG_WRITTEN (1u<<21) - static struct obj_info *obj_list; -unsigned nr_objects; - -static void write_cached_object(struct object *obj) -{ - unsigned char sha1[20]; - struct obj_buffer *obj_buf = lookup_object_buffer(obj); - if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0) - die("failed to write object %s", sha1_to_hex(obj->sha1)); - obj->flags |= FLAG_WRITTEN; -} - -static int check_object(struct object *obj, int type, void *data) -{ - if (!obj) - return 0; - - if (obj->flags & FLAG_WRITTEN) - return 1; - - if (type != OBJ_ANY && obj->type != type) - die("object type mismatch"); - - if (!(obj->flags & FLAG_OPEN)) { - unsigned long size; - int type = sha1_object_info(obj->sha1, &size); - if (type != obj->type || type <= 0) - die("object of unexpected type"); - obj->flags |= FLAG_WRITTEN; - return 1; - } - - if (fsck_object(obj, 1, fsck_error_function)) - die("Error in object"); - if (!fsck_walk(obj, check_object, 0)) - die("Error on reachable objects of %s", sha1_to_hex(obj->sha1)); - write_cached_object(obj); - return 1; -} - -static void write_rest(void) -{ - unsigned i; - for (i = 0; i < nr_objects; i++) - check_object(obj_list[i].obj, OBJ_ANY, 0); -} static void added_object(unsigned nr, enum object_type type, void *data, unsigned long size); @@ -205,36 +144,9 @@ static void added_object(unsigned nr, enum object_type type, static void write_object(unsigned nr, enum object_type type, void *buf, unsigned long size) { + if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0) + die("failed to write object"); added_object(nr, type, buf, size); - if (!strict) { - if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0) - die("failed to write object"); - free(buf); - obj_list[nr].obj = 0; - } else if (type == OBJ_BLOB) { - struct blob *blob; - if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0) - die("failed to write object"); - free(buf); - - blob = lookup_blob(obj_list[nr].sha1); - if (blob) - blob->object.flags |= FLAG_WRITTEN; - else - die("invalid blob object"); - obj_list[nr].obj = 0; - } else { - struct object *obj; - int eaten; - hash_sha1_file(buf, size, typename(type), obj_list[nr].sha1); - obj = parse_object_buffer(obj_list[nr].sha1, type, size, buf, &eaten); - if (!obj) - die("invalid %s", typename(type)); - /* buf is stored via add_object_buffer and in obj, if its a tree or commit */ - add_object_buffer(obj, buf, size); - obj->flags |= FLAG_OPEN; - obj_list[nr].obj = obj; - } } static void resolve_delta(unsigned nr, enum object_type type, @@ -251,6 +163,7 @@ static void resolve_delta(unsigned nr, enum object_type type, die("failed to apply delta"); free(delta); write_object(nr, type, result, result_size); + free(result); } static void added_object(unsigned nr, enum object_type type, @@ -280,8 +193,7 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size, if (!dry_run && buf) write_object(nr, type, buf, size); - else - free(buf); + free(buf); } static void unpack_delta_entry(enum object_type type, unsigned long delta_size, @@ -424,8 +336,7 @@ static void unpack_all(void) int i; struct progress *progress = NULL; struct pack_header *hdr = fill(sizeof(struct pack_header)); - - nr_objects = ntohl(hdr->hdr_entries); + unsigned nr_objects = ntohl(hdr->hdr_entries); if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE) die("bad pack file"); @@ -436,7 +347,6 @@ static void unpack_all(void) if (!quiet) progress = start_progress("Unpacking objects", nr_objects); obj_list = xmalloc(nr_objects * sizeof(*obj_list)); - memset(obj_list, 0, nr_objects * sizeof(*obj_list)); for (i = 0; i < nr_objects; i++) { unpack_one(i); display_progress(progress, i + 1); @@ -472,10 +382,6 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) recover = 1; continue; } - if (!strcmp(arg, "--strict")) { - strict = 1; - continue; - } if (!prefixcmp(arg, "--pack_header=")) { struct pack_header *hdr; char *c; @@ -501,8 +407,6 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix) unpack_all(); SHA1_Update(&ctx, buffer, offset); SHA1_Final(sha1, &ctx); - if (strict) - write_rest(); if (hashcmp(fill(20), sha1)) die("final sha1 did not match"); use(20); diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 8f70e1efc1..848c067b57 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -70,7 +70,15 @@ __git_ps1 () local b if [ -d "$g/../.dotest" ] then - r="|AM/REBASE" + if test -f "$g/../.dotest/rebasing" + then + r="|REBASE" + elif test -f "$g/../.dotest/applying" + then + r="|AM" + else + r="|AM/REBASE" + fi b="$(git symbolic-ref HEAD 2>/dev/null)" elif [ -f "$g/.dotest-merge/interactive" ] then @@ -506,7 +514,33 @@ _git_bisect () _git_branch () { - __gitcomp "$(__git_refs)" + local i c=1 only_local_ref="n" has_r="n" + + while [ $c -lt $COMP_CWORD ]; do + i="${COMP_WORDS[c]}" + case "$i" in + -d|-m) only_local_ref="y" ;; + -r) has_r="y" ;; + esac + c=$((++c)) + done + + case "${COMP_WORDS[COMP_CWORD]}" in + --*=*) COMPREPLY=() ;; + --*) + __gitcomp " + --color --no-color --verbose --abbrev= --no-abbrev + --track --no-track + " + ;; + *) + if [ $only_local_ref = "y" -a $has_r = "n" ]; then + __gitcomp "$(__git_heads)" + else + __gitcomp "$(__git_refs)" + fi + ;; + esac } _git_bundle () diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el index c9268234a5..4fa853fae7 100644 --- a/contrib/emacs/git.el +++ b/contrib/emacs/git.el @@ -1299,7 +1299,7 @@ Return the list of files that haven't been handled." (let (author-name author-email subject date msg) (with-temp-buffer (let ((coding-system (git-get-logoutput-coding-system))) - (git-call-process-env t nil "log" "-1" commit) + (git-call-process-env t nil "log" "-1" "--pretty=medium" commit) (goto-char (point-min)) (when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t) (setq author-name (match-string 1)) diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index be96600753..650ea34176 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -850,29 +850,32 @@ class P4Sync(Command): ## Should move this out, doesn't use SELF. def readP4Files(self, files): + filesForCommit = [] + filesToRead = [] + for f in files: + includeFile = True for val in self.clientSpecDirs: if f['path'].startswith(val[0]): - if val[1] > 0: - f['include'] = True - else: - f['include'] = False + if val[1] <= 0: + includeFile = False break - files = [f for f in files - if f['action'] != 'delete' and - (f.has_key('include') == False or f['include'] == True)] + if includeFile: + filesForCommit.append(f) + if f['action'] != 'delete': + filesToRead.append(f) - if not files: - return [] + filedata = [] + if len(filesToRead) > 0: + filedata = p4CmdList('-x - print', + stdin='\n'.join(['%s#%s' % (f['path'], f['rev']) + for f in filesToRead]), + stdin_mode='w+') - filedata = p4CmdList('-x - print', - stdin='\n'.join(['%s#%s' % (f['path'], f['rev']) - for f in files]), - stdin_mode='w+') - if "p4ExitCode" in filedata[0]: - die("Problems executing p4. Error: [%d]." - % (filedata[0]['p4ExitCode'])); + if "p4ExitCode" in filedata[0]: + die("Problems executing p4. Error: [%d]." + % (filedata[0]['p4ExitCode'])); j = 0; contents = {} @@ -896,10 +899,12 @@ class P4Sync(Command): contents[stat['depotFile']] = text - for f in files: - assert not f.has_key('data') - f['data'] = contents[f['path']] - return files + for f in filesForCommit: + path = f['path'] + if contents.has_key(path): + f['data'] = contents[path] + + return filesForCommit def commit(self, details, files, branch, branchPrefixes, parent = ""): epoch = details["time"] diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index 77c88ebf1f..62a740c482 100644 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -567,7 +567,7 @@ generate_general_email() echo "" if [ "$newrev_type" = "commit" ]; then echo $LOGBEGIN - git show --no-color --root -s $newrev + git show --no-color --root -s --pretty=medium $newrev echo $LOGEND else # What can we do here? The tag marks an object that is not diff --git a/fast-import.c b/fast-import.c index 7f197d5e36..655913ddb2 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2291,7 +2291,8 @@ static void cmd_reset_branch(void) else b = new_branch(sp); read_next_command(); - if (!cmd_from(b) && command_buf.len > 0) + cmd_from(b); + if (command_buf.len > 0) unread_command_buf = 1; } @@ -155,8 +155,6 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func) o_mode = 0; o_name = NULL; o_sha1 = NULL; - if (!desc.size) - return error_func(&item->object, FSCK_ERROR, "empty tree"); while (desc.size) { unsigned mode; @@ -9,7 +9,7 @@ git-am [options] <mbox>|<Maildir>... git-am [options] --resolved git-am [options] --skip -- -d,dotest= use <dir> and not .dotest +d,dotest= (removed -- do not use) i,interactive run interactively b,binary pass --allo-binary-replacement to git-apply 3,3way allow fall back on 3way merging if needed @@ -21,9 +21,11 @@ C= pass it through git-apply p= pass it through git-apply resolvemsg= override error message when patch failure occurs r,resolved to be used after a patch failure -skip skip the current patch" +skip skip the current patch +rebasing (internal use for git-rebase)" . git-sh-setup +prefix=$(git rev-parse --show-prefix) set_reflog_action am require_work_tree cd_to_toplevel @@ -49,10 +51,6 @@ stop_here_user_resolve () { then cmdline="$cmdline -3" fi - if test '.dotest' != "$dotest" - then - cmdline="$cmdline -d=$dotest" - fi echo "When you have resolved this problem run \"$cmdline --resolved\"." echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"." @@ -124,7 +122,8 @@ reread_subject () { } prec=4 -dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= +dotest=".dotest" +sign= utf8=t keep= skip= interactive= resolved= binary= rebasing= resolvemsg= resume= git_apply_opt= @@ -149,8 +148,11 @@ do resolved=t ;; --skip) skip=t ;; + --rebasing) + rebasing=t threeway=t keep=t binary=t ;; -d|--dotest) - shift; dotest=$1;; + die "-d option is no longer supported. Do not use." + ;; --resolvemsg) shift; resolvemsg=$1 ;; --whitespace) @@ -186,7 +188,7 @@ then 0,) # No file input but without resume parameters; catch # user error to feed us a patch from standard input - # when there is already .dotest. This is somewhat + # when there is already $dotest. This is somewhat # unreliable -- stdin could be /dev/null for example # and the caller did not intend to feed us a patch but # wanted to continue unattended. @@ -206,6 +208,24 @@ else # Start afresh. mkdir -p "$dotest" || exit + if test -n "$prefix" && test $# != 0 + then + first=t + for arg + do + test -n "$first" && { + set x + first= + } + case "$arg" in + /*) + set "$@" "$arg" ;; + *) + set "$@" "$prefix$arg" ;; + esac + done + shift + fi git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || { rm -fr "$dotest" exit 1 @@ -220,6 +240,12 @@ else echo "$utf8" >"$dotest/utf8" echo "$keep" >"$dotest/keep" echo 1 >"$dotest/next" + if test -n "$rebasing" + then + : >"$dotest/rebasing" + else + : >"$dotest/applying" + fi fi case "$resolved" in diff --git a/git-compat-util.h b/git-compat-util.h index 2a40703c85..591244351e 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -437,4 +437,10 @@ void git_qsort(void *base, size_t nmemb, size_t size, #define qsort git_qsort #endif +#ifndef DIR_HAS_BSD_GROUP_SEMANTICS +# define FORCE_DIR_SET_GID S_ISGID +#else +# define FORCE_DIR_SET_GID 0 +#endif + #endif diff --git a/git-cvsserver.perl b/git-cvsserver.perl index afe3d0b7fe..7f632af20d 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -2556,7 +2556,7 @@ sub update if ($base) { my @merged; # print "want to log between $base $parent \n"; - open(GITLOG, '-|', 'git-log', "$base..$parent") + open(GITLOG, '-|', 'git-log', '--pretty=medium', "$base..$parent") or die "Cannot call git-log: $!"; my $mergedhash; while (<GITLOG>) { diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 49e13f0bb1..010353ad82 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -252,7 +252,16 @@ while read commit parents; do git read-tree -i -m $commit ;; *) - git read-tree -i -m $commit:"$filter_subdir" + # The commit may not have the subdirectory at all + err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || { + if ! git rev-parse --verify $commit:"$filter_subdir" 2>/dev/null + then + rm -f "$GIT_INDEX_FILE" + else + echo >&2 "$err" + false + fi + } esac || die "Could not initialize the index" GIT_COMMIT=$commit diff --git a/git-gui/Makefile b/git-gui/Makefile index 01e0a46ba5..4e321742ab 100644 --- a/git-gui/Makefile +++ b/git-gui/Makefile @@ -224,6 +224,11 @@ else ifeq ($(shell $(MSGFMT) >/dev/null 2>&1 || echo $$?),127) MSGFMT := $(TCL_PATH) po/po2msg.sh endif + ifeq (msgfmt,$(MSGFMT)) + ifeq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null || echo $?),1) + MSGFMT := $(TCL_PATH) po/po2msg.sh + endif + endif endif msgsdir = $(gg_libdir)/msgs diff --git a/git-merge.sh b/git-merge.sh index 1c123a37e6..7dbbb1d79d 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -37,6 +37,7 @@ use_strategies= allow_fast_forward=t allow_trivial_merge=t +squash= no_commit= dropsave() { rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \ @@ -70,7 +71,7 @@ finish_up_to_date () { squash_message () { echo Squashed commit of the following: echo - git log --no-merges ^"$head" $remoteheads + git log --no-merges --pretty=medium ^"$head" $remoteheads } finish () { @@ -152,17 +153,21 @@ parse_config () { --summary) show_diffstat=t ;; --squash) - allow_fast_forward=t squash=t no_commit=t ;; + test "$allow_fast_forward" = t || + die "You cannot combine --squash with --no-ff." + squash=t no_commit=t ;; --no-squash) - allow_fast_forward=t squash= no_commit= ;; + squash= no_commit= ;; --commit) - allow_fast_forward=t squash= no_commit= ;; + no_commit= ;; --no-commit) - allow_fast_forward=t squash= no_commit=t ;; + no_commit=t ;; --ff) - allow_fast_forward=t squash= no_commit= ;; + allow_fast_forward=t ;; --no-ff) - allow_fast_forward=false squash= no_commit= ;; + test "$squash" != t || + die "You cannot combine --squash with --no-ff." + allow_fast_forward=f ;; -s|--strategy) shift case " $all_strategies " in diff --git a/git-mergetool.sh b/git-mergetool.sh index cbbb707959..5c86f69229 100755 --- a/git-mergetool.sh +++ b/git-mergetool.sh @@ -34,7 +34,7 @@ base_present () { cleanup_temp_files () { if test "$1" = --save-backup ; then - mv -- "$BACKUP" "$path.orig" + mv -- "$BACKUP" "$MERGED.orig" rm -f -- "$LOCAL" "$REMOTE" "$BASE" else rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP" @@ -67,14 +67,14 @@ resolve_symlink_merge () { read ans case "$ans" in [lL]*) - git checkout-index -f --stage=2 -- "$path" - git add -- "$path" + git checkout-index -f --stage=2 -- "$MERGED" + git add -- "$MERGED" cleanup_temp_files --save-backup return ;; [rR]*) - git checkout-index -f --stage=3 -- "$path" - git add -- "$path" + git checkout-index -f --stage=3 -- "$MERGED" + git add -- "$MERGED" cleanup_temp_files --save-backup return ;; @@ -95,12 +95,12 @@ resolve_deleted_merge () { read ans case "$ans" in [mMcC]*) - git add -- "$path" + git add -- "$MERGED" cleanup_temp_files --save-backup return ;; [dD]*) - git rm -- "$path" > /dev/null + git rm -- "$MERGED" > /dev/null cleanup_temp_files return ;; @@ -112,11 +112,11 @@ resolve_deleted_merge () { } check_unchanged () { - if test "$path" -nt "$BACKUP" ; then + if test "$MERGED" -nt "$BACKUP" ; then status=0; else while true; do - echo "$path seems unchanged." + echo "$MERGED seems unchanged." printf "Was the merge successful? [y/n] " read answer < /dev/tty case "$answer" in @@ -127,50 +127,38 @@ check_unchanged () { fi } -save_backup () { - if test "$status" -eq 0; then - mv -- "$BACKUP" "$path.orig" - fi -} - -remove_backup () { - if test "$status" -eq 0; then - rm "$BACKUP" - fi -} - merge_file () { - path="$1" + MERGED="$1" - f=`git ls-files -u -- "$path"` + f=`git ls-files -u -- "$MERGED"` if test -z "$f" ; then - if test ! -f "$path" ; then - echo "$path: file not found" + if test ! -f "$MERGED" ; then + echo "$MERGED: file not found" else - echo "$path: file does not need merging" + echo "$MERGED: file does not need merging" fi exit 1 fi - ext="$$$(expr "$path" : '.*\(\.[^/]*\)$')" - BACKUP="$path.BACKUP.$ext" - LOCAL="$path.LOCAL.$ext" - REMOTE="$path.REMOTE.$ext" - BASE="$path.BASE.$ext" + ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')" + BACKUP="$MERGED.BACKUP.$ext" + LOCAL="$MERGED.LOCAL.$ext" + REMOTE="$MERGED.REMOTE.$ext" + BASE="$MERGED.BASE.$ext" - mv -- "$path" "$BACKUP" - cp -- "$BACKUP" "$path" + mv -- "$MERGED" "$BACKUP" + cp -- "$BACKUP" "$MERGED" - base_mode=`git ls-files -u -- "$path" | awk '{if ($3==1) print $1;}'` - local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'` - remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'` + base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'` + local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'` + remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'` - base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null - local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null - remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null + base_present && git cat-file blob ":1:$prefix$MERGED" >"$BASE" 2>/dev/null + local_present && git cat-file blob ":2:$prefix$MERGED" >"$LOCAL" 2>/dev/null + remote_present && git cat-file blob ":3:$prefix$MERGED" >"$REMOTE" 2>/dev/null if test -z "$local_mode" -o -z "$remote_mode"; then - echo "Deleted merge conflict for '$path':" + echo "Deleted merge conflict for '$MERGED':" describe_file "$local_mode" "local" "$LOCAL" describe_file "$remote_mode" "remote" "$REMOTE" resolve_deleted_merge @@ -178,14 +166,14 @@ merge_file () { fi if is_symlink "$local_mode" || is_symlink "$remote_mode"; then - echo "Symbolic link merge conflict for '$path':" + echo "Symbolic link merge conflict for '$MERGED':" describe_file "$local_mode" "local" "$LOCAL" describe_file "$remote_mode" "remote" "$REMOTE" resolve_symlink_merge return fi - echo "Normal merge conflict for '$path':" + echo "Normal merge conflict for '$MERGED':" describe_file "$local_mode" "local" "$LOCAL" describe_file "$remote_mode" "remote" "$REMOTE" printf "Hit return to start merge resolution tool (%s): " "$merge_tool" @@ -194,36 +182,32 @@ merge_file () { case "$merge_tool" in kdiff3) if base_present ; then - ("$merge_tool_path" --auto --L1 "$path (Base)" --L2 "$path (Local)" --L3 "$path (Remote)" \ - -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1) + ("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \ + -o "$MERGED" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1) else - ("$merge_tool_path" --auto --L1 "$path (Local)" --L2 "$path (Remote)" \ - -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1) + ("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \ + -o "$MERGED" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1) fi status=$? - remove_backup ;; tkdiff) if base_present ; then - "$merge_tool_path" -a "$BASE" -o "$path" -- "$LOCAL" "$REMOTE" + "$merge_tool_path" -a "$BASE" -o "$MERGED" -- "$LOCAL" "$REMOTE" else - "$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE" + "$merge_tool_path" -o "$MERGED" -- "$LOCAL" "$REMOTE" fi status=$? - save_backup ;; meld|vimdiff) touch "$BACKUP" - "$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE" + "$merge_tool_path" -- "$LOCAL" "$MERGED" "$REMOTE" check_unchanged - save_backup ;; gvimdiff) - touch "$BACKUP" - "$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE" - check_unchanged - save_backup - ;; + touch "$BACKUP" + "$merge_tool_path" -f -- "$LOCAL" "$MERGED" "$REMOTE" + check_unchanged + ;; xxdiff) touch "$BACKUP" if base_present ; then @@ -231,53 +215,68 @@ merge_file () { -R 'Accel.SaveAsMerged: "Ctrl-S"' \ -R 'Accel.Search: "Ctrl+F"' \ -R 'Accel.SearchForward: "Ctrl-G"' \ - --merged-file "$path" -- "$LOCAL" "$BASE" "$REMOTE" + --merged-file "$MERGED" -- "$LOCAL" "$BASE" "$REMOTE" else "$merge_tool_path" -X --show-merged-pane \ -R 'Accel.SaveAsMerged: "Ctrl-S"' \ -R 'Accel.Search: "Ctrl+F"' \ -R 'Accel.SearchForward: "Ctrl-G"' \ - --merged-file "$path" -- "$LOCAL" "$REMOTE" + --merged-file "$MERGED" -- "$LOCAL" "$REMOTE" fi check_unchanged - save_backup ;; opendiff) touch "$BACKUP" if base_present; then - "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$path" | cat + "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" | cat else - "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat + "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED" | cat fi check_unchanged - save_backup ;; ecmerge) touch "$BACKUP" if base_present; then - "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$path" + "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$MERGED" else - "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path" + "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$MERGED" fi check_unchanged - save_backup ;; emerge) if base_present ; then - "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")" + "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")" else - "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")" + "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$MERGED")" fi status=$? - save_backup + ;; + *) + if test -n "$merge_tool_cmd"; then + if test "$merge_tool_trust_exit_code" = "false"; then + touch "$BACKUP" + ( eval $merge_tool_cmd ) + check_unchanged + else + ( eval $merge_tool_cmd ) + status=$? + fi + fi ;; esac if test "$status" -ne 0; then - echo "merge of $path failed" 1>&2 - mv -- "$BACKUP" "$path" + echo "merge of $MERGED failed" 1>&2 + mv -- "$BACKUP" "$MERGED" exit 1 fi - git add -- "$path" + + if test "$merge_keep_backup" = "true"; then + mv -- "$BACKUP" "$MERGED.orig" + else + rm -- "$BACKUP" + fi + + git add -- "$MERGED" cleanup_temp_files } @@ -309,12 +308,20 @@ do shift done +valid_custom_tool() +{ + merge_tool_cmd="$(git config mergetool.$1.cmd)" + test -n "$merge_tool_cmd" +} + valid_tool() { case "$1" in kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge) ;; # happy *) - return 1 + if ! valid_custom_tool "$1"; then + return 1 + fi ;; esac } @@ -380,10 +387,16 @@ else init_merge_tool_path "$merge_tool" - if ! type "$merge_tool_path" > /dev/null 2>&1; then + merge_keep_backup="$(git config --bool merge.keepBackup || echo true)" + + if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then echo "The merge tool $merge_tool is not available as '$merge_tool_path'" exit 1 fi + + if ! test -z "$merge_tool_cmd"; then + merge_tool_trust_exit_code="$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)" + fi fi diff --git a/git-rebase.sh b/git-rebase.sh index 6b9af962a9..452c5e7e01 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -376,7 +376,7 @@ fi if test -z "$do_merge" then git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD | - git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" && + git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" && move_to_original_branch ret=$? test 0 != $ret -a -d .dotest && diff --git a/git-send-email.perl b/git-send-email.perl index 29b1105c4c..be4a20d7cd 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -317,7 +317,7 @@ if ($suppress_cc{'all'}) { # If explicit old-style ones are specified, they trump --suppress-cc. $suppress_cc{'self'} = $suppress_from if defined $suppress_from; -$suppress_cc{'sob'} = $signed_off_cc if defined $signed_off_cc; +$suppress_cc{'sob'} = !$signed_off_cc if defined $signed_off_cc; # Debugging, print out the suppressions. if (0) { @@ -855,6 +855,7 @@ foreach my $t (@files) { $message .= $_; if (/^(Signed-off-by|Cc): (.*)$/i) { next if ($suppress_cc{'sob'}); + chomp; my $c = $2; chomp $c; next if ($c eq $sender and $suppress_cc{'self'}); diff --git a/git-stash.sh b/git-stash.sh index b00f888169..c2b68205a2 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (c) 2007, Nanako Shiraishi -USAGE='[ | save | list | show | apply | clear | create ]' +USAGE='[ | save | list | show | apply | clear | drop | pop | create ]' SUBDIRECTORY_OK=Yes OPTIONS_SPEC= @@ -196,6 +196,28 @@ apply_stash () { fi } +drop_stash () { + have_stash || die 'No stash entries to drop' + + if test $# = 0 + then + set x "$ref_stash@{0}" + shift + fi + # Verify supplied argument looks like a stash entry + s=$(git rev-parse --revs-only --no-flags "$@") && + git rev-parse --verify "$s:" > /dev/null 2>&1 && + git rev-parse --verify "$s^1:" > /dev/null 2>&1 && + git rev-parse --verify "$s^2:" > /dev/null 2>&1 || + die "$*: not a valid stashed state" + + git reflog delete --updateref --rewrite "$@" && + echo "Dropped $* ($s)" || die "$*: Could not drop stash entry" + + # clear_stash if we just dropped the last stash entry + git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash +} + # Main command set case "$1" in list) @@ -230,6 +252,18 @@ create) fi create_stash "$*" && echo "$w_commit" ;; +drop) + shift + drop_stash "$@" + ;; +pop) + shift + if apply_stash "$@" + then + test -z "$unstash_index" || shift + drop_stash "$@" + fi + ;; *) if test $# -eq 0 then diff --git a/git-svn.perl b/git-svn.perl index 9e2faf90aa..1195569529 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1540,9 +1540,14 @@ sub find_by_url { # repos_root and, path are optional $remotes->{$repo_id}->{$_}); } my $p = $path; + my $rwr = rewrite_root({repo_id => $repo_id}); unless (defined $p) { $p = $full_url; - $p =~ s#^\Q$u\E(?:/|$)## or next; + my $z = $u; + if ($rwr) { + $z = $rwr; + } + $p =~ s#^\Q$z\E(?:/|$)## or next; } foreach my $f (keys %$fetch) { next if $f ne $p; diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 922dee98b9..ec73cb1256 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -5305,51 +5305,19 @@ sub git_search { print "<table class=\"pickaxe search\">\n"; my $alternate = 1; $/ = "\n"; - my $git_command = git_cmd_str(); - my $searchqtext = $searchtext; - $searchqtext =~ s/'/'\\''/; - my $pickaxe_flags = $search_use_regexp ? '--pickaxe-regex' : ''; - open my $fd, "-|", "$git_command rev-list $hash | " . - "$git_command diff-tree -r --stdin -S\'$searchqtext\' $pickaxe_flags"; + open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts, + '--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext", + ($search_use_regexp ? '--pickaxe-regex' : ()); undef %co; my @files; while (my $line = <$fd>) { - if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) { - my %set; - $set{'file'} = $6; - $set{'from_id'} = $3; - $set{'to_id'} = $4; - $set{'id'} = $set{'to_id'}; - if ($set{'id'} =~ m/0{40}/) { - $set{'id'} = $set{'from_id'}; - } - if ($set{'id'} =~ m/0{40}/) { - next; - } - push @files, \%set; - } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){ + chomp $line; + next unless $line; + + my %set = parse_difftree_raw_line($line); + if (defined $set{'commit'}) { + # finish previous commit if (%co) { - if ($alternate) { - print "<tr class=\"dark\">\n"; - } else { - print "<tr class=\"light\">\n"; - } - $alternate ^= 1; - my $author = chop_and_escape_str($co{'author_name'}, 15, 5); - print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . - "<td><i>" . $author . "</i></td>\n" . - "<td>" . - $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}), - -class => "list subject"}, - chop_and_escape_str($co{'title'}, 50) . "<br/>"); - while (my $setref = shift @files) { - my %set = %$setref; - print $cgi->a({-href => href(action=>"blob", hash_base=>$co{'id'}, - hash=>$set{'id'}, file_name=>$set{'file'}), - -class => "list"}, - "<span class=\"match\">" . esc_path($set{'file'}) . "</span>") . - "<br/>\n"; - } print "</td>\n" . "<td class=\"link\">" . $cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") . @@ -5358,11 +5326,44 @@ sub git_search { print "</td>\n" . "</tr>\n"; } - %co = parse_commit($1); + + if ($alternate) { + print "<tr class=\"dark\">\n"; + } else { + print "<tr class=\"light\">\n"; + } + $alternate ^= 1; + %co = parse_commit($set{'commit'}); + my $author = chop_and_escape_str($co{'author_name'}, 15, 5); + print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" . + "<td><i>$author</i></td>\n" . + "<td>" . + $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}), + -class => "list subject"}, + chop_and_escape_str($co{'title'}, 50) . "<br/>"); + } elsif (defined $set{'to_id'}) { + next if ($set{'to_id'} =~ m/^0{40}$/); + + print $cgi->a({-href => href(action=>"blob", hash_base=>$co{'id'}, + hash=>$set{'to_id'}, file_name=>$set{'to_file'}), + -class => "list"}, + "<span class=\"match\">" . esc_path($set{'file'}) . "</span>") . + "<br/>\n"; } } close $fd; + # finish last commit (warning: repetition!) + if (%co) { + print "</td>\n" . + "<td class=\"link\">" . + $cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") . + " | " . + $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$co{'id'})}, "tree"); + print "</td>\n" . + "</tr>\n"; + } + print "</table>\n"; } @@ -284,23 +284,15 @@ void http_init(struct remote *remote) void http_cleanup(void) { struct active_request_slot *slot = active_queue_head; -#ifdef USE_CURL_MULTI - char *wait_url; -#endif while (slot != NULL) { struct active_request_slot *next = slot->next; + if (slot->curl != NULL) { #ifdef USE_CURL_MULTI - if (slot->in_use) { - curl_easy_getinfo(slot->curl, - CURLINFO_EFFECTIVE_URL, - &wait_url); - fprintf(stderr, "Waiting for %s\n", wait_url); - run_active_slot(slot); - } + curl_multi_remove_handle(curlm, slot->curl); #endif - if (slot->curl != NULL) curl_easy_cleanup(slot->curl); + } free(slot); slot = next; } @@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME"; static const char co_env[] = "GIT_COMMITTER_NAME"; static const char *env_hint = "\n" -"*** Your name cannot be determined from your system services (gecos).\n" +"*** Please tell me who you are.\n" "\n" "Run\n" "\n" @@ -283,7 +283,7 @@ int adjust_shared_perm(const char *path) ? (S_IXGRP|S_IXOTH) : 0)); if (S_ISDIR(mode)) - mode |= S_ISGID; + mode |= FORCE_DIR_SET_GID; if ((mode & st.st_mode) != mode && chmod(path, mode) < 0) return -2; return 0; @@ -288,7 +288,7 @@ int unquote_c_style(struct strbuf *sb, const char *quoted, const char **endp) switch (*quoted++) { case '"': if (endp) - *endp = quoted + 1; + *endp = quoted; return 0; case '\\': break; diff --git a/receive-pack.c b/receive-pack.c index de7e18c49e..f83ae87e15 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -10,7 +10,6 @@ static const char receive_pack_usage[] = "git-receive-pack <git-dir>"; static int deny_non_fast_forwards = 0; -static int receive_fsck_objects = 1; static int receive_unpack_limit = -1; static int transfer_unpack_limit = -1; static int unpack_limit = 100; @@ -36,11 +35,6 @@ static int receive_pack_config(const char *var, const char *value) return 0; } - if (strcmp(var, "receive.fsckobjects") == 0) { - receive_fsck_objects = git_config_bool(var, value); - return 0; - } - return git_default_config(var, value); } @@ -374,13 +368,11 @@ static const char *unpack(void) ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries)); if (ntohl(hdr.hdr_entries) < unpack_limit) { - int code, i = 0; - const char *unpacker[4]; - unpacker[i++] = "unpack-objects"; - if (receive_fsck_objects) - unpacker[i++] = "--strict"; - unpacker[i++] = hdr_arg; - unpacker[i++] = NULL; + int code; + const char *unpacker[3]; + unpacker[0] = "unpack-objects"; + unpacker[1] = hdr_arg; + unpacker[2] = NULL; code = run_command_v_opt(unpacker, RUN_GIT_CMD); switch (code) { case 0: @@ -401,8 +393,8 @@ static const char *unpack(void) return "unpacker exited with error code"; } } else { - const char *keeper[7]; - int s, status, i = 0; + const char *keeper[6]; + int s, status; char keep_arg[256]; struct child_process ip; @@ -410,14 +402,12 @@ static const char *unpack(void) if (gethostname(keep_arg + s, sizeof(keep_arg) - s)) strcpy(keep_arg + s, "localhost"); - keeper[i++] = "index-pack"; - keeper[i++] = "--stdin"; - if (receive_fsck_objects) - keeper[i++] = "--strict"; - keeper[i++] = "--fix-thin"; - keeper[i++] = hdr_arg; - keeper[i++] = keep_arg; - keeper[i++] = NULL; + keeper[0] = "index-pack"; + keeper[1] = "--stdin"; + keeper[2] = "--fix-thin"; + keeper[3] = hdr_arg; + keeper[4] = keep_arg; + keeper[5] = NULL; memset(&ip, 0, sizeof(ip)); ip.argv = keeper; ip.out = -1; @@ -1033,7 +1033,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) return 1; } -static int close_ref(struct ref_lock *lock) +int close_ref(struct ref_lock *lock) { if (close_lock_file(lock->lk)) return -1; @@ -1041,7 +1041,7 @@ static int close_ref(struct ref_lock *lock) return 0; } -static int commit_ref(struct ref_lock *lock) +int commit_ref(struct ref_lock *lock) { if (commit_lock_file(lock->lk)) return -1; @@ -33,6 +33,12 @@ extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_ #define REF_NODEREF 0x01 extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags); +/** Close the file descriptor owned by a lock and return the status */ +extern int close_ref(struct ref_lock *lock); + +/** Close and commit the ref locked by the lock */ +extern int commit_ref(struct ref_lock *lock); + /** Release any lock taken but not written. **/ extern void unlock_ref(struct ref_lock *lock); diff --git a/run-command.c b/run-command.c index 743757c36e..44100a749b 100644 --- a/run-command.c +++ b/run-command.c @@ -91,6 +91,13 @@ int start_command(struct child_process *cmd) close(cmd->in); } + if (cmd->no_stderr) + dup_devnull(2); + else if (need_err) { + dup2(fderr[1], 2); + close_pair(fderr); + } + if (cmd->no_stdout) dup_devnull(1); else if (cmd->stdout_to_stderr) @@ -103,13 +110,6 @@ int start_command(struct child_process *cmd) close(cmd->out); } - if (cmd->no_stderr) - dup_devnull(2); - else if (need_err) { - dup2(fderr[1], 2); - close_pair(fderr); - } - if (cmd->dir && chdir(cmd->dir)) die("exec %s: cd to %s failed (%s)", cmd->argv[0], cmd->dir, strerror(errno)); diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh index f959aae846..24476bede5 100755 --- a/t/t1410-reflog.sh +++ b/t/t1410-reflog.sh @@ -175,6 +175,33 @@ test_expect_success 'recover and check' ' ' +test_expect_success 'delete' ' + echo 1 > C && + test_tick && + git commit -m rat C && + + echo 2 > C && + test_tick && + git commit -m ox C && + + echo 3 > C && + test_tick && + git commit -m tiger C && + + test 5 = $(git reflog | wc -l) && + + git reflog delete master@{1} && + git reflog show master > output && + test 4 = $(wc -l < output) && + ! grep ox < output && + + git reflog delete master@{07.04.2005.15:15:00.-0700} && + git reflog show master > output && + test 3 = $(wc -l < output) && + ! grep dragon < output + +' + test_expect_success 'prune --expire' ' before=$(git count-objects | sed "s/ .*//") && diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 3417138a80..37944c39a3 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -23,37 +23,49 @@ test_expect_success setup ' git branch pre-rebase ' -test_expect_success 'rebase --abort' ' - test_must_fail git rebase master && - git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) -' +testrebase() { + type=$1 + dotest=$2 -test_expect_success 'rebase --abort after --skip' ' - # Clean up the state from the previous one - git reset --hard pre-rebase - rm -rf .dotest + test_expect_success "rebase$type --abort" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + git rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' - test_must_fail git rebase master && - test_must_fail git rebase --skip && - test $(git rev-parse HEAD) = $(git rev-parse master) && - git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) -' + test_expect_success "rebase$type --abort after --skip" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + test_must_fail git rebase --skip && + test $(git rev-parse HEAD) = $(git rev-parse master) && + git-rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' -test_expect_success 'rebase --abort after --continue' ' - # Clean up the state from the previous one - git reset --hard pre-rebase - rm -rf .dotest + test_expect_success "rebase$type --abort after --continue" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + echo c > a && + echo d >> a && + git add a && + test_must_fail git rebase --continue && + test $(git rev-parse HEAD) != $(git rev-parse master) && + git rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' +} - test_must_fail git rebase master && - echo c > a && - echo d >> a && - git add a && - test_must_fail git rebase --continue && - test $(git rev-parse HEAD) != $(git rev-parse master) && - git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) -' +testrebase "" .dotest +testrebase " --merge" .git/.dotest-merge test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 9a9a250d2c..aa282e1bc1 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -40,8 +40,8 @@ test_expect_success 'parents of stash' ' test_expect_success 'apply needs clean working directory' ' echo 4 > other-file && git add other-file && - echo 5 > other-file - ! git stash apply + echo 5 > other-file && + test_must_fail git stash apply ' test_expect_success 'apply stashed changes' ' @@ -70,7 +70,51 @@ test_expect_success 'unstashing in a subdirectory' ' git reset --hard HEAD && mkdir subdir && cd subdir && - git stash apply + git stash apply && + cd .. +' + +test_expect_success 'drop top stash' ' + git reset --hard && + git stash list > stashlist1 && + echo 7 > file && + git stash && + git stash drop && + git stash list > stashlist2 && + diff stashlist1 stashlist2 && + git stash apply && + test 3 = $(cat file) && + test 1 = $(git show :file) && + test 1 = $(git show HEAD:file) +' + +test_expect_success 'drop middle stash' ' + git reset --hard && + echo 8 > file && + git stash && + echo 9 > file && + git stash && + git stash drop stash@{1} && + test 2 = $(git stash list | wc -l) && + git stash apply && + test 9 = $(cat file) && + test 1 = $(git show :file) && + test 1 = $(git show HEAD:file) && + git reset --hard && + git stash drop && + git stash apply && + test 3 = $(cat file) && + test 1 = $(git show :file) && + test 1 = $(git show HEAD:file) +' + +test_expect_success 'stash pop' ' + git reset --hard && + git stash pop && + test 3 = $(cat file) && + test 1 = $(git show :file) && + test 1 = $(git show HEAD:file) && + test 0 = $(git stash list | wc -l) ' test_done diff --git a/t/t4150-am-subdir.sh b/t/t4150-am-subdir.sh new file mode 100755 index 0000000000..929d2cbd87 --- /dev/null +++ b/t/t4150-am-subdir.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +test_description='git am running from a subdirectory' + +. ./test-lib.sh + +test_expect_success setup ' + echo hello >world && + git add world && + test_tick && + git commit -m initial && + git tag initial && + echo goodbye >world && + git add world && + test_tick && + git commit -m second && + git format-patch --stdout HEAD^ >patchfile && + : >expect +' + +test_expect_success 'am regularly from stdin' ' + git checkout initial && + git am <patchfile && + git diff master >actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file' ' + git checkout initial && + git am patchfile && + git diff master >actual && + diff -u expect actual +' + +test_expect_success 'am regularly from stdin in subdirectory' ' + rm -fr subdir && + git checkout initial && + ( + mkdir -p subdir && + cd subdir && + git am <../patchfile + ) && + git diff master>actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file in subdirectory' ' + rm -fr subdir && + git checkout initial && + ( + mkdir -p subdir && + cd subdir && + git am ../patchfile + ) && + git diff master >actual && + diff -u expect actual +' + +test_expect_success 'am regularly from file in subdirectory with full path' ' + rm -fr subdir && + git checkout initial && + P=$(pwd) && + ( + mkdir -p subdir && + cd subdir && + git am "$P/patchfile" + ) && + git diff master >actual && + diff -u expect actual +' + +test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index a7557bdc79..56bbd8519d 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -15,8 +15,11 @@ test_description='test describe check_describe () { expect="$1" shift - R=$(git describe "$@") && + R=$(git describe "$@" 2>err.actual) + S=$? + cat err.actual >&3 test_expect_success "describe $*" ' + test $S = 0 && case "$R" in $expect) echo happy ;; *) echo "Oops - $R is not $expect"; @@ -95,5 +98,23 @@ check_describe A-* --tags HEAD^^2 check_describe B --tags HEAD^^2^ check_describe B-0-* --long HEAD^^2^ +check_describe A-3-* --long HEAD^^2 + +test_expect_success 'rename tag A to Q locally' ' + mv .git/refs/tags/A .git/refs/tags/Q +' +cat - >err.expect <<EOF +warning: tag 'A' is really 'Q' here +EOF +check_describe A-* HEAD +test_expect_success 'warning was displayed for Q' ' + git diff err.expect err.actual +' +test_expect_success 'rename tag Q back to A' ' + mv .git/refs/tags/Q .git/refs/tags/A +' + +test_expect_success 'pack tag refs' 'git pack-refs' +check_describe A-* HEAD test_done diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 868babc4b2..6e14bf1c7f 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -179,4 +179,28 @@ test_expect_success 'Name needing quotes' ' ' +test_expect_success 'Subdirectory filter with disappearing trees' ' + git reset --hard && + git checkout master && + + mkdir foo && + touch foo/bar && + git add foo && + test_tick && + git commit -m "Adding foo" && + + git rm -r foo && + test_tick && + git commit -m "Removing foo" && + + mkdir foo && + touch foo/bar && + git add foo && + test_tick && + git commit -m "Re-adding foo" && + + git filter-branch -f --subdirectory-filter foo && + test $(git rev-list master | wc -l) = 3 +' + test_done diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 38403643a6..4037142927 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -320,8 +320,9 @@ test_expect_success 'removal failure' ' mkdir foo && touch foo/bar && + exec <foo/bar && chmod 0 foo && - ! git clean -f -d + test_must_fail git clean -f -d ' chmod 755 foo diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 50c51c82fa..5d166280cb 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -419,6 +419,7 @@ test_debug 'gitk --all' test_expect_success 'merge c0 with c1 (no-ff)' ' git reset --hard c0 && + git config branch.master.mergeoptions "" && test_tick && git merge --no-ff c1 && verify_merge file result.1 && @@ -427,6 +428,11 @@ test_expect_success 'merge c0 with c1 (no-ff)' ' test_debug 'gitk --all' +test_expect_success 'combining --squash and --no-ff is refused' ' + test_must_fail git merge --squash --no-ff c1 && + test_must_fail git merge --no-ff --squash c1 +' + test_expect_success 'merge c0 with c1 (ff overrides no-ff)' ' git reset --hard c0 && git config branch.master.mergeoptions "--no-ff" && diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh new file mode 100644 index 0000000000..6b0483f3e9 --- /dev/null +++ b/t/t7610-mergetool.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Copyright (c) 2008 Charles Bailey +# + +test_description='git-mergetool + +Testing basic merge tool invocation' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo master >file1 && + git add file1 && + git commit -m "added file1" && + git checkout -b branch1 master && + echo branch1 change >file1 && + echo branch1 newfile >file2 && + git add file1 file2 && + git commit -m "branch1 changes" && + git checkout -b branch2 master && + echo branch2 change >file1 && + echo branch2 newfile >file2 && + git add file1 file2 && + git commit -m "branch2 changes" && + git checkout master && + echo master updated >file1 && + echo master new >file2 && + git add file1 file2 && + git commit -m "master updates" +' + +test_expect_success 'custom mergetool' ' + git config merge.tool mytool && + git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" && + git config mergetool.mytool.trustExitCode true && + git checkout branch1 && + ! git merge master >/dev/null 2>&1 && + ( yes "" | git mergetool file1>/dev/null 2>&1 ) && + ( yes "" | git mergetool file2>/dev/null 2>&1 ) && + test "$(cat file1)" = "master updated" && + test "$(cat file2)" = "master new" && + git commit -m "branch1 resolved with mergetool" +' + +test_done diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index cceedbb2b7..c4f4465dc6 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -869,6 +869,8 @@ zcommits COMMIT reset refs/tags/O3-2nd from :5 +reset refs/tags/O3-3rd +from :5 INPUT_END cat >expect <<INPUT_END diff --git a/t/test-lib.sh b/t/test-lib.sh index 87a5ea4a6a..6aea0ea0a5 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -3,12 +3,16 @@ # Copyright (c) 2005 Junio C Hamano # +# Keep the original TERM for say_color +ORIGINAL_TERM=$TERM + # For repeatability, reset the environment to known value. LANG=C LC_ALL=C PAGER=cat TZ=UTC -export LANG LC_ALL PAGER TZ +TERM=dumb +export LANG LC_ALL PAGER TERM TZ EDITOR=: VISUAL=: unset GIT_EDITOR @@ -58,12 +62,14 @@ esac # This test checks if command xyzzy does the right thing... # ' # . ./test-lib.sh - -[ "x$TERM" != "xdumb" ] && - [ -t 1 ] && - tput bold >/dev/null 2>&1 && - tput setaf 1 >/dev/null 2>&1 && - tput sgr0 >/dev/null 2>&1 && +[ "x$ORIGINAL_TERM" != "xdumb" ] && ( + TERM=$ORIGINAL_TERM && + export TERM && + [ -t 1 ] && + tput bold >/dev/null 2>&1 && + tput setaf 1 >/dev/null 2>&1 && + tput sgr0 >/dev/null 2>&1 + ) && color=t while test "$#" -ne 0 @@ -91,6 +97,9 @@ done if test -n "$color"; then say_color () { + ( + TERM=$ORIGINAL_TERM + export TERM case "$1" in error) tput bold; tput setaf 1;; # bold red skip) tput bold; tput setaf 2;; # bold green @@ -101,6 +110,7 @@ if test -n "$color"; then shift echo "* $*" tput sgr0 + ) } else say_color() { |