From: Junio C Hamano Date: Mon, 2 Jun 2008 05:55:33 +0000 (-0700) Subject: Merge branch 'jc/checkout' X-Git-Tag: v1.5.6-rc1~12 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=8f1b0637c15bdd67170db423c86f06ee5db273b7;hp=291d823e364cb51cab67f0786b809fe038b92aa8;p=git.git Merge branch 'jc/checkout' * 'jc/checkout': checkout: "best effort" checkout unpack_trees(): allow callers to differentiate worktree errors from merge errors checkout: consolidate reset_{to_new,clean_to_new}() checkout: make reset_clean_to_new() not die by itself --- diff --git a/Documentation/Makefile b/Documentation/Makefile index 9750334b9..ca4dadf94 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -4,7 +4,7 @@ MAN1_TXT= \ gitk.txt MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt MAN7_TXT=git.txt gitcli.txt gittutorial.txt gittutorial-2.txt \ - gitcvs-migration.txt + gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT) MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT)) @@ -12,13 +12,11 @@ MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT)) DOC_HTML=$(MAN_HTML) -ARTICLES = core-tutorial -ARTICLES += diffcore +ARTICLES = diffcore ARTICLES += howto-index ARTICLES += repository-layout ARTICLES += everyday ARTICLES += git-tools -ARTICLES += glossary # with their own formatting rules. SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt))) diff --git a/Documentation/config.txt b/Documentation/config.txt index c298dc21c..5331b450e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -205,10 +205,13 @@ Can be overridden by the 'GIT_PROXY_COMMAND' environment variable handling). core.ignoreStat:: - The working copy files are assumed to stay unchanged until you - mark them otherwise manually - Git will not detect the file changes - by lstat() calls. This is useful on systems where those are very - slow, such as Microsoft Windows. See linkgit:git-update-index[1]. + If true, commands which modify both the working tree and the index + will mark the updated paths with the "assume unchanged" bit in the + index. These marked files are then assumed to stay unchanged in the + working copy, until you mark them otherwise manually - Git will not + detect the file changes by lstat() calls. This is useful on systems + where those are very slow, such as Microsoft Windows. + See linkgit:git-update-index[1]. False by default. core.preferSymlinkRefs:: diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index b17ae8485..b48c31289 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one SYNOPSIS -------- -'git-init' [-q | --quiet] [--template=] [--shared[=]] +'git-init' [-q | --quiet] [--bare] [--template=] [--shared[=]] OPTIONS @@ -20,6 +20,11 @@ OPTIONS Only print error and warning messages, all other output will be suppressed. +--bare:: + +Create a bare repository. If GIT_DIR environment is not set, it is set to the +current working directory. + --template=:: Provide the directory from which templates will be used. The default template diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index c9e4efe7f..f4cbd2f21 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -365,11 +365,15 @@ Passed directly to git-rebase when using 'dcommit' if a -n:: --dry-run:: -This is only used with the 'dcommit' command. +This can be used with the 'dcommit' and 'rebase' commands. -Print out the series of git arguments that would show +For 'dcommit', print out the series of git arguments that would show which diffs would be committed to SVN. +For 'rebase', display the local branch associated with the upstream svn +repository associated with the current branch and the URL of svn +repository that will be fetched from. + -- ADVANCED OPTIONS diff --git a/Documentation/git.txt b/Documentation/git.txt index 7182bb7f7..dae1b4031 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -174,7 +174,7 @@ See the references above to get started using git. The following is probably more detail than necessary for a first-time user. The link:user-manual.html#git-concepts[git concepts chapter of the -user-manual] and the link:core-tutorial.html[Core tutorial] both provide +user-manual] and the linkgit:gitcore-tutorial[7][Core tutorial] both provide introductions to the underlying git architecture. See also the link:howto-index.html[howto] documents for some useful @@ -374,7 +374,7 @@ Higher level SCMs may provide and manage additional information in the Terminology ----------- -Please see the link:glossary.html[glossary] document. +Please see the linkgit:gitglossary[7][glossary] document. Environment Variables @@ -518,7 +518,7 @@ Discussion[[Discussion]] More detail on the following is available from the link:user-manual.html#git-concepts[git concepts chapter of the -user-manual] and the link:core-tutorial.html[Core tutorial]. +user-manual] and the linkgit:gitcore-tutorial[7][Core tutorial]. A git project normally consists of a working directory with a ".git" subdirectory at the top level. The .git directory contains, among other @@ -579,6 +579,13 @@ The documentation for git suite was started by David Greaves , and later enhanced greatly by the contributors on the git-list . +SEE ALSO +-------- +linkgit:gittutorial[7], linkgit:gittutorial-2[7], +linkgit:giteveryday[7], linkgit:gitcvs-migration[7], +linkgit:gitglossary[7], linkgit:gitcore-tutorial[7], +link:user-manual.html[The Git User's Manual] + GIT --- Part of the linkgit:git[7] suite diff --git a/Documentation/core-tutorial.txt b/Documentation/gitcore-tutorial.txt similarity index 99% rename from Documentation/core-tutorial.txt rename to Documentation/gitcore-tutorial.txt index b50b5dd48..5995a2e15 100644 --- a/Documentation/core-tutorial.txt +++ b/Documentation/gitcore-tutorial.txt @@ -1,8 +1,16 @@ -A git core tutorial for developers -================================== +gitcore-tutorial(7) +=================== -Introduction ------------- +NAME +---- +gitcore-tutorial - A git core tutorial for developers + +SYNOPSIS +-------- +git * + +DESCRIPTION +----------- This tutorial explains how to use the "core" git programs to set up and work with a git repository. @@ -1679,3 +1687,13 @@ merge two at a time, documenting how you resolved the conflicts, and the reason why you preferred changes made in one side over the other. Otherwise it would make the project history harder to follow, not easier. + +SEE ALSO +-------- +linkgit:gittutorial[7], linkgit:gittutorial-2[7], +linkgit:giteveryday[7], linkgit:gitcvs-migration[7], +link:user-manual.html[The Git User's Manual] + +GIT +--- +Part of the linkgit:git[7] suite. diff --git a/Documentation/gitcvs-migration.txt b/Documentation/gitcvs-migration.txt index c41080502..de02a4268 100644 --- a/Documentation/gitcvs-migration.txt +++ b/Documentation/gitcvs-migration.txt @@ -20,7 +20,7 @@ this document explains how to do that. Some basic familiarity with git is required. This linkgit:gittutorial[7][tutorial introduction to git] and the -link:glossary.html[git glossary] should be sufficient. +linkgit:gitglossary[7][git glossary] should be sufficient. Developing against a shared repository -------------------------------------- @@ -184,7 +184,10 @@ repositories without the need for a central maintainer. SEE ALSO -------- -linkgit:gittutorial[7], linkgit:gittutorial-2[7], +linkgit:gittutorial[7], +linkgit:gittutorial-2[7], +linkgit:gitcore-tutorial[7], +linkgit:gitglossary[7], link:everyday.html[Everyday Git], link:user-manual.html[The Git User's Manual] diff --git a/Documentation/gitglossary.txt b/Documentation/gitglossary.txt new file mode 100644 index 000000000..e8475a042 --- /dev/null +++ b/Documentation/gitglossary.txt @@ -0,0 +1,25 @@ +gitglossary(7) +============== + +NAME +---- +gitglossary - A GIT Glossary + +SYNOPSIS +-------- +* + +DESCRIPTION +----------- + +include::glossary-content.txt[] + +SEE ALSO +-------- +linkgit:gittutorial[7], linkgit:gittutorial-2[7], +linkgit:giteveryday[7], linkgit:gitcvs-migration[7], +link:user-manual.html[The Git User's Manual] + +GIT +--- +Part of the linkgit:git[7] suite. diff --git a/Documentation/gittutorial-2.txt b/Documentation/gittutorial-2.txt index 5bbbf4305..4880ba9ae 100644 --- a/Documentation/gittutorial-2.txt +++ b/Documentation/gittutorial-2.txt @@ -390,7 +390,7 @@ in the index file is identical to the one in the working directory. In addition to being the staging area for new commits, the index file is also populated from the object database when checking out a branch, and is used to hold the trees involved in a merge operation. -See the link:core-tutorial.html[core tutorial] and the relevant man +See the linkgit:gitcore-tutorial[7][core tutorial] and the relevant man pages for details. What next? @@ -400,7 +400,7 @@ At this point you should know everything necessary to read the man pages for any of the git commands; one good place to start would be with the commands mentioned in link:everyday.html[Everyday git]. You should be able to find any unknown jargon in the -link:glossary.html[Glossary]. +linkgit:gitglossary[7][Glossary]. The link:user-manual.html[Git User's Manual] provides a more comprehensive introduction to git. @@ -412,7 +412,7 @@ CVS-like way. For some interesting examples of git use, see the link:howto-index.html[howtos]. -For git developers, the link:core-tutorial.html[Core tutorial] goes +For git developers, the linkgit:gitcore-tutorial[7][Core tutorial] goes into detail on the lower-level git mechanisms involved in, for example, creating a new commit. @@ -420,6 +420,8 @@ SEE ALSO -------- linkgit:gittutorial[7], linkgit:gitcvs-migration[7], +linkgit:gitcore-tutorial[7], +linkgit:gitglossary[7], link:everyday.html[Everyday git], link:user-manual.html[The Git User's Manual] diff --git a/Documentation/gittutorial.txt b/Documentation/gittutorial.txt index 898acdb53..722b32321 100644 --- a/Documentation/gittutorial.txt +++ b/Documentation/gittutorial.txt @@ -598,6 +598,8 @@ SEE ALSO -------- linkgit:gittutorial-2[7], linkgit:gitcvs-migration[7], +linkgit:gitcore-tutorial[7], +linkgit:gitglossary[7], link:everyday.html[Everyday git], link:user-manual.html[The Git User's Manual] diff --git a/Documentation/glossary.txt b/Documentation/glossary-content.txt similarity index 98% rename from Documentation/glossary.txt rename to Documentation/glossary-content.txt index 51b63532b..9b4a4f45e 100644 --- a/Documentation/glossary.txt +++ b/Documentation/glossary-content.txt @@ -1,6 +1,3 @@ -GIT Glossary -============ - [[def_alternate_object_database]]alternate object database:: Via the alternates mechanism, a <> can inherit part of its <> @@ -90,11 +87,10 @@ to point at the new commit. source code management tools. [[def_DAG]]DAG:: - Directed acyclic graph. The <> objects form a + Directed acyclic graph. The <> form a directed acyclic graph, because they have parents (directed), and the - graph of commit objects is acyclic (there is no - <> which begins and ends with the same - <>). + graph of commit objects is acyclic (there is no <> + which begins and ends with the same <>). [[def_dangling_object]]dangling object:: An <> which is not @@ -250,9 +246,10 @@ This commit is referred to as a "merge commit", or sometimes just a the <> of the object. [[def_object_type]]object type:: - One of the identifiers - "<>","<>","<>" or "<>" - describing the type of an <>. + One of the identifiers "<>", + "<>", "<>" or + "<>" describing the type of an + <>. [[def_octopus]]octopus:: To <> more than two <>. Also denotes an diff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt index b6eb7fc61..cbee36994 100644 --- a/Documentation/pull-fetch-param.txt +++ b/Documentation/pull-fetch-param.txt @@ -1,6 +1,8 @@ :: The "remote" repository that is the source of a fetch - or pull operation. See the section <> below. + or pull operation. This parameter can be either a URL + (see the section <> below) or the name + of a remote (see the section <> below). :: The canonical format of a parameter is diff --git a/Documentation/technical/api-revision-walking.txt b/Documentation/technical/api-revision-walking.txt index 01a24551a..996da0503 100644 --- a/Documentation/technical/api-revision-walking.txt +++ b/Documentation/technical/api-revision-walking.txt @@ -1,9 +1,67 @@ revision walking API ==================== +The revision walking API offers functions to build a list of revisions +and then iterate over that list. + +Calling sequence +---------------- + +The walking API has a given calling sequence: first you need to +initialize a rev_info structure, then add revisions to control what kind +of revision list do you want to get, finally you can iterate over the +revision list. + +Functions +--------- + +`init_revisions`:: + + Initialize a rev_info structure with default values. The second + parameter may be NULL or can be prefix path, and then the `.prefix` + variable will be set to it. This is typically the first function you + want to call when you want to deal with a revision list. After calling + this function, you are free to customize options, like set + `.ignore_merges` to 0 if you don't want to ignore merges, and so on. See + `revision.h` for a complete list of available options. + +`add_pending_object`:: + + This function can be used if you want to add commit objects as revision + information. You can use the `UNINTERESTING` object flag to indicate if + you want to include or exclude the given commit (and commits reachable + from the given commit) from the revision list. ++ +NOTE: If you have the commits as a string list then you probably want to +use setup_revisions(), instead of parsing each string and using this +function. + +`setup_revisions`:: + + Parse revision information, filling in the `rev_info` structure, and + removing the used arguments from the argument list. Returns the number + of arguments left that weren't recognized, which are also moved to the + head of the argument list. The last parameter is used in case no + parameter given by the first two arguments. + +`prepare_revision_walk`:: + + Prepares the rev_info structure for a walk. You should check if it + returns any error (non-zero return code) and if it does not, you can + start using get_revision() to do the iteration. + +`get_revision`:: + + Takes a pointer to a `rev_info` structure and iterates over it, + returning a `struct commit *` each time you call it. The end of the + revision list is indicated by returning a NULL pointer. + +Data structures +--------------- + Talk about , things like: * two diff_options, one for path limiting, another for output; -* calling sequence: init_revisions(), setup_revsions(), get_revision(); +* remaining functions; (Linus, JC, Dscho) diff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt index 5dd1f836c..99753006e 100644 --- a/Documentation/urls-remotes.txt +++ b/Documentation/urls-remotes.txt @@ -1,55 +1,82 @@ include::urls.txt[] -REMOTES -------- +REMOTES[[REMOTES]] +------------------ -In addition to the above, as a short-hand, the name of a -file in `$GIT_DIR/remotes` directory can be given; the -named file should be in the following format: +The name of one of the following can be used instead +of a URL as `` argument: ------------- - URL: one of the above URL format - Push: - Pull: +* a remote in the git configuration file: `$GIT_DIR/config`, +* a file in the `$GIT_DIR/remotes` directory, or +* a file in the `$GIT_DIR/branches` directory. ------------- +All of these also allow you to omit the refspec from the command line +because they each contain a refspec which git will use by default. -Then such a short-hand is specified in place of - without parameters on the command -line, specified on `Push:` lines or `Pull:` -lines are used for `git-push` and `git-fetch`/`git-pull`, -respectively. Multiple `Push:` and `Pull:` lines may -be specified for additional branch mappings. +Named remote in configuration file +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Or, equivalently, in the `$GIT_DIR/config` (note the use -of `fetch` instead of `Pull:`): +You can choose to provide the name of a remote which you had previously +configured using linkgit:git-remote[1], linkgit:git-config[1] +or even by a manual edit to the `$GIT_DIR/config` file. The URL of +this remote will be used to access the repository. The refspec +of this remote will be used by default when you do +not provide a refspec on the command line. The entry in the +config file would appear like this: ------------ - [remote ""] + [remote ""] url = push = fetch = - ------------ -The name of a file in `$GIT_DIR/branches` directory can be -specified as an older notation short-hand; the named -file should contain a single line, a URL in one of the -above formats, optionally followed by a hash `#` and the -name of remote head (URL fragment notation). -`$GIT_DIR/branches/` file that stores a -without the fragment is equivalent to have this in the -corresponding file in the `$GIT_DIR/remotes/` directory. + +Named file in `$GIT_DIR/remotes` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can choose to provide the name of a +file in `$GIT_DIR/remotes`. The URL +in this file will be used to access the repository. The refspec +in this file will be used as default when you do not +provide a refspec on the command line. This file should have the +following format: + +------------ + URL: one of the above URL format + Push: + Pull: ------------ - URL: - Pull: refs/heads/master: +`Push:` lines are used by `git-push` and +`Pull:` lines are used by `git-pull` and `git-fetch`. +Multiple `Push:` and `Pull:` lines may +be specified for additional branch mappings. + +Named file in `$GIT_DIR/branches` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can choose to provide the name of a +file in `$GIT_DIR/branches`. +The URL in this file will be used to access the repository. +This file should have the following format: + + +------------ + # ------------ -while having `#` is equivalent to +`` is required; `#` is optional. +When you do not provide a refspec on the command line, +git will use the following refspec, where `` defaults to `master`, +and `` is the name of this file +you provided in the command line. ------------ - URL: - Pull: refs/heads/: + refs/heads/: ------------ + + + + diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index fd8cdb625..bfde507e0 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -4252,7 +4252,10 @@ You see, Git is actually the best tool to find out about the source of Git itself! [[glossary]] -include::glossary.txt[] +GIT Glossary +============ + +include::glossary-content.txt[] [[git-quick-start]] Appendix A: Git Quick Reference diff --git a/builtin-init-db.c b/builtin-init-db.c index d8bdf928b..e23b8438c 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -364,7 +364,7 @@ static int guess_repository_type(const char *git_dir) } static const char init_db_usage[] = -"git-init [-q | --quiet] [--template=] [--shared]"; +"git-init [-q | --quiet] [--bare] [--template=] [--shared[=]]"; /* * If you want to, you can share the DB area with any number of branches. @@ -383,7 +383,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *arg = argv[1]; if (!prefixcmp(arg, "--template=")) template_dir = arg+11; - else if (!strcmp(arg, "--shared")) + else if (!strcmp(arg, "--bare")) { + static char git_dir[PATH_MAX+1]; + is_bare_repository_cfg = 1; + setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, + sizeof(git_dir)), 0); + } else if (!strcmp(arg, "--shared")) shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); diff --git a/git-svn.perl b/git-svn.perl index 3a6eb1cb9..47b0c37d1 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -177,6 +177,7 @@ my %cmd = ( 'strategy|s=s' => \$_strategy, 'local|l' => \$_local, 'fetch-all|all' => \$_fetch_all, + 'dry-run|n' => \$_dry_run, %fc_opts } ], 'commit-diff' => [ \&cmd_commit_diff, 'Commit a diff between two trees', @@ -557,6 +558,11 @@ sub cmd_rebase { die "Unable to determine upstream SVN information from ", "working tree history\n"; } + if ($_dry_run) { + print "Remote Branch: " . $gs->refname . "\n"; + print "SVN URL: " . $url . "\n"; + return; + } if (command(qw/diff-index HEAD --/)) { print STDERR "Cannot rebase with uncommited changes:\n"; command_noisy('status'); @@ -745,7 +751,7 @@ sub cmd_commit_diff { my $usage = "Usage: $0 commit-diff -r ". " []"; fatal($usage) if (!defined $ta || !defined $tb); - my $svn_path; + my $svn_path = ''; if (!defined $url) { my $gs = eval { Git::SVN->new }; if (!$gs) { @@ -769,7 +775,6 @@ sub cmd_commit_diff { $_message ||= get_commit_entry($tb)->{log}; } my $ra ||= Git::SVN::Ra->new($url); - $svn_path ||= $ra->{svn_path}; my $r = $_revision; if ($r eq 'HEAD') { $r = $ra->get_latest_revnum; @@ -1918,7 +1923,7 @@ sub prop_walk { foreach (sort keys %$dirent) { next if $dirent->{$_}->{kind} != $SVN::Node::dir; - $self->prop_walk($p . $_, $rev, $sub); + $self->prop_walk($self->{path} . $p . $_, $rev, $sub); } } diff --git "a/gitweb/test/M\303\244rchen" "b/gitweb/test/M\303\244rchen" deleted file mode 100644 index 8f7a1d3e9..000000000 --- "a/gitweb/test/M\303\244rchen" +++ /dev/null @@ -1,2 +0,0 @@ -Märchen -Märchen diff --git a/gitweb/test/file with spaces b/gitweb/test/file with spaces deleted file mode 100644 index f108543c4..000000000 --- a/gitweb/test/file with spaces +++ /dev/null @@ -1,4 +0,0 @@ -This -filename -contains -spaces. diff --git a/gitweb/test/file+plus+sign b/gitweb/test/file+plus+sign deleted file mode 100644 index fd0527880..000000000 --- a/gitweb/test/file+plus+sign +++ /dev/null @@ -1,6 +0,0 @@ -This -filename -contains -+ -plus -chars. diff --git a/graph.c b/graph.c index 26b8c5209..edfab2d5b 100644 --- a/graph.c +++ b/graph.c @@ -80,6 +80,27 @@ struct git_graph { * This tells us what kind of line graph_next_line() should output. */ enum graph_state state; + /* + * The output state for the previous line of output. + * This is primarily used to determine how the first merge line + * should appear, based on the last line of the previous commit. + */ + enum graph_state prev_state; + /* + * The index of the column that refers to this commit. + * + * If none of the incoming columns refer to this commit, + * this will be equal to num_columns. + */ + int commit_index; + /* + * The commit_index for the previously displayed commit. + * + * This is used to determine how the first line of a merge + * graph output should appear, based on the last line of the + * previous commit. + */ + int prev_commit_index; /* * The maximum number of columns that can be stored in the columns * and new_columns arrays. This is also half the number of entries @@ -137,6 +158,9 @@ struct git_graph *graph_init(struct rev_info *opt) graph->num_parents = 0; graph->expansion_row = 0; graph->state = GRAPH_PADDING; + graph->prev_state = GRAPH_PADDING; + graph->commit_index = 0; + graph->prev_commit_index = 0; graph->num_columns = 0; graph->num_new_columns = 0; graph->mapping_size = 0; @@ -164,6 +188,12 @@ void graph_release(struct git_graph *graph) free(graph); } +static void graph_update_state(struct git_graph *graph, enum graph_state s) +{ + graph->prev_state = graph->state; + graph->state = s; +} + static void graph_ensure_capacity(struct git_graph *graph, int num_columns) { if (graph->column_capacity >= num_columns) @@ -342,6 +372,7 @@ static void graph_update_columns(struct git_graph *graph) if (col_commit == graph->commit) { int old_mapping_idx = mapping_idx; seen_this = 1; + graph->commit_index = i; for (parent = graph->commit->parents; parent; parent = parent->next) { @@ -394,6 +425,13 @@ void graph_update(struct git_graph *graph, struct commit *commit) graph->num_parents++; } + /* + * Store the old commit_index in prev_commit_index. + * graph_update_columns() will update graph->commit_index for this + * commit. + */ + graph->prev_commit_index = graph->commit_index; + /* * Call graph_update_columns() to update * columns, new_columns, and mapping. @@ -404,21 +442,26 @@ void graph_update(struct git_graph *graph, struct commit *commit) /* * Update graph->state. + * Note that we don't call graph_update_state() here, since + * we don't want to update graph->prev_state. No line for + * graph->state was ever printed. * * If the previous commit didn't get to the GRAPH_PADDING state, * it never finished its output. Goto GRAPH_SKIP, to print out * a line to indicate that portion of the graph is missing. * - * Otherwise, if there are 3 or more parents, we need to print - * extra rows before the commit, to expand the branch lines around - * it and make room for it. + * If there are 3 or more parents, we may need to print extra rows + * before the commit, to expand the branch lines around it and make + * room for it. We need to do this only if there is a branch row + * (or more) to the right of this commit. * * If there are less than 3 parents, we can immediately print the * commit line. */ if (graph->state != GRAPH_PADDING) graph->state = GRAPH_SKIP; - else if (graph->num_parents >= 3) + else if (graph->num_parents >= 3 && + graph->commit_index < (graph->num_columns - 1)) graph->state = GRAPH_PRE_COMMIT; else graph->state = GRAPH_COMMIT; @@ -497,10 +540,11 @@ static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb) strbuf_addstr(sb, "..."); graph_pad_horizontally(graph, sb); - if (graph->num_parents >= 3) - graph->state = GRAPH_PRE_COMMIT; + if (graph->num_parents >= 3 && + graph->commit_index < (graph->num_columns - 1)) + graph_update_state(graph, GRAPH_PRE_COMMIT); else - graph->state = GRAPH_COMMIT; + graph_update_state(graph, GRAPH_COMMIT); } static void graph_output_pre_commit_line(struct git_graph *graph, @@ -535,7 +579,22 @@ static void graph_output_pre_commit_line(struct git_graph *graph, if (col->commit == graph->commit) { seen_this = 1; strbuf_addf(sb, "| %*s", graph->expansion_row, ""); - } else if (seen_this) { + } else if (seen_this && (graph->expansion_row == 0)) { + /* + * This is the first line of the pre-commit output. + * If the previous commit was a merge commit and + * ended in the GRAPH_POST_MERGE state, all branch + * lines after graph->prev_commit_index were + * printed as "\" on the previous line. Continue + * to print them as "\" on this line. Otherwise, + * print the branch lines as "|". + */ + if (graph->prev_state == GRAPH_POST_MERGE && + graph->prev_commit_index < i) + strbuf_addstr(sb, "\\ "); + else + strbuf_addstr(sb, "| "); + } else if (seen_this && (graph->expansion_row > 0)) { strbuf_addstr(sb, "\\ "); } else { strbuf_addstr(sb, "| "); @@ -550,7 +609,7 @@ static void graph_output_pre_commit_line(struct git_graph *graph, */ graph->expansion_row++; if (graph->expansion_row >= num_expansion_rows) - graph->state = GRAPH_COMMIT; + graph_update_state(graph, GRAPH_COMMIT); } static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb) @@ -625,10 +684,8 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb) seen_this = 1; graph_output_commit_char(graph, sb); - if (graph->num_parents < 2) + if (graph->num_parents < 3) strbuf_addch(sb, ' '); - else if (graph->num_parents == 2) - strbuf_addstr(sb, " "); else { int num_dashes = ((graph->num_parents - 2) * 2) - 1; @@ -636,8 +693,27 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb) strbuf_addch(sb, '-'); strbuf_addstr(sb, ". "); } - } else if (seen_this && (graph->num_parents > 1)) { + } else if (seen_this && (graph->num_parents > 2)) { strbuf_addstr(sb, "\\ "); + } else if (seen_this && (graph->num_parents == 2)) { + /* + * This is a 2-way merge commit. + * There is no GRAPH_PRE_COMMIT stage for 2-way + * merges, so this is the first line of output + * for this commit. Check to see what the previous + * line of output was. + * + * If it was GRAPH_POST_MERGE, the branch line + * coming into this commit may have been '\', + * and not '|' or '/'. If so, output the branch + * line as '\' on this line, instead of '|'. This + * makes the output look nicer. + */ + if (graph->prev_state == GRAPH_POST_MERGE && + graph->prev_commit_index < i) + strbuf_addstr(sb, "\\ "); + else + strbuf_addstr(sb, "| "); } else { strbuf_addstr(sb, "| "); } @@ -649,11 +725,11 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb) * Update graph->state */ if (graph->num_parents > 1) - graph->state = GRAPH_POST_MERGE; + graph_update_state(graph, GRAPH_POST_MERGE); else if (graph_is_mapping_correct(graph)) - graph->state = GRAPH_PADDING; + graph_update_state(graph, GRAPH_PADDING); else - graph->state = GRAPH_COLLAPSING; + graph_update_state(graph, GRAPH_COLLAPSING); } void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb) @@ -679,9 +755,7 @@ void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb) strbuf_addch(sb, '|'); for (j = 0; j < graph->num_parents - 1; j++) strbuf_addstr(sb, "\\ "); - if (graph->num_parents == 2) - strbuf_addch(sb, ' '); - } else if (seen_this && (graph->num_parents > 2)) { + } else if (seen_this) { strbuf_addstr(sb, "\\ "); } else { strbuf_addstr(sb, "| "); @@ -694,9 +768,9 @@ void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb) * Update graph->state */ if (graph_is_mapping_correct(graph)) - graph->state = GRAPH_PADDING; + graph_update_state(graph, GRAPH_PADDING); else - graph->state = GRAPH_COLLAPSING; + graph_update_state(graph, GRAPH_COLLAPSING); } void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb) @@ -801,7 +875,7 @@ void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb) * Otherwise, we need to collapse some branch lines together. */ if (graph_is_mapping_correct(graph)) - graph->state = GRAPH_PADDING; + graph_update_state(graph, GRAPH_PADDING); } int graph_next_line(struct git_graph *graph, struct strbuf *sb) @@ -865,6 +939,11 @@ void graph_padding_line(struct git_graph *graph, struct strbuf *sb) } graph_pad_horizontally(graph, sb); + + /* + * Update graph->prev_state since we have output a padding line + */ + graph->prev_state = GRAPH_PADDING; } int graph_is_commit_finished(struct git_graph const *graph) diff --git a/http-push.c b/http-push.c index f173dcd64..c93e781c3 100644 --- a/http-push.c +++ b/http-push.c @@ -2277,6 +2277,7 @@ int main(int argc, char **argv) signal(SIGINT, remove_locks_on_signal); signal(SIGHUP, remove_locks_on_signal); signal(SIGQUIT, remove_locks_on_signal); + signal(SIGTERM, remove_locks_on_signal); /* Check whether the remote has server info files */ remote->can_update_info_refs = 0; diff --git a/lockfile.c b/lockfile.c index cfc733534..4023797b0 100644 --- a/lockfile.c +++ b/lockfile.c @@ -135,6 +135,9 @@ static int lock_file(struct lock_file *lk, const char *path) if (0 <= lk->fd) { if (!lock_file_list) { signal(SIGINT, remove_lock_file_on_signal); + signal(SIGHUP, remove_lock_file_on_signal); + signal(SIGTERM, remove_lock_file_on_signal); + signal(SIGQUIT, remove_lock_file_on_signal); atexit(remove_lock_file); } lk->owner = getpid(); diff --git a/perl/Git.pm b/perl/Git.pm index d05b633b6..97e61efaf 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -565,7 +565,7 @@ sub config { my $E = shift; if ($E->value() == 1) { # Key not found. - return undef; + return; } else { throw $E; } @@ -719,9 +719,8 @@ sub ident_person { =item hash_object ( TYPE, FILENAME ) -Compute the SHA1 object id of the given C (or data waiting in -C) considering it is of the C object type (C, -C, C). +Compute the SHA1 object id of the given C considering it is +of the C object type (C, C, C). The method can be called without any instance or on a specified Git repository, it makes zero difference. diff --git a/read-cache.c b/read-cache.c index ac9a8e7e3..8e5fbb619 100644 --- a/read-cache.c +++ b/read-cache.c @@ -893,6 +893,15 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate, if (ce_uptodate(ce)) return ce; + /* + * CE_VALID means the user promised us that the change to + * the work tree does not matter and told us not to worry. + */ + if (!ignore_valid && (ce->ce_flags & CE_VALID)) { + ce_mark_uptodate(ce); + return ce; + } + if (lstat(ce->name, &st) < 0) { if (err) *err = errno; diff --git a/t/t0001-init.sh b/t/t0001-init.sh index b0289e397..d31887f9b 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -79,6 +79,17 @@ test_expect_success 'GIT_DIR bare' ' check_config git-dir-bare.git true unset ' +test_expect_success 'init --bare' ' + + ( + unset GIT_DIR GIT_WORK_TREE GIT_CONFIG + mkdir git-init-bare.git && + cd git-init-bare.git && + git init --bare + ) && + check_config git-init-bare.git true unset +' + test_expect_success 'GIT_DIR non-bare' ' ( diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh index 3531a992a..46ec1ce8a 100755 --- a/t/t7502-commit.sh +++ b/t/t7502-commit.sh @@ -212,4 +212,18 @@ test_expect_success 'do not fire editor in the presence of conflicts' ' test "`cat .git/result`" = "editor not started" ' +pwd=`pwd` +cat > .git/FAKE_EDITOR << EOF +#! /bin/sh +# kill -TERM command added below. +EOF + +test_expect_success 'a SIGTERM should break locks' ' + echo >>negative && + sh -c '\'' + echo kill -TERM $$ >> .git/FAKE_EDITOR + GIT_EDITOR=.git/FAKE_EDITOR exec git commit -a'\'' && exit 1 # should fail + ! test -f .git/index.lock +' + test_done